1
0
Fork 0
mirror of https://github.com/munin-monitoring/contrib.git synced 2025-07-21 18:41:03 +00:00

Plugin-Gallery: Better 2nd level headings

This commit is contained in:
dipohl 2017-02-24 16:11:20 +01:00
parent 6ffdebec0d
commit f769371079
22 changed files with 0 additions and 0 deletions

View file

@ -1,90 +0,0 @@
#!/usr/bin/perl -w
# -*- perl -*-
# vim: ft=perl
=head1 NAME
snmp__cisco_sbs_cpu - Munin plugin to monitor CPU Usage on Cisco Small Business Switches.
=head1 APPLICABLE SYSTEMS
Cisco Small Business Switches (SBXXXX devices)
=head1 CONFIGURATION
As a rule SNMP plugins need site specific configuration. The default
configuration (shown here) will only work on insecure sites/devices.
[snmp_*]
env.version 2
env.community public
In general SNMP is not very secure at all unless you use SNMP version
3 which supports authentication and privacy (encryption). But in any
case the community string for your devices should not be "public".
Please see 'perldoc Munin::Plugin::SNMP' for further configuration
information.
=head1 INTERPRETATION
CPU Percentage gives an idea of utilization of the device. High CPU
can indicate a configuration problem or overutilization of the device.
=head1 MAGIC MARKERS
#%# family=snmpauto
#%# capabilities=snmpconf
=head1 VERSION
$Id$
=head1 BUGS
None known.
=head1 AUTHOR
Copyright (C) 2015 James DeVincentis
=head1 LICENSE
GPLv3.
=cut
use strict;
use Munin::Plugin::SNMP;
if (defined $ARGV[0] and $ARGV[0] eq 'snmpconf') {
print "require 1.3.6.1.4.1.9.6.1.101.1.7.0 [0-9]\n";
exit 0;
}
if (defined $ARGV[0] and $ARGV[0] eq "config") {
my ($host) = Munin::Plugin::SNMP->config_session();
print "host_name $host\n" unless $host eq 'localhost';
print <<"EOF";
graph_title CPU Utilization
graph_args --base 1000 -l 0 -u 100
graph_vlabel CPU %
graph_category system
graph_info This graph shows the percentage of CPU used at different intervals. High CPU Utilization can indicate a configuration problem or overutilization of the device.
load5sec.label 5s
load5sec.info 5 Second CPU Utilization Average
load5sec.draw LINE1
load1min.label 1m
load1min.info 1 Minute CPU Utilization Average
load1min.draw LINE1
load5min.label 5m
load5min.info 5 Minute CPU Utilization Average
EOF
exit 0;
}
my $session = Munin::Plugin::SNMP->session();
print "load5sec.value ", $session->get_single('1.3.6.1.4.1.9.6.1.101.1.7.0'), "\n";
print "load1min.value ", $session->get_single('1.3.6.1.4.1.9.6.1.101.1.8.0'), "\n";
print "load5min.value ", $session->get_single('1.3.6.1.4.1.9.6.1.101.1.9.0'), "\n";

View file

