-
-
Save themegabyte/16a63068feab3d292aae0556386e7479 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#!/usr/local/bin/bash | |
# pkg install bash | |
# add to shellcmd as "/root/push_ip_metrics.sh &" via Services/shellcmd | |
pushgatewayip="192.168.1.2:9091" | |
network="192.168.1.0/24" | |
interface="bce1" | |
interval="1" | |
rate -i "${interface}" -r "${interval}" -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 [ "${line}" == "- - - - - - - - - - - - - - - - - - -" ]; then | |
continue | |
fi | |
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