From 45941d87dc57dbc386877d2ebffa82e88fba520c Mon Sep 17 00:00:00 2001 From: Alex Mestiashvili Date: Fri, 2 Dec 2016 15:19:44 +0100 Subject: [PATCH 1/5] Add munin2snmp, snmp agent for querying munin-node plugins over snmp --- tools/munin2snmp/MUNIN-MIB | 113 ++++++++++++++++++ tools/munin2snmp/README.pod | 58 ++++++++++ tools/munin2snmp/munin2snmp.pl | 201 +++++++++++++++++++++++++++++++++ 3 files changed, 372 insertions(+) create mode 100644 tools/munin2snmp/MUNIN-MIB create mode 100644 tools/munin2snmp/README.pod create mode 100755 tools/munin2snmp/munin2snmp.pl diff --git a/tools/munin2snmp/MUNIN-MIB b/tools/munin2snmp/MUNIN-MIB new file mode 100644 index 00000000..1878802d --- /dev/null +++ b/tools/munin2snmp/MUNIN-MIB @@ -0,0 +1,113 @@ +-- -*- snmpv2 -*- +-- ---------------------------------------------------------------------- +-- MIB file for munin +-- ---------------------------------------------------------------------- +-- +-- Currenly, only statistics are available. + +MUNIN-MIB DEFINITIONS ::= BEGIN + +IMPORTS + OBJECT-TYPE, MODULE-IDENTITY, enterprises, + Counter64 + FROM SNMPv2-SMI + OBJECT-GROUP, MODULE-COMPLIANCE + FROM SNMPv2-CONF + TEXTUAL-CONVENTION + FROM SNMPv2-TC; + +munin MODULE-IDENTITY + LAST-UPDATED "201101060000Z" + ORGANIZATION "BlackMesa" + CONTACT-INFO "GordonFreeman@BlackMesa.mil" + DESCRIPTION + "This MIB module describes information gathered through MUNIN + ioctl for each interface available on the monitored + system. Currently, only statistics are available. Information + may be redundant with what is available in IF-MIB, RMON-MIB, + EtherLike-MIB and some other MIB but they are presented here + without any abstraction." + + REVISION "201101060000Z" + DESCRIPTION "Initial revision." + + ::= { munin2snmp } + +-- We are hosted under The IMS Company OID. +munin2snmp OBJECT IDENTIFIER ::= { enterprises 123456 } + +MuninStatString ::= TEXTUAL-CONVENTION + DISPLAY-HINT "32a" + STATUS current + DESCRIPTION "Name of statistic" + SYNTAX OCTET STRING (SIZE (1..32)) + + +--- +--- muninStatTable +--- + +muninStatTable OBJECT-TYPE + SYNTAX SEQUENCE OF MuninStatEntry + MAX-ACCESS not-accessible + STATUS current + DESCRIPTION + "Statistics from munin" + ::= { munin 100 } + +muninStatEntry OBJECT-TYPE + SYNTAX MuninStatEntry + MAX-ACCESS not-accessible + STATUS current + DESCRIPTION + "Statistic for one interface" + INDEX { IMPLIED muninStatName } + ::= { muninStatTable 1 } + +MuninStatEntry ::= SEQUENCE { + muninStatName MuninStatString, + muninStat Counter64 +} + +muninStatName OBJECT-TYPE + SYNTAX MuninStatString + MAX-ACCESS not-accessible + STATUS current + DESCRIPTION + "Name of the statistic as returned by MUNIN ioctl." + ::= { muninStatEntry 1 } + +muninStat OBJECT-TYPE + SYNTAX Counter64 + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "Value of the statistic as returned by MUNIN ioctl." + ::= { muninStatEntry 2 } + +--- +--- muninConformance +--- + +muninConformance OBJECT IDENTIFIER ::= { munin 101 } + +muninCompliances MODULE-COMPLIANCE + STATUS current + DESCRIPTION + "munin compliance statement" + MODULE -- this module + MANDATORY-GROUPS { + muninStatGroup + } + ::= { muninConformance 1 } + +muninStatGroup OBJECT-GROUP + OBJECTS { + muninStat + } + STATUS current + DESCRIPTION + "Conformance groupe for munin statistics." + ::= { muninConformance 2 } + +END diff --git a/tools/munin2snmp/README.pod b/tools/munin2snmp/README.pod new file mode 100644 index 00000000..310e6f7d --- /dev/null +++ b/tools/munin2snmp/README.pod @@ -0,0 +1,58 @@ +=head1 NAME + +munin2snmp - SNMP Agent to query munin-node over snmp + +=head1 REQUIREMENTS + +Net::SNMP and IO::Socket perl modules, munin-node with some plugins + +=head2 Example configuration + +/etc/snmp/snmpd.conf + + master agentx + agentAddress udp:127.0.0.1:161 + rocommunity public 127.0.0.1 + +On a newer system it is enough to define "master" option only + +MUNIN-MIB should be installed on the client, +it goes to /usr/local/share/snmp/mibs or /usr/share/munin/mibs +or another place where snmpd expects to find the MIB files. + +See also http://www.net-snmp.org/wiki/index.php/FAQ:MIBs_03 + + +=head2 Usage + +After setting up snmpd, start the agent: + + ./munin2snmp.pl + +Now one can query the agent + + snmpwalk -v 2c -mMUNIN-MIB -c public localhost .1.3.6.1.4.1.123456.100.1.1 + +where "1.3.6.1.4.1.123456.100.1.1" is example OID selected as the base +tree for the agent. + +You might need to change the host, port, oidbase and munin_plugins you want to use. + +The defaults: + + $Munin{PORT} = '4949'; + $Munin{HOST} = 'localhost' + $oidbase = ".1.3.6.1.4.1.123456.100.1.1" + @munin_plugins = qw ( load swap users uptime vmstat df ); + +=head1 ACKNOWLEDGEMENTS + +Heavily inspired by +Vincent Bernat: https://github.com/vincentbernat/extend-netsnmp +and Masahito Zembutsu: https://github.com/zembutsu/muninwalk + +=head1 LICENSE + +GPLv2 + + diff --git a/tools/munin2snmp/munin2snmp.pl b/tools/munin2snmp/munin2snmp.pl new file mode 100755 index 00000000..8301c29b --- /dev/null +++ b/tools/munin2snmp/munin2snmp.pl @@ -0,0 +1,201 @@ +#!/usr/bin/perl + +use strict; +use NetSNMP::OID; +use NetSNMP::ASN (':all'); +use NetSNMP::agent (':all'); +use IO::Socket; + +my %cache = (); # Cache +my @cache_oids = (); # Keys, sorted +my $cache_updated = 0; +my $oidbase = ".1.3.6.1.4.1.123456.100.1.1"; +my $delimiter = ' = '; + +# initialize +my %Munin; +$Munin{PORT} = '4949'; +$Munin{HOST} = 'localhost'; + +# See munin plugins dir for more plugins +our @munin_plugins= qw ( load swap users uptime vmstat df ); + +# Update cache +sub update_stats { + return if time() - $cache_updated < 30; + %cache = (); + + foreach my $plugin (@munin_plugins) { + $plugin =~ s/^.*\///; + my $DATA = munin_fetch($plugin); + foreach my $line (@$DATA) { + # Extract name and value + next if $line !~ m/^(.*)\s=\s(.*)$/xms; + my ($name,$value) = ($1,$2); + # Compute OID + my $oid = "$oidbase"; + foreach my $char (split //, $name) { + $oid .= "."; + $oid .= ord($char); + } + # Put in the cache + $cache{$oid} = $value; + } + } + @cache_oids = sort { new NetSNMP::OID($a) <=> new NetSNMP::OID($b) } (keys %cache); + $cache_updated = time(); +} + +# Handle request +sub handle_stats { + my ($handler, $registration_info, $request_info, $requests) = @_; + update_stats; # Maybe we should do this in a thread... + for (my $request = $requests; $request; $request = $request->next()) { + $SNMP::use_numeric = 1; + my $oid = $request->getOID(); + my $noid=SNMP::translateObj($oid); + if ($request_info->getMode() == MODE_GET) { + # For a GET request, we just check the cache + if (exists $cache{$noid}) { + $request->setValue(ASN_OCTET_STR, "$cache{$noid}"); + } + } + elsif ($request_info->getMode() == MODE_GETNEXT) { + # For a GETNEXT, we need to find a best match. This is the + # first match strictly superior to the requested OID. + my $bestoid = undef; + foreach my $currentoid (@cache_oids) { + $currentoid = new NetSNMP::OID($currentoid); + next if $currentoid <= $oid; + $bestoid = $currentoid; + last; + } + if (defined $bestoid) { + $SNMP::use_numeric = 1; + my $noid=SNMP::translateObj($bestoid); + $request->setOID($bestoid); + $request->setValue(ASN_OCTET_STR, "$cache{$noid}"); + } + } + } +} + +my $agent = new NetSNMP::agent( + 'Name' => "munin", + 'AgentX' => 1); + +# Register MIB +$agent->register("munin-stats", $oidbase, + \&handle_stats) or die "registration of handler failed!\n"; + +# Main loop +$SIG{'INT'} = \&shutdown; +$SIG{'QUIT'} = \&shutdown; +my $running = 1; +while ($running) { + $agent->agent_check_and_process(1); +} +$agent->shutdown(); + +sub shutdown { + # Shutdown requested + $running = 0; +} + +#muninwalk +my @collect; +sub munin_fetch { + my $SOCKET = IO::Socket::INET -> new ( PeerAddr => $Munin{HOST}, + PeerPort => $Munin{PORT}, + Proto => 'tcp', + Timeout => '10', + Type => SOCK_STREAM, + ) or die "Cannot create socket - $@\n"; + my $tmp = <$SOCKET>; + while (my $fetch = shift(@_)) { + my $obj = ''; + if ($fetch =~ /^(\w+)(\.)(\w+)$/ ) { + ($fetch,$obj) = ($1,$3); + } + $SOCKET->print("fetch $fetch\n"); + select($SOCKET); + select(STDOUT); + while (<$SOCKET> ) { + chomp; + $_ =~ s/(.value)//; + if ($_ =~ /^(.*)(\s)(.+)$/) { + if (($1 eq '# Unknown') or ($1 eq '# Bad')) { + push (@collect,$fetch.$delimiter.'NULL'); + } else { + if (!$obj or ($1 eq $obj)) { + push (@collect,$fetch.".".$1.$delimiter.$3); + } + } + } else { + last; + } + } + } + $SOCKET->print("quit\n"); + $SOCKET->close(); + return \@collect if @collect; +} + +=head1 NAME + +munin2snmp - SNMP Agent to query munin-node over snmp + +=head1 REQUIREMENTS + +Net::SNMP and IO::Socket perl modules, munin-node with some plugins + +=head2 Example configuration + +/etc/snmp/snmpd.conf + + master agentx + agentAddress udp:127.0.0.1:161 + rocommunity public 127.0.0.1 + +On a newer system it is enough to define "master" option only + +MUNIN-MIB should be installed on the client, +it goes to /usr/local/share/snmp/mibs or /usr/share/munin/mibs +or another place where snmpd expects to find the MIB files. + +See also http://www.net-snmp.org/wiki/index.php/FAQ:MIBs_03 + + +=head2 Usage + +After setting up snmpd, start the agent: + + ./munin2snmp.pl + +Now one can query the agent + + snmpwalk -v 2c -mMUNIN-MIB -c public localhost .1.3.6.1.4.1.123456.100.1.1 + +where "1.3.6.1.4.1.123456.100.1.1" is example OID selected as the base +tree for the agent. + +You might need to change the host, port, oidbase and munin_plugins you want to use. + +The defaults: + + $Munin{PORT} = '4949'; + $Munin{HOST} = 'localhost' + $oidbase = ".1.3.6.1.4.1.123456.100.1.1" + @munin_plugins = qw ( load swap users uptime vmstat df ); + +=head1 ACKNOWLEDGEMENTS + +Heavily inspired by +Vincent Bernat: https://github.com/vincentbernat/extend-netsnmp +and Masahito Zembutsu: https://github.com/zembutsu/muninwalk + +=head1 LICENSE + +GPLv2 + + From 05d4ad0ac72bb012de4e76593b9109fb93c02724 Mon Sep 17 00:00:00 2001 From: Alex Mestiashvili Date: Fri, 2 Dec 2016 15:25:32 +0100 Subject: [PATCH 2/5] Add author for munin2snmp tool --- tools/munin2snmp/README.pod | 4 ++++ tools/munin2snmp/munin2snmp.pl | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/tools/munin2snmp/README.pod b/tools/munin2snmp/README.pod index 310e6f7d..1e039bc4 100644 --- a/tools/munin2snmp/README.pod +++ b/tools/munin2snmp/README.pod @@ -50,6 +50,10 @@ The defaults: Heavily inspired by Vincent Bernat: https://github.com/vincentbernat/extend-netsnmp and Masahito Zembutsu: https://github.com/zembutsu/muninwalk + +=head1 AUTHOR + +Alex Mestiashvili =head1 LICENSE diff --git a/tools/munin2snmp/munin2snmp.pl b/tools/munin2snmp/munin2snmp.pl index 8301c29b..62a9081e 100755 --- a/tools/munin2snmp/munin2snmp.pl +++ b/tools/munin2snmp/munin2snmp.pl @@ -193,6 +193,10 @@ The defaults: Heavily inspired by Vincent Bernat: https://github.com/vincentbernat/extend-netsnmp and Masahito Zembutsu: https://github.com/zembutsu/muninwalk + +=head1 AUTHOR + +Alex Mestiashvili =head1 LICENSE From 9c29d49666a9fe536f74759e4647210cd8fe3d59 Mon Sep 17 00:00:00 2001 From: Alex Mestiashvili Date: Tue, 6 Dec 2016 18:36:33 +0100 Subject: [PATCH 3/5] Read options from a config file or as the programm arguments, update POD --- .../munin2snmp/{munin2snmp.pl => munin2snmp} | 107 +++++++++++++++--- 1 file changed, 93 insertions(+), 14 deletions(-) rename tools/munin2snmp/{munin2snmp.pl => munin2snmp} (59%) diff --git a/tools/munin2snmp/munin2snmp.pl b/tools/munin2snmp/munin2snmp similarity index 59% rename from tools/munin2snmp/munin2snmp.pl rename to tools/munin2snmp/munin2snmp index 62a9081e..fb36c9f8 100755 --- a/tools/munin2snmp/munin2snmp.pl +++ b/tools/munin2snmp/munin2snmp @@ -1,24 +1,66 @@ #!/usr/bin/perl +use warnings; use strict; use NetSNMP::OID; use NetSNMP::ASN (':all'); use NetSNMP::agent (':all'); use IO::Socket; +use Getopt::Long; +use Pod::Usage; my %cache = (); # Cache my @cache_oids = (); # Keys, sorted my $cache_updated = 0; -my $oidbase = ".1.3.6.1.4.1.123456.100.1.1"; my $delimiter = ' = '; +my $conf = '/etc/munin2snmp.conf'; +my %config; +my $pidfile = '/var/run/munin2snmp.pid'; + +my $usage = "Usage: $0 [options] \ +Options: +--help : print help message\ +--host [host] : munin-node host, default localhost\ +--port [port] : munin-node port, default 4949\ +--base_oid [OID] : base oid, default .1.3.6.1.4.1.123456.100.1.1\ + Don't forget to update MUNIN-MIB OBJECT IDENTIFIER if you modify base_oid\ +--plugins [load,cpu,..] : comma separated list of munin-node plugins, default cpu,load,df\ +--pidfile [file path] : pidfile, default /var/run/munin2snmp.pid\ +"; + +sub read_conf { + return if ( ! -e $conf ); + open my $conf_fh,'<',$conf or die "Can't open the $conf, $!\n"; + while (<$conf_fh>) { + chomp; + my ($param, $val) = split(/\s*=\s*/); + $config{"$param"} = $val; + } +} # initialize my %Munin; -$Munin{PORT} = '4949'; -$Munin{HOST} = 'localhost'; - +if ( ! scalar @ARGV ) { + read_conf; +} +GetOptions ( + "help" => sub{pod2usage($usage)}, + "host=s" => \$config{munin_host}, + "port=s" => \$config{munin_port}, + "base_oid=s" => \$config{'base_oid'}, + "plugins=s" => \$config{'munin_plugins'}, + "pidfile=s" => \$pidfile, +); +$Munin{PORT} = $config{'munin_port'} || '4949'; +$Munin{HOST} = $config{'munin_host'} || 'localhost'; +my $oidbase = $config{'base_oid'} || '.1.3.6.1.4.1.123456.100.1.1'; # See munin plugins dir for more plugins -our @munin_plugins= qw ( load swap users uptime vmstat df ); +my @munin_plugins = qw (cpu load df); +@munin_plugins = split(',',$config{'munin_plugins'}) if ( $config{'munin_plugins'}); + +open my $pidfd,'>',$pidfile or die "Can't open $pidfile, $!\n"; +print $pidfd $$; +close $pidfd; # Update cache sub update_stats { @@ -59,7 +101,7 @@ sub handle_stats { if (exists $cache{$noid}) { $request->setValue(ASN_OCTET_STR, "$cache{$noid}"); } - } + } elsif ($request_info->getMode() == MODE_GETNEXT) { # For a GETNEXT, we need to find a best match. This is the # first match strictly superior to the requested OID. @@ -100,6 +142,7 @@ $agent->shutdown(); sub shutdown { # Shutdown requested $running = 0; + unlink $pidfile if -e $pidfile; } #muninwalk @@ -147,7 +190,7 @@ munin2snmp - SNMP Agent to query munin-node over snmp =head1 REQUIREMENTS -Net::SNMP and IO::Socket perl modules, munin-node with some plugins +Net::SNMP, Getopt::Long, Pod::Usage perl modules, munin-node with some plugins =head2 Example configuration @@ -165,12 +208,28 @@ or another place where snmpd expects to find the MIB files. See also http://www.net-snmp.org/wiki/index.php/FAQ:MIBs_03 +It is possible to start munin2snmp as non-root user, for example +run munin2snmp as Debian-snmp user on Debian Stretch: + +fix the /var/agentx permissions: + + chmod g+rx /var/agentx + chgrp Debian-snmp /var/agentx + +add to /etc/snmp/snmpd.conf: + + master agentx + agentXperms 0640 0550 Debian-snmp Debian-snmp + +restart snmpd and start the agent as Debian-snmp: + + su -l Debian-snmp -s /bin/bash -c "/tmp/munin2snmp.pl --pidfile /tmp/munin2snmp.pid --plugins iostat,vmstat" =head2 Usage After setting up snmpd, start the agent: - ./munin2snmp.pl + ./munin2snmp Now one can query the agent @@ -179,6 +238,8 @@ Now one can query the agent where "1.3.6.1.4.1.123456.100.1.1" is example OID selected as the base tree for the agent. +Change OBJECT IDENTIFIER in the MUNIN-MIB file if you plan to use a different OID. + You might need to change the host, port, oidbase and munin_plugins you want to use. The defaults: @@ -186,7 +247,17 @@ The defaults: $Munin{PORT} = '4949'; $Munin{HOST} = 'localhost' $oidbase = ".1.3.6.1.4.1.123456.100.1.1" - @munin_plugins = qw ( load swap users uptime vmstat df ); + @munin_plugins = qw ( load cpu df ); + +One can override the defaults by creating /etc/munin2snmp.conf file with the following +configuration options: + + munin_port = [port] + munin_host = [host] + base_oid = [oid] + munin_plugins = [comma separated list of munin-node plugins] + +Or by specifying the parameters, see munin2snmp --help for the usage =head1 ACKNOWLEDGEMENTS @@ -194,12 +265,20 @@ Heavily inspired by Vincent Bernat: https://github.com/vincentbernat/extend-netsnmp and Masahito Zembutsu: https://github.com/zembutsu/muninwalk -=head1 AUTHOR - -Alex Mestiashvili - =head1 LICENSE -GPLv2 +ISC License (ISC) +Copyright (c) 2016, Alex Mestiashvili +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. From 06c8538aa15fb4be1491f1f57ba615a9d791fb1b Mon Sep 17 00:00:00 2001 From: Alex Mestiashvili Date: Tue, 6 Dec 2016 18:42:20 +0100 Subject: [PATCH 4/5] Update README.pod --- tools/munin2snmp/README.pod | 52 +++++++++++++++++++++++++++++++------ 1 file changed, 44 insertions(+), 8 deletions(-) diff --git a/tools/munin2snmp/README.pod b/tools/munin2snmp/README.pod index 1e039bc4..c23d145d 100644 --- a/tools/munin2snmp/README.pod +++ b/tools/munin2snmp/README.pod @@ -4,7 +4,7 @@ munin2snmp - SNMP Agent to query munin-node over snmp =head1 REQUIREMENTS -Net::SNMP and IO::Socket perl modules, munin-node with some plugins +Net::SNMP, Getopt::Long, Pod::Usage perl modules, munin-node with some plugins =head2 Example configuration @@ -22,12 +22,28 @@ or another place where snmpd expects to find the MIB files. See also http://www.net-snmp.org/wiki/index.php/FAQ:MIBs_03 +It is possible to start munin2snmp as non-root user, for example +run munin2snmp as Debian-snmp user on Debian Stretch: + +fix the /var/agentx permissions: + + chmod g+rx /var/agentx + chgrp Debian-snmp /var/agentx + +add to /etc/snmp/snmpd.conf: + + master agentx + agentXperms 0640 0550 Debian-snmp Debian-snmp + +restart snmpd and start the agent as Debian-snmp: + + su -l Debian-snmp -s /bin/bash -c "/tmp/munin2snmp.pl --pidfile /tmp/munin2snmp.pid --plugins iostat,vmstat" =head2 Usage After setting up snmpd, start the agent: - ./munin2snmp.pl + ./munin2snmp Now one can query the agent @@ -36,6 +52,8 @@ Now one can query the agent where "1.3.6.1.4.1.123456.100.1.1" is example OID selected as the base tree for the agent. +Change OBJECT IDENTIFIER in the MUNIN-MIB file if you plan to use a different OID. + You might need to change the host, port, oidbase and munin_plugins you want to use. The defaults: @@ -43,7 +61,17 @@ The defaults: $Munin{PORT} = '4949'; $Munin{HOST} = 'localhost' $oidbase = ".1.3.6.1.4.1.123456.100.1.1" - @munin_plugins = qw ( load swap users uptime vmstat df ); + @munin_plugins = qw ( load cpu df ); + +One can override the defaults by creating /etc/munin2snmp.conf file with the following +configuration options: + + munin_port = [port] + munin_host = [host] + base_oid = [oid] + munin_plugins = [comma separated list of munin-node plugins] + +Or by specifying the parameters, see munin2snmp --help for the usage =head1 ACKNOWLEDGEMENTS @@ -51,12 +79,20 @@ Heavily inspired by Vincent Bernat: https://github.com/vincentbernat/extend-netsnmp and Masahito Zembutsu: https://github.com/zembutsu/muninwalk -=head1 AUTHOR - -Alex Mestiashvili - =head1 LICENSE -GPLv2 +ISC License (ISC) +Copyright (c) 2016, Alex Mestiashvili +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. From 6aa03315eb06e18d4a0d1bae0824bc57ffc98403 Mon Sep 17 00:00:00 2001 From: Alex Mestiashvili Date: Mon, 30 Jan 2017 13:22:12 +0100 Subject: [PATCH 5/5] Drop README.pod file, see the pod section for the docs --- tools/munin2snmp/README.pod | 98 ------------------------------------- 1 file changed, 98 deletions(-) delete mode 100644 tools/munin2snmp/README.pod diff --git a/tools/munin2snmp/README.pod b/tools/munin2snmp/README.pod deleted file mode 100644 index c23d145d..00000000 --- a/tools/munin2snmp/README.pod +++ /dev/null @@ -1,98 +0,0 @@ -=head1 NAME - -munin2snmp - SNMP Agent to query munin-node over snmp - -=head1 REQUIREMENTS - -Net::SNMP, Getopt::Long, Pod::Usage perl modules, munin-node with some plugins - -=head2 Example configuration - -/etc/snmp/snmpd.conf - - master agentx - agentAddress udp:127.0.0.1:161 - rocommunity public 127.0.0.1 - -On a newer system it is enough to define "master" option only - -MUNIN-MIB should be installed on the client, -it goes to /usr/local/share/snmp/mibs or /usr/share/munin/mibs -or another place where snmpd expects to find the MIB files. - -See also http://www.net-snmp.org/wiki/index.php/FAQ:MIBs_03 - -It is possible to start munin2snmp as non-root user, for example -run munin2snmp as Debian-snmp user on Debian Stretch: - -fix the /var/agentx permissions: - - chmod g+rx /var/agentx - chgrp Debian-snmp /var/agentx - -add to /etc/snmp/snmpd.conf: - - master agentx - agentXperms 0640 0550 Debian-snmp Debian-snmp - -restart snmpd and start the agent as Debian-snmp: - - su -l Debian-snmp -s /bin/bash -c "/tmp/munin2snmp.pl --pidfile /tmp/munin2snmp.pid --plugins iostat,vmstat" - -=head2 Usage - -After setting up snmpd, start the agent: - - ./munin2snmp - -Now one can query the agent - - snmpwalk -v 2c -mMUNIN-MIB -c public localhost .1.3.6.1.4.1.123456.100.1.1 - -where "1.3.6.1.4.1.123456.100.1.1" is example OID selected as the base -tree for the agent. - -Change OBJECT IDENTIFIER in the MUNIN-MIB file if you plan to use a different OID. - -You might need to change the host, port, oidbase and munin_plugins you want to use. - -The defaults: - - $Munin{PORT} = '4949'; - $Munin{HOST} = 'localhost' - $oidbase = ".1.3.6.1.4.1.123456.100.1.1" - @munin_plugins = qw ( load cpu df ); - -One can override the defaults by creating /etc/munin2snmp.conf file with the following -configuration options: - - munin_port = [port] - munin_host = [host] - base_oid = [oid] - munin_plugins = [comma separated list of munin-node plugins] - -Or by specifying the parameters, see munin2snmp --help for the usage - -=head1 ACKNOWLEDGEMENTS - -Heavily inspired by -Vincent Bernat: https://github.com/vincentbernat/extend-netsnmp -and Masahito Zembutsu: https://github.com/zembutsu/muninwalk - -=head1 LICENSE - -ISC License (ISC) - -Copyright (c) 2016, Alex Mestiashvili - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.