Tazz_Tux
Linux Guru
Hello Everyone,
I use this "quick-and-dirty" script to show usage under Linux. I am sure it can be made better, but it was a 2 min job. I have this in my cron jobs that calcs usage for the day, then rotates the log.
I have added a line to my /etc/syslog.conf:
Restart syslog after that. I also have debugging on in /etc/ppp/options:
calc_usage.sh
Demo:
localhost tests # ./calc_usage.sh
Sent Total : 9891729
Recv Total : 10027875
Enjoy !!!
I use this "quick-and-dirty" script to show usage under Linux. I am sure it can be made better, but it was a 2 min job. I have this in my cron jobs that calcs usage for the day, then rotates the log.
I have added a line to my /etc/syslog.conf:
Code:
*.* /var/log/all.log
Code:
debug
kdebug 4
calc_usage.sh
Code:
#!/bin/bash
logfile="/var/log/all.log"
tempfile="/tmp/logs"
datafile="/tests/data_usage"
cat $logfile | grep pppd | grep Sent > $tempfile
cat $datafile >> $tempfile
cat $tempfile | grep pppd | grep Sent | sort | uniq > $datafile
cat $datafile | gawk -F\ '{print $7"+"}' | xargs > /tmp/sent
echo "0" >> /tmp/sent
echo -n "Sent Total : " && cat /tmp/sent | xargs | bc
cat $datafile | gawk -F\ '{print $10"+"}' | xargs > /tmp/recv
echo "0" >> /tmp/recv
echo -n "Recv Total : " && cat /tmp/recv | xargs | bc
rm -rf /tmp/sent
rm -rf /tmp/recv
rm -rf $tempfile
Demo:
localhost tests # ./calc_usage.sh
Sent Total : 9891729
Recv Total : 10027875
Enjoy !!!
Please do not post question in this thread - rather post them in the sub forum
Last edited: