mirror of
https://github.com/munin-monitoring/contrib.git
synced 2025-07-22 02:51:03 +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,107 +0,0 @@
|
|||
#!/usr/bin/perl -w
|
||||
#
|
||||
# Copyright (C) 2006 Lars Strand
|
||||
#
|
||||
# Munin plugin to monitor CPU-load by use of SNMP.
|
||||
# Based on snmp__df plugin.
|
||||
#
|
||||
# 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$
|
||||
#
|
||||
#
|
||||
#
|
||||
#%# 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 $response;
|
||||
|
||||
if (defined $ARGV[0] and $ARGV[0] eq "snmpconf")
|
||||
{
|
||||
print "index 1.3.6.1.2.1.25.3.3.1.2.\n";
|
||||
print "require 1.3.6.1.2.1.25.3.3.1.2.1\n"; # CPU #1
|
||||
exit 0;
|
||||
}
|
||||
|
||||
if ($0 =~ /^(?:|.*\/)snmp_([^_]+)_cpu$/)
|
||||
{
|
||||
$host = $1;
|
||||
if ($host =~ /^([^:]+):(\d+)$/)
|
||||
{
|
||||
$host = $1;
|
||||
$port = $2;
|
||||
}
|
||||
}
|
||||
|
||||
elsif (!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";
|
||||
}
|
||||
|
||||
# CPUs
|
||||
my $hrProcessorLoad = "1.3.6.1.2.1.25.3.3.1.2.";
|
||||
$response = $session->get_table($hrProcessorLoad);
|
||||
|
||||
if (!defined ($response))
|
||||
{
|
||||
die "Croaking: $error";
|
||||
}
|
||||
|
||||
if (defined $ARGV[0] and $ARGV[0] eq "config")
|
||||
{
|
||||
print "host_name $host\n";
|
||||
print "graph_title CPU usage (in %)
|
||||
graph_category system
|
||||
graph_args --upper-limit 100 -l 0
|
||||
graph_vlabel %
|
||||
graph_info This graph shows the CPU load on the system.
|
||||
";
|
||||
foreach my $cpuoid (keys %$response) {
|
||||
my @oid = split(/\./, $cpuoid);
|
||||
my $cpu = pop @oid;
|
||||
print "cpu$cpu.label CPU $cpu\n";
|
||||
print "cpu$cpu.info CPU load on CPU $cpu\n";
|
||||
}
|
||||
exit 0;
|
||||
}
|
||||
|
||||
# the values
|
||||
while (my ($cpuoid, $load) = each(%$response)) {
|
||||
my @oid = split(/\./, $cpuoid);
|
||||
my $cpu = pop @oid;
|
||||
print "cpu$cpu.value $load\n";
|
||||
}
|
||||
|
|
@ -1,175 +0,0 @@
|
|||
#!/usr/bin/perl -w
|
||||
#
|
||||
# Copyright (C) 2004 Jimmy Olsen
|
||||
# Copyright (C) 2009 Xavier Montagutelli
|
||||
#
|
||||
# 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: snmp__cpu_usage,v $
|
||||
# Revision 1.1 2009/09/21 06:59:33 root
|
||||
# Initial revision
|
||||
#
|
||||
# Revision 1.1 2009/09/17 13:43:35 root
|
||||
# Initial revision
|
||||
#
|
||||
# Revision 1.11 2004/12/10 18:51:43 jimmyo
|
||||
# linux/apt* has been forced to LANG=C, to get predictable output.
|
||||
#
|
||||
# Revision 1.10 2004/12/10 10:47:47 jimmyo
|
||||
# Change name from ${scale} to ${graph_period}, to be more consistent.
|
||||
#
|
||||
# Revision 1.9 2004/12/09 22:12:55 jimmyo
|
||||
# Added "graph_period" option, to make "graph_sums" usable.
|
||||
#
|
||||
# Revision 1.8 2004/11/21 00:16:56 jimmyo
|
||||
# Changed a lot of plugins so they use DERIVE instead of COUNTER.
|
||||
#
|
||||
# Revision 1.7 2004/11/16 20:08:26 jimmyo
|
||||
# License cleanups.
|
||||
#
|
||||
# Revision 1.6 2004/11/12 20:28:03 ilmari
|
||||
# No debugging info by default
|
||||
#
|
||||
# Revision 1.5 2004/09/08 15:25:33 ilmari
|
||||
# Use /usr/bin/perl in all perl shebang lines.
|
||||
#
|
||||
# Revision 1.4 2004/09/07 13:19:22 ilmari
|
||||
# SNMP plugins now honour the "host" environment variable if they can't deduce the hostname from zsh.
|
||||
#
|
||||
# Revision 1.3 2004/09/05 12:00:18 jimmyo
|
||||
# Set family and capabilities.
|
||||
#
|
||||
# Revision 1.2 2004/09/04 21:58:28 jimmyo
|
||||
# Set category and info fields.
|
||||
#
|
||||
# Revision 1.1 2004/04/30 22:22:07 jimmyo
|
||||
# Added to SNMP based fibre-channel plugins: fc_if and fc_if_err.
|
||||
#
|
||||
# Revision 1.4 2004/04/30 16:58:14 jimmyo
|
||||
# Added max.
|
||||
#
|
||||
# Revision 1.3 2004/02/22 20:17:58 jimmyo
|
||||
# Typo fix
|
||||
#
|
||||
# Revision 1.2 2004/02/18 21:54:56 jimmyo
|
||||
# Did a bit of work on the snmp-thingie.
|
||||
#
|
||||
# Revision 1.1 2004/01/02 18:50:00 jimmyo
|
||||
# Renamed occurrances of lrrd -> munin
|
||||
#
|
||||
# Revision 1.1.1.1 2004/01/02 15:18:07 jimmyo
|
||||
# Import of LRRD CVS tree after renaming to Munin
|
||||
#
|
||||
# Revision 1.1 2003/12/19 20:53:45 jimmyo
|
||||
# Created by jo
|
||||
#
|
||||
#
|
||||
#%# family=snmpauto
|
||||
#%# capabilities=snmpconf
|
||||
|
||||
use strict;
|
||||
use Munin::Plugin::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.4.1.2021.11.9\n";
|
||||
exit 0;
|
||||
}
|
||||
|
||||
if ($0 =~ /^(?:|.*\/)snmp_([^_]+)_cpu_usage$/)
|
||||
{
|
||||
$host = $1;
|
||||
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 $cpuUser = "1.3.6.1.4.1.2021.11.9";
|
||||
my $cpuSystem = "1.3.6.1.4.1.2021.11.10";
|
||||
my $cpuIdle = "1.3.6.1.4.1.2021.11.11";
|
||||
|
||||
my $cpu = 0;
|
||||
|
||||
my %cpuCounters = (
|
||||
cpuUser => "1.3.6.1.4.1.2021.11.9.$cpu", # The percentage of CPU time spent processing user-level code, calculated over the last minute
|
||||
cpuSystem => "1.3.6.1.4.1.2021.11.10.$cpu", # The percentage of CPU time spent processing system-level code, calculated over the last minute
|
||||
cpuIdle => "1.3.6.1.4.1.2021.11.11.$cpu", # The percentage of processor time spent idle, calculated over the last minute
|
||||
);
|
||||
|
||||
my $session = Munin::Plugin::SNMP->session(-translate =>
|
||||
[ -timeticks => 0x0 ]);
|
||||
|
||||
if (!defined ($session))
|
||||
{
|
||||
die "Croaking: could not establish SNMP object";
|
||||
}
|
||||
|
||||
|
||||
if (!defined ($session))
|
||||
{
|
||||
die "Croaking: $error";
|
||||
}
|
||||
|
||||
if ($ARGV[0] and $ARGV[0] eq "config")
|
||||
{
|
||||
print "host_name $host\n";
|
||||
my $warn = undef;
|
||||
print "graph_title CPU Usage on $host\n";
|
||||
print "graph_args --base 1000 --lower-limit 0\n";
|
||||
print "graph_vlabel Percentage on one minute\n";
|
||||
print "graph_category system\n";
|
||||
print "graph_info This graph shows the CPU usage on one minute\n";
|
||||
|
||||
my $firstCounter = 1;
|
||||
foreach my $c (keys %cpuCounters) {
|
||||
print $c . ".label $c\n";
|
||||
print $c . ".type GAUGE\n";
|
||||
if ($firstCounter) {
|
||||
print $c . ".draw AREA\n";
|
||||
$firstCounter = 0;
|
||||
} else {
|
||||
print $c . ".draw STACK\n";
|
||||
}
|
||||
print $c . ".min 0\n";
|
||||
}
|
||||
|
||||
exit 0;
|
||||
}
|
||||
|
||||
foreach my $c (keys %cpuCounters) {
|
||||
if (defined ($response = $session->get_request($cpuCounters{$c})) && $response->{$cpuCounters{$c}} =~ /^[0-9]*$/) {
|
||||
print $c . ".value ", $response->{$cpuCounters{$c}}, "\n";
|
||||
} else {
|
||||
print $c . ".value U\n";
|
||||
}
|
||||
}
|
||||
|
|
@ -1,184 +0,0 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# File: snmp__fn
|
||||
# Description: SNMP plugin to monitor open sessions, sslvpn, CPU and Memory on a
|
||||
# Fortinet Fortigate firewall.
|
||||
#
|
||||
# Author: Thom Diener <munin@tmd.ch>
|
||||
# License: 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.
|
||||
#
|
||||
# Version: v1.00 30.10.2011 First draft of the fortigate plugin
|
||||
# v1.01 19.01.2012 OID to MIB changed, plugins gets faster
|
||||
# v1.02 25.01.2012 MIB file availability check added
|
||||
# v1.03 01.04.2012 Update to work with Firmware v4.00MR3Patch6
|
||||
#
|
||||
# Parameters: config (required)
|
||||
# autoconf (optional)
|
||||
#
|
||||
# Usage: place in /etc/munin/plugins/ (or link it there using ln -s)
|
||||
# (Example: ln -s /usr/share/munin/plugins/snmp__fn \
|
||||
# /etc/munin/plugins/snmp_foo.example.com_fn)
|
||||
#
|
||||
# Add global community string
|
||||
# vi /etc/munin/plugin-conf.d/munin-node
|
||||
# [snmp_*]
|
||||
# env.community private
|
||||
# timeout 45 # In case low latency or timeout
|
||||
#
|
||||
# Fortigate Activate snmp on your Fortigate firewall.
|
||||
# Fortigate documentation at https://support.fortinet.com
|
||||
#
|
||||
# MIB Download and copy the original Fortigate MIB defintion files to:
|
||||
# /usr/share/snmp/mibs/FORTINET-CORE-MIB.mib.txt
|
||||
# /usr/share/snmp/mibs/FORTINET-FORTIGATE-MIB.mib
|
||||
#
|
||||
# Testing This plugin has been tested with the following OS/software:
|
||||
#
|
||||
# Appliance/Firmware:
|
||||
# Fortigate-50B 3.00-b0662(MR6 Patch 1) work with v1.00-1.02
|
||||
# Fortigate-50B 3.00-b0678(MR6 Patch 6) work with v1.00-1.02
|
||||
# Fortigate-50B 4.00-b0178(MR1 Patch 1) work with v1.00-1.02
|
||||
# Fortigate-50B 4.00-b0217(MR1 Patch 10) work with v1.00-1.02
|
||||
# Fortigate-50B 4.00-b0217(MR2 Patch 4) work with v1.00-1.02
|
||||
# Fortigate-50B 4.00-b0521(MR3 Patch 6) work with v1.03
|
||||
#
|
||||
# Munin-Version:
|
||||
# Munin 1.4.4 (1.4.4-1ubuntu1)
|
||||
# OS-Version:
|
||||
# Ubuntu 10.04.3 LTS (lucid) x86_32/64
|
||||
#
|
||||
#%# family=manual
|
||||
#
|
||||
#set -x
|
||||
|
||||
### Constants ------------------------------------------------------------------
|
||||
SNMPCLIENT=`basename $0 | sed 's/^snmp_//g' | cut -d "_" -f1`
|
||||
MIBFILE="/usr/share/snmp/mibs/FORTINET-FORTIGATE-MIB.mib"
|
||||
FNTYPE=`echo $MIBFILE | cut -d "." -f1 | cut -d "/" -f6`
|
||||
if [ -r $MIBFILE ]; then
|
||||
SNMPGET="/usr/bin/snmpget -m $MIBFILE -c $community -v 2c $SNMPCLIENT"
|
||||
else
|
||||
echo No, MIB definition file not available or readable.
|
||||
exit 1
|
||||
fi
|
||||
UNIT="Fortinet Fortigate Unit"
|
||||
|
||||
|
||||
### Variables ------------------------------------------------------------------
|
||||
FGTcpu="$FNTYPE::fgSysCpuUsage.0"
|
||||
fnSysMemUsage="$FNTYPE::fgSysMemUsage.0"
|
||||
fnSysSesCount="$FNTYPE::fgSysSesCount.0"
|
||||
fnVPNSslStatsLoginUsers="$FNTYPE::fgVpnSslStatsLoginUsers.1"
|
||||
fnVPNSslStatsActiveWebSessions="$FNTYPE::fgVpnSslStatsActiveWebSessions.1"
|
||||
fnVPNSslStatsActiveTunnels="$FNTYPE::fgVpnSslStatsActiveTunnels.1"
|
||||
|
||||
SCPU=`$SNMPGET $FGTcpu | cut -d ":" -f4 | cut -d " " -f2`
|
||||
SMEM=`$SNMPGET $fnSysMemUsage | cut -d ":" -f4 | cut -d " " -f2`
|
||||
SCNT=`$SNMPGET $fnSysSesCount | cut -d ":" -f4 | cut -d " " -f2`
|
||||
USER=`$SNMPGET $fnVPNSslStatsLoginUsers | cut -d ":" -f4 | cut -d " " -f2`
|
||||
WEBS=`$SNMPGET $fnVPNSslStatsActiveWebSessions | cut -d ":" -f4 | cut -d " " -f2`
|
||||
ATUN=`$SNMPGET $fnVPNSslStatsActiveTunnels | cut -d ":" -f4 | cut -d " " -f2`
|
||||
|
||||
|
||||
### Functions ------------------------------------------------------------------
|
||||
|
||||
autoconf()
|
||||
{
|
||||
if [ $SCPU ]; then
|
||||
echo yes, OID $FGTcpu can be readed.
|
||||
else
|
||||
echo no, one or multiple OID can not be readed.
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ $SMEM ]; then
|
||||
echo yes, OID $fnSysMemUsage can be readed.
|
||||
else
|
||||
echo no, one or multiple OID can not be readed.
|
||||
exit 1
|
||||
fi
|
||||
if [ $SCNT ]; then
|
||||
echo yes, OID $fnSysSesCount can be readed.
|
||||
else
|
||||
echo no, one or multiple OID can not be read.
|
||||
exit 1
|
||||
fi
|
||||
exit 0
|
||||
}
|
||||
|
||||
config()
|
||||
{
|
||||
echo "multigraph fn_cpu"
|
||||
echo "host_name $SNMPCLIENT"
|
||||
echo "graph_title $UNIT - CPU usage"
|
||||
echo 'graph_category system'
|
||||
echo 'graph_vlabel %'
|
||||
echo 'graph_info This graph shows current CPU usage.'
|
||||
echo 'graph_args --base 1000 -r --lower-limit 0 --upper-limit 100'
|
||||
echo 'forticpu.label CPU'
|
||||
echo 'forticpu.info CPU usage'
|
||||
echo 'forticpu.draw AREA'
|
||||
echo ''
|
||||
echo "multigraph fn_memory"
|
||||
echo "host_name $SNMPCLIENT"
|
||||
echo "graph_title $UNIT - Memory usage"
|
||||
echo 'graph_category system'
|
||||
echo 'graph_vlabel %'
|
||||
echo 'graph_info This graph shows current memory usage.'
|
||||
echo 'graph_args --base 1000 -r --lower-limit 0 --upper-limit 100'
|
||||
echo 'fortimemory.label Memory'
|
||||
echo 'fortimemory.info Memory usage'
|
||||
echo 'fortimemory.draw AREA'
|
||||
echo ''
|
||||
echo "multigraph fn_sessions"
|
||||
echo "host_name $SNMPCLIENT"
|
||||
echo "graph_title $UNIT - Sessions"
|
||||
echo 'graph_category Other'
|
||||
echo 'graph_vlabel Active Sessions'
|
||||
echo 'graph_info Active session count on the Fortigate firewall'
|
||||
echo 'fortisessions.label Sessions'
|
||||
echo 'fortisessions.info Active session count'
|
||||
echo 'fortisessions.draw AREA'
|
||||
echo ''
|
||||
echo "multigraph fn_vpnsessions"
|
||||
echo "host_name $SNMPCLIENT"
|
||||
echo "graph_title $UNIT - SSLvpn Sessions"
|
||||
echo 'graph_category Other'
|
||||
echo 'graph_vlabel Sessions/Users'
|
||||
echo 'graph_info Loged in users with SSLvpn (WebSession or Tunnel-Mode)'
|
||||
echo 'fortiuser.label Users'
|
||||
echo 'fortiuser.info Loged in SSLvpn users'
|
||||
echo 'fortiwebs.label WebSessions'
|
||||
echo 'fortiwebs.info Active SSLvpn WebSessions'
|
||||
echo 'fortiatun.label ActiveTunnels'
|
||||
echo 'fortiatun.info Active SSLvpn Tunnels'
|
||||
exit 0
|
||||
}
|
||||
|
||||
values()
|
||||
{
|
||||
echo "multigraph fn_cpu"
|
||||
echo "forticpu.value $SCPU"
|
||||
echo ""
|
||||
echo "multigraph fn_memory"
|
||||
echo "fortimemory.value $SMEM"
|
||||
echo ""
|
||||
echo "multigraph fn_sessions"
|
||||
echo "fortisessions.value $SCNT"
|
||||
echo ""
|
||||
echo "multigraph fn_vpnsessions"
|
||||
echo "fortiuser.value $USER"
|
||||
echo "fortiwebs.value $WEBS"
|
||||
echo "fortiatun.value $ATUN"
|
||||
}
|
||||
|
||||
### Main -----------------------------------------------------------------------
|
||||
|
||||
if [ "$1" = "autoconf" ]; then autoconf
|
||||
fi
|
||||
if [ "$1" = "config" ]; then config
|
||||
fi
|
||||
values
|
Binary file not shown.
Before Width: | Height: | Size: 16 KiB |
Binary file not shown.
Before Width: | Height: | Size: 15 KiB |
Binary file not shown.
Before Width: | Height: | Size: 18 KiB |
Binary file not shown.
Before Width: | Height: | Size: 18 KiB |
|
@ -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;
|
|
@ -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};
|
||||
}
|
||||
}
|
|
@ -1,266 +0,0 @@
|
|||
#!/usr/bin/perl -w
|
||||
#
|
||||
# Copyright (C) 2004 Jimmy Olsen
|
||||
#
|
||||
# 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$
|
||||
# Revision 1.10 2004/11/16 20:08:26 jimmyo
|
||||
# License cleanups.
|
||||
#
|
||||
# Revision 1.9 2004/09/08 15:25:33 ilmari
|
||||
# Use /usr/bin/perl in all perl shebang lines.
|
||||
#
|
||||
# Revision 1.8 2004/09/07 13:19:22 ilmari
|
||||
# SNMP plugins now honour the "host" environment variable if they can't deduce the hostname from zsh.
|
||||
#
|
||||
# Revision 1.7 2004/09/07 12:58:41 ilmari
|
||||
# SNMP plugin "df" properly strips the label and serial number fromWindows drive labels.
|
||||
#
|
||||
# Revision 1.6 2004/09/05 12:00:18 jimmyo
|
||||
# Set family and capabilities.
|
||||
#
|
||||
# Revision 1.5 2004/09/04 21:58:28 jimmyo
|
||||
# Set category and info fields.
|
||||
#
|
||||
# Revision 1.4 2004/09/04 21:33:12 jimmyo
|
||||
# Handle strange characters better.
|
||||
#
|
||||
# Revision 1.3 2004/09/04 21:08:16 jimmyo
|
||||
# SNMP df plugin now talks Windowese.
|
||||
#
|
||||
# Revision 1.2 2004/09/03 22:56:51 jimmyo
|
||||
# Added support for SNMP probing.
|
||||
#
|
||||
# Revision 1.1 2004/04/29 22:29:57 jimmyo
|
||||
# New SNMP plugin for disk usage.
|
||||
#
|
||||
# Revision 1.3 2004/02/22 20:17:58 jimmyo
|
||||
# Typo fix
|
||||
#
|
||||
# Revision 1.2 2004/02/18 21:54:56 jimmyo
|
||||
# Did a bit of work on the snmp-thingie.
|
||||
#
|
||||
# Revision 1.1 2004/01/02 18:50:00 jimmyo
|
||||
# Renamed occurrances of lrrd -> munin
|
||||
#
|
||||
# Revision 1.1.1.1 2004/01/02 15:18:07 jimmyo
|
||||
# Import of LRRD CVS tree after renaming to Munin
|
||||
#
|
||||
# Revision 1.1 2003/12/19 20:53:45 jimmyo
|
||||
# Created by jo
|
||||
#
|
||||
#%# family=snmpauto
|
||||
#%# capabilities=snmpconf
|
||||
|
||||
use strict;
|
||||
use Net::SNMP;
|
||||
|
||||
my $DEBUG = 0;
|
||||
my $MAXLABEL = 20;
|
||||
|
||||
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 "index 1.3.6.1.2.1.25.2.3.1.1.\n";
|
||||
print "index 1.3.6.1.2.1.25.5.1.1.2.\n";
|
||||
print "require 1.3.6.1.2.1.25.5.1.1.2. [1-9]\n";
|
||||
print "require 1.3.6.1.2.1.25.2.2.0\n"; # memsize
|
||||
print "require 1.3.6.1.2.1.25.2.3.1.2. 1.3.6.1.2.1.25.2.1.(2|3)\n"; # Type=fixed disk
|
||||
print "require 1.3.6.1.2.1.25.2.3.1.5. [1-9]\n"; # Size > 0
|
||||
exit 0;
|
||||
}
|
||||
|
||||
if ($0 =~ /^(?:|.*\/)snmp_([^_]+)_memory_win$/)
|
||||
{
|
||||
$host = $1;
|
||||
if ($host =~ /^([^:]+):(\d+)$/)
|
||||
{
|
||||
$host = $1;
|
||||
$port = $2;
|
||||
}
|
||||
}
|
||||
elsif (!defined($host))
|
||||
{
|
||||
print "# Debug: $0 -- $1\n" if $DEBUG;
|
||||
die "# Error: couldn't understand what I'm supposed to monitor.";
|
||||
}
|
||||
|
||||
# Disk level
|
||||
my $hrDeviceType = "1.3.6.1.2.1.25.3.2.1.2."; # Should be iso.3.6.1.2.1.25.3.1.6 (DiskStorage)
|
||||
my $hrDiskStorageRemoveble = "1.3.6.1.2.1.25.3.6.1.3."; # Should be false (2).
|
||||
# Windows reports 0.
|
||||
my $hrDiskStorageCapacity = "1.3.6.1.2.1.25.3.6.1.4."; # Should be more than 0
|
||||
|
||||
# Partition level
|
||||
my $hrPartitionFSIndex = "1.3.6.1.2.1.25.3.7.1.5."; # Should be more than 0
|
||||
my $hrFSMountPoint = "1.3.6.1.2.1.25.3.8.1.2."; # Used to look up filesystem
|
||||
|
||||
# Filesystem level
|
||||
my $hrStorageType = "1.3.6.1.2.1.25.2.3.1.2."; # Backup for hrFS*
|
||||
my $hrStorageDesc = "1.3.6.1.2.1.25.2.3.1.3."; # Used as key from partitions
|
||||
my $hrStorageSize = "1.3.6.1.2.1.25.2.3.1.5."; # Data point 1
|
||||
my $hrStorageUnit = "1.3.6.1.2.1.25.2.3.1.4."; # Data point 3
|
||||
my $hrStorageUsed = "1.3.6.1.2.1.25.2.3.1.6."; # Data point 2
|
||||
|
||||
# Memory
|
||||
my $hrSWRunPerfMem = "1.3.6.1.2.1.25.5.1.1.2.";
|
||||
|
||||
|
||||
my ($session, $error) = Net::SNMP->session(
|
||||
-hostname => $host,
|
||||
-community => $community,
|
||||
-port => $port
|
||||
);
|
||||
|
||||
if (!defined ($session))
|
||||
{
|
||||
die "Croaking: $error";
|
||||
}
|
||||
|
||||
my %partitions;
|
||||
my $stor_id;
|
||||
$stor_id = get_by_regex ($session, $hrStorageType, "1.3.6.1.2.1.25.2.1.(3|2)");
|
||||
%partitions = ();
|
||||
|
||||
foreach my $id (keys %$stor_id)
|
||||
{
|
||||
my $part = get_single ($session, $hrStorageDesc . $id);
|
||||
$partitions{$part}{storage} = $id;
|
||||
$partitions{$part}{extinfo} = $part;
|
||||
$stor_id->{$id} = $part;
|
||||
}
|
||||
|
||||
if (defined $ARGV[0] and $ARGV[0] eq "config")
|
||||
{
|
||||
print "host_name $host\n";
|
||||
print "graph_title Windows memory usage\n";
|
||||
print "graph_args -l 0 --base 1024\n";
|
||||
print "graph_vlabel Bytes\n";
|
||||
print "graph_category system\n";
|
||||
print "graph_info This graph shows Windows memory usage in bytes.\n";
|
||||
|
||||
foreach my $part (keys %partitions)
|
||||
{
|
||||
print (&get_name_by_mp ($part), ".label $part Usage\n");
|
||||
# print (&get_name_by_mp ($part), ".warning 92\n");
|
||||
# print (&get_name_by_mp ($part), ".critical 98\n");
|
||||
print (&get_name_by_mp ($part) . "_s", ".label $part Size\n");
|
||||
print (&get_name_by_mp ($part) . "_s", ".graph no\n");
|
||||
}
|
||||
print "pused.label In use by programs\n";
|
||||
print "pused.draw AREA\n";
|
||||
exit 0;
|
||||
}
|
||||
|
||||
foreach my $storage (keys %$stor_id)
|
||||
{
|
||||
$partitions{$stor_id->{$storage}}{storage} = $storage;
|
||||
$partitions{$stor_id->{$storage}}{size} = get_single ($session, $hrStorageSize . $storage);
|
||||
$partitions{$stor_id->{$storage}}{unit} = get_single ($session, $hrStorageUnit . $storage);
|
||||
$partitions{$stor_id->{$storage}}{used} = get_single ($session, $hrStorageUsed . $storage);
|
||||
}
|
||||
|
||||
foreach my $part (keys %partitions)
|
||||
{
|
||||
print (&get_name_by_mp ($part), ".value ", $partitions{$part}{used}*$partitions{$part}{unit}, "\n");
|
||||
print (&get_name_by_mp ($part) . "_s", ".value ", $partitions{$part}{size}*$partitions{$part}{unit}, "\n");
|
||||
}
|
||||
my $memsize = &get_single($session, "1.3.6.1.2.1.25.2.2.0") * 1024;
|
||||
my $processes = get_by_regex($session, $hrSWRunPerfMem, "[1-9]");
|
||||
# the values
|
||||
my $memtotal = 0;
|
||||
while (my ($pid, $mem) = each(%$processes)) {
|
||||
$memtotal += $mem;
|
||||
}
|
||||
$memtotal*=1024;
|
||||
printf "pused.value $memtotal\n";
|
||||
|
||||
sub get_single
|
||||
{
|
||||
my $handle = shift;
|
||||
my $oid = shift;
|
||||
|
||||
print "# Getting single $oid..." if $DEBUG;
|
||||
|
||||
$response = $handle->get_request ($oid);
|
||||
|
||||
if (!defined $response->{$oid})
|
||||
{
|
||||
print "undef\n" if $DEBUG;
|
||||
return undef;
|
||||
}
|
||||
else
|
||||
{
|
||||
print "\"$response->{$oid}\"\n" if $DEBUG;
|
||||
return $response->{$oid};
|
||||
}
|
||||
}
|
||||
|
||||
sub get_by_regex
|
||||
{
|
||||
my $handle = shift;
|
||||
my $oid = shift;
|
||||
my $regex = shift;
|
||||
my $result = {};
|
||||
my $num = 0;
|
||||
my $ret = $oid . "0";
|
||||
my $response;
|
||||
|
||||
print "# Starting browse of $oid...\n" if $DEBUG;
|
||||
|
||||
while (1)
|
||||
{
|
||||
if ($num == 0)
|
||||
{
|
||||
print "# Checking for $ret...\n" if $DEBUG;
|
||||
$response = $handle->get_request ($ret);
|
||||
}
|
||||
if ($num or !defined $response)
|
||||
{
|
||||
print "# Checking for sibling of $ret...\n" if $DEBUG;
|
||||
$response = $handle->get_next_request ($ret);
|
||||
}
|
||||
if (!$response)
|
||||
{
|
||||
return undef;
|
||||
}
|
||||
my @keys = keys %$response;
|
||||
$ret = $keys[0];
|
||||
print "# Analyzing $ret (compared to $oid)...\n" if $DEBUG;
|
||||
last unless ($ret =~ /^$oid/);
|
||||
$num++;
|
||||
next unless ($response->{$ret} =~ /$regex/);
|
||||
@keys = split (/\./, $ret);
|
||||
$result->{$keys[-1]} = ($1) ? $1 : $response->{$ret};
|
||||
print "# Index $num: ", $keys[-1], " (", $response->{$ret}, ")\n" if $DEBUG;
|
||||
};
|
||||
return $result;
|
||||
}
|
||||
|
||||
sub get_name_by_mp
|
||||
{
|
||||
my $mp = shift;
|
||||
$mp =~ s/[^a-z0-9_]/_/gi;
|
||||
$mp =~ tr/A-Z/a-z/;
|
||||
return "p" . $mp;
|
||||
}
|
|
@ -1,350 +0,0 @@
|
|||
#!/usr/bin/perl
|
||||
#
|
||||
# Copyright (C) 2008 Gorlow Maxim [Sheridan]
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
# ups_host_volt - IO voltage (volt)
|
||||
# ups_host_freq - IO frequency (hz)
|
||||
# ups_host_status - UPS status (online, off....)
|
||||
# ups_host_temp - Temperature (c)
|
||||
# ups_host_battcap - Battery capacity (%)
|
||||
# ups_host_load - UPS load (%)
|
||||
# ups_host_curr - Current (ampers)
|
||||
|
||||
|
||||
|
||||
|
||||
#
|
||||
#%# family=snmpauto
|
||||
#
|
||||
|
||||
use strict;
|
||||
use SNMP '5.0.2.pre1' || die("Cannot load module\n");
|
||||
$ENV{'MIBS'}="ALL";
|
||||
|
||||
my $host = $ENV{host} || undef;
|
||||
my $community = $ENV{community} || "public";
|
||||
my $type = "volt";
|
||||
my $response;
|
||||
|
||||
if ($0 =~ /^(?:|.*\/)snmp_([^_]+)_ups_(.+)$/)
|
||||
{
|
||||
$host = $1;
|
||||
$type = $2;
|
||||
if ($host =~ /^([^:]+):(\d+)$/)
|
||||
{
|
||||
$host = $1;
|
||||
$type = $2;
|
||||
}
|
||||
}
|
||||
elsif (!defined($host)) {
|
||||
die "# Error: couldn't understand what I'm supposed to monitor."; }
|
||||
|
||||
|
||||
my $session = new SNMP::Session (
|
||||
DestHost => $host,
|
||||
Community => $community,
|
||||
Version => 1
|
||||
);
|
||||
my $oidsList;
|
||||
my $modelList = new SNMP::VarList(['upsBasicIdentModel'],['upsAdvIdentSerialNumber']);
|
||||
if ($type eq "volt")
|
||||
{
|
||||
$oidsList = new SNMP::VarList (
|
||||
['upsAdvOutputVoltage'],
|
||||
['upsAdvInputLineVoltage'],
|
||||
['upsAdvInputMaxLineVoltage'],
|
||||
['upsAdvInputMinLineVoltage']
|
||||
);
|
||||
}
|
||||
elsif ($type eq "freq")
|
||||
{
|
||||
$oidsList = new SNMP::VarList (
|
||||
['upsAdvOutputFrequency'],
|
||||
['upsAdvInputFrequency']
|
||||
);
|
||||
}
|
||||
elsif ($type eq "status")
|
||||
{
|
||||
$oidsList = new SNMP::VarList (
|
||||
['upsBasicOutputStatus']
|
||||
);
|
||||
}
|
||||
elsif ($type eq "temp")
|
||||
{
|
||||
$oidsList = new SNMP::VarList (
|
||||
['upsAdvBatteryTemperature']
|
||||
);
|
||||
}
|
||||
elsif ($type eq "battcap")
|
||||
{
|
||||
$oidsList = new SNMP::VarList (
|
||||
['upsAdvBatteryCapacity']
|
||||
);
|
||||
}
|
||||
elsif ($type eq "load")
|
||||
{
|
||||
$oidsList = new SNMP::VarList (
|
||||
['upsAdvOutputLoad']
|
||||
);
|
||||
}
|
||||
elsif ($type eq "curr")
|
||||
{
|
||||
$oidsList = new SNMP::VarList (
|
||||
['upsAdvOutputCurrent']
|
||||
);
|
||||
}
|
||||
#if (defined $ARGV[0] and $ARGV[0] eq "snmpconf")
|
||||
#{}
|
||||
|
||||
if ($ARGV[0] and $ARGV[0] eq "config")
|
||||
{
|
||||
|
||||
my $model;
|
||||
my $vLabel;
|
||||
my $hLabel;
|
||||
if ($type eq "volt")
|
||||
{
|
||||
$vLabel = "Voltage";
|
||||
$hLabel = "IO Voltage";
|
||||
}
|
||||
elsif ($type eq "freq")
|
||||
{
|
||||
$vLabel = "Frequency";
|
||||
$hLabel = "IO Frequency";
|
||||
}
|
||||
elsif ($type eq "status")
|
||||
{
|
||||
$vLabel = "Status";
|
||||
$hLabel = "Status";
|
||||
}
|
||||
elsif ($type eq "temp")
|
||||
{
|
||||
$vLabel = "Temperature, C";
|
||||
$hLabel = "Temperature";
|
||||
}
|
||||
elsif ($type eq "battcap")
|
||||
{
|
||||
$vLabel = "Percent";
|
||||
$hLabel = "Batt. capacity";
|
||||
}
|
||||
elsif ($type eq "load")
|
||||
{
|
||||
$vLabel = "Percent";
|
||||
$hLabel = "UPS load";
|
||||
}
|
||||
elsif ($type eq "curr")
|
||||
{
|
||||
$vLabel = "Ampers";
|
||||
$hLabel = "Current";
|
||||
}
|
||||
print "host_name $host\n" unless $host eq 'localhost';
|
||||
my @response = $session->getnext($modelList);
|
||||
$response[0] =~ s/[\" ]//g; # Ditch the quotes.
|
||||
$response[1] =~ s/[\" ]//g;
|
||||
$model = "$response[0] [$response[1]]";
|
||||
print "graph_title $hLabel, $model\n";
|
||||
print "graph_args --base 1000\n";
|
||||
print "graph_vlabel $vLabel\n";
|
||||
print "graph_category system\n";
|
||||
print "graph_info This graph shows the $hLabel ($vLabel) of $model\n";
|
||||
if ($type eq "volt")
|
||||
{
|
||||
print "graph_order in out inmax inmin\n";
|
||||
print "in.label Input\n";
|
||||
print "in.type GAUGE\n";
|
||||
print "in.info Input voltage.\n";
|
||||
print "in.colour FFCC99\n";
|
||||
print "in.draw AREA\n";
|
||||
print "out.label Output\n";
|
||||
print "out.type GAUGE\n";
|
||||
print "out.info Output voltage.\n";
|
||||
print "out.colour 009BCC\n";
|
||||
print "out.draw AREA\n";
|
||||
print "inmax.label Input max\n";
|
||||
print "inmax.type GAUGE\n";
|
||||
print "inmax.info Input voltage maximum.\n";
|
||||
print "inmax.colour FF0033\n";
|
||||
print "inmax.draw LINE1\n";
|
||||
print "inmin.label Input min\n";
|
||||
print "inmin.type GAUGE\n";
|
||||
print "inmin.info Input voltage minimum.\n";
|
||||
print "inmin.colour 66FF00\n";
|
||||
print "inmin.draw LINE1\n";
|
||||
|
||||
}
|
||||
elsif ($type eq "freq")
|
||||
{
|
||||
print "graph_order in out\n";
|
||||
print "out.label Output\n";
|
||||
print "out.type GAUGE\n";
|
||||
print "out.info Output frequency.\n";
|
||||
print "out.draw LINE2\n";
|
||||
print "in.label Input\n";
|
||||
print "in.type GAUGE\n";
|
||||
print "in.info Input frequency.\n";
|
||||
print "in.draw LINE2\n";
|
||||
}
|
||||
elsif ($type eq "status")
|
||||
{
|
||||
print "state.label Status\n";
|
||||
print "state.type GAUGE\n";
|
||||
print "state.draw AREA\n";
|
||||
print "state.min 1\n";
|
||||
print "state.max 12\n";
|
||||
print "unknown.label Unknown\n";
|
||||
print "unknown.type GAUGE\n";
|
||||
print "unknown.draw LINE3\n";
|
||||
print "onLine.label Online\n";
|
||||
print "onLine.type GAUGE\n";
|
||||
print "onLine.draw LINE3\n";
|
||||
print "onBattery.label On Battery\n";
|
||||
print "onBattery.type GAUGE\n";
|
||||
print "onBattery.draw LINE3\n";
|
||||
print "onSmartBoost.label On Smart Boost\n";
|
||||
print "onSmartBoost.type GAUGE\n";
|
||||
print "onSmartBoost.draw LINE3\n";
|
||||
print "timedSleeping.label Timed Sleeping\n";
|
||||
print "timedSleeping.type GAUGE\n";
|
||||
print "timedSleeping.draw LINE3\n";
|
||||
print "softwareBypass.label Software Bypass\n";
|
||||
print "softwareBypass.type GAUGE\n";
|
||||
print "softwareBypass.draw LINE3\n";
|
||||
print "off.label Off\n";
|
||||
print "off.type GAUGE\n";
|
||||
print "off.draw LINE3\n";
|
||||
print "rebooting.label Rebooting\n";
|
||||
print "rebooting.type GAUGE\n";
|
||||
print "rebooting.draw LINE3\n";
|
||||
print "switchedBypass.label Switched Bypass\n";
|
||||
print "switchedBypass.type GAUGE\n";
|
||||
print "switchedBypass.draw LINE3\n";
|
||||
print "hardwareFailureBypass.label HW Failure Bypass\n";
|
||||
print "hardwareFailureBypass.type GAUGE\n";
|
||||
print "hardwareFailureBypass.draw LINE3\n";
|
||||
print "sleepingUntilPowerReturn.label Sleep Until Power Return\n";
|
||||
print "sleepingUntilPowerReturn.type GAUGE\n";
|
||||
print "sleepingUntilPowerReturn.draw LINE3\n";
|
||||
print "onSmartTrim.label On Smart Trim\n";
|
||||
print "onSmartTrim.type GAUGE\n";
|
||||
print "onSmartTrim.draw LINE3\n";
|
||||
}
|
||||
elsif ($type eq "temp")
|
||||
{
|
||||
print "batt.label Battery temperature\n";
|
||||
print "batt.type GAUGE\n";
|
||||
print "batt.info Battery temperature.\n";
|
||||
print "batt.draw LINE2\n";
|
||||
}
|
||||
elsif ($type eq "battcap")
|
||||
{
|
||||
print "bcap.label Battery capacity\n";
|
||||
print "bcap.type GAUGE\n";
|
||||
print "bcap.info Battery capacity.\n";
|
||||
print "bcap.draw AREA\n";
|
||||
print "bcap.warning 30\n";
|
||||
print "bcap.critical 15\n";
|
||||
}
|
||||
elsif ($type eq "load")
|
||||
{
|
||||
print "load.label UPS load\n";
|
||||
print "load.type GAUGE\n";
|
||||
print "load.info UPS load.\n";
|
||||
print "load.draw AREA\n";
|
||||
print "load.warning 95\n";
|
||||
print "load.critical 100\n";
|
||||
}
|
||||
elsif ($type eq "curr")
|
||||
{
|
||||
print "out.label Output\n";
|
||||
print "out.type GAUGE\n";
|
||||
print "out.info Output current\n";
|
||||
print "out.draw LINE2\n";
|
||||
}
|
||||
exit 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
my @response = $session->getnext($oidsList);
|
||||
if ($type eq "volt")
|
||||
{
|
||||
print "out.value $response[0]\n";
|
||||
print "in.value $response[1]\n";
|
||||
print "inmax.value $response[2]\n";
|
||||
print "inmin.value $response[3]\n";
|
||||
}
|
||||
elsif ($type eq "freq")
|
||||
{
|
||||
print "out.value $response[0]\n";
|
||||
print "in.value $response[1]\n";
|
||||
}
|
||||
elsif ($type eq "status")
|
||||
{
|
||||
my $unknown = $response[0]==1 || "U";
|
||||
my $onLine = $response[0]==2 || "U";
|
||||
my $onBattery = $response[0]==3 || "U";
|
||||
my $onSmartBoost = $response[0]==4 || "U";
|
||||
my $timedSleeping = $response[0]==5 || "U";
|
||||
my $softwareBypass = $response[0]==6 || "U";
|
||||
my $off = $response[0]==7 || "U";
|
||||
my $rebooting = $response[0]==8 || "U";
|
||||
my $switchedBypass = $response[0]==9 || "U";
|
||||
my $hardwareFailureBypass = $response[0]==10 || "U";
|
||||
my $sleepingUntilPowerReturn = $response[0]==11 || "U";
|
||||
my $onSmartTrim = $response[0]==12 || "U";
|
||||
|
||||
print "state.value $response[0]\n";
|
||||
print "unknown.value $unknown\n";
|
||||
print "onLine.value $onLine\n";
|
||||
print "onBattery.value $onBattery\n";
|
||||
print "onSmartBoost.value $onSmartBoost\n";
|
||||
print "timedSleeping.value $timedSleeping\n";
|
||||
print "softwareBypass.value $softwareBypass\n";
|
||||
print "off.value $off\n";
|
||||
print "rebooting.value $rebooting\n";
|
||||
print "switchedBypass.value $switchedBypass\n";
|
||||
print "hardwareFailureBypass.value $hardwareFailureBypass\n";
|
||||
print "sleepingUntilPowerReturn.value $sleepingUntilPowerReturn\n";
|
||||
print "onSmartTrim.value $onSmartTrim\n";
|
||||
}
|
||||
elsif ($type eq "temp")
|
||||
{
|
||||
print "batt.value $response[0]\n";
|
||||
}
|
||||
elsif ($type eq "battcap")
|
||||
{
|
||||
print "bcap.value $response[0]\n";
|
||||
}
|
||||
elsif ($type eq "load")
|
||||
{
|
||||
print "load.value $response[0]\n";
|
||||
}
|
||||
elsif ($type eq "curr")
|
||||
{
|
||||
print "out.value $response[0]\n";
|
||||
}
|
||||
|
||||
__END__
|
||||
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;
|
||||
}
|
|
@ -1,174 +0,0 @@
|
|||
#!/usr/bin/perl -w
|
||||
#
|
||||
# Copyright (C) 2006 Lars Strand
|
||||
#
|
||||
# Munin plugin to monitor memory usage by use of SNMP.
|
||||
# Based on snmp__df plugin.
|
||||
#
|
||||
# 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$
|
||||
#
|
||||
#%# 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 $response;
|
||||
|
||||
if (defined $ARGV[0] and $ARGV[0] eq "snmpconf")
|
||||
{
|
||||
print "index 1.3.6.1.2.1.25.5.1.1.2.\n";
|
||||
print "require 1.3.6.1.2.1.25.5.1.1.2. [1-9]\n";
|
||||
print "require 1.3.6.1.2.1.25.2.2.0\n"; # memsize
|
||||
exit 0;
|
||||
}
|
||||
|
||||
if ($0 =~ /^(?:|.*\/)snmp_([^_]+)_memory$/)
|
||||
{
|
||||
$host = $1;
|
||||
if ($host =~ /^([^:]+):(\d+)$/)
|
||||
{
|
||||
$host = $1;
|
||||
$port = $2;
|
||||
}
|
||||
}
|
||||
elsif (!defined($host))
|
||||
{
|
||||
print "# Debug: $0 -- $1\n" if $DEBUG;
|
||||
die "# Error: couldn't understand what I'm supposed to monitor.";
|
||||
}
|
||||
|
||||
# memory usage pr. process
|
||||
my $hrSWRunPerfMem = "1.3.6.1.2.1.25.5.1.1.2.";
|
||||
|
||||
my ($session, $error) = Net::SNMP->session(
|
||||
-hostname => $host,
|
||||
-community => $community,
|
||||
-port => $port
|
||||
);
|
||||
|
||||
if (!defined ($session))
|
||||
{
|
||||
die "Croaking: $error";
|
||||
}
|
||||
|
||||
# total memory
|
||||
my $memsize = &get_single($session, "1.3.6.1.2.1.25.2.2.0") * 1024;
|
||||
|
||||
if (defined $ARGV[0] and $ARGV[0] eq "config")
|
||||
{
|
||||
print "host_name $host\n";
|
||||
print "graph_title Memory usage\n";
|
||||
print "graph_category system\n";
|
||||
print "graph_vlabel Bytes\n";
|
||||
print "graph_info This grap shows memory usage.\n";
|
||||
|
||||
# some devices reports negative memtotal value
|
||||
print "# Total memsize reported $memsize..." if $DEBUG;
|
||||
|
||||
if ($memsize > 0)
|
||||
{
|
||||
print "graph_args --base 1024 -l 0 --upper-limit $memsize\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
print "graph_args --base 1024 -l 0\n";
|
||||
}
|
||||
|
||||
print "memory.draw AREA\n";
|
||||
print "memory.label memory\n";
|
||||
|
||||
exit 0;
|
||||
}
|
||||
|
||||
my $processes = get_by_regex($session, $hrSWRunPerfMem, "[1-9]");
|
||||
|
||||
# the values
|
||||
my $memtotal = 0;
|
||||
while (my ($pid, $mem) = each(%$processes)) {
|
||||
$memtotal += $mem;
|
||||
}
|
||||
$memtotal*=1024;
|
||||
printf "memory.value $memtotal\n";
|
||||
|
||||
sub get_single
|
||||
{
|
||||
my $handle = shift;
|
||||
my $oid = shift;
|
||||
|
||||
print "# Getting single $oid..." if $DEBUG;
|
||||
|
||||
$response = $handle->get_request ($oid);
|
||||
|
||||
if (!defined $response->{$oid})
|
||||
{
|
||||
print "undef\n" if $DEBUG;
|
||||
return undef;
|
||||
}
|
||||
else
|
||||
{
|
||||
print "\"$response->{$oid}\"\n" if $DEBUG;
|
||||
return $response->{$oid};
|
||||
}
|
||||
}
|
||||
|
||||
sub get_by_regex
|
||||
{
|
||||
my $handle = shift;
|
||||
my $oid = shift;
|
||||
my $regex = shift;
|
||||
my $result = {};
|
||||
my $num = 0;
|
||||
my $ret = $oid . "0";
|
||||
my $response;
|
||||
|
||||
print "# Starting browse of $oid...\n" if $DEBUG;
|
||||
|
||||
while (1)
|
||||
{
|
||||
if ($num == 0)
|
||||
{
|
||||
print "# Checking for $ret...\n" if $DEBUG;
|
||||
$response = $handle->get_request ($ret);
|
||||
}
|
||||
if ($num or !defined $response)
|
||||
{
|
||||
print "# Checking for sibling of $ret...\n" if $DEBUG;
|
||||
$response = $handle->get_next_request ($ret);
|
||||
}
|
||||
if (!$response)
|
||||
{
|
||||
return undef;
|
||||
}
|
||||
my @keys = keys %$response;
|
||||
$ret = $keys[0];
|
||||
print "# Analyzing $ret (compared to $oid)...\n" if $DEBUG;
|
||||
last unless ($ret =~ /^$oid/);
|
||||
$num++;
|
||||
next unless ($response->{$ret} =~ /$regex/);
|
||||
@keys = split (/\./, $ret);
|
||||
$result->{$keys[-1]} = $response->{$ret};;
|
||||
print "# Index $num: ", $keys[-1], " (", $response->{$ret}, ")\n" if $DEBUG;
|
||||
};
|
||||
return $result;
|
||||
}
|
|
@ -1,139 +0,0 @@
|
|||
#!/usr/bin/perl -w
|
||||
#
|
||||
# Copyright (C) 2009 Branislav Bozgai
|
||||
#
|
||||
# Munin plugin to monitor ZyXel USG series routers CPU utilization.
|
||||
# Based on snmp__if_ plugin.
|
||||
#
|
||||
# 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.
|
||||
|
||||
|
||||
#%# 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 $response;
|
||||
|
||||
if (defined $ARGV[0] and $ARGV[0] eq "snmpconf")
|
||||
{
|
||||
print "require 1.3.6.1.4.1.890.1.6.22.1.1.0 \n";
|
||||
exit 0;
|
||||
}
|
||||
|
||||
if ($0 =~ /^(?:|.*\/)snmp_zyxel_usg_([^_]+)_cpu$/)
|
||||
{
|
||||
$host = $1;
|
||||
if ($host =~ /^([^:]+):(\d+)$/)
|
||||
{
|
||||
$host = $1;
|
||||
$port = $2;
|
||||
}
|
||||
}
|
||||
elsif (!defined($host))
|
||||
{
|
||||
print "# Debug: $0 -- $1\n" if $DEBUG;
|
||||
die "# Error: couldn't understand what I'm supposed to monitor.";
|
||||
}
|
||||
|
||||
my $sysCPUUsage = "1.3.6.1.4.1.890.1.6.22.1.1.0";
|
||||
my $sysCPU5SecUsage = "1.3.6.1.4.1.890.1.6.22.1.3.0";
|
||||
my $sysCPU1MinUsage = "1.3.6.1.4.1.890.1.6.22.1.4.0";
|
||||
my $sysCPU5MinUsage = "1.3.6.1.4.1.890.1.6.22.1.5.0";
|
||||
|
||||
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($sysCPUUsage)))
|
||||
{
|
||||
die "Croaking: " . $session->error();
|
||||
}
|
||||
print "graph_title CPU usage\n";
|
||||
print "graph_category system\n";
|
||||
print "graph_args --base 1000 -r --lower-limit 0 --upper-limit 100\n";
|
||||
print "graph_vlabel %\n";
|
||||
print "graph_scale no\n";
|
||||
print "graph_period second\n";
|
||||
print "graph_info CPU usage\n";
|
||||
print "sysCPUUsage.label CPU Usage\n";
|
||||
print "sysCPU5SecUsage.label CPU 5 sec Avg Usage\n";
|
||||
print "sysCPU1MinUsage.label CPU 1 min Avg Usage\n";
|
||||
print "sysCPU5MinUsage.label CPU 5 min Avg Usage\n";
|
||||
print "sysCPUUsage.draw AREA\n";
|
||||
print "sysCPU5SecUsage.draw AREA\n";
|
||||
print "sysCPU1MinUsage.draw AREA\n";
|
||||
print "sysCPU5MinUsage.draw AREA\n";
|
||||
exit 0;
|
||||
}
|
||||
|
||||
|
||||
if (defined ($response = $session->get_request($sysCPUUsage)))
|
||||
{
|
||||
print "sysCPUUsage.value ", $response->{$sysCPUUsage}, "\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
print "sysCPUUsage.value U\n";
|
||||
}
|
||||
|
||||
if (defined ($response = $session->get_request($sysCPU5SecUsage)))
|
||||
{
|
||||
print "sysCPU5SecUsage.value ", $response->{$sysCPU5SecUsage}, "\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
print "sysCPU5SecUsage.value U\n";
|
||||
}
|
||||
|
||||
if (defined ($response = $session->get_request($sysCPU1MinUsage)))
|
||||
{
|
||||
print "sysCPU1MinUsage.value ", $response->{$sysCPU1MinUsage}, "\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
print "sysCPU1MinUsage.value U\n";
|
||||
}
|
||||
|
||||
if (defined ($response = $session->get_request($sysCPU5MinUsage)))
|
||||
{
|
||||
print "sysCPU5MinUsage.value ", $response->{$sysCPU5MinUsage}, "\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
print "sysCPU5MinUsage.value U\n";
|
||||
}
|
||||
|
||||
|
||||
# vim:syntax=perl
|
|
@ -1,102 +0,0 @@
|
|||
#!/usr/bin/perl -w
|
||||
#
|
||||
# Copyright (C) 2009 Branislav Bozgai
|
||||
#
|
||||
# Munin plugin to monitor ZyXel USG series routers RAM utilization.
|
||||
# Based on snmp__if_ plugin.
|
||||
#
|
||||
# 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.
|
||||
|
||||
|
||||
#%# 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 $response;
|
||||
|
||||
if (defined $ARGV[0] and $ARGV[0] eq "snmpconf")
|
||||
{
|
||||
print "require 1.3.6.1.4.1.890.1.6.22.1.2.0 \n";
|
||||
exit 0;
|
||||
}
|
||||
|
||||
if ($0 =~ /^(?:|.*\/)snmp_zyxel_usg_([^_]+)_ram$/)
|
||||
{
|
||||
$host = $1;
|
||||
if ($host =~ /^([^:]+):(\d+)$/)
|
||||
{
|
||||
$host = $1;
|
||||
$port = $2;
|
||||
}
|
||||
}
|
||||
elsif (!defined($host))
|
||||
{
|
||||
print "# Debug: $0 -- $1\n" if $DEBUG;
|
||||
die "# Error: couldn't understand what I'm supposed to monitor.";
|
||||
}
|
||||
|
||||
my $sysRAMUsage = "1.3.6.1.4.1.890.1.6.22.1.2.0";
|
||||
|
||||
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($sysRAMUsage)))
|
||||
{
|
||||
die "Croaking: " . $session->error();
|
||||
}
|
||||
print "graph_title RAM usage\n";
|
||||
print "graph_category system\n";
|
||||
print "graph_args --base 1000 -r --lower-limit 0 --upper-limit 100\n";
|
||||
print "graph_vlabel %\n";
|
||||
print "graph_scale no\n";
|
||||
print "graph_period second\n";
|
||||
print "graph_info RAM usage\n";
|
||||
print "sysRAMUsage.label RAM Usage\n";
|
||||
print "sysRAMUsage.draw AREA\n";
|
||||
exit 0;
|
||||
}
|
||||
|
||||
|
||||
if (defined ($response = $session->get_request($sysRAMUsage)))
|
||||
{
|
||||
print "sysRAMUsage.value ", $response->{$sysRAMUsage}, "\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
print "sysRAMUsage.value U\n";
|
||||
}
|
||||
|
||||
# vim:syntax=perl
|
|
@ -1,101 +0,0 @@
|
|||
#!/usr/bin/perl -w
|
||||
#
|
||||
# Copyright (C) 2009 Branislav Bozgai
|
||||
#
|
||||
# Munin plugin to monitor ZyXel USG series routers Sessions utilization.
|
||||
# Based on snmp__if_ plugin.
|
||||
#
|
||||
# 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.
|
||||
|
||||
|
||||
#%# 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 $response;
|
||||
|
||||
if (defined $ARGV[0] and $ARGV[0] eq "snmpconf")
|
||||
{
|
||||
print "require 1.3.6.1.4.1.890.1.6.22.1.6.0 \n";
|
||||
exit 0;
|
||||
}
|
||||
|
||||
if ($0 =~ /^(?:|.*\/)snmp_zyxel_usg_([^_]+)_sessions$/)
|
||||
{
|
||||
$host = $1;
|
||||
if ($host =~ /^([^:]+):(\d+)$/)
|
||||
{
|
||||
$host = $1;
|
||||
$port = $2;
|
||||
}
|
||||
}
|
||||
elsif (!defined($host))
|
||||
{
|
||||
print "# Debug: $0 -- $1\n" if $DEBUG;
|
||||
die "# Error: couldn't understand what I'm supposed to monitor.";
|
||||
}
|
||||
|
||||
my $sysActiveSessions = "1.3.6.1.4.1.890.1.6.22.1.6.0";
|
||||
|
||||
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($sysActiveSessions)))
|
||||
{
|
||||
die "Croaking: " . $session->error();
|
||||
}
|
||||
print "graph_title Active Sessions\n";
|
||||
print "graph_category system\n";
|
||||
print "graph_args --base 1000 --lower-limit 0\n";
|
||||
print "graph_vlabel Active Sessions\n";
|
||||
print "graph_period second\n";
|
||||
print "graph_info Active Sessions\n";
|
||||
print "sysActiveSessions.label Sessions\n";
|
||||
print "sysActiveSessions.draw AREA\n";
|
||||
exit 0;
|
||||
}
|
||||
|
||||
|
||||
if (defined ($response = $session->get_request($sysActiveSessions)))
|
||||
{
|
||||
print "sysActiveSessions.value ", $response->{$sysActiveSessions}, "\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
print "sysActiveSessions.value U\n";
|
||||
}
|
||||
|
||||
# vim:syntax=perl
|
|
@ -1,102 +0,0 @@
|
|||
#!/usr/bin/perl -w
|
||||
#
|
||||
# Copyright (C) 2009 Branislav Bozgai
|
||||
#
|
||||
# Munin plugin to monitor ZyXel ZyWall series routers CPU utilization.
|
||||
# Based on snmp__if_ plugin.
|
||||
#
|
||||
# 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.
|
||||
|
||||
|
||||
#%# 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 $response;
|
||||
|
||||
if (defined $ARGV[0] and $ARGV[0] eq "snmpconf")
|
||||
{
|
||||
print "require 1.3.6.1.4.1.890.1.6.1.1.1.0 \n";
|
||||
exit 0;
|
||||
}
|
||||
|
||||
if ($0 =~ /^(?:|.*\/)snmp_zyxel_zywall_([^_]+)_cpu$/)
|
||||
{
|
||||
$host = $1;
|
||||
if ($host =~ /^([^:]+):(\d+)$/)
|
||||
{
|
||||
$host = $1;
|
||||
$port = $2;
|
||||
}
|
||||
}
|
||||
elsif (!defined($host))
|
||||
{
|
||||
print "# Debug: $0 -- $1\n" if $DEBUG;
|
||||
die "# Error: couldn't understand what I'm supposed to monitor.";
|
||||
}
|
||||
|
||||
my $sysCPUUsage = "1.3.6.1.4.1.890.1.6.1.1.1.0";
|
||||
|
||||
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($sysCPUUsage)))
|
||||
{
|
||||
die "Croaking: " . $session->error();
|
||||
}
|
||||
print "graph_title CPU usage\n";
|
||||
print "graph_category system\n";
|
||||
print "graph_args --base 1000 -r --lower-limit 0 --upper-limit 100\n";
|
||||
print "graph_vlabel %\n";
|
||||
print "graph_scale no\n";
|
||||
print "graph_period second\n";
|
||||
print "graph_info CPU usage\n";
|
||||
print "sysCPUUsage.label CPU Usage\n";
|
||||
print "sysCPUUsage.draw AREA\n";
|
||||
exit 0;
|
||||
}
|
||||
|
||||
|
||||
if (defined ($response = $session->get_request($sysCPUUsage)))
|
||||
{
|
||||
print "sysCPUUsage.value ", $response->{$sysCPUUsage}, "\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
print "sysCPUUsage.value U\n";
|
||||
}
|
||||
|
||||
# vim:syntax=perl
|
|
@ -1,102 +0,0 @@
|
|||
#!/usr/bin/perl -w
|
||||
#
|
||||
# Copyright (C) 2009 Branislav Bozgai
|
||||
#
|
||||
# Munin plugin to monitor ZyXel ZyWall series routers Flash memory utilization.
|
||||
# Based on snmp__if_ plugin.
|
||||
#
|
||||
# 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.
|
||||
|
||||
|
||||
#%# 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 $response;
|
||||
|
||||
if (defined $ARGV[0] and $ARGV[0] eq "snmpconf")
|
||||
{
|
||||
print "require 1.3.6.1.4.1.890.1.6.1.1.2.0 \n";
|
||||
exit 0;
|
||||
}
|
||||
|
||||
if ($0 =~ /^(?:|.*\/)snmp_zyxel_zywall_([^_]+)_flash$/)
|
||||
{
|
||||
$host = $1;
|
||||
if ($host =~ /^([^:]+):(\d+)$/)
|
||||
{
|
||||
$host = $1;
|
||||
$port = $2;
|
||||
}
|
||||
}
|
||||
elsif (!defined($host))
|
||||
{
|
||||
print "# Debug: $0 -- $1\n" if $DEBUG;
|
||||
die "# Error: couldn't understand what I'm supposed to monitor.";
|
||||
}
|
||||
|
||||
my $sysFLASHUsage = "1.3.6.1.4.1.890.1.6.1.1.2.0";
|
||||
|
||||
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($sysFLASHUsage)))
|
||||
{
|
||||
die "Croaking: " . $session->error();
|
||||
}
|
||||
print "graph_title FLASH usage\n";
|
||||
print "graph_category system\n";
|
||||
print "graph_args --base 1000 -r --lower-limit 0 --upper-limit 100\n";
|
||||
print "graph_vlabel %\n";
|
||||
print "graph_scale no\n";
|
||||
print "graph_period second\n";
|
||||
print "graph_info FLASH usage\n";
|
||||
print "sysFLASHUsage.label FLASH Usage\n";
|
||||
print "sysFLASHUsage.draw AREA\n";
|
||||
exit 0;
|
||||
}
|
||||
|
||||
|
||||
if (defined ($response = $session->get_request($sysFLASHUsage)))
|
||||
{
|
||||
print "sysFLASHUsage.value ", $response->{$sysFLASHUsage}, "\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
print "sysFLASHUsage.value U\n";
|
||||
}
|
||||
|
||||
# vim:syntax=perl
|
|
@ -1,102 +0,0 @@
|
|||
#!/usr/bin/perl -w
|
||||
#
|
||||
# Copyright (C) 2009 Branislav Bozgai
|
||||
#
|
||||
# Munin plugin to monitor ZyXel ZyWall series routers RAM utilization.
|
||||
# Based on snmp__if_ plugin.
|
||||
#
|
||||
# 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.
|
||||
|
||||
|
||||
#%# 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 $response;
|
||||
|
||||
if (defined $ARGV[0] and $ARGV[0] eq "snmpconf")
|
||||
{
|
||||
print "require 1.3.6.1.4.1.890.1.6.1.1.3.0 \n";
|
||||
exit 0;
|
||||
}
|
||||
|
||||
if ($0 =~ /^(?:|.*\/)snmp_zyxel_zywall_([^_]+)_ram$/)
|
||||
{
|
||||
$host = $1;
|
||||
if ($host =~ /^([^:]+):(\d+)$/)
|
||||
{
|
||||
$host = $1;
|
||||
$port = $2;
|
||||
}
|
||||
}
|
||||
elsif (!defined($host))
|
||||
{
|
||||
print "# Debug: $0 -- $1\n" if $DEBUG;
|
||||
die "# Error: couldn't understand what I'm supposed to monitor.";
|
||||
}
|
||||
|
||||
my $sysRAMUsage = "1.3.6.1.4.1.890.1.6.1.1.3.0";
|
||||
|
||||
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($sysRAMUsage)))
|
||||
{
|
||||
die "Croaking: " . $session->error();
|
||||
}
|
||||
print "graph_title RAM usage\n";
|
||||
print "graph_category system\n";
|
||||
print "graph_args --base 1000 -r --lower-limit 0 --upper-limit 100\n";
|
||||
print "graph_vlabel %\n";
|
||||
print "graph_scale no\n";
|
||||
print "graph_period second\n";
|
||||
print "graph_info RAM usage\n";
|
||||
print "sysRAMUsage.label RAM Usage\n";
|
||||
print "sysRAMUsage.draw AREA\n";
|
||||
exit 0;
|
||||
}
|
||||
|
||||
|
||||
if (defined ($response = $session->get_request($sysRAMUsage)))
|
||||
{
|
||||
print "sysRAMUsage.value ", $response->{$sysRAMUsage}, "\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
print "sysRAMUsage.value U\n";
|
||||
}
|
||||
|
||||
# vim:syntax=perl
|
|
@ -1,101 +0,0 @@
|
|||
#!/usr/bin/perl -w
|
||||
#
|
||||
# Copyright (C) 2009 Branislav Bozgai
|
||||
#
|
||||
# Munin plugin to monitor ZyXel ZyWall series routers Sessions utilization.
|
||||
# Based on snmp__if_ plugin.
|
||||
#
|
||||
# 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.
|
||||
|
||||
|
||||
#%# 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 $response;
|
||||
|
||||
if (defined $ARGV[0] and $ARGV[0] eq "snmpconf")
|
||||
{
|
||||
print "require 1.3.6.1.4.1.890.1.6.1.1.4.0\n";
|
||||
exit 0;
|
||||
}
|
||||
|
||||
if ($0 =~ /^(?:|.*\/)snmp_zyxel_zywall_([^_]+)_sessions$/)
|
||||
{
|
||||
$host = $1;
|
||||
if ($host =~ /^([^:]+):(\d+)$/)
|
||||
{
|
||||
$host = $1;
|
||||
$port = $2;
|
||||
}
|
||||
}
|
||||
elsif (!defined($host))
|
||||
{
|
||||
print "# Debug: $0 -- $1\n" if $DEBUG;
|
||||
die "# Error: couldn't understand what I'm supposed to monitor.";
|
||||
}
|
||||
|
||||
my $sysActiveSessions = "1.3.6.1.4.1.890.1.6.1.1.4.0";
|
||||
|
||||
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($sysActiveSessions)))
|
||||
{
|
||||
die "Croaking: " . $session->error();
|
||||
}
|
||||
print "graph_title Active Sessions\n";
|
||||
print "graph_category system\n";
|
||||
print "graph_args --base 1000 --lower-limit 0\n";
|
||||
print "graph_vlabel Active Sessions\n";
|
||||
print "graph_period second\n";
|
||||
print "graph_info Active Sessions\n";
|
||||
print "sysActiveSessions.label Sessions\n";
|
||||
print "sysActiveSessions.draw AREA\n";
|
||||
exit 0;
|
||||
}
|
||||
|
||||
|
||||
if (defined ($response = $session->get_request($sysActiveSessions)))
|
||||
{
|
||||
print "sysActiveSessions.value ", $response->{$sysActiveSessions}, "\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
print "sysActiveSessions.value U\n";
|
||||
}
|
||||
|
||||
# vim:syntax=perl
|
Loading…
Add table
Add a link
Reference in a new issue