@ -1,445 +0,0 @@
#!/usr/bin/perl -w
#
# What is snmp__ipoman_
# ----------------------
# snmp__ipoman is a munin plugin written for the Ingrasys IpomanII 1202
# Power Distribution Unit. It should work on any PDU conforming to
# the IPOMANII-MIB.
#
# How do I use it
# ---------------
# You can use this plugin on a system with a working munin-node. Here's
# how:
#
# 1. Copy snmp__ipoman_ to the directory where all your munin plugins
# reside, for example /usr/share/munin/plugins.
#
# 2. Make the following symlinks to snmp__ipoman_ in that same directory
#
# snmp__ipoman_inletcurrent_
# snmp__ipoman_inletpower_
# snmp__ipoman_inletvoltage_
# snmp__ipoman_outletpower_
# snmp__ipoman_outletcurrent_
#
# (If you wonder why. I did not manage to make a plugin which has both
# the 'snmpconf' and the 'suggest' capabilities. So either I had to make
# separate plugins for all graph types, or I would have to make
# assumptions on the number of ports and the address of the ipoman in
# the script.)
#
# 3. Change to the directory where the links to munin plugins reside
# that are to be run by munin-node, for example /etc/munin/plugins/
#
# 4. Run munin-node-configure-snmp:
#
# $ munin-node-configure-snmp --snmpversion=1 <hostname> | sh -x
#
# where <hostname> is the hostname or ip address of your ipoman. This
# will create and print a bunch of symlinks to snmp__ipoman_ which will
# output current and power usage for all available outlets of the
# ipoman, and current, power usage and voltage/frequency on all inlets
# of the ipoman.
#
# 5. Restart munin-node
#
# 6. Make an entry in your munin server's munin.conf:
#
# [<hostname of ipoman as entered in 4.>]
# address <address of munin-node>
# use_node_name no
#
# 7. Done.
#
# Copyright (C) 2009 Rien Broekstra <rien@rename-it.nl>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; version 2 dated June,
# 1991.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
# Munin plugin to monitor power consumption and current of the sockets of an
# Ingrasys IpomanII 1202 Power Distribution Unit, or any power distribution
# unit that conforms to IPOMANII-MIB via SNMP.
#
# Parameters:
#
# config
# snmpconf
#
# Relevant OID's under .iso.org.dod.internet.private.enterprises.ingrasys.product.pduAgent.iPoManII
# .ipmObjects.ipmDevice.ipmDeviceOutlet.ipmDeviceOutletNumber.0
# .ipmObjects.ipmDevice.ipmDeviceOutlet.ipmDeviceOutletStatusTable.ipmDeviceOutletStatusEntry.outletStatusIndex.1
# .ipmObjects.ipmDevice.ipmDeviceOutlet.ipmDeviceOutletStatusTable.ipmDeviceOutletStatusEntry.outletStatusCurrent.1
# .ipmObjects.ipmDevice.ipmDeviceOutlet.ipmDeviceOutletStatusTable.ipmDeviceOutletStatusEntry.outletStatusKwatt.1
# .ipmObjects.ipmDevice.ipmDeviceOutlet.ipmDeviceOutletStatusTable.ipmDeviceOutletStatusEntry.outletStatusWH.1
#
# Version 0.1, Aug 4, 2009
#
#
#
#
#
#
#
#
#
#
# MAGIC MARKERS:
#
#%# family=snmpauto
#%# capabilities=snmpconf
use strict;
use Net::SNMP;
my $DEBUG = 0;
my $host = $ENV{host} || undef;
my $port = $ENV{port} || 161;
my $community = $ENV{community} || "public";
my $iface = $ENV{interface} || undef;
my $socketnumber;
my $response;
my $graphtype;
#
# Infer host, inlet/socketnumber and graphtype from the symlink name to this plugin.
#
if ($0 =~ /^(?:|.*\/)snmp_([^_]*)_ipoman_([^_]*)_(.*)$/)
{
$host = $1;
$graphtype = $2;
$socketnumber = $3;
if ($host =~ /^([^:]+):(\d+)$/) {
$host = $1;
$port = $2;
}
}
if (!defined($graphtype)) {
die "# Error: couldn't understand what quantity I'm supposed to monitor.";
}
#
# The relevant OID's on the IPOMAN
#
my $oid_inletnumber = ".1.3.6.1.4.1.2468.1.4.2.1.3.1.1.0";
my $oid_inletindextable = ".1.3.6.1.4.1.2468.1.4.2.1.3.1.2.1.1.";
my $oid_inletvoltage = ".1.3.6.1.4.1.2468.1.4.2.1.3.1.3.1.2.";
my $oid_inletcurrent = ".1.3.6.1.4.1.2468.1.4.2.1.3.1.3.1.3.";
my $oid_inletfrequency = ".1.3.6.1.4.1.2468.1.4.2.1.3.1.3.1.4.";
my $oid_inletenergy = ".1.3.6.1.4.1.2468.1.4.2.1.3.1.3.1.5.";
my $oid_outletnumber = ".1.3.6.1.4.1.2468.1.4.2.1.3.2.1.0";
my $oid_outletindextable = ".1.3.6.1.4.1.2468.1.4.2.1.3.2.3.1.1.";
my $oid_outletdescription = ".1.3.6.1.4.1.2468.1.4.2.1.3.2.2.1.2.";
my $oid_outletcurrent = ".1.3.6.1.4.1.2468.1.4.2.1.3.2.3.1.3.";
my $oid_outletenergy = ".1.3.6.1.4.1.2468.1.4.2.1.3.2.3.1.4.";
# FIXME: The voltage is not defined per outlet. For now we just assume that all sockets have the voltage on inlet 1.
my $oid_outletvoltage = ".1.3.6.1.4.1.2468.1.4.2.1.3.1.3.1.2.1";
#
# The snmpconf section prints out what oid's we need for the quantity we want to monitor, and where we find out how many ports the device has.
#
if (defined $ARGV[0] and $ARGV[0] eq "snmpconf") {
if ($graphtype eq "inletvoltage") {
print "number $oid_inletnumber\n";
print "index $oid_inletindextable\n";
print "require $oid_inletvoltage [0-9]+\n";
print "require $oid_inletfrequency [0-9]+\n";
}
elsif ($graphtype eq "inletcurrent") {
print "number $oid_inletnumber\n";
print "index $oid_inletindextable\n";
print "require $oid_inletcurrent [0-9]+\n";
}
elsif ($graphtype eq "inletpower") {
print "number $oid_inletnumber\n";
print "index $oid_inletindextable\n";
print "require $oid_inletvoltage [0-9]+\n";
print "require $oid_inletcurrent [0-9]+\n";
}
elsif ($graphtype eq "outletcurrent") {
print "number $oid_outletnumber\n";
print "index $oid_outletindextable\n";
print "require $oid_outletcurrent [0-9]+\n";
}
elsif ($graphtype eq "outletpower") {
print "number $oid_outletnumber\n";
print "index $oid_outletindextable\n";
print "require $oid_outletvoltage [0-9]+\n";
print "require $oid_outletcurrent [0-9]+\n";
}
else {
print "require dont.graph.anything [0-9]+\n"
}
exit 0;
}
#
# For all other options we need to connect to the host in our $0. if we cannot, bail out.
#
if (!defined($host))
{
print "# Debug: $0 -- $1 -- $2\n" if $DEBUG;
die "# Error: couldn't understand what I'm supposed to monitor.";
}
my ($session, $error) = Net::SNMP->session(
-hostname => $host,
-community => $community,
-port => $port
);
if (!defined ($session))
{
die "Croaking: $error";
}
#
# Output graph configuration depending on what quantity we want to plot
#
if (defined $ARGV[0] and $ARGV[0] eq "config") {
print "host_name $host\n";
if ($graphtype eq "inletvoltage") {
print "graph_title Inlet $socketnumber voltage/frequency\n";
print "graph_args --base 1000 -l 0\n";
print "graph_category system\n";
print "graph_info This graph shows the tension and frequency to inlet $socketnumber on the Power Distribution Unit\n";
print "voltage.label Tension (V)\n";
print "voltage.draw LINE2\n";
print "voltage.type GAUGE\n";
print "frequency.label Frequency (Hz)\n";
print "frequency.draw LINE2\n";
print "frequency.type GAUGE\n";
}
elsif ($graphtype eq "inletcurrent") {
print "graph_title Inlet $socketnumber current\n";
print "graph_args --base 1000 -l 0\n";
print "graph_category system\n";
print "graph_info This graph shows the delivered current to inlet $socketnumber on the Power Distribution Unit\n";
print "current.label Current (A)\n";
print "current.draw AREA\n";
print "current.type GAUGE\n";
}
elsif ($graphtype eq "inletpower") {
print "graph_title Inlet $socketnumber power\n";
print "graph_args --base 1000 -l 0\n";
print "graph_category system\n";
print "graph_info This graph shows the delivered apparent and real power to inlet $socketnumber of the Power Distribution Unit\n";
print "apparentpower.label Apparent power (kVA)\n";
print "apparentpower.draw LINE3\n";
print "apparentpower.type GAUGE\n";
print "realpower.label Real power (kW)\n";
print "realpower.draw AREA\n";
print "realpower.type COUNTER\n";
exit 0;
}
elsif ($graphtype eq "outletcurrent") {
print "graph_title Outlet $socketnumber current\n";
print "graph_args --base 1000 -l 0\n";
print "graph_category system\n";
print "graph_info This graph shows the delivered current to outlet $socketnumber of the Power Distribution Unit\n";
print "current.label Delivered current (A)\n";
print "current.draw AREA\n";
print "current.type GAUGE\n";
}
elsif ($graphtype eq "outletpower") {
print "graph_title Outlet $socketnumber power\n";
print "graph_args --base 1000 -l 0\n";
print "graph_category system\n";
print "graph_info This graph shows the delivered apparent and real power to outlet $socketnumber of the Power Distribution Unit\n";
print "apparentpower.label Apparent power (kVA)\n";
print "apparentpower.draw LINE3\n";
print "apparentpower.type GAUGE\n";
print "realpower.label Real power (kW)\n";
print "realpower.draw AREA\n";
print "realpower.type COUNTER\n";
exit 0;
}
exit 0;
}
if ($graphtype eq "inletvoltage") {
my ($voltage, $frequency);
if (defined ($response = $session->get_request($oid_inletvoltage.$socketnumber))) {
$voltage = $response->{$oid_inletvoltage.$socketnumber};
}
else {
$voltage = 'U';
}
if (defined ($response = $session->get_request($oid_inletfrequency.$socketnumber))) {
$frequency = $response->{$oid_inletfrequency.$socketnumber};
}
else {
$frequency = 'U';
}
# The IPOMAN returns tension in 0.1V units.
# Convert to V
if ($voltage ne 'U') {
$voltage = $voltage/10;
}
# The IPOMAN returns frequency in 0.1Hz units.
# Convert to Hz
if ($frequency ne 'U') {
$frequency = $frequency/10;
}
print "voltage.value ", $voltage, "\n";
print "frequency.value ", $frequency, "\n";
}
elsif ($graphtype eq "inletcurrent") {
my $current;
if (defined ($response = $session->get_request($oid_inletcurrent.$socketnumber))) {
$current = $response->{$oid_inletcurrent.$socketnumber};
}
else {
$current = 'U';
}
# The IPOMAN returns power in mA.
# Convert to A:
#
if ($current ne 'U') {
$current = $current/1000;
}
print "current.value ", $current, "\n";
}
elsif ($graphtype eq "inletpower") {
my ($current, $energy, $voltage, $apparentpower);
if (defined ($response = $session->get_request($oid_inletcurrent.$socketnumber))) {
$current = $response->{$oid_inletcurrent.$socketnumber};
}
else {
$current = 'U';
}
if (defined ($response = $session->get_request($oid_inletenergy.$socketnumber))) {
$energy = $response->{$oid_inletenergy.$socketnumber};
}
else {
$energy = 'U';
}
if (defined ($response = $session->get_request($oid_inletvoltage.$socketnumber))) {
$voltage = $response->{$oid_inletvoltage.$socketnumber};
}
else {
$voltage = 'U';
}
# Calculate results
# Apparent power (VA)= Voltage (V)* Current(A).
# IPOMAN delivers voltage in units of 0.1V. and current in units of mA:
if ($current ne 'U' && $voltage ne 'U') {
$apparentpower = ($current/1000)*($voltage/10);
}
#
# The IPOMAN returns consumed energy in Wh. We want it in J (= Ws), in order for munin to graph in W.
#
if ($energy ne 'U') {
$energy = $energy*3600;
}
print "realpower.value ", $energy, "\n";
print "apparentpower.value ", $apparentpower, "\n";
}
elsif ($graphtype eq "outletcurrent") {
my $current;
if (defined ($response = $session->get_request($oid_outletcurrent.$socketnumber))) {
$current = $response->{$oid_outletcurrent.$socketnumber};
}
else {
$current = 'U';
}
# The IPOMAN returns power in mA.
# Convert to A:
#
if ($current ne 'U') {
$current = $current/1000;
}
print "current.value ", $current, "\n";
}
elsif ($graphtype eq "outletpower") {
my ($current, $energy, $voltage, $apparentpower);
if (defined ($response = $session->get_request($oid_outletcurrent.$socketnumber))) {
$current = $response->{$oid_outletcurrent.$socketnumber};
}
else {
$current = 'U';
}
if (defined ($response = $session->get_request($oid_outletenergy.$socketnumber))) {
$energy = $response->{$oid_outletenergy.$socketnumber};
}
else {
$energy = 'U';
}
if (defined ($response = $session->get_request($oid_outletvoltage))) {
$voltage = $response->{$oid_outletvoltage};
}
else {
$voltage = 'U';
}
#
# Calculate results
# Apparent power (VA)= Voltage (V)* Current(A).
# IPOMAN delivers voltage in units of 0.1V. and current in units of mA:
if ($current ne 'U' && $voltage ne 'U') {
$apparentpower = ($current/1000)*($voltage/10);
}
#
# The IPOMAN returns consumed energy in Wh. We want it in J (= Ws), in order for munin to graph in W.
#
if ($energy ne 'U') {
$energy = $energy*3600;
}
print "realpower.value ", $energy, "\n";
print "apparentpower.value ", $apparentpower, "\n";
}
exit 0;

