Skip to content

Instantly share code, notes, and snippets.

@valentt
Created June 14, 2017 19:36
Show Gist options
  • Save valentt/8be9087b9cf36466623e51b7b106e928 to your computer and use it in GitHub Desktop.
Save valentt/8be9087b9cf36466623e51b7b106e928 to your computer and use it in GitHub Desktop.
#!/bin/sh
if [ -z "$1" ]; then
echo "Please run this command with Location as a parameter"
exit 1
else
location=$1
fi
sysname=`uci get system.@system[0].hostname`
korisnici=`cat /tmp/dhcp.leases|wc -l`
POST_korisnici='Korisnici,grad='$location',naziv='$sysname' Korisnici='$korisnici
wget -O /dev/null http://188.166.87.171:8086/write?db=mydb --post-data "$POST_korisnici"
RX=`ifconfig eth0|grep bytes|cut -f 2 -d ':'|cut -f 1 -d ' '`
TX=`ifconfig eth0|grep bytes|cut -f 3 -d ':'|cut -f 1 -d ' '`
if [ -e /var/downloaded.txt ]; then
D=`cat /var/downloaded.txt`
D=$(($RX-$D))
POST_D='Downloaded,grad='$location',naziv='$sysname' Downloaded='$D
wget -O /dev/null http://188.166.87.171:8086/write?db=mydb --post-data "$POST_D"
fi
if [ -e /var/uploaded.txt ]; then
U=`cat /var/uploaded.txt`
U=$(($TX-$U))
POST_U='Uploaded,grad='$location',naziv='$sysname' Uploaded='$U
wget -O /dev/null http://188.166.87.171:8086/write?db=mydb --post-data "$POST_U"
fi
echo "$RX" > /var/downloaded.txt
echo "$TX" > /var/uploaded.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment