Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # Curl Script to pull statistics from client side. Dispay results in JSON Format
- statistics () {
- local site=$1
- if [ $firstline -eq 1 ] ; then
- echo -e "\t,"
- fi
- firstline=1
- echo -e "\t{"
- curl -w '
- \t\t"{#SITE}":"'$1'",
- \t\t"{#LOOKUPTIME}":"%{time_namelookup}",
- \t\t"{#CONNECTTIME}":"%{time_connect}",
- \t\t"{#PRETRANSFERTIME}":"%{time_pretransfer}",
- \t\t"{#STARTTRANSFERTIME}":"%{time_starttransfer}",
- \t\t"{#SIZEDOWNLOAD}":"%{size_download}",
- \t\t"{#SPEEDDOWNLOAD}":"%{speed_download}",
- \t\t"{#TOTALTIME}":"%{time_total}"
- \t}
- ' -o /dev/null -s $site
- #echo
- }
- firstline=0
- echo -e "{"
- echo -e "\t\"data\":["
- ## declare an array variable with site links to meassure performance
- #declare -a arr=("http://www.google.com.au" "http://www.microsoft.com")
- arr=()
- # Read the file in parameter and fill the array named "array"
- getArray() {
- i=0
- while read line # Read a line
- do
- arr[i]=$line # Put it into the array
- i=$(($i + 1))
- done < $1
- }
- getArray "/opt/zabbix/sites.txt"
- #for i in ${@}; do
- for i in "${arr[@]}"; do
- statistics $i
- done
- echo -e "\t]"
- echo -e "}"
Advertisement
Add Comment
Please, Sign In to add comment