View file

@ -1,114 +0,0 @@
#!/usr/bin/ruby
"
=head1 NAME
snmp__linksys_poe - Munin plugin to monitor the current supplied by Linksys PoE
switches.
Requires ruby and the ruby SNMP library.
=head1 APPLICABLE SYSTEMS
I wrote this to query SRW2008MP switches and determined the OIDs by trial and
error. There may be other Linksys devices that this will also work for.
=head1 CONFIGURATION
This plugin defaults to SNMP version 2c and a community string of 'public'. The
defaults can be overridden in the usual way:
[snmp_*]
env.version 1
env.community private
SNMP version 3 is not supported.
=head1 INTERPRETATION
The plugin simply reports the current being supplied on each of the device's
PoE ports.
=head1 MIB INFORMATION
Information is gathered from Linksys' private MIB space, so it's probably only
applicable to Linksys devices. I have been unable to get an actual copy of
the appropriate MIB, so I don't know the actual names of the values I'm
retrieving.
=head1 MAGIC MARKERS
#%# family=snmpauto contrib
#%# capabilities=snmpconf
=head1 VERSION
1.0
=head1 BUGS
None known.
=head1 AUTHOR
Written by Phil Gold <phil_g@pobox.com>.
=head1 LICENSE
CC0 <http://creativecommons.org/publicdomain/zero/1.0/>
To the extent possible under law, all copyright and related or neighboring
rights to this plugin are waived. Do with it as you wish.
=cut
"
require 'snmp'
idx_oid = "enterprises.3955.89.108.1.1.2"
max_oid = "enterprises.3955.89.108.1.1.6"
cur_oid = "enterprises.3955.89.108.1.1.5"
community = ENV['community'] || "public"
version = ENV['version'] == '1' ? :SNMPv1 : :SNMPv2c
case ARGV[0]
when "autoconf"
puts "no"
exit 1
when "snmpconf"
puts "require 1.3.6.1.4.1.3955.89.108.1.1.2.1. [0-9]"
puts "require 1.3.6.1.4.1.3955.89.108.1.1.5.1. [0-9]"
puts "require 1.3.6.1.4.1.3955.89.108.1.1.6.1. [0-9]"
exit 0;
when "config"
host = $0.match('^(?:|.*\/)snmp_([^_]+)')[1]
puts "host_name #{host}"
puts "graph_title PoE Power Usage"
puts "graph_vlabel Watts"
puts "graph_category sensors"
max_current = 0
SNMP::Manager.open(:Host => host,
:Community => community,
:Version => version) do |manager|
manager.walk([idx_oid, max_oid]) do |row|
puts "iface_#{row[0].value}.label Port #{row[0].value}"
puts "iface_#{row[0].value}.cdef iface_#{row[0].value},1000,/"
puts "iface_#{row[0].value}.line #{row[1].value.to_f / 1000}"
if row[1].value > max_current
max_current = row[1].value
end
end
end
puts "graph_args --upper-limit #{max_current.to_f / 1000}"
exit 0
else
host = $0.match('^(?:|.*\/)snmp_([^_]+)')[1]
SNMP::Manager.open(:Host => host,
:Community => community,
:Version => version) do |manager|
manager.walk([idx_oid, cur_oid]) do |row|
puts "iface_#{row[0].value}.value #{row[1].value}"
end
end
end

