Skip to content

Instantly share code, notes, and snippets.

@solariz
Created January 18, 2017 08:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save solariz/29362abbcf45605ab700df6f6e6be141 to your computer and use it in GitHub Desktop.
Save solariz/29362abbcf45605ab700df6f6e6be141 to your computer and use it in GitHub Desktop.
Bash Script to push Service Discovery Helper stats into a influx DB
#!/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