2007-09-08 20:03:59 +02:00
|
|
|
#!/usr/bin/perl -w
|
|
|
|
#
|
|
|
|
# File: snmp__gwmta_msgs_
|
|
|
|
# Copyright (C) 2007 Gabriele Pohl (contact@dipohl.de)
|
|
|
|
#
|
|
|
|
# Derived from plugin snmp__load
|
|
|
|
# Copyright (C) 2004 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.
|
|
|
|
#
|
|
|
|
# ------------------------------------------------------------
|
|
|
|
# Plugin to monitor Novell Groupwise MTA (GWMTA)
|
|
|
|
# ------------------------------------------------------------
|
2018-08-02 02:03:42 +02:00
|
|
|
#
|
|
|
|
# Management Information Base (MIB) GWMTA-MIB
|
2007-09-08 20:03:59 +02:00
|
|
|
#
|
|
|
|
# Naming Tree: 1.3.6.1.4.1.23
|
|
|
|
# iso(1) org(3) dod(6) internet(1) private(4) enterprises(1) novell(23)
|
|
|
|
#
|
|
|
|
# To see all values available for your GWMTA, type
|
|
|
|
# snmpwalk -v1 -c public -m GWMTA-MIB <HOST> gwmta
|
|
|
|
#
|
2018-08-02 02:03:42 +02:00
|
|
|
# This plugin fetches:
|
2007-09-08 20:03:59 +02:00
|
|
|
#
|
2018-08-02 02:03:42 +02:00
|
|
|
# * mtaDomainName 1.3.6.1.4.1.23.2.37.1.1.1.2.
|
|
|
|
# * mtaTenMinuteRoutedMsgs - 1.3.6.1.4.1.23.2.37.1.1.1.10.
|
2007-09-08 20:03:59 +02:00
|
|
|
# * mtaTenMinuteUndeliverableMsgs - 1.3.6.1.4.1.23.2.37.1.1.1.12.
|
|
|
|
# * mtaTenMinuteErrorMsgs - 1.3.6.1.4.1.23.2.37.1.1.1.14.
|
|
|
|
#
|
|
|
|
# Usage:
|
|
|
|
# --------------
|
2018-08-02 02:03:42 +02:00
|
|
|
# Link this file snmp__gwmta_msgs_ to your nodes servicedir [/etc/munin/plugins]
|
2007-09-08 20:03:59 +02:00
|
|
|
#
|
2018-08-02 02:03:42 +02:00
|
|
|
# as:
|
|
|
|
# snmp_<host>_gwmta_msgs_<pos>
|
2007-09-08 20:03:59 +02:00
|
|
|
#
|
|
|
|
# with:
|
2018-08-02 02:03:42 +02:00
|
|
|
# <host> = Name or IP-Number of host
|
2007-09-08 20:03:59 +02:00
|
|
|
# <pos> = table index of the GWMTA Object
|
2018-08-02 02:03:42 +02:00
|
|
|
#
|
2007-09-08 20:03:59 +02:00
|
|
|
# E.g.
|
|
|
|
# ln -s /usr/share/munin/plugins/snmp__gwmta_msgs_ \
|
|
|
|
# /etc/munin/plugins/snmp_foo.example.com_gwmta_msgs_0
|
2018-08-02 02:03:42 +02:00
|
|
|
# ...will monitor a single GWMTA object on host foo.example.com.
|
2007-09-08 20:03:59 +02:00
|
|
|
#
|
|
|
|
# Parameters
|
|
|
|
# community - Specify wich community string to use (Default: public)
|
|
|
|
# port - Specify which port to read from (Default: 161)
|
|
|
|
# host - Specify which host to monitor (Default: Read from link in servicedir)
|
2018-08-02 02:03:42 +02:00
|
|
|
# pos - Specify which table Object to read (Default: Read from link in servicedir,
|
|
|
|
#
|
2007-09-08 20:03:59 +02:00
|
|
|
# You may adjust settings to your need via configuration in plugin-conf.d/munin-node:
|
|
|
|
# [snmp_*_gwmta_msgs_*]
|
|
|
|
# env.port <your_port_number>
|
|
|
|
# env.community <your SNMP community string>
|
2018-08-02 02:03:42 +02:00
|
|
|
# env.pos <your objects table position. Values: 0,1,2,..>
|
2007-09-08 20:03:59 +02:00
|
|
|
# env.host <name or IP of your host>
|
|
|
|
#
|
|
|
|
# Parameters can also be specified on a per GWMTA basis, eg:
|
|
|
|
# [snmp_example.com_gwmta_msgs_1]
|
|
|
|
# env.port 166
|
|
|
|
# env.community example
|
|
|
|
#
|
|
|
|
# $Log$
|
|
|
|
# Revision 1.0 2007/09/08 19:44 gap
|
|
|
|
# Created by gap
|
|
|
|
#
|
|
|
|
#%# 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 $pos = $ENV{pos} || 1;
|
|
|
|
|
|
|
|
my $response;
|
|
|
|
|
|
|
|
# fix values
|
|
|
|
my $GRAPH_PERIOD = "minute";
|
|
|
|
my $GRAPH_VLABEL = "number of messages / 10 min";
|
|
|
|
my $ROUTED_LABEL="Routed";
|
|
|
|
my $ROUTED_CRITICAL=500;
|
|
|
|
my $UNDELIVERED_LABEL="Undeliverable";
|
|
|
|
my $UNDELIVERED_CRITICAL=10;
|
|
|
|
my $ERRORS_LABEL="Errors";
|
|
|
|
my $ERRORS_CRITICAL=10;
|
|
|
|
|
|
|
|
if (defined $ARGV[0] and $ARGV[0] eq "snmpconf")
|
|
|
|
{
|
2018-08-02 02:03:42 +02:00
|
|
|
print "index 1.3.6.1.4.1.23.2.37.1.1.1.1.\n"; # mtaIndex
|
|
|
|
print "require 1.3.6.1.4.1.23.2.37.1.1.1.2. \n"; # mtaDomainName
|
2007-09-08 20:03:59 +02:00
|
|
|
print "require 1.3.6.1.4.1.23.2.37.1.1.1.10. [\\d+]\n"; # mtaTenMinuteRoutedMsgs
|
|
|
|
print "require 1.3.6.1.4.1.23.2.37.1.1.1.12. [\\d+]\n"; # mtaTenMinuteUndeliverableMsgs
|
|
|
|
print "require 1.3.6.1.4.1.23.2.37.1.1.1.14. [\\d+]\n"; # mtaTenMinuteErrorMsgs
|
|
|
|
|
|
|
|
exit 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($0 =~ /^(?:|.*\/)snmp_([^_]+)_gwmta_msgs_(\d+)*$/)
|
|
|
|
{
|
|
|
|
$host = $1;
|
|
|
|
$pos = $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";
|
|
|
|
}
|
|
|
|
|
|
|
|
if (defined $ARGV[0] and $ARGV[0] eq "config")
|
|
|
|
{
|
2018-08-02 02:03:42 +02:00
|
|
|
# get name of domain
|
|
|
|
my $domain = &get_single ($session, "1.3.6.1.4.1.23.2.37.1.1.1.2.$pos"); # mtaDomainName
|
2007-09-08 20:03:59 +02:00
|
|
|
|
|
|
|
# output to munin
|
|
|
|
print "host_name $host
|
2017-02-20 16:42:38 +01:00
|
|
|
graph_category mail
|
2007-09-08 20:03:59 +02:00
|
|
|
graph_args --base 1000
|
|
|
|
graph_period $GRAPH_PERIOD
|
2018-08-02 02:03:42 +02:00
|
|
|
graph_title GWMTA load ($domain)
|
|
|
|
graph_info Monitors status of Groupwise MTA, here: $domain. It reports values for the last 10 minutes.
|
2007-09-08 20:03:59 +02:00
|
|
|
graph_vlabel $GRAPH_VLABEL
|
|
|
|
graph_args -l 0
|
|
|
|
routed.label $ROUTED_LABEL
|
2018-08-02 02:03:42 +02:00
|
|
|
routed.info mtaTenMinuteRoutedMsgs (1.3.6.1.4.1.23.2.37.1.1.1.10.)
|
2007-09-08 20:03:59 +02:00
|
|
|
routed.critical $ROUTED_CRITICAL
|
|
|
|
routed.type GAUGE
|
|
|
|
routed.min 0
|
|
|
|
routed.draw AREA
|
|
|
|
routed.graph yes
|
|
|
|
undelivered.label $UNDELIVERED_LABEL
|
|
|
|
undelivered.info mtaTenMinuteUndeliverableMsgs (1.3.6.1.4.1.23.2.37.1.1.1.12.)
|
|
|
|
undelivered.critical $UNDELIVERED_CRITICAL
|
|
|
|
undelivered.type GAUGE
|
|
|
|
undelivered.min 0
|
|
|
|
undelivered.draw STACK
|
|
|
|
undelivered.graph yes
|
|
|
|
errors.label $ERRORS_LABEL
|
|
|
|
errors.info mtaTenMinuteErrorMsgs (1.3.6.1.4.1.23.2.37.1.1.1.14.)
|
|
|
|
errors.critical $ERRORS_CRITICAL
|
|
|
|
errors.type GAUGE
|
|
|
|
errors.min 0
|
|
|
|
errors.draw STACK
|
|
|
|
errors.graph yes";
|
|
|
|
|
|
|
|
exit 0;
|
|
|
|
}
|
|
|
|
# fetch the data and print
|
|
|
|
print "routed.value ", &get_single ($session, "1.3.6.1.4.1.23.2.37.1.1.1.10.$pos"), "\n"; # mtaTenMinuteRoutedMsgs
|
|
|
|
print "undelivered.value ", &get_single ($session, "1.3.6.1.4.1.23.2.37.1.1.1.12.$pos"), "\n"; # mtaTenMinuteUndeliverableMsgs
|
|
|
|
print "errors.value ", &get_single ($session, "1.3.6.1.4.1.23.2.37.1.1.1.14.$pos"), "\n"; # mtaTenMinuteErrorMsgs
|
|
|
|
|
|
|
|
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};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|