View file

@ -1,109 +0,0 @@
#!/usr/bin/perl -w
#
# Copyright (C) 2008 J.M.Roth
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; version 2 dated June,
# 1991.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
#
# $Log$
#
# Inspired by snmp__processes
#
#%# family=snmpauto
#%# capabilities=snmpconf
use strict;
use Net::SNMP;
my $DEBUG = 0;
my $host = $ENV{host} || undef;
my $port = $ENV{port} || 161;
my $community = $ENV{community} || "public";
my $iface = $ENV{interface} || undef;
my $response;
if (defined $ARGV[0] and $ARGV[0] eq "snmpconf")
{
print "require 1.3.6.1.2.1.25.2.3.1.5.2\n"; # Number
print "require 1.3.6.1.2.1.25.2.3.1.6.2\n"; # Number
exit 0;
}
my @split_result = split(/_/, $0);
$host = $split_result[1];
if ($host =~ /^([^:]+):(\d+)$/)
{
$host = $1;
$port = $2;
}
if ($host eq '' || !defined $host)
{
print "# Debug: $0 -- $1\n" if $DEBUG;
die "# Error: couldn't understand what I'm supposed to monitor.";
}
my ($session, $error) = Net::SNMP->session(
-hostname => $host,
-community => $community,
-port => $port
);
if (!defined ($session))
{
die "Croaking: $error";
}
if (defined $ARGV[0] and $ARGV[0] eq "config")
{
print "host_name $host\n";
print "graph_title Memory usage
graph_args --base 1000 -l 0
graph_vlabel kB
graph_category system
graph_info This graph shows total and used memory on the host.
memsize.label total
memused.label used
memsize.info The total memory.
memused.info The memory in use.
memsize.draw LINE1
memused.draw LINE2
";
exit 0;
}
print "memsize.value ", &get_single ($session, "1.3.6.1.2.1.25.2.3.1.5.2"), "\n";
print "memused.value ", &get_single ($session, "1.3.6.1.2.1.25.2.3.1.6.2"), "\n";
sub get_single
{
my $handle = shift;
my $oid = shift;
print "# Getting single $oid...\n" if $DEBUG;
$response = $handle->get_request ($oid);
if (!defined $response->{$oid})
{
return undef;
}
else
{
return $response->{$oid};
}
}

View file

@ -1,170 +0,0 @@
#!/usr/bin/perl -w
# -*- cperl -*-
=head1 NAME
snmp__screenos_ - SNMP plugin to monitor Juniper ScreenOS based routers
=head1 APPLICABLE SYSTEMS
This has been developed against a Juniper SSG5-Serial router, but
should work with any ScreenOS-based router as manufactured by Juniper.
Using a command such as "munin-node-configure --snmp
switch.langfeldt.net --snmpversion 2c --snmpcommunity public | sh -x"
should identify whether this plugin can apply.
=head1 CONFIGURATION
As a rule SNMP plugins need site specific configuration. The default
configuration (shown here) will only work on insecure sites/devices:
[snmp_*]
env.version 2
env.community public
In general SNMP is not very secure at all unless you use SNMP version
3 which supports authentication and privacy (encryption). But in any
case the community string for your devices should not be "public".
Please see 'perldoc Munin::Plugin::SNMP' for further configuration
information.
=head1 MIB INFORMATION
This plugin requires NETSCREEN-RESOURCE-MIB information.
=head1 MAGIC MARKERS
#%# family=snmpauto
#%# capabilities=snmpconf
=head1 AUTHOR
Copyright (C) 2012 Diego Elio Pettenò.
=head1 LICENSE
GPLv2
=cut
use strict;
use Munin::Plugin;
use Munin::Plugin::SNMP;
# This corresponds to NETSCREEN-SMI::netscreenResource
my $oidBase = '1.3.6.1.4.1.3224.16';
my $oidCpuAvg = "$oidBase.1.1";
my $oidCpuLast1Min = "$oidBase.1.2";
my $oidCpuLast5Min = "$oidBase.1.3";
my $oidCpuLast15Min = "$oidBase.1.4";
my $oidMemAllocate = "$oidBase.2.1";
my $oidMemLeft = "$oidBase.2.2";
my $oidSessAllocate = "$oidBase.3.2";
my $oidSessMaximum = "$oidBase.3.3";
my $oidSessFailed = "$oidBase.3.4";
if (defined $ARGV[0] and $ARGV[0] eq "snmpconf") {
print "require $oidBase.[23].[13].0";
exit 0;
}
my $session = Munin::Plugin::SNMP->session();
my $data = $session->get_entries(-columns => [$oidCpuAvg,
$oidCpuLast1Min,
$oidCpuLast5Min,
$oidCpuLast15Min,
$oidMemAllocate,
$oidMemLeft,
$oidSessAllocate,
$oidSessMaximum,
$oidSessFailed ]);
if ($ARGV[0] and $ARGV[0] eq "config") {
my ($host) = Munin::Plugin::SNMP->config_session();
my $memTotal = $data->{"$oidMemAllocate.0"} + $data->{"$oidMemLeft.0"};
# this is the closet I can get to the yellow/red on the ScreenOS
# interface.
my $memWarning = int($memTotal * 0.75 + 0.5);
my $memCritical = int($memTotal * 0.85 + 0.5);
my $sessWarning = int($data->{"$oidSessMaximum.0"} * 0.75 + 0.5);
my $sessCritical = int($data->{"$oidSessMaximum.0"} * 0.85 + 0.5);
print <<END;
host_name $host
multigraph screenos_memory
graph_title Memory allocation
graph_vlabel bytes
graph_args --base 1024
graph_category system
memory.label Memory
memory.min 0
memory.max $memTotal
memory.warning $memWarning
memory.critical $memCritical
multigraph screenos_sessions
graph_title Sessions allocation
graph_vlabel Count
graph_category system
sessions.label Active Sessions
sessions.min 0
sessions.max $data->{"$oidSessMaximum.0"}
sessions.warning $sessWarning
sessions.critical $sessCritical
failed.label Failed Sessions
failed.min 0
failed.critical 1
multigraph screenos_cpu
graph_title CPU Utilization
graph_vlabel Percentage
graph_category system
average.label Average
average.min 0
average.max 100
average.warning 75
average.critical 85
last1.label Last minute
last1.min 0
last1.max 100
last1.warning 75
last1.critical 85
last5.label Last 5 minutes
last5.min 0
last5.max 100
last5.warning 75
last5.critical 85
last15.label Last 15 minutes
last15.min 0
last15.max 100
last15.warning 75
last15.critical 85
END
exit 0;
}
print <<END;
multigraph screenos_memory
memory.value $data->{"$oidMemAllocate.0"}
multigraph screenos_sessions
sessions.value $data->{"$oidSessAllocate.0"}
failed.value $data->{"$oidSessFailed.0"}
multigraph screenos_cpu
average.value $data->{"$oidCpuAvg.0"}
last1.value $data->{"$oidCpuLast1Min.0"}
last5.value $data->{"$oidCpuLast5Min.0"}
last15.value $data->{"$oidCpuLast15Min.0"}
END

