Statistics with Cacti

If you want to store and graph values from your MuMuDVB server

Polling Script
I used this script in Python :
#!/usr/bin/python
import sys
import os
import simplejson as json
import urllib
import traceback

if len(sys.argv) != 3:
print "Usage: " + sys.argv[0] + " "
sys.stdout.write("Sorry: you must specify those two arguments\n")
sys.exit(1)

ip = sys.argv[1]
port = "420" + sys.argv[2]
url = "http://" + ip + ":" + port + "/monitor/signal_power.json"

try:
conn = urllib.urlopen(url)
res = conn.read()
conn.close()
data = json.loads(res);
snr = data['snr']
strength = data['strength']
ber = data['ber']
print "snr:" + str(snr) + " strength:" + str(strength) + " ber:" + str(ber)

except:
print >> sys.stderr, url
print >> sys.stderr, sys.exc_info()[:2]
traceback.print_tb(sys.exc_info()[2])
sys.exit(1)

Put it in the following folder : usr/local/share/cacti/scripts/
This script needs simplejson library :

sudo apt-get install python-simplejson

The command-line to get values :
/usr/bin/python /usr/local/share/cacti/scripts/mumudvb_get_signal_strength.py reactive11 4242
snr:270 strength:54113 ber:0

Cacti integration
You will find Cacti template here, soon.

Debugging
Check if "max" parameters are enough big comparing valued returns by the script :
sudo rrdtool info /usr/share/cacti/site/rra/tnt_reactive11_ber_2346.rrd

To get the last value from the file :
sudo rrdtool last /usr/share/cacti/site/rra/tnt_reactive11_ber_2346.rrd

If you run into this, please do not only update the data source definition within the Data Template, but perform a :
sudo rrdtool tune --maximum :
for all existing rrd files belonging to that Data Template.

sudo rrdtool tune /usr/share/cacti/site/rra/reactive11_strength_2352.rrd --maximum snr:300
sudo rrdtool tune /usr/share/cacti/site/rra/reactive11_strength_2352.rrd --maximum strength:60000
$ sudo rrdtool tune /usr/share/cacti/site/rra/reactive11_strength_2352.rrd --maximum ber:100

sudo rrdupdate /usr/share/cacti/site/rra/reactive11_strength_2352.rrd N:270:10:0 ;date +%s
sudo rrdtool fetch /usr/share/cacti/site/rra/reactive11_strength_2352.rrd AVERAGE |more

Or you can follow instructions here : Check RRD File Numbers