Hello Thwack - my first post!
I'm writing a script to measure bandwidth between 2 remote nodes. The script works fine, and returns the bandwidth in Kbps but I can't get APM to store the value correctly
-----BEGIN SCRIPT-----
#!/bin/bash
NEAR_SERVER="172.22.8.1"
FAR_SERVER="172.27.2.5"
RESULT=`sudo /usr/sbin/bing -c 1 -e 10 ${NEAR_SERVER} ${FAR_SERVER} 2> /dev/null | tail -n 1 | awk '{print $2}'`
# If the bandwidth is under 1mbps we need to treat the result differently
if [[ $RESULT =~ "Kbps" ]]
then
printf "Message: Available bandwidth to $FAR_SERVER is ${RESULT}\n"
TOTAL_BW=`printf ${RESULT} | sed 's/Kbps//'`
printf "Statistic:$(echo -e "${TOTAL_BW}\n*\n0.5\n+\n1\n/p" | dc 2> /dev/null)\n"
exit 0
elif [[ $RESULT =~ "Mbps" ]]
then
printf "Message: Available bandwidth to ${FAR_SERVER} is ${RESULT}\n"
TOTAL_BW=`printf ${RESULT} | sed 's/Mbps//'`
printf "Statistic:$(echo -e "${TOTAL_BW}\n1024\n*\n0.5\n+\n1\n/p" | dc)\n"
exit 0
elif [ $RESULT == "not" ]
then
printf "Message: Cannot reach host\n"
printf "Statistic:0\n"
exit 1
else:
printf "Message: ERROR\n"
printf "Statistic: 0\n"
exit 1
fi
-----END SCRIPT-----
The script runs correctly and outputs
Message: Available bandwidth to 172.27.2.5 is 80.674Kbps
Statistic:81
and I see the correct output being collected and displayed in APM.
"Component Status Details: Component is up. Message: Available bandwidth to 172.27.2.5 is 1.007Mbps
Statistic:1031"
The problem is that the integer value of 1031 (in this case) isn't being stored in the Statistic field so I can't build graphs on the data.
"Statistic Data: 0.00"
Can anyone see an obvious error in my BASH script that is stopping APM recognising the Statistic number?
Thanks
~sm