(Tips & Tricks) measure is to know

April 5, 2014


I can’t stress the importance of monitoring and alerting enough.

Having historic and actual data are invaluable in making decicions. And, of course, alerting keeps you ahead of problems.

A fun example I made was to keep track of internet-credits having a 3G modem for schools in Africa. The idea is to send the correct USSD-code to get your current balance for your provider.
Every provider has it’s own USSD-codes and till now I only implemented this for Tanzania’s Airtel. But extending with other providers should be obvious.

Here’s my little script (/usr/local/bin/get_balance.pl):

#!/usr/bin/perl my @devices = qw(/dev/ttyUSB1 /dev/ttyUSB0 /dev/ttyUSB2); my $continue = 1; my $balance = 0; for my $dev (@devices) { if ($continue) { system("/usr/bin/comgt -d $dev sig >/dev/null 2>&1"); if ($? == 0) { $balance=`/usr/local/bin/gsm-ussd -m $dev *102# | cut -d" " -f4`; $continue = 0; } } } if ($balance < 1000) { print "CRITICAL - Your balance is Tsh $balance."; exit 2; } else { print "OK - Your balance is Tsh $balance."; exit 0; }

Call this script from nagios and you get an actual overview of the data:
mwereni

 
"Oh Lord give me patience... NOW!"

Powered by Wordpress. Theme by Shlomi Noach, openark.org
© 2017 KwaLinux Trainingen | Algemene voorwaarden | KvK: 10147727 | Disclaimer