Home > coding, python, server, website > custom munin plugins the easy way (or: python rocks, perl sucks)

custom munin plugins the easy way (or: python rocks, perl sucks)

i just wrote this little neat python plugin for munin, to be able to track some lighttpd statistics

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
#!/bin/env python
import sys
if len(sys.argv) == 2 and sys.argv[1] == "autoconf":
        print "yes"
elif len(sys.argv) == 2 and sys.argv[1] == "config":
        print 'graph_title Lighttpd Stats'
        print 'graph_vlabel count'
        print 'graph_category lighttpd'

        print 'total_accesses.label Total Accesses'
        #print 'Total_Accesses.draw AREA'
        print 'total_accesses.type COUNTER'

        print 'total_kbytes.label Total kBytes transferred'
        #print 'Total_kBytes.draw AREA'
        print 'total_kbytes.type COUNTER'

        print 'total_uptime.label Total Uptime'
        #print 'Total_Uptime.draw AREA'
        #print 'Total_Uptime.type GAUGE'

        print 'total_busyservers.label Total Busy servers'
        #print 'Total_BusyServers.draw AREA'
        #print 'Total_BusyServers.type GAUGE'

        print 'graph_args --base 1000'
else:
   import urllib2
   f = urllib2.urlopen('http://127.0.0.1/server-status?auto')
   temp = f.read()
   f.close()
   temp = temp.replace(" ", "_")
   temp = temp.replace(":_", ".value ")
   print temp.lower()

EDIT: got an error in the first version, fixed that in the above one
EDIT2: now its finally working :)

Related posts:

  1. munin and custom database statistics
  2. linux custom firefox protocols the easy way
  3. write your own mailserver in python
  4. ‘strict’ typing of function arguments in python
  5. how to get the client IP in python XMLRPC – the easy way

Categories: coding, python, server, website Tags:
  1. November 17th, 2008 at 14:58 | #1

    thanks for this short overview of writing munin plugins in python. helped me a lot.

    cheers jan

  1. No trackbacks yet.


2 + one =