mirror of
https://github.com/pstadler/metrics.sh.git
synced 2025-11-10 14:09:43 -05:00
get rid of some bashisms / clean up. add ping metric. add --metrics cli option
This commit is contained in:
9
metrics/heartbeat.sh
Normal file
9
metrics/heartbeat.sh
Normal file
@@ -0,0 +1,9 @@
|
||||
#!/bin/sh
|
||||
|
||||
collect () {
|
||||
report 1
|
||||
}
|
||||
|
||||
docs () {
|
||||
echo "Send a simple heartbeat in form of an integer '1'."
|
||||
}
|
||||
@@ -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
|
||||
|
||||
@@ -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="
|
||||
}
|
||||
Reference in New Issue
Block a user