View file

@ -1,188 +0,0 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
# Copyright (C) 2014 Johann Schmitz <johann@j-schmitz.net>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU Library General Public License as published by
# the Free Software Foundation; version 2 only
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Library General Public License for more details.
#
# You should have received a copy of the GNU Library General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
"""
=head1 NAME
snmp__synology_ - Health and system status monitoring plugin for Synology NAS systems
=head1 CONFIGURATION
Make sure your Synology device is accessible via SNMP (e.g. via snmpwalk) and the munin-node
has been configured correctly.
=head1 MAGIC MARKERS
#%# family=snmpauto
#%# capabilities=snmpconf
=head1 VERSION
0.0.1
=head1 BUGS
Open a ticket at https://github.com/ercpe/contrib if you find one.
=head1 AUTHOR
Johann Schmitz <johann@j-schmitz.net>
=head1 LICENSE
GPLv2
=cut
"""
import re
import sys
import os
import logging
from pysnmp.entity.rfc3413.oneliner import cmdgen
disktable_id = '1.3.6.1.4.1.6574.2.1.1.2'
disktable_model = '1.3.6.1.4.1.6574.2.1.1.3'
disktable_temp = '1.3.6.1.4.1.6574.2.1.1.6'
sys_temperature = '1.3.6.1.4.1.6574.1.2.0'
class SynologySNMPClient(object):
def __init__(self, host, port, community):
self.hostname = host
self.transport = cmdgen.UdpTransportTarget((host, int(port)))
self.auth = cmdgen.CommunityData('test-agent', community)
self.gen = cmdgen.CommandGenerator()
def _get_disks(self):
disk_table = '1.3.6.1.4.1.6574.2.1'
errorIndication, errorStatus, errorIndex, varBindTable = self.gen.bulkCmd(
self.auth,
self.transport,
0, 24,
disk_table)
if errorIndication:
logging.error("SNMP bulkCmd for devices failed: %s, %s, %s" % (errorIndication, errorStatus, errorIndex))
return
devices = {}
for row in varBindTable:
for oid, value in row:
oid = str(oid)
if not oid.startswith(disk_table):
continue
disk_id = oid[oid.rindex('.')+1:]
values = devices.get(disk_id, [None, None, None])
if oid.startswith(disktable_id):
values[0] = str(value).strip()
if oid.startswith(disktable_model):
values[1] = str(value).strip()
if oid.startswith(disktable_temp):
values[2] = int(value)
devices[disk_id] = values
for x in sorted(devices.keys()):
yield tuple([x] + devices[x])
def _get_sys_temperature(self):
errorIndication, errorStatus, errorIndex, varBindTable = self.gen.getCmd(
self.auth,
self.transport,
sys_temperature)
if errorIndication:
logging.error("SNMP getCmd for %s failed: %s, %s, %s" % (sys_temperature, errorIndication, errorStatus, errorIndex))
return None
return int(varBindTable[0][1])
def print_config(self):
print """multigraph synology_hdd_temperatures
host_name {hostname}
graph_title HDD temperatures on {hostname}
graph_vlabel Temperature in °C
graph_args --base 1000
graph_category system
graph_info HDD temperatures on {hostname}""".format(hostname=self.hostname)
for id, name, model, temp in self._get_disks():
print """disk{disk_id}.info Temperature of {name} ({model})
disk{disk_id}.label {name} ({model})
disk{disk_id}.type GAUGE
disk{disk_id}.min 0""".format(disk_id=id, name=name, model=model)
print """multigraph synology_sys_temperature
host_name {hostname}
graph_title System temperatures of {hostname}
graph_vlabel Temperature in °C
graph_args --base 1000
graph_category system
graph_info System temperature of {hostname}
sys_temp.info System temperature
sys_temp.label Temperature
sys_temp.type GAUGE
sys_temp.min 0
""".format(hostname=self.hostname)
def execute(self):
print """multigraph synology_hdd_temperatures"""
for id, name, model, temp in self._get_disks():
print """disk{disk_id}.value {temp}""".format(disk_id=id, temp=temp)
print """multigraph synology_sys_temperature"""
print "sys_temp.value {temp}".format(temp=self._get_sys_temperature())
host = None
port = os.getenv('port', 161)
community = os.getenv('community', None)
debug = bool(os.getenv('MUNIN_DEBUG', os.getenv('DEBUG', 0)))
if debug:
logging.basicConfig(level=logging.DEBUG, format='%(asctime)s %(levelname)-7s %(message)s')
try:
match = re.search("^(?:|.*\/)snmp_([^_]+)_synology$", sys.argv[0])
host = match.group(1)
match = re.search("^([^:]+):(\d+)$", host)
if match is not None:
host = match.group(1)
port = match.group(2)
except Exception as ex:
logging.error("Caught exception: %s" % ex)
if "snmpconf" in sys.argv[1:]:
print "require 1.3.6.1.4.1.6574.2.1.1"
sys.exit(0)
else:
if not (host and port and community):
print "# Bad configuration. Cannot run with Host=%s, port=%s and community=%s" % (host, port, community)
sys.exit(1)
c = SynologySNMPClient(host, port, community)
if "config" in sys.argv[1:]:
c.print_config()
else:
c.execute()

