--- /tmp/mon-contrib-1.0+dfsg-4+b2oj__qhrl/debian/mon-contrib_1.0+dfsg-4+b2_amd64.deb +++ mon-contrib_1.0+dfsg-4+b2_amd64.deb ├── file list │ @@ -1,3 +1,3 @@ │ -rw-r--r-- 0 0 0 4 2019-08-08 09:37:52.000000 debian-binary │ -rw-r--r-- 0 0 0 3516 2019-08-08 09:37:52.000000 control.tar.xz │ --rw-r--r-- 0 0 0 71256 2019-08-08 09:37:52.000000 data.tar.xz │ +-rw-r--r-- 0 0 0 70944 2019-08-08 09:37:52.000000 data.tar.xz ├── control.tar.xz │ ├── control.tar │ │ ├── ./control │ │ │ @@ -1,13 +1,13 @@ │ │ │ Package: mon-contrib │ │ │ Source: mon-contrib (1.0+dfsg-4) │ │ │ Version: 1.0+dfsg-4+b2 │ │ │ Architecture: amd64 │ │ │ Maintainer: Dario Minnucci │ │ │ -Installed-Size: 451 │ │ │ +Installed-Size: 454 │ │ │ Depends: mon (>= 1.2.0-3) │ │ │ Section: admin │ │ │ Priority: extra │ │ │ Homepage: https://mon.wiki.kernel.org/articles/c/o/n/Contrib_repository.html │ │ │ Description: contributed tools, monitors and alert for mon │ │ │ mon-contrib is the mon /contrib archive. It contains user-submitted │ │ │ add-ons to mon, which are not included in the main mon distribution. │ │ ├── ./md5sums │ │ │ ├── ./md5sums │ │ │ │┄ Files differ ├── data.tar.xz │ ├── data.tar │ │ ├── file list │ │ │ @@ -7,15 +7,15 @@ │ │ │ drwxr-xr-x 0 root (0) root (0) 0 2019-08-08 09:37:52.000000 ./usr/lib/mon-contrib/ │ │ │ drwxr-xr-x 0 root (0) root (0) 0 2019-08-08 09:37:52.000000 ./usr/lib/mon-contrib/alert.d/ │ │ │ -rwxr-xr-x 0 root (0) root (0) 4948 2019-08-08 09:37:52.000000 ./usr/lib/mon-contrib/alert.d/aim.alert │ │ │ -rwxr-xr-x 0 root (0) root (0) 4041 2019-08-08 09:37:52.000000 ./usr/lib/mon-contrib/alert.d/bugzilla.alert │ │ │ -rwxr-xr-x 0 root (0) root (0) 3108 2019-08-08 09:37:52.000000 ./usr/lib/mon-contrib/alert.d/gnats.alert │ │ │ -rwxr-xr-x 0 root (0) root (0) 4477 2019-08-08 09:37:52.000000 ./usr/lib/mon-contrib/alert.d/hpov.alert │ │ │ -rwxr-xr-x 0 root (0) root (0) 3880 2019-08-08 09:37:52.000000 ./usr/lib/mon-contrib/alert.d/ipvs.alert │ │ │ --rwxr-xr-x 0 root (0) root (0) 2330 2019-08-08 09:37:52.000000 ./usr/lib/mon-contrib/alert.d/sms.alert │ │ │ +-rwxr-xr-x 0 root (0) root (0) 460 2019-08-08 09:37:52.000000 ./usr/lib/mon-contrib/alert.d/sms.alert │ │ │ -rwxr-xr-x 0 root (0) root (0) 3960 2019-08-08 09:37:52.000000 ./usr/lib/mon-contrib/alert.d/snapdelete.alert │ │ │ -rwxr-xr-x 0 root (0) root (0) 2580 2019-08-08 09:37:52.000000 ./usr/lib/mon-contrib/alert.d/winpopup.alert │ │ │ drwxr-xr-x 0 root (0) root (0) 0 2019-08-08 09:37:52.000000 ./usr/lib/mon-contrib/mon-local.d/ │ │ │ drwxr-xr-x 0 root (0) root (0) 0 2019-08-08 09:37:52.000000 ./usr/lib/mon-contrib/mon.d/ │ │ │ -rwxr-xr-x 0 root (0) root (0) 6967 2019-08-08 09:37:52.000000 ./usr/lib/mon-contrib/mon.d/bgp.monitor │ │ │ -rwxr-xr-x 0 root (0) root (0) 7258 2019-08-08 09:37:52.000000 ./usr/lib/mon-contrib/mon.d/cisco-env.monitor │ │ │ -rwxr-xr-x 0 root (0) root (0) 2490 2019-08-08 09:37:52.000000 ./usr/lib/mon-contrib/mon.d/citrix.monitor │ │ │ @@ -33,15 +33,15 @@ │ │ │ -rwxr-xr-x 0 root (0) root (0) 1289 2019-08-08 09:37:52.000000 ./usr/lib/mon-contrib/mon.d/ipsec.monitor │ │ │ -rwxr-xr-x 0 root (0) root (0) 2301 2019-08-08 09:37:52.000000 ./usr/lib/mon-contrib/mon.d/ipvs.monitor │ │ │ -rwxr-xr-x 0 root (0) root (0) 7051 2019-08-08 09:37:52.000000 ./usr/lib/mon-contrib/mon.d/krb5.monitor │ │ │ -rwxr-xr-x 0 root (0) root (0) 3837 2019-08-08 09:37:52.000000 ./usr/lib/mon-contrib/mon.d/lmtp.monitor │ │ │ -rwxr-xr-x 0 root (0) root (0) 5088 2019-08-08 09:37:52.000000 ./usr/lib/mon-contrib/mon.d/mailloop.monitor │ │ │ -rwxr-xr-x 0 root (0) root (0) 3857 2019-08-08 09:37:52.000000 ./usr/lib/mon-contrib/mon.d/mupdate.monitor │ │ │ -rwxr-xr-x 0 root (0) root (0) 7497 2019-08-08 09:37:52.000000 ./usr/lib/mon-contrib/mon.d/netsnmp-exec.monitor │ │ │ --rwxr-xr-x 0 root (0) root (0) 3208 2019-08-08 09:37:52.000000 ./usr/lib/mon-contrib/mon.d/netsnmp-freespace.monitor │ │ │ +-rwxr-xr-x 0 root (0) root (0) 6648 2019-08-08 09:37:52.000000 ./usr/lib/mon-contrib/mon.d/netsnmp-freespace.monitor │ │ │ -rwxr-xr-x 0 root (0) root (0) 7359 2019-08-08 09:37:52.000000 ./usr/lib/mon-contrib/mon.d/netsnmp-proc.monitor │ │ │ -rwxr-xr-x 0 root (0) root (0) 7799 2019-08-08 09:37:52.000000 ./usr/lib/mon-contrib/mon.d/netwarefree.monitor │ │ │ -rwxr-xr-x 0 root (0) root (0) 8405 2019-08-08 09:37:52.000000 ./usr/lib/mon-contrib/mon.d/ospf.monitor │ │ │ -rwxr-xr-x 0 root (0) root (0) 3165 2019-08-08 09:37:52.000000 ./usr/lib/mon-contrib/mon.d/postgresql.monitor │ │ │ -rwxr-xr-x 0 root (0) root (0) 4415 2019-08-08 09:37:52.000000 ./usr/lib/mon-contrib/mon.d/printmib.monitor │ │ │ -rwxr-xr-x 0 root (0) root (0) 3314 2019-08-08 09:37:52.000000 ./usr/lib/mon-contrib/mon.d/process-full-command-line.monitor │ │ │ -rwxr-xr-x 0 root (0) root (0) 5740 2019-08-08 09:37:52.000000 ./usr/lib/mon-contrib/mon.d/pubcookielogin.monitor │ │ │ @@ -95,15 +95,15 @@ │ │ │ -rw-r--r-- 0 root (0) root (0) 1421 2019-08-08 09:37:52.000000 ./usr/share/doc/mon-contrib/monitors/informix.monitor.README │ │ │ -rw-r--r-- 0 root (0) root (0) 921 2019-08-08 09:37:52.000000 ./usr/share/doc/mon-contrib/monitors/informixdbspace.monitor.README │ │ │ -rw-r--r-- 0 root (0) root (0) 1410 2019-08-08 09:37:52.000000 ./usr/share/doc/mon-contrib/monitors/ipsec.monitor.README │ │ │ -rw-r--r-- 0 root (0) root (0) 982 2019-08-08 09:37:52.000000 ./usr/share/doc/mon-contrib/monitors/krb5.monitor.README │ │ │ -rw-r--r-- 0 root (0) root (0) 439 2019-08-08 09:37:52.000000 ./usr/share/doc/mon-contrib/monitors/lwp-http.mon.README │ │ │ -rw-r--r-- 0 root (0) root (0) 2517 2019-08-08 09:37:52.000000 ./usr/share/doc/mon-contrib/monitors/mailloop.monitor.README │ │ │ -rw-r--r-- 0 root (0) root (0) 2345 2019-08-08 09:37:52.000000 ./usr/share/doc/mon-contrib/monitors/netsnmp-exec.monitor.README │ │ │ --rw-r--r-- 0 root (0) root (0) 813 2019-08-08 09:37:52.000000 ./usr/share/doc/mon-contrib/monitors/netsnmp-freespace.monitor.README │ │ │ +-rw-r--r-- 0 root (0) root (0) 2116 2019-08-08 09:37:52.000000 ./usr/share/doc/mon-contrib/monitors/netsnmp-freespace.monitor.README │ │ │ -rw-r--r-- 0 root (0) root (0) 980 2019-08-08 09:37:52.000000 ./usr/share/doc/mon-contrib/monitors/netsnmp-proc.monitor.README │ │ │ -rw-r--r-- 0 root (0) root (0) 1784 2019-08-08 09:37:52.000000 ./usr/share/doc/mon-contrib/monitors/postgresql.monitor.README │ │ │ -rw-r--r-- 0 root (0) root (0) 1462 2019-08-08 09:37:52.000000 ./usr/share/doc/mon-contrib/monitors/printmib.monitor.README │ │ │ -rw-r--r-- 0 root (0) root (0) 253 2019-08-08 09:37:52.000000 ./usr/share/doc/mon-contrib/monitors/process-full-command-line.monitor.README │ │ │ -rw-r--r-- 0 root (0) root (0) 906 2019-08-08 09:37:52.000000 ./usr/share/doc/mon-contrib/monitors/radius.monitor.detailcheck.README │ │ │ -rw-r--r-- 0 root (0) root (0) 3522 2019-08-08 09:37:52.000000 ./usr/share/doc/mon-contrib/monitors/remote.monitor.README │ │ │ -rw-r--r-- 0 root (0) root (0) 2090 2019-08-08 09:37:52.000000 ./usr/share/doc/mon-contrib/monitors/rptr.monitor.README │ │ ├── ./usr/lib/mon-contrib/alert.d/sms.alert │ │ │ @@ -1,75 +1,26 @@ │ │ │ -#!/usr/bin/perl │ │ │ -# │ │ │ -# sms.alert - send an alert via SMS (sendsms) v1.5 2003-04-07 │ │ │ -# │ │ │ -# This will accept multiple phone numbers in @ARGV and call │ │ │ -# sendsms for each one of them. │ │ │ -# │ │ │ -# sendsms-specific options: │ │ │ -# -n destination number │ │ │ -# -t "message" │ │ │ -# host │ │ │ -# │ │ │ -# Peter Holzleitner, P.Holzleitner@computer.org │ │ │ -# Jim Trocki, trockij@transmeta.com │ │ │ -# │ │ │ -# Copyright (C) 1998, Peter Holzleitner │ │ │ -# Copyright (C) 1998, Jim Trocki │ │ │ -# │ │ │ -# 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; either version 2 of the License, or │ │ │ -# (at your option) any later version. │ │ │ -# │ │ │ -# 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 │ │ │ -# │ │ │ -# History: │ │ │ -# │ │ │ -# 1.5 filter single quotes (Erik Bolso) │ │ │ -# 1.4 fix loop break bug (Geta Andualem) │ │ │ -# 1.0 original release (P.Holzleitner) │ │ │ -# │ │ │ -use Getopt::Std; │ │ │ -use Sys::Syslog; │ │ │ - │ │ │ -openlog('sms.alert', '', 'user'); │ │ │ -getopts ("s:g:h:t:c:f:l:q:u"); │ │ │ - │ │ │ -# │ │ │ -# the first line is summary information, adequate to send to a pager │ │ │ -# or email subject line │ │ │ -# │ │ │ -# the following lines normally contain more detailed information, │ │ │ -# but this is monitor-dependent │ │ │ -# │ │ │ -@MSG=; │ │ │ -$summary = shift @MSG; │ │ │ -chomp $summary; │ │ │ -$detail = join(' ', @MSG); │ │ │ -$detail =~ tr/\r\n\'/ /s; │ │ │ -$detail = substr($detail, 0, 130); # real cutoff to 160 total done in sendsms │ │ │ - │ │ │ -$t = localtime($opt_t); │ │ │ -($wday,$mon,$day,$tm) = split (/\s+/, $t); │ │ │ -($hr,$min,$sec) = split(':', $tm); │ │ │ - │ │ │ -$ALERT = $opt_u ? "UPALERT" : "ALERT"; │ │ │ - │ │ │ -foreach $pagedest (@ARGV) { │ │ │ - syslog('notice', "sendsms calling $pagedest"); │ │ │ - SMS: for($retry = 1; $retry < 4; $retry++) │ │ │ - { │ │ │ - $res = system("/usr/sbin/sendsms -n '$pagedest' -t '$ALERT $opt_g/$opt_s: $summary ($hr:$min) $detail' &"); │ │ │ - last SMS if $res == 0; │ │ │ - syslog('warning', "sendsms to $pagedest failed, retrying($retry) after delay"); │ │ │ - sleep 15; │ │ │ - } │ │ │ - sleep 5; │ │ │ -} │ │ │ +#!/usr/bin/perl │ │ │ + │ │ │ +use Getopt::Std; │ │ │ +getopts ("s:g:h:t:l:u"); │ │ │ + │ │ │ +$summary=; │ │ │ +chomp $summary; │ │ │ + │ │ │ +$rest=""; │ │ │ +while () { │ │ │ + $rest .= $_; │ │ │ +} │ │ │ + │ │ │ +foreach $number (@ARGV) { │ │ │ + │ │ │ + # system("echo `date` `id` $number $summary >> /var/lib/mon/sms.alert.log"); │ │ │ + │ │ │ + open (SMS, "| /usr/bin/gnokii --sendsms $number") || die "could not open pipe to sms: $!\n"; │ │ │ + │ │ │ + print SMS $summary; │ │ │ + print SMS "\n"; │ │ │ + print SMS $rest; │ │ │ + │ │ │ + close (SMS); │ │ │ + │ │ │ +} │ │ ├── ./usr/lib/mon-contrib/mon.d/netsnmp-freespace.monitor │ │ │ @@ -1,29 +1,50 @@ │ │ │ #!/usr/bin/perl │ │ │ # │ │ │ # Monitor diskspace via SNMP │ │ │ # (based on process.monitor by Brian Moore) │ │ │ # │ │ │ -# Arguments are: │ │ │ +# Originally written by SATOH Fumiyasu . │ │ │ +# Modified Oct 2001 by Dan Urist │ │ │ +# Changes: added usage, SNMP v.3 support, -T threshold option and │ │ │ +# unique-ified errors │ │ │ +# │ │ │ +# Usage: │ │ │ +# [-h] # Usage │ │ │ +# [-t Timeout] # Timeout in ms (default: 1000000) │ │ │ +# [-r Retries] # Retries before failure (default: 5) │ │ │ +# [-v SNMPversion] # 1,2,2c or 3 (default: 1) │ │ │ +# [-c Community] # For SNMP v.1,2,2c (default: public) │ │ │ +# [-u snmpuser] # For SNMP v.3 (default: initial) │ │ │ +# [-l seclevel] # For SNMP v.3 (default: noAuthNoPriv) │ │ │ +# [-A authpassphrase] # For SNMP v.3 │ │ │ +# [-T threshold] # If a disk threshold is given, the script │ │ │ +# # will exit with the value of the highest │ │ │ +# # disk percentage found that is over the │ │ │ +# # threshold; if no disks are over the threshold │ │ │ +# # it will exit with value 0, and it will exit │ │ │ +# # with value 2 for SNMP error │ │ │ +# host [host ...] │ │ │ # │ │ │ -# [-c community] host [host ...] │ │ │ # │ │ │ # This script will exit with value 1 if host:community has dskErrorFlag │ │ │ # set. The summary output line will be the host names that failed │ │ │ # and the disk information. The detail lines are what UCD snmp returns │ │ │ # for an dskErrMessage. ('/filesystem: less than WATERMARK free (= CURRENT)'). │ │ │ # If there is an SNMP error (either a problem with the SNMP libraries, │ │ │ # or a problem communicating via SNMP with the destination host), │ │ │ # this script will exit with a warning value of 2. │ │ │ # │ │ │ -# There probably should be a better way to specify a given filesystem to │ │ │ -# watch instead of everything-ucd-snmp-is-watching. │ │ │ -# │ │ │ -# $Id: netsnmp-freespace.monitor,v 1.2 2005/03/18 19:25:27 trockij Exp $ │ │ │ -# │ │ │ +# If the -T threshold option is used, the script will exit with the │ │ │ +# highest disk percentage found that is over the threshold. The intent │ │ │ +# is to allow use with mon's "alert exit=value" parameter to allow for │ │ │ +# finer-grained alerts based on disk usage. If no disks are over the │ │ │ +# threshold, the script will exit with value 0; if an SNMP error │ │ │ +# occurs (and there are no other errors), the script will exit with │ │ │ +# value 2. │ │ │ # │ │ │ # Copyright (C) 2001 SATOH Fumiyasu │ │ │ # │ │ │ # 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; either version 2 of the License, or │ │ │ # (at your option) any later version. │ │ │ @@ -33,69 +54,132 @@ │ │ │ # 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 │ │ │ # │ │ │ -use SNMP; │ │ │ + │ │ │ +use SNMP; │ │ │ use Getopt::Std; │ │ │ │ │ │ $ENV{'MIBS'} = "UCD-SNMP-MIB"; │ │ │ │ │ │ -getopts("c:"); │ │ │ -$community = $opt_c || $ENV{'COMMUNITY'} || 'public'; │ │ │ - │ │ │ -$RETVAL = 0; │ │ │ +getopts("ht:r:v:c:u:l:A:T:"); │ │ │ +my $VERSION = "0.1"; │ │ │ +if( $opt_h || (scalar @ARGV == 0) ){ │ │ │ + print <<"USAGE"; │ │ │ +$0 Version $VERSION; original version by SATOH Fumiyasu , │ │ │ +SNMP v.3 support by Daniel J. Urist . │ │ │ + │ │ │ +Usage: │ │ │ + [-h] # Usage │ │ │ + [-t Timeout] # Timeout in ms (default: 1000000) │ │ │ + [-r Retries] # Retries before failure (default: 5) │ │ │ + [-v SNMPversion] # 1,2,2c or 3 (default: 1) │ │ │ + [-c Community] # For SNMP v.1,2,2c (default: public) │ │ │ + [-u snmpuser] # For SNMP v.3 (default: initial) │ │ │ + [-l seclevel] # For SNMP v.3 (default: noAuthNoPriv) │ │ │ + [-A authpassphrase] # For SNMP v.3 │ │ │ + [-T threshold] # If a disk threshold is given, the script will exit │ │ │ + # with the value of the highest disk percentage found │ │ │ + # that is over the threshold; if no disks are over the │ │ │ + # the threshold it will exit with value 0, and it will │ │ │ + # exit with value 2 for SNMP error │ │ │ + host [host ...] │ │ │ │ │ │ -foreach $host (@ARGV) { │ │ │ - $session = new SNMP::Session(DestHost => $host, │ │ │ - Community => $community); │ │ │ - if (!defined ($session)) { │ │ │ - $RETVAL = ($RETVAL == 1) ? 1 : 2; │ │ │ - push @failures, "$host session error"; │ │ │ - push @longerr, "$host could not get SNMP session"; │ │ │ - next; │ │ │ - } │ │ │ +USAGE │ │ │ + exit; │ │ │ +} │ │ │ │ │ │ - my $v = new SNMP::Varbind (["dskIndex"]); │ │ │ - $session->getnext ($v); │ │ │ +# FIXME we should probably offer all the v3 options that the SNMP module does │ │ │ +my $Timeout = $opt_t || 1000000; │ │ │ +my $Retries = $opt_r || 5; │ │ │ +my $SNMPVersion = $opt_v || 1; │ │ │ +my $Community = $opt_c || 'public'; │ │ │ +my $SecName = $opt_u || 'initial'; │ │ │ +my $SecLevel = $opt_l || 'noAuthNoPriv'; │ │ │ +my $Authpass = $opt_A || ''; │ │ │ +my $Threshold = $opt_T if defined($opt_T); │ │ │ + │ │ │ +my %SNMPARGS = ( │ │ │ + Timeout => $Timeout, │ │ │ + Version => $SNMPVersion, │ │ │ + ); │ │ │ + │ │ │ +if ($SNMPVersion eq "3"){ │ │ │ + $SNMPARGS{SecName} = $SecName; │ │ │ + $SNMPARGS{SecLevel} = $SecLevel; │ │ │ + $SNMPARGS{AuthPass} = $Authpass; │ │ │ +} │ │ │ +else{ │ │ │ + $SNMPARGS{Community} = $Community; │ │ │ +} │ │ │ │ │ │ - while (!$session->{"ErrorStr"} && $v->tag eq "dskIndex") { │ │ │ - my @q = $session->get ([ │ │ │ - ["dskPath", $v->iid], # 0 │ │ │ - ["dskDevice", $v->iid], # 1 │ │ │ - ["dskMinimum", $v->iid], # 2 │ │ │ - ["dskMinPercent", $v->iid], # 3 │ │ │ - ["dskTotal", $v->iid], # 4 │ │ │ - ["dskAvail", $v->iid], # 5 │ │ │ - ["dskUsed", $v->iid], # 6 │ │ │ - ["dskPercent", $v->iid], # 7 │ │ │ - ["dskPercentNode", $v->iid],# 8 │ │ │ - ["dskErrorFlag", $v->iid], # 9 │ │ │ - ["dskErrorMsg", $v->iid], # 10 │ │ │ - ]); │ │ │ - │ │ │ - last if ($session->{"ErrorStr"}); │ │ │ - │ │ │ - if ($q[9] > 0) { │ │ │ - $RETVAL = 1; │ │ │ - my ($t, $u, $a) = map { int($_/1024) } @q[4, 6, 5]; │ │ │ - push (@failures, $host); │ │ │ - push (@longerr, "$host:$q[0]($q[1]) total=$t used=$u($q[7]%) free=$a err=$q[10]"); │ │ │ - } │ │ │ +my $RETVAL = 0; │ │ │ +my %Failures; │ │ │ +my %Longerr; │ │ │ +my $Session; │ │ │ │ │ │ - $session->getnext ($v); │ │ │ +foreach $host (@ARGV) { │ │ │ + $Session = new SNMP::Session( │ │ │ + DestHost => $host, │ │ │ + %SNMPARGS, │ │ │ + ); │ │ │ + unless( defined($Session) ) { │ │ │ + $RETVAL = 2 if $RETVAL == 0; # Other errors take precedence over SNMP error │ │ │ + $Failures{"$host session error"} = ""; │ │ │ + $Longerr{"$host could not get SNMP session"} = ""; │ │ │ + next; │ │ │ + } │ │ │ + │ │ │ + my $v = new SNMP::Varbind (["dskIndex"]); │ │ │ + $Session->getnext ($v); │ │ │ + │ │ │ + while (!$Session->{"ErrorStr"} && $v->tag eq "dskIndex") { │ │ │ + my @q = $Session->get ([ │ │ │ + ["dskPath", $v->iid], # 0 │ │ │ + ["dskDevice", $v->iid], # 1 │ │ │ + ["dskMinimum", $v->iid], # 2 │ │ │ + ["dskMinPercent", $v->iid], # 3 │ │ │ + ["dskTotal", $v->iid], # 4 │ │ │ + ["dskAvail", $v->iid], # 5 │ │ │ + ["dskUsed", $v->iid], # 6 │ │ │ + ["dskPercent", $v->iid], # 7 │ │ │ + ["dskPercentNode", $v->iid],# 8 │ │ │ + ["dskErrorFlag", $v->iid], # 9 │ │ │ + ["dskErrorMsg", $v->iid], # 10 │ │ │ + ]); │ │ │ + last if ($Session->{"ErrorStr"}); │ │ │ + │ │ │ + if( defined $Threshold ){ │ │ │ + if($q[7] > $Threshold){ │ │ │ + $RETVAL = $q[7] if $q[7] > $RETVAL; │ │ │ + my ($t, $u, $a) = map { int($_/1024) } @q[4, 6, 5]; │ │ │ + $Failures{$host} = ""; │ │ │ + $Longerr{"$host:$q[0]($q[1]) total=$t used=$u($q[7]%) free=$a threshold=$Threshold%"} = ""; │ │ │ + } │ │ │ } │ │ │ - │ │ │ - if ($session->{"ErrorStr"}) { │ │ │ - push (@failures, $host); │ │ │ - push (@longerr, "$host returned an SNMP error: " . $session->{"ErrorStr"}); │ │ │ + elsif ($q[9] > 0) { │ │ │ + $RETVAL = 1; │ │ │ + my ($t, $u, $a) = map { int($_/1024) } @q[4, 6, 5]; │ │ │ + $Failures{$host} = ""; │ │ │ + $Longerr{"$host:$q[0]($q[1]) total=$t used=$u($q[7]%) free=$a err=$q[10]"} = ""; │ │ │ } │ │ │ + │ │ │ + $Session->getnext ($v); │ │ │ + } │ │ │ + │ │ │ + if ($Session->{"ErrorStr"}) { │ │ │ + $RETVAL = 2 if $RETVAL == 0; # Other errors take precedence over SNMP error │ │ │ + $Failures{$host} = ""; │ │ │ + $Longerr{"$host returned an SNMP error: " . $Session->{"ErrorStr"}} = ""; │ │ │ + } │ │ │ } │ │ │ │ │ │ -if (@failures) { │ │ │ - print join (", ", @failures), "\n", "\n"; │ │ │ - print join ("\n", @longerr), "\n"; │ │ │ +if (scalar keys %Failures) { │ │ │ + print join (", ", sort keys %Failures), "\n", "\n"; │ │ │ + print join ("\n", sort keys %Longerr), "\n"; │ │ │ } │ │ │ │ │ │ exit $RETVAL; │ │ │ + │ │ ├── ./usr/share/doc/mon-contrib/monitors/netsnmp-freespace.monitor.README │ │ │ @@ -1,20 +1,43 @@ │ │ │ -Date: Thu, 21 Jun 2001 05:46:47 +0900 │ │ │ -From: SATOH Fumiyasu │ │ │ -To: trockij@transmeta.com │ │ │ -Subject: freespace-snmp.monitor │ │ │ +# │ │ │ +# Monitor diskspace via SNMP │ │ │ +# (based on process.monitor by Brian Moore) │ │ │ +# │ │ │ +# Originally written by SATOH Fumiyasu . │ │ │ +# Modified Oct 2001 by Dan Urist │ │ │ +# Changes: added usage, SNMP v.3 support, -T threshold option and │ │ │ +# unique-ified errors │ │ │ +# │ │ │ +# Usage: │ │ │ +# [-h] # Usage │ │ │ +# [-t Timeout] # Timeout in ms (default: 1000000) │ │ │ +# [-r Retries] # Retries before failure (default: 5) │ │ │ +# [-v SNMPversion] # 1,2,2c or 3 (default: 1) │ │ │ +# [-c Community] # For SNMP v.1,2,2c (default: public) │ │ │ +# [-u snmpuser] # For SNMP v.3 (default: initial) │ │ │ +# [-l seclevel] # For SNMP v.3 (default: noAuthNoPriv) │ │ │ +# [-A authpassphrase] # For SNMP v.3 │ │ │ +# [-T threshold] # If a disk threshold is given, the script │ │ │ +# # will exit with the value of the highest │ │ │ +# # disk percentage found that is over the │ │ │ +# # threshold; if no disks are over the threshold │ │ │ +# # it will exit with value 0, and it will exit │ │ │ +# # with value 2 for SNMP error │ │ │ +# host [host ...] │ │ │ +# │ │ │ +# │ │ │ +# This script will exit with value 1 if host:community has dskErrorFlag │ │ │ +# set. The summary output line will be the host names that failed │ │ │ +# and the disk information. The detail lines are what UCD snmp returns │ │ │ +# for an dskErrMessage. ('/filesystem: less than WATERMARK free (= CURRENT)'). │ │ │ +# If there is an SNMP error (either a problem with the SNMP libraries, │ │ │ +# or a problem communicating via SNMP with the destination host), │ │ │ +# this script will exit with a warning value of 2. │ │ │ +# │ │ │ +# If the -T threshold option is used, the script will exit with the │ │ │ +# highest disk percentage found that is over the threshold. The intent │ │ │ +# is to allow use with mon's "alert exit=value" parameter to allow for │ │ │ +# finer-grained alerts based on disk usage. If no disks are over the │ │ │ +# threshold, the script will exit with value 0; if an SNMP error │ │ │ +# occurs (and there are no other errors), the script will exit with │ │ │ +# value 2. │ │ │ │ │ │ -Hi, ``mon'' developper. │ │ │ - │ │ │ -I wrote freespace-snmp.monitor based on process.monitor for mon. │ │ │ -This monitors disk space via SNMP (NET-SNMP, aka UCD-SNMP). │ │ │ - │ │ │ -I want to commit this monitor to mon archive. Any comments? │ │ │ -If you think that ``freespace-snmp'' is not suitable name, │ │ │ -please name this monitor as you wish :-). │ │ │ - │ │ │ --- │ │ │ -SATOH Fumiyasu - fumiya @net-thrust.com, @samba.gr.jp, @namazu.org or ... │ │ │ -THRUST Co., Ltd. @ Fujisawa, Kanagawa, Japan - http://www.net-thrust.com │ │ │ -Samba-JP, aka `Samba Users Group Japan' - http://www.samba.gr.jp │ │ │ -Apache-JP(?), aka `Japan Apache Users Group' - http://www.apache.or.jp │ │ │ -Namazu, a full-text search engine - http://www.namazu.org