forked from mobiletulip/munin-kannel-plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
/
kannel_sms
executable file
·70 lines (56 loc) · 2.11 KB
/
kannel_sms
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/usr/bin/env python
import urllib2
from xml.etree.ElementTree import XML
import sys
import os
import kannel_util
def make_names(id, admin_id):
return (admin_id or id,
"%s / %s" % (id, admin_id) if admin_id and admin_id != id else id)
def print_config():
print "multigraph kannel_sms"
print "graph_order in out"
print "graph_title Kannel SMS throughput"
print "graph_vlabel messages received (-) / sent (+) per ${graph_period}"
print "graph_category kannel"
print "graph_info This graph shows inbound and outbound SMS throughput"
print "in.label received"
print "in.type DERIVE"
print "in.graph no"
print "in.min 0"
print "out.label message rate"
print "out.type DERIVE"
print "out.negative in"
print "out.min 0"
status = kannel_util.get_status()
for smsc in status['smscs']:
(name, full_name) = make_names(smsc['id'], smsc.get('admin_id'))
print "multigraph kannel_sms.%s" % name
print "graph_order in out"
print "graph_title Kannel SMS throughput for '%s' SMSC" % full_name
print "graph_vlabel messages received (-) / sent (+) per ${graph_period}"
print "graph_category kannel"
print "graph_info This graph shows inbound and outbound SMS throughput"
print "in.label received"
print "in.type DERIVE"
print "in.graph no"
print "in.min 0"
print "out.label message rate"
print "out.type DERIVE"
print "out.negative in"
print "out.min 0"
def print_data():
status = kannel_util.get_status()
print "multigraph kannel_sms"
print "in.value " + str(status['sms']['received']['total'])
print "out.value " + str(status['sms']['sent']['total'])
for smsc in status['smscs']:
(name, full_name) = make_names(smsc['id'], smsc.get('admin_id'))
print "multigraph kannel_sms.%s" % name
print "in.value %s" % smsc['received']['sms']
print "out.value %s" % smsc['sent']['sms']
if __name__ == "__main__":
if len(sys.argv) > 1 and sys.argv[1] == "config":
print_config()
else:
print_data()