View file

@ -1,109 +0,0 @@
#!/usr/bin/perl -w
# -*- perl -*-
# vim: ft=perl
=head1 NAME
snmp__syno_hddtemp - Munin plugin to monitor the temperature of
harddisks in an Synology NAS.
=head1 APPLICABLE SYSTEMS
Any Synology NAS device which provides the synoDisk MIB.
=head1 CONFIGURATION
As a rule SNMP plugins need site specific configuration. The default
configuration (shown here) will only work on insecure sites/devices.
[snmp_*]
env.version 2
env.community public
In general SNMP is not very secure at all unless you use SNMP version
3 which supports authentication and privacy (encryption). But in any
case the community string for your devices should not be "public".
Please see 'perldoc Munin::Plugin::SNMP' for further configuration
information.
=head1 INTERPRETATION
The temperature of each disk installed in °C.
=head1 MIB INFORMATION
This plugin requires support for the synoDisk. It reports
the temperature of the installed disks.
=head1 MAGIC MARKERS
#%# family=snmpauto
#%# capabilities=snmpconf
=head1 VERSION
$Id$
=head1 BUGS
None known.
=head1 AUTHOR
Copyright (C) 2015 Thomas Arthofer
This plugin was derived from snmp__netstat by Lars Strand with updates
by Matthew Boyle.
=head1 LICENSE
GPLv2.
=cut
use strict;
use Munin::Plugin::SNMP;
my $oid_drives = '1.3.6.1.4.1.6574.2.1.1';
if (defined $ARGV[0] and $ARGV[0] eq 'snmpconf') {
print "require ${oid_drives}. [0-9]\n";
exit 0;
}
my ($session, $error) = Munin::Plugin::SNMP->session();
my $table = $session->get_hash(
-baseoid => $oid_drives, # IF-MIB
-cols => {
2 => 'name',
3 => 'type',
6 => 'temp',
}
);
if (defined $ARGV[0] and $ARGV[0] eq 'config') {
my ($host) = Munin::Plugin::SNMP->config_session();
print "host_name $host\n" unless $host eq 'localhost';
print "graph_title HDD temperature\n";
print "graph_category sensors\n";
print "graph_vlabel Degrees Celsius\n";
print "graph_info This graph shows the temperature of all HDDs in the Diskstation.\n";
foreach my $key ( sort keys %$table )
{
print "temp$key.label $table->{$key}->{'name'}\n";
print "temp$key.info Temperature of $table->{$key}->{'name'} ($table->{$key}->{'type'})\n";
}
exit 0;
}
my $names = $session->get_entries(-columns => [ $oid_drives ]);
foreach my $key ( sort keys %$table )
{
print "temp$key.value $table->{$key}->{'temp'}\n";
}

View file

@ -1,91 +0,0 @@
#!/usr/bin/perl -w
# -*- cperl -*-
# vim: ft=perl
=head1 NAME
snmp__syno_temperature - Munin plugin to retrieve current temperature from a
Synology NAS.
=head1 APPLICABLE SYSTEMS
Any Synology NAS device which provides the synoSystem MIB.
=head1 CONFIGURATION
As a rule SNMP plugins need site specific configuration. The default
configuration (shown here) will only work on insecure sites/devices.
[snmp_*]
env.version 2
env.community public
In general SNMP is not very secure at all unless you use SNMP version
3 which supports authentication and privacy (encryption). But in any
case the community string for your devices should not be "public".
Please see 'perldoc Munin::Plugin::SNMP' for further configuration
information.
=head1 INTERPRETATION
This plugin queries the current temperature of the NAS.
=head1 MIB INFORMATION
This plugin requires support for the synoSystem MIB by Synology.
It reports the contents of the temperature OID.
=head1 MAGIC MARKERS
#%# family=snmpauto
#%# capabilities=snmpconf
=head1 VERSION
$Id$
=head1 BUGS
None known.
=head1 AUTHOR
Copyright (C) 2015 Thomas Arthofer
=head1 LICENSE
GPLv2 or (at your option) any later version.
=cut
use strict;
use Munin::Plugin::SNMP;
if (defined $ARGV[0] and $ARGV[0] eq "snmpconf") {
print "require 1.3.6.1.4.1.6574.1.2.0 [0-9]\n"; # Number
exit 0;
}
if (defined $ARGV[0] and $ARGV[0] eq "config") {
my ($host) = Munin::Plugin::SNMP->config_session();
print "host_name $host\n" unless $host eq 'localhost';
print "graph_title Temperatures
graph_args --base 1000 -l 0
graph_vlabel Degrees Celsius
graph_category sensors
graph_info This graph shows the temperature of the diskstation.
temp.label CPU
temp.info The temperature of the onboard CPU.
";
exit 0;
}
my $session = Munin::Plugin::SNMP->session(-translate =>
[ -timeticks => 0x0 ]);
my $temp = $session->get_single (".1.3.6.1.4.1.6574.1.2.0") || 'ERROR';
print "Retrived uptime is '$temp'\n" if $Munin::Plugin::SNMP::DEBUG;
print "temp.value ", $temp, "\n";

View file

