]> gitweb.fluxo.info Git - puppet-lighttpd.git/commitdiff
added munin plugins for lighttpd
authormh <mh@immerda.ch>
Tue, 27 Jan 2009 00:22:27 +0000 (00:22 +0000)
committermh <mh@immerda.ch>
Tue, 27 Jan 2009 00:22:27 +0000 (00:22 +0000)
files/munin/lighttpd_ [new file with mode: 0644]
manifests/init.pp
manifests/munin.pp [new file with mode: 0644]

diff --git a/files/munin/lighttpd_ b/files/munin/lighttpd_
new file mode 100644 (file)
index 0000000..5862ee9
--- /dev/null
@@ -0,0 +1,46 @@
+#!/usr/bin/python
+
+# Idea from http://thelabmill.de/index.php/92
+# adapted and splitted into submodules by
+# immerda project group <admin+munin(at)immerda.ch>
+# GPLv3
+
+import sys
+kind = sys.argv[0].replace('lighttpd_', '')
+if kind == "total_accesses":
+       graph_title = "Total Accesses"
+       graph_type = "DERIVE"
+       graph_vlabel = "Handled Requests"
+elif kind == "total_kbytes":
+       graph_title = "Total KBytes"
+       graph_type = "DERIVE"
+       graph_vlabel = "Transferred KBytes"
+elif kind == "uptime":
+       graph_title = "Uptime"
+       graph_type = "DERIVE"
+       graph_vlabel = "uptime in seconds"
+elif kind == "busyservers":
+       graph_title = "Busy Servers"
+       graph_type = "GAUGE"
+       graph_vlabel = "amount of busyservers"
+
+
+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 - " + graph_title
+        print 'graph_vlabel ' + graph_vlabel
+        print 'graph_category lighttpd'
+        print kind+'.type ' + graph_type
+
+        print 'graph_args --base 1000'
+else:
+   import urllib2
+   f = urllib2.urlopen('http://127.0.0.1/server-status?auto')
+   content = f.read()
+   f.close()
+   for temp in content.lower().splitlines():
+       temp = temp.replace(" ", "_")
+       temp = temp.replace(":_", ".value ")
+       if temp.find(kind) >= 0:
+            print temp
index 987af7d46f0b710cec69f75239da8b70b3ef1226..d44d4a2bdb7b0c12cc1837b14c3b2b2f3cb61993 100644 (file)
@@ -38,4 +38,7 @@ class lighttpd::base {
         owner => root, group => 0, mode => 0644;
     }
 
+    if $use_munin {
+        include lighttpd::munin
+    }
 }
diff --git a/manifests/munin.pp b/manifests/munin.pp
new file mode 100644 (file)
index 0000000..b2e24a8
--- /dev/null
@@ -0,0 +1,34 @@
+class lighttpd::munin {
+  file{'/etc/lighttpd/conf.d/status.conf':
+    content => 'server.modules += ( "mod_status" )
+$HTTP["remoteip"] == "127.0.0.1" {
+  status.status-url = "/server-status"
+  status.config-url = "/server-config"
+}
+',
+    require => Package['lighttpd'],
+    notify => Service['lighttpd'],
+    owner => root, group => 0, mode => 0644;
+  }
+  munin::plugin::deploy{'lighttpd_': 
+    source => "lighttpd/munin/lighttpd_", 
+    ensure => absent,
+    require => File['/etc/lighttpd/conf.d/status.conf'],
+  }
+  munin::plugin{'lighttpd_total_accesses': 
+    require => Munin::Plugin::Deploy['lighttpd_'],
+    ensure => 'lighttpd_',
+  }
+  munin::plugin{'lighttpd_total_kbytes': 
+    require => Munin::Plugin::Deploy['lighttpd_'],
+    ensure => 'lighttpd_',
+  }
+  munin::plugin{'lighttpd_uptime': 
+    require => Munin::Plugin::Deploy['lighttpd_'],
+    ensure => 'lighttpd_',
+  }
+  munin::plugin{'lighttpd_busyservers': 
+    require => Munin::Plugin::Deploy['lighttpd_'],
+    ensure => 'lighttpd_',
+  }
+}