diff --git a/munin/manifests/init.pp b/munin/manifests/init.pp index 5b44cde..4698c6c 100644 --- a/munin/manifests/init.pp +++ b/munin/manifests/init.pp @@ -54,6 +54,47 @@ class munin::node { } +# Configure SNMP node. +# +# === Parameters +# +# $name: +# Target SNMP host. +# $snmp_community: +# SNMP community. Defaults to public. +# $snmp_version: +# SNMP version. Defaults to 2. +# +# === Sample usage +# +# munin::snmpnode { "sw1.example.com": +# $snmp_community => "mycommunity", +# } +# +define munin::snmpnode($snmp_community="public", $snmp_version="2") { + + file { "/etc/munin/plugin-conf.d/snmp_${name}": + content => "[snmp_${name}_*]\nenv.community ${snmp_community}\nenv.version ${snmp_version}\n", + ensure => present, + owner => root, + group => $operatingsystem ? { + OpenBSD => wheel, + default => root, + }, + mode => 0600, + notify => Service["munin-node"], + } + + @@file { "/etc/munin/nodes.d/${name}.conf": + content => "[${name}]\n address ${ipaddress}\n use_node_name no\n", + ensure => present, + tag => "munin", + notify => Exec["generate-munin-conf"], + } + +} + + # Add new custom munin plugin. # # === Parameters