@ -1,102 +0,0 @@
#!/usr/bin/perl -w
# -*- cperl -*-
# vim: ft=perl
=head1 NAME
snmp__syno_ups - Munin plugin to retrieve various information of the
UPS attached to a Synology NAS.
=head1 APPLICABLE SYSTEMS
Any Synology NAS device which provides the synoUPS MIB.
=head1 CONFIGURATION
As a rule SNMP plugins need site specific configuration. The default
configuration (shown here) will only work on insecure sites/devices.
[snmp_*]
env.version 2
env.community public
In general SNMP is not very secure at all unless you use SNMP version
3 which supports authentication and privacy (encryption). But in any
case the community string for your devices should not be "public".
Please see 'perldoc Munin::Plugin::SNMP' for further configuration
information.
=head1 INTERPRETATION
The plugin reports the following stats about the UPS attached:
- Load in %
- Charge in %
=head1 MIB INFORMATION
This plugin requires support for the synoUPS MIB by Synology.
=head1 MAGIC MARKERS
#%# family=snmpauto
#%# capabilities=snmpconf
=head1 VERSION
$Id$
=head1 BUGS
None known.
=head1 AUTHOR
Copyright (C) 2015 Thomas Arthofer
=head1 LICENSE
GPLv2 or (at your option) any later version.
=cut
use strict;
use Munin::Plugin::SNMP;
if (defined $ARGV[0] and $ARGV[0] eq "snmpconf") {
print "require 1.3.6.1.4.1.6574.4.3.1.1.0 [0-9]\n"; # Charge
print "require 1.3.6.1.4.1.6574.4.2.12.1.0 [0-9]\n"; # Load
exit 0;
}
if (defined $ARGV[0] and $ARGV[0] eq "config") {
my ($host) = Munin::Plugin::SNMP->config_session();
print "host_name $host\n" unless $host eq 'localhost';
print "graph_title UPS
graph_args --base 1000 -l 0
graph_vlabel Status of UPS
graph_category system
graph_info This graph shows the status of the attached UPS.
charge.label Charge
charge.info Charge status of battery.
charge.draw LINE2
load.label Load
load.info Load on the UPS
";
exit 0;
}
my $session = Munin::Plugin::SNMP->session(-translate =>
[ -timeticks => 0x0 ]);
my $charge = $session->get_single (".1.3.6.1.4.1.6574.4.3.1.1.0") || 'ERROR';
$charge = unpack "f", reverse pack "H*", $charge;
my $load = $session->get_single (".1.3.6.1.4.1.6574.4.2.12.1.0") || 'ERROR';
$load = unpack "f", reverse pack "H*", $load;
print "Retrived charge '$charge'\n" if $Munin::Plugin::SNMP::DEBUG;
print "Retrived load '$load'\n" if $Munin::Plugin::SNMP::DEBUG;
print "charge.value ", $charge, "\n";
print "load.value ", $load, "\n";

View file

@ -1,104 +0,0 @@
#!/usr/bin/perl -w
# -*- cperl -*-
=head1 NAME
snmp__thecus_fans - Munin plugin to retrive fanspeed readings from a Thecus
NAS device running SNMP.
=head1 APPLICABLE SYSTEMS
All Thecus NAS devices which have the third party NETSNMPD module installed.
This is available at http://www.fajo.de/main/thecus/modules/netsnmpd
=head1 CONFIGURATION
As a rule SNMP plugins need site specific configuration. The default
configuration (shown here) will only work on insecure sites/devices.
[snmp_*]
env.version 2
env.community public
In general SNMP is not very secure at all unless you use SNMP version
3 which supports authentication and privacy (encryption). But in any
case the community string for your devices should not be "public".
Please see 'perldoc Munin::Plugin::SNMP' for further configuration
information.
=head1 INTERPRETATION
The plugin reports the current fan speed readings as reported by the thecusIO
module.
=head1 MIB INFORMATION
Private MIB
=head1 MAGIC MARKERS
#%# family=snmpauto
#%# capabilities=snmpconf
=head1 VERSION
0.0.20120307
=head1 BUGS
None known.
=head1 AUTHOR
Copyright (C) 2011 - 2012 Andreas Thienemann <andreas@bawue.net>
Based on the snmp__uptime plugin as a template.
=head1 LICENSE
GPLv2 or (at your option) any later version.
=cut
use strict;
use Munin::Plugin::SNMP;
use vars qw($DEBUG);
$DEBUG = $ENV{'MUNIN_DEBUG'};
my $response;
if (defined $ARGV[0] and $ARGV[0] eq "snmpconf") {
print "index 1.3.6.1.4.1.14822.101.21.\n";
print "require 1.3.6.1.4.1.14822.101.21.5200.1.1.0 [0-9]\n";
print "require 1.3.6.1.4.1.14822.101.21.5200.1.2.0 [0-9]\n";
exit 0;
}
if (defined $ARGV[0] and $ARGV[0] eq "config") {
my ($host) = Munin::Plugin::SNMP->config_session();
print "host_name $host\n" unless $host eq 'localhost';
print "graph_title Thecus Fans
graph_args --base 1000 -l 0
graph_vlabel RPM
graph_info This graph shows the RPMs of the fans as reported by the ThecusIO module.
graph_category sensors
fan1.label Fan 1
fan1.info Thecus CPU Fan
fan2.label Fan 2
fan2.info Thecus System Fan
";
exit 0;
}
my $session = Munin::Plugin::SNMP->session(-translate =>
[ -timeticks => 0x0 ]);
my $fan1 = $session->get_single ("1.3.6.1.4.1.14822.101.21.5200.1.1.0") || 'U';
my $fan2 = $session->get_single ("1.3.6.1.4.1.14822.101.21.5200.1.2.0") || 'U';
#print "Retrived uptime is '$uptime'\n" if $DEBUG;
print "fan1.value ", $fan1, "\n";
print "fan2.value ", $fan2, "\n";

View file

