Skip to content

Instantly share code, notes, and snippets.

@crawc
Forked from charlie-haley/rate_to_pushgateway.sh
Created November 20, 2020 23:18
Show Gist options
  • Select an option

  • Save crawc/ee0a81c4988aacf3303021ceda945d8f to your computer and use it in GitHub Desktop.

Select an option

Save crawc/ee0a81c4988aacf3303021ceda945d8f to your computer and use it in GitHub Desktop.
pushgatewayip="192.168.1.2:9091"
network="192.168.1.0/24"
rate -i bce1 -r 1 -e -n -Ab -a 255 -c "${network}" -d | while read -r line; do
host=`echo $line | cut -d':' -f1`
downloadrate=`echo $line | cut -d':' -f4`
uploadrate=`echo $line | cut -d':' -f5`
if [ ! -z "$downloadrate" -a "$downloadrate" != " " ]; then
echo "download_rate_bits $downloadrate" | curl --data-binary @- "${pushgatewayip}/metrics/job/pfsense/instance/${host}"
fi
if [ ! -z "$uploadrate" -a "$uploadrate" != " " ]; then
echo "upload_rate_bits $uploadrate" | curl --data-binary @- "${pushgatewayip}/metrics/job/pfsense/instance/${host}"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment