get rid of some bashisms / clean up. add ping metric. add --metrics cli option

This commit is contained in:
Patrick Stadler
2015-03-15 14:55:36 +01:00
parent 470ed0a828
commit d018d6ea12
12 changed files with 166 additions and 48 deletions

9
metrics/heartbeat.sh Normal file
View File

@@ -0,0 +1,9 @@
#!/bin/sh
collect () {
report 1
}
docs () {
echo "Send a simple heartbeat in form of an integer '1'."
}

View File

@@ -8,7 +8,7 @@ init () {
NETWORK_IO_INTERFACE="eth0"
fi
fi
readonly __network_io_divisor=$[$INTERVAL * 1024]
readonly __network_io_divisor=$(($INTERVAL * 1024))
}
if is_osx; then

View File

@@ -1,9 +1,23 @@
#!/bin/sh
init () {
if [ -z $PING_REMOTE_HOST ]; then
echo "Error: ping metric requires \$PING_REMOTE_HOST to be specified"
exit 1
fi
}
collect () {
report 1
ping -c 1 $PING_REMOTE_HOST > /dev/null 2>&1
if [ $? -eq 0 ]; then
report 1
else
report 0
fi
}
docs () {
echo "Send a simple ping in form of an integer '1'."
echo "Check if remote host is reachable by sending a single ping."
echo "Reports '1' if ping was successful, '0' if not."
echo "\$PING_REMOTE_HOST="
}