Created
January 18, 2017 08:26
-
-
Save solariz/29362abbcf45605ab700df6f6e6be141 to your computer and use it in GitHub Desktop.
Bash Script to push Service Discovery Helper stats into a influx DB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
SDHSTAT="/opt/service-discovery-helper/sdh.stat" | |
CURLOPTIONS='-s -i -XPOST -u youruser:yourpasswd https://your.influxdb.server:8086/write?db=event --data-binary' | |
re='^[0-9]+$' | |
function toInflux { | |
if [ ! -z $2 ]; then | |
echo $1:$2 | |
curl $CURLOPTIONS $1',event=DHDE17 value='$2 >/dev/null | |
fi | |
} | |
while read line | |
do | |
TYPE=$(echo $line|cut -f1 -d":") | |
VALUE=$(echo $line|cut -f2 -d":") | |
if [ $TYPE == "TX" ]; then | |
toInflux OutBcastPkts $VALUE | |
elif [ $TYPE == "RX" ]; then | |
toInflux InBcastPkts $VALUE | |
else | |
curl $CURLOPTIONS 'SDHSTAT,event=DHDE17,TYPE='$TYPE' value='$VALUE | |
fi | |
done <<< "$(cat $SDHSTAT)" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment