mirror of
https://github.com/munin-monitoring/contrib.git
synced 2025-07-23 06:35:42 +00:00
Put order in SNMP plugins by moving all of them together in snmp/
This makes it easier to find what should be used for SNMP monitoring.
This commit is contained in:
parent
2fc9c2400b
commit
7da1b039c2
45 changed files with 0 additions and 0 deletions
|
@ -1,63 +0,0 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Munin plugin snmp__bri_se_
|
||||
#
|
||||
# Version: 0.2, released on 30/02/2009, tested on Debian GNU/Linux 4.0 (etch)
|
||||
# using Cisco 5350 gateways.
|
||||
#
|
||||
# This plugin reports the number of BRI channels currently in use on SE/foo
|
||||
# using SNMP community bar.
|
||||
#
|
||||
# Requirements: bash, snmpget, rev, cut, which
|
||||
#
|
||||
# Copyright (c) 2009 by Kees Meijs <kees@kumina.nl> for Kumina bv.
|
||||
#
|
||||
# This work is licensed under the Creative Commons Attribution-Share Alike 3.0
|
||||
# Unported license. In short: you are free to share and to make derivatives of
|
||||
# this work under the conditions that you appropriately attribute it, and that
|
||||
# you only distribute it under the same, similar or a compatible license. Any
|
||||
# of the above conditions can be waived if you get permission from the copyright
|
||||
# holder.
|
||||
|
||||
# HOW TO?
|
||||
#
|
||||
# Symlink snmp___bri_se_ to /etc/munin/plugins/snmp_HOSTNAME_COMMUNITY_bri_se_SEOFGATEWAY
|
||||
# For example: snmp_1.2.3.4_public_bri_se_3 to check community "public" on host "1.2.3.4"
|
||||
# using SE #3.
|
||||
|
||||
# More strict checking
|
||||
set -e
|
||||
|
||||
# Check for snmpget
|
||||
SNMPGET=$(which snmpget)
|
||||
|
||||
# Catch command line arguments
|
||||
JOB=$1
|
||||
|
||||
# Set variables
|
||||
HOSTNAME=$(echo $0 | rev | cut -d '_' -f 5 | rev)
|
||||
COMMUNITY=$(echo $0 | rev | cut -d '_' -f 4 | rev)
|
||||
SE=$(echo $0 | rev | cut -d '_' -f 1 | rev)
|
||||
|
||||
# Configure Munin
|
||||
case "$1" in
|
||||
"config")
|
||||
echo "host_name $HOSTNAME"
|
||||
echo "graph_title BRI usage on SE-$SE"
|
||||
echo "graph_vlabel Number of used BRI channels"
|
||||
echo "graph_scale no"
|
||||
echo "graph_category network"
|
||||
for CHANNEL in $(seq 0 7); do
|
||||
echo "chan_$CHANNEL.label SE-$SE/$CHANNEL used channels"
|
||||
done
|
||||
exit 0;;
|
||||
esac
|
||||
|
||||
# Return fetched SNMP values
|
||||
for CHANNEL in $(seq 0 7); do
|
||||
echo -n "chan_$CHANNEL.value "
|
||||
$SNMPGET -v 1 -c $COMMUNITY $HOSTNAME 1.3.6.1.4.1.9.10.19.1.1.9.1.3.$SE.$CHANNEL | rev | cut -d ' ' -f 1 | rev
|
||||
done
|
||||
|
||||
# Exit cleanly
|
||||
exit 0
|
|
@ -1,88 +0,0 @@
|
|||
#!/usr/bin/perl -w
|
||||
|
||||
=head1 MAGIC MARKERS
|
||||
|
||||
#%# family=snmpauto
|
||||
#%# capabilities=snmpconf
|
||||
|
||||
=cut
|
||||
|
||||
use strict;
|
||||
use Munin::Plugin;
|
||||
use Munin::Plugin::SNMP;
|
||||
|
||||
my $DEBUG=$ENV{'MUNIN_DEBUG'};
|
||||
|
||||
# This is the snmpwalk:
|
||||
# snAgentTempSensorDescr.1.1 = STRING: "Line module 1, sensor 1 temperature"
|
||||
# snAgentTempSensorDescr.1.2 = STRING: "Line module 1, sensor 2 temperature"
|
||||
# snAgentTempSensorDescr.1.3 = STRING: "Line module 1, sensor 3 temperature"
|
||||
# snAgentTempSensorDescr.1.4 = STRING: "Line module 1, sensor 4 temperature"
|
||||
# snAgentTempSensorDescr.2.1 = STRING: "Line module 2, sensor 1 temperature"
|
||||
# snAgentTempSensorDescr.2.2 = STRING: "Line module 2, sensor 2 temperature"
|
||||
# snAgentTempSensorDescr.2.3 = STRING: "Line module 2, sensor 3 temperature"
|
||||
# snAgentTempSensorDescr.2.4 = STRING: "Line module 2, sensor 4 temperature"
|
||||
# snAgentTempSensorDescr.3.1 = STRING: "Active management module temperature"
|
||||
# snAgentTempSensorDescr.3.2 = STRING: "Active management module temperature"
|
||||
# snAgentTempValue.1.1 = INTEGER: 100
|
||||
# snAgentTempValue.1.2 = INTEGER: 106
|
||||
# snAgentTempValue.1.3 = INTEGER: 82
|
||||
# snAgentTempValue.1.4 = INTEGER: 72
|
||||
# snAgentTempValue.2.1 = INTEGER: 74
|
||||
# snAgentTempValue.2.2 = INTEGER: 102
|
||||
# snAgentTempValue.2.3 = INTEGER: 70
|
||||
# snAgentTempValue.2.4 = INTEGER: 74
|
||||
# snAgentTempValue.3.1 = INTEGER: 78
|
||||
# snAgentTempValue.3.2 = INTEGER: 84
|
||||
|
||||
my $brcdIp = '1.3.6.1.4.1.1991';
|
||||
my $snAgentTempTable = "$brcdIp.1.1.2.13.1";
|
||||
my $snAgentTempSensorDescr = "$snAgentTempTable.1.3";
|
||||
my $snAgentTempValue = "$snAgentTempTable.1.4";
|
||||
|
||||
|
||||
if (defined $ARGV[0] and $ARGV[0] eq "snmpconf") {
|
||||
print "index $snAgentTempTable.1.3.\n";
|
||||
print "require $snAgentTempSensorDescr. [1-9]\n";
|
||||
print "require $snAgentTempValue. [1-9]\n";
|
||||
exit 0;
|
||||
}
|
||||
|
||||
my $module = 0;
|
||||
|
||||
if ($Munin::Plugin::me =~ /_module_(\d+)$/) {
|
||||
$module = $1;
|
||||
} else {
|
||||
die "Could not determine module number from ".$Munin::Plugin::me."\n";
|
||||
}
|
||||
|
||||
my ($session,$error);
|
||||
|
||||
$session = Munin::Plugin::SNMP->session(-translate => [ -nosuchinstance => undef ]);
|
||||
|
||||
my $sensor = 1;
|
||||
if ($ARGV[0] and $ARGV[0] eq "config") {
|
||||
my ($host,undef,$version) = Munin::Plugin::SNMP->config_session();
|
||||
|
||||
print "host_name $host\n" unless $host eq 'localhost';
|
||||
print "graph_title Module $module
|
||||
graph_args --base 1000 --lower-limit 0
|
||||
graph_vlabel °C
|
||||
graph_category system
|
||||
graph_scale no\n";
|
||||
|
||||
my $descr = undef;
|
||||
while (defined ($descr = $session->get_single("$snAgentTempSensorDescr.$module.$sensor"))) {
|
||||
print "sensor$sensor.label $descr\n";
|
||||
$sensor ++;
|
||||
}
|
||||
exit 0;
|
||||
}
|
||||
|
||||
my $value = undef;
|
||||
while (defined ($value = $session->get_single("$snAgentTempValue.$module.$sensor"))) {
|
||||
$value /= 2;
|
||||
print "sensor$sensor.value $value\n";
|
||||
$sensor++;
|
||||
}
|
||||
# vim:ft=perl
|
|
@ -1,170 +0,0 @@
|
|||
#!/usr/bin/perl -w
|
||||
##
|
||||
## Copyright (C) 2007 OZ
|
||||
##
|
||||
## interface-traffic including warnlevels, based on snmp__if_.
|
||||
##
|
||||
## supports entries for maximum bitrates in
|
||||
## /etc/munin/plugin-conf.d/munin-node like:
|
||||
## [snmp_<hostname>_if_*]
|
||||
## env.levelwarn 800000
|
||||
## env.levelcrit 1000000
|
||||
##
|
||||
## 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.
|
||||
##
|
||||
|
||||
## Revision 0.1 2007/01/18 15:00:00 oz
|
||||
|
||||
#
|
||||
#%# 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 "number 1.3.6.1.2.1.2.1.0\n";
|
||||
print "index 1.3.6.1.2.1.2.2.1.1.\n";
|
||||
print "require 1.3.6.1.2.1.2.2.1.3. ^(6|23)\$\n"; # Type
|
||||
print "require 1.3.6.1.2.1.2.2.1.5. [1-9]\n"; # Speed
|
||||
exit 0;
|
||||
}
|
||||
|
||||
if ($0 =~ /^(?:|.*\/)snmp_([^_]+)_if_(.+)$/)
|
||||
{
|
||||
$host = $1;
|
||||
$iface = $2;
|
||||
if ($host =~ /^([^:]+):(\d+)$/)
|
||||
{
|
||||
$host = $1;
|
||||
$port = $2;
|
||||
}
|
||||
}
|
||||
elsif (!defined($host))
|
||||
{
|
||||
print "# Debug: $0 -- $1 -- $2\n" if $DEBUG;
|
||||
die "# Error: couldn't understand what I'm supposed to monitor.";
|
||||
}
|
||||
|
||||
my $ifEntryDescr = "1.3.6.1.2.1.2.2.1.2.$iface";
|
||||
my $ifEntrySpeed = "1.3.6.1.2.1.2.2.1.5.$iface";
|
||||
my $ifEntryStatus = "1.3.6.1.2.1.2.2.1.8.$iface";
|
||||
my $ifEntryInOctets = "1.3.6.1.2.1.2.2.1.10.$iface";
|
||||
my $ifEntryOutOctets = "1.3.6.1.2.1.2.2.1.16.$iface";
|
||||
|
||||
my ($session, $error) = Net::SNMP->session(
|
||||
-hostname => $host,
|
||||
-community => $community,
|
||||
-port => $port
|
||||
);
|
||||
|
||||
if (!defined ($session))
|
||||
{
|
||||
die "Croaking: $error";
|
||||
}
|
||||
|
||||
if ($ARGV[0] and $ARGV[0] eq "config")
|
||||
{
|
||||
print "host_name $host\n";
|
||||
if (!defined ($response = $session->get_request($ifEntryDescr)))
|
||||
{
|
||||
die "Croaking: " . $session->error();
|
||||
}
|
||||
my $name = $response->{$ifEntryDescr};
|
||||
$name =~ s/[^\w\s]//g;
|
||||
my $warn = undef;
|
||||
if (defined ($response = $session->get_request($ifEntrySpeed)))
|
||||
{
|
||||
$warn = $response->{$ifEntrySpeed}/8;
|
||||
}
|
||||
my $levelwarn=undef;
|
||||
$levelwarn=$ENV{levelwarn} if defined($ENV{levelwarn});
|
||||
my $levelcrit=undef;
|
||||
$levelcrit=$ENV{levelcrit} if defined($ENV{levelcrit});
|
||||
if (length ($name) > 15)
|
||||
{
|
||||
print "graph_title Interface $iface traffic\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
print "graph_title Interface $name traffic\n";
|
||||
}
|
||||
print "graph_order recv send\n";
|
||||
print "graph_args --base 1000\n";
|
||||
print "graph_vlabel bits in (-) / out (+) per \${graph_period}\n";
|
||||
print "graph_category network\n";
|
||||
print "graph_info This graph shows traffic for the \"$name\" network interface.\n";
|
||||
print "send.info Bits sent/received by this interface.\n";
|
||||
print "recv.label recv\n";
|
||||
print "recv.type DERIVE\n";
|
||||
print "recv.graph no\n";
|
||||
print "recv.cdef recv,8,*\n";
|
||||
print "recv.max 2000000000\n";
|
||||
print "recv.min 0\n";
|
||||
print "recv.warn ", (-$warn), "\n" if defined $warn;
|
||||
print "recv.warning $levelwarn\n" if defined $levelwarn;
|
||||
print "recv.critical $levelcrit\n" if defined $levelcrit;
|
||||
print "send.label bps\n";
|
||||
print "send.type DERIVE\n";
|
||||
print "send.negative recv\n";
|
||||
print "send.cdef send,8,*\n";
|
||||
print "send.max 2000000000\n";
|
||||
print "send.min 0\n";
|
||||
print "send.warn $warn\n" if defined $warn;
|
||||
print "send.warning $levelwarn\n" if defined $levelwarn;
|
||||
print "send.critical $levelcrit\n" if defined $levelcrit;
|
||||
exit 0;
|
||||
}
|
||||
|
||||
my $status = 1;
|
||||
if (defined ($response = $session->get_request($ifEntryStatus)))
|
||||
{
|
||||
$status = $response->{$ifEntryStatus};
|
||||
}
|
||||
|
||||
if ($status == 2)
|
||||
{
|
||||
print "recv.value U\n";
|
||||
print "send.value U\n";
|
||||
exit 0;
|
||||
}
|
||||
|
||||
if (defined ($response = $session->get_request($ifEntryInOctets)))
|
||||
{
|
||||
print "recv.value ", $response->{$ifEntryInOctets}, "\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
print "recv.value U\n";
|
||||
}
|
||||
|
||||
if (defined ($response = $session->get_request($ifEntryOutOctets)))
|
||||
{
|
||||
print "send.value ", $response->{$ifEntryOutOctets}, "\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
print "send.value U\n";
|
||||
}
|
|
@ -1,164 +0,0 @@
|
|||
#!/usr/bin/perl -w
|
||||
#
|
||||
# Copyright (C) 2008 François Borlet-Hote
|
||||
#
|
||||
# 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$
|
||||
#
|
||||
# Based on snmp_if from the Revision 1.18 2004/12/10 18:51:43 by jimmyo
|
||||
#
|
||||
# Revision 1.0 2008/05/29 16:10:00 fbh
|
||||
# Created by fbh
|
||||
#
|
||||
#
|
||||
#%# 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 $version = $ENV{version} || "2c";
|
||||
|
||||
my $response;
|
||||
|
||||
if (defined $ARGV[0] and $ARGV[0] eq "snmpconf")
|
||||
{
|
||||
print "number 1.3.6.1.2.1.2.1.0\n";
|
||||
print "index 1.3.6.1.2.1.2.2.1.1.\n";
|
||||
print "require 1.3.6.1.2.1.2.2.1.3. ^(6|23)\$\n"; # Type
|
||||
print "require 1.3.6.1.2.1.2.2.1.5. [1-9]\n"; # Speed
|
||||
exit 0;
|
||||
}
|
||||
|
||||
if ($0 =~ /^(?:|.*\/)snmp_([^_]+)_ifX_(.+)$/)
|
||||
{
|
||||
$host = $1;
|
||||
$iface = $2;
|
||||
if ($host =~ /^([^:]+):(\d+)$/)
|
||||
{
|
||||
$host = $1;
|
||||
$port = $2;
|
||||
}
|
||||
}
|
||||
elsif (!defined($host))
|
||||
{
|
||||
print "# Debug: $0 -- $1 -- $2\n" if $DEBUG;
|
||||
die "# Error: couldn't understand what I'm supposed to monitor.";
|
||||
}
|
||||
|
||||
my $ifEntryDescr = "1.3.6.1.2.1.2.2.1.2.$iface";
|
||||
my $ifEntrySpeed = "1.3.6.1.2.1.2.2.1.5.$iface";
|
||||
my $ifEntryStatus = "1.3.6.1.2.1.2.2.1.8.$iface";
|
||||
my $ifEntryInOctets = "1.3.6.1.2.1.31.1.1.1.6.$iface";
|
||||
my $ifEntryOutOctets = "1.3.6.1.2.1.31.1.1.1.10.$iface";
|
||||
|
||||
my ($session, $error) = Net::SNMP->session(
|
||||
-hostname => $host,
|
||||
-community => $community,
|
||||
-port => $port,
|
||||
-version => $version
|
||||
);
|
||||
|
||||
if (!defined ($session))
|
||||
{
|
||||
die "Croaking: $error";
|
||||
}
|
||||
|
||||
if ($ARGV[0] and $ARGV[0] eq "config")
|
||||
{
|
||||
print "host_name $host\n";
|
||||
if (!defined ($response = $session->get_request($ifEntryDescr)))
|
||||
{
|
||||
die "Croaking: " . $session->error();
|
||||
}
|
||||
my $name = $response->{$ifEntryDescr};
|
||||
$name =~ s/[^\w\s]//g;
|
||||
my $warn = undef;
|
||||
my $max = 1000000000;
|
||||
if (defined ($response = $session->get_request($ifEntrySpeed)))
|
||||
{
|
||||
$max = $response->{$ifEntrySpeed};
|
||||
$warn = $response->{$ifEntrySpeed}*0.8;
|
||||
}
|
||||
if (length ($name) > 15)
|
||||
{
|
||||
print "graph_title Interface $iface traffic\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
print "graph_title Interface $name traffic\n";
|
||||
}
|
||||
|
||||
print "graph_order recv send\n";
|
||||
print "graph_args --base 1000\n";
|
||||
print "graph_vlabel bits in (-) / out (+) per \${graph_period}\n";
|
||||
print "graph_category network\n";
|
||||
print "graph_info This graph shows traffic for the \"$name\" network interface.\n";
|
||||
print "send.info Bits sent/received by this interface.\n";
|
||||
print "recv.label recv\n";
|
||||
print "recv.type DERIVE\n";
|
||||
print "recv.graph no\n";
|
||||
print "recv.cdef recv,8,*\n";
|
||||
print "recv.max ",$max,"\n";
|
||||
print "recv.min 0\n";
|
||||
print "recv.warn ", (-$warn), "\n" if defined $warn;
|
||||
print "send.label bps\n";
|
||||
print "send.type DERIVE\n";
|
||||
print "send.negative recv\n";
|
||||
print "send.cdef send,8,*\n";
|
||||
print "send.max ",$max,"\n";
|
||||
print "send.min 0\n";
|
||||
print "send.warn $warn\n" if defined $warn;
|
||||
exit 0;
|
||||
}
|
||||
|
||||
my $status = 1;
|
||||
if (defined ($response = $session->get_request($ifEntryStatus)))
|
||||
{
|
||||
$status = $response->{$ifEntryStatus};
|
||||
}
|
||||
|
||||
if ($status == 2)
|
||||
{
|
||||
print "recv.value U\n";
|
||||
print "send.value U\n";
|
||||
exit 0;
|
||||
}
|
||||
|
||||
if (defined ($response = $session->get_request($ifEntryInOctets)))
|
||||
{
|
||||
print "recv.value ", $response->{$ifEntryInOctets}, "\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
print "recv.value U\n";
|
||||
}
|
||||
|
||||
if (defined ($response = $session->get_request($ifEntryOutOctets)))
|
||||
{
|
||||
print "send.value ", $response->{$ifEntryOutOctets}, "\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
print "send.value U\n";
|
||||
}
|
|
@ -1,167 +0,0 @@
|
|||
#!/usr/bin/perl -w
|
||||
#
|
||||
# Jean-Samuel Reynaud <js.reynaud@free.fr>
|
||||
# base 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__ups2_ /etc/munin/node.d/snmp_ups.address.loc_mode
|
||||
# with mode : batteryVoltage, batteryTemperature,inputVoltage,inputCurrent,inputFrequency,outputVoltage,outputCurrent,outputPower,outputPercentLoad,ChargeRemaining
|
||||
#
|
||||
|
||||
#%# 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_([^_]+)_ups2_(.+)$/)
|
||||
{
|
||||
$host = $1;
|
||||
$mode = $2;
|
||||
if ($host =~ /^([^:]+):(\d+)$/)
|
||||
{
|
||||
$host = $1;
|
||||
$port = $2;
|
||||
}
|
||||
}
|
||||
elsif (!defined($host))
|
||||
{
|
||||
print "# Debug: $0 -- $1 -- $2\n" if $DEBUG;
|
||||
die "# Error: couldn't understand what I'm supposed to monitor.";
|
||||
}
|
||||
|
||||
|
||||
|
||||
my $graphs = {
|
||||
'batteryVoltage' => { 'title' => 'Battery Voltage',
|
||||
'category' => 'network',
|
||||
'unit' => 'Volt',
|
||||
'value' => '.1.3.6.1.2.1.33.1.2.5'},
|
||||
'batteryTemperature' => { 'title' => 'Battery Temperature',
|
||||
'category' => 'network',
|
||||
'unit' => 'DegC',
|
||||
'value' => '.1.3.6.1.2.1.33.1.2.7'},
|
||||
'inputVoltage' => { 'title' => 'Input Voltage',
|
||||
'category' => 'network',
|
||||
'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',
|
||||
'category' => 'network',
|
||||
'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.4'},
|
||||
'inputFrequency' => { 'title' => 'Input Frequency',
|
||||
'category' => 'network',
|
||||
'list' => '.1.3.6.1.2.1.33.1.3.2',
|
||||
'unit' => 'Hz',
|
||||
'value' => '.1.3.6.1.2.1.33.1.3.3.1.2'},
|
||||
|
||||
'outputVoltage' => { 'title' => 'Output Voltage',
|
||||
'category' => 'network',
|
||||
'list' => '.1.3.6.1.2.1.33.1.4.3',
|
||||
'unit' => 'Hz',
|
||||
'value' => '.1.3.6.1.2.1.33.1.4.4.1.2'},
|
||||
'outputCurrent' => { 'title' => 'Output Current',
|
||||
'category' => 'network',
|
||||
'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',
|
||||
'category' => 'network',
|
||||
'list' => '.1.3.6.1.2.1.33.1.4.3',
|
||||
'unit' => 'Hz',
|
||||
'value' => '.1.3.6.1.2.1.33.1.4.4.1.4'},
|
||||
|
||||
'outputPercentLoad' => { 'title' => 'Output PercentLoad',
|
||||
'category' => 'network',
|
||||
'list' => '.1.3.6.1.2.1.33.1.4.3',
|
||||
'unit' => '%',
|
||||
'value' => '.1.3.6.1.2.1.33.1.4.4.1.5'},
|
||||
|
||||
'ChargeRemaining' => { 'title' => 'Charge remaining',
|
||||
'unit' => 'Seconds',
|
||||
'category' => 'network',
|
||||
'value' => '.1.3.6.1.2.1.33.1.2.4'}
|
||||
};
|
||||
|
||||
|
||||
my ($session, $error) = Net::SNMP->session(
|
||||
-hostname => $host,
|
||||
-community => $community,
|
||||
-port => $port
|
||||
);
|
||||
|
||||
if (!defined ($session))
|
||||
{
|
||||
die "Croaking: $error";
|
||||
}
|
||||
|
||||
my $count_data = 1;
|
||||
if (defined $graphs->{$mode}->{'list'} &&
|
||||
defined ($response = $session->get_request($graphs->{$mode}->{'list'} . ".0"))) {
|
||||
$count_data = $response->{$graphs->{$mode}->{'list'} . ".0"};
|
||||
|
||||
}
|
||||
|
||||
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 network\n";
|
||||
|
||||
|
||||
for(my $i=0;$i<$count_data;$i++) {
|
||||
printf "line%u.label Line %u\n",$i+1,$i+1;
|
||||
printf "line%u.type GAUGE\n",$i+1;
|
||||
# printf "line%u.cdef recv,8,*\n",$i+1;
|
||||
printf "line%u.info %s\n",$i+1,$graphs->{$mode}->{'unit'};
|
||||
}
|
||||
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)))) {
|
||||
printf "line%u.value %u\n",$i+1,$response->{$graphs->{$mode}->{'value'} . sprintf(".%u",$l_current)};
|
||||
} else {
|
||||
printf "line%u.value U\n",$i+1;
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue