finally implemented snmp client
authorMarcel Haerry <haerry@puzzle.ch>
Wed, 15 Apr 2009 10:00:48 +0000 (12:00 +0200)
committermh <mh@immerda.ch>
Tue, 2 Jun 2009 09:46:59 +0000 (11:46 +0200)
manifests/client.pp
templates/snmpclient.erb [new file with mode: 0644]

index c59369b..9524edf 100644 (file)
@@ -38,13 +38,27 @@ define munin::register()
        }
 }
 
-define munin::register_snmp()
+# snmp_testplugin: the plugin we use to test if it's set
+define munin::register_snmp(
+    $snmpd_testplugin = 'load'
+)
 {
-       @@file { "munin_snmp_${name}": path => "${NODESDIR}/${name}",
-               ensure => present,
-               content => template("munin/snmpclient.erb"),
-               tag => 'munin',
-       }
+       $munin_port_real = $munin_port ? { '' => 4949, default => $munin_port } 
+       $munin_host_real = $munin_host ? {
+               '' => '*',
+               'fqdn' => '*',
+               default => $munin_host
+    }
+    exec{"register_snmp_munin_for_${name}":
+        command => "munin-node-configure-snmp ${name} | sh",
+        unless => "test -e /etc/munin/plugins/snmp_${name}_${snmpd_testplugin}",
+    }
+    @@file { "munin_snmp_${name}": path => "${NODESDIR}/${name}",
+        ensure => present,
+        content => template("munin/snmpclient.erb"),
+        require => Exec["register_snmp_munin_for_${name}"],
+        tag => 'munin',
+    }
 }
 
 class munin::client::base {
diff --git a/templates/snmpclient.erb b/templates/snmpclient.erb
new file mode 100644 (file)
index 0000000..44ecc6d
--- /dev/null
@@ -0,0 +1,10 @@
+<%
+       # Downcase all information
+       dom = domain.downcase
+       host = hostname.downcase
+       fhost = name.downcase
+%>
+### This syntax can be extended, it might get better ...
+#<%= dom %> snmp -> <%= fhost %>
+[<%= fhost %>] # snmp box 
+       address <%= munin_host_real %>