@ -1,217 +0,0 @@
#!/usr/bin/perl -w
#
# This plugin is for querying UPSes that support the UPS-MIB from RFC 1628
# - NOT APC (apparently)
#
# current version by Michael Meier <michael.meier@fau.de>
# previous version by Jean-Samuel Reynaud <js.reynaud@free.fr>
# based on snmp__if_ from Jimmy Olsen, Dagfinn Ilmari Mannsaaker
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; version 2 dated June,
# 1991.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
#
# Usage:
# ln -s /usr/share/munin/node/plugins-auto/snmp__ups_ /etc/munin/node.d/snmp_ups.domain.tld_ups_mode
# available modes:
# batteryruntime, batteryremaining, batterypercent, batteryvoltage,
# batterycurrent, batterytemperature,
# inputfrequency, inputvoltage, inputcurrent, inputpower,
# outputvoltage, outputcurrent, outputpower, outputpercentload,
# inputlinebads
# Most UPSs only support a small subset of these modes.
#
#%# family=snmpauto
#%# capabilities=snmpconf
use strict;
use Net::SNMP;
my $DEBUG = 0;
my $host = $ENV{host} || undef;
my $port = $ENV{port} || 161;
my $community = $ENV{community} || "public";
my $mode = $ENV{mode} || undef;
my $response;
if (defined $ARGV[0] and $ARGV[0] eq "snmpconf")
{
print "require .1.3.6.1.2.1.33.1.2.7 [0-9]\n"; # Bat temp
exit 0;
}
if ($0 =~ /^(?:|.*\/)snmp_([^_]+)_ups_(.+)$/)
{
$host = $1;
$mode = $2;
if ($host =~ /^([^:]+):(\d+)$/) {
$host = $1;
$port = $2;
}
}
elsif (!defined($host))
{
print("# Debug: $0 -- $1 -- $2\n") if $DEBUG;
print("# Error: couldn't understand what I'm supposed to monitor.\n");
print("# You need to either name this plugin properly in the scheme\n");
print("# snmp_HOSTNAME_ups_MODE\n");
print("# or alternatively set the environment variables 'host' and 'mode'\n");
exit(1);
}
my $graphs = {
'batteryruntime' => { 'title' => 'Seconds running on battery',
'unit' => 'seconds',
'label' => 'onbatteryfor',
'value' => '.1.3.6.1.2.1.33.1.2.2' },
'batteryremaining' => { 'title' => 'Estimated remaining runtime on battery',
'unit' => 'minutes',
'label' => 'remaining',
'value' => '.1.3.6.1.2.1.33.1.2.3' },
'batterypercent' => { 'title' => 'Estimated remaining charge',
'unit' => '%',
'label' => 'remaining',
'value' => '.1.3.6.1.2.1.33.1.2.4' },
'batteryvoltage' => { 'title' => 'Battery Voltage',
'unit' => 'Volt',
'scale' => 0.1,
'value' => '.1.3.6.1.2.1.33.1.2.5' },
'batterycurrent' => { 'title' => 'Battery current',
'unit' => 'Ampere',
'scale' => 0.1,
'value' => '.1.3.6.1.2.1.33.1.2.6' },
'batterytemperature' => { 'title' => 'Battery Temperature',
'unit' => 'degC',
'label' => 'Temperature %u',
'value' => '.1.3.6.1.2.1.33.1.2.7' },
'inputfrequency' => { 'title' => 'Input Frequency',
'scale' => 0.1,
'unit' => 'Hz',
'list' => '.1.3.6.1.2.1.33.1.3.2',
'value' => '.1.3.6.1.2.1.33.1.3.3.1.2' },
'inputvoltage' => { 'title' => 'Input Voltage',
'unit' => 'Volt',
'list' => '.1.3.6.1.2.1.33.1.3.2',
'value' => '.1.3.6.1.2.1.33.1.3.3.1.3' },
'inputcurrent' => { 'title' => 'Input Current',
'unit' => 'Ampere',
'scale' => 0.1,
'list' => '.1.3.6.1.2.1.33.1.3.2',
'value' => '.1.3.6.1.2.1.33.1.3.3.1.4' },
'inputpower' => { 'title' => 'Input Power',
'unit' => 'Watt',
'list' => '.1.3.6.1.2.1.33.1.3.2',
'value' => '.1.3.6.1.2.1.33.1.3.3.1.5' },
'outputvoltage' => { 'title' => 'Output Voltage',
'list' => '.1.3.6.1.2.1.33.1.4.3',
'unit' => 'Volt',
'value' => '.1.3.6.1.2.1.33.1.4.4.1.2' },
'outputcurrent' => { 'title' => 'Output Current',
'unit' => 'Ampere',
'scale' => 0.1,
'list' => '.1.3.6.1.2.1.33.1.4.3',
'value' => '.1.3.6.1.2.1.33.1.4.4.1.3' },
'outputpower' => { 'title' => 'Output Power',
'unit' => 'Watt',
'list' => '.1.3.6.1.2.1.33.1.4.3',
'value' => '.1.3.6.1.2.1.33.1.4.4.1.4' },
'outputpercentload' => { 'title' => 'Output Load',
'unit' => '%',
'list' => '.1.3.6.1.2.1.33.1.4.3',
'value' => '.1.3.6.1.2.1.33.1.4.4.1.5' },
'inputlinebads' => { 'title' => 'Number of times input power went bad',
'unit' => 'n',
'value' => '.1.3.6.1.2.1.33.1.3.1' }
};
my ($session, $error) = Net::SNMP->session(
-hostname => $host,
-community => $community,
-port => $port,
-timeout => 1.0
);
if (!defined($session)) {
print("# Failed to open SNMP session: $error\n");
exit(1);
}
unless (defined($graphs->{$mode}->{'title'})) {
print("# Unknown mode '$mode'! Available modes are:\n");
foreach my $m (keys(%{$graphs})) {
if (defined($graphs->{$m}->{'title'})) {
printf("# %-18s %s\n", $m, $graphs->{$m}->{'title'});
}
}
exit(1);
}
my $count_data = 1;
if (defined $graphs->{$mode}->{'list'}) {
if (defined ($response = $session->get_request($graphs->{$mode}->{'list'} . ".0"))) {
$count_data = $response->{$graphs->{$mode}->{'list'} . ".0"};
} else { # Unfortunately, some UPSs do not properly implement RFC 1628:
# They fail to report the number of lines.
# We will default to 3 as that will work in most cases.
# The environment variable 'numlines' can be used to override the default.
$count_data = 3;
if (defined($ENV{'numlines'})) {
$count_data = int($ENV{'numlines'});
}
}
}
if ($ARGV[0] and $ARGV[0] eq "config") {
print("host_name $host\n");
printf("graph_title %s\n", $graphs->{$mode}->{'title'});
# print "graph_args --base 1000\n";
print("graph_category sensors\n");
printf("graph_vlabel %s\n", $graphs->{$mode}->{'unit'});
for (my $i=0; $i < $count_data; $i++) {
my $ip1 = $i + 1;
if (defined($graphs->{$mode}->{'label'})) {
printf("%s%u.label %s\n", $mode, $ip1, sprintf($graphs->{$mode}->{'label'}, $ip1));
} else {
printf("%s%u.label Line %u\n", $mode, $ip1, $ip1);
}
printf("%s%u.type GAUGE\n", $mode, $ip1);
#printf "line%u.info %s\n",$i+1,$graphs->{$mode}->{'unit'};
if (defined($ENV{"${mode}${ip1}.warning"})) { printf("%s%s.warning %s\n", $mode, $ip1, $ENV{"${mode}${ip1}.warning"}); }
if (defined($ENV{"${mode}${ip1}.critical"})) { printf("%s%s.critical %s\n", $mode, $ip1, $ENV{"${mode}${ip1}.critical"}); }
}
exit(0);
}
for (my $i = 0; $i < $count_data; $i++) {
my $l_current = $i+1;
if ($count_data == 1) {
$l_current = 0;
}
if (defined ($response = $session->get_request($graphs->{$mode}->{'value'} . sprintf(".%u",$l_current)))) {
my $v = $response->{$graphs->{$mode}->{'value'} . sprintf(".%u",$l_current)};
if (defined($graphs->{$mode}->{'scale'})) {
$v = $v * $graphs->{$mode}->{'scale'};
printf("%s%u.value %.1f\n", $mode, $i+1, $v);
} else {
printf("%s%u.value %u\n", $mode, $i+1, $v);
}
} else {
printf("%s%u.value U\n", $mode, $i+1);
}
}