mon-commit Mailing List for mon (Page 7)
Brought to you by:
trockij
You can subscribe to this list here.
| 2004 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(36) |
Jul
(21) |
Aug
(9) |
Sep
(1) |
Oct
(2) |
Nov
(12) |
Dec
(6) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2005 |
Jan
(4) |
Feb
(10) |
Mar
(5) |
Apr
(22) |
May
(17) |
Jun
(3) |
Jul
(4) |
Aug
(10) |
Sep
(2) |
Oct
(1) |
Nov
(2) |
Dec
(2) |
| 2006 |
Jan
|
Feb
(4) |
Mar
|
Apr
|
May
|
Jun
|
Jul
(2) |
Aug
|
Sep
(6) |
Oct
|
Nov
|
Dec
(2) |
| 2007 |
Jan
|
Feb
|
Mar
|
Apr
(2) |
May
(22) |
Jun
(19) |
Jul
(7) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(6) |
| 2008 |
Jan
(1) |
Feb
(1) |
Mar
(3) |
Apr
(1) |
May
|
Jun
|
Jul
|
Aug
(4) |
Sep
|
Oct
(7) |
Nov
(1) |
Dec
|
| 2009 |
Jan
(2) |
Feb
(9) |
Mar
(1) |
Apr
|
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(5) |
| 2010 |
Jan
(2) |
Feb
(1) |
Mar
|
Apr
|
May
(4) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2011 |
Jan
|
Feb
|
Mar
(2) |
Apr
(1) |
May
(2) |
Jun
(2) |
Jul
(65) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: Jim T. <tr...@us...> - 2007-05-08 11:05:56
|
Update of /cvsroot/mon/mon
In directory sc8-pr-cvs16:/tmp/cvs-serv16113
Modified Files:
Tag: mon-1-2-branch
CHANGES
Log Message:
added -m to http.monitor
fixed path to perl in snmpdiskspace.monitor
Index: CHANGES
===================================================================
RCS file: /cvsroot/mon/mon/CHANGES,v
retrieving revision 1.3.2.2
retrieving revision 1.3.2.3
diff -C2 -d -r1.3.2.2 -r1.3.2.3
*** CHANGES 3 May 2007 19:55:36 -0000 1.3.2.2
--- CHANGES 8 May 2007 11:05:47 -0000 1.3.2.3
***************
*** 2,6 ****
Changes between mon-1.2.0- and mon-1.2.0-release
! Thu May 3 15:38:58 EDT 2007
-----------------------------------------------
--- 2,6 ----
Changes between mon-1.2.0- and mon-1.2.0-release
! Tue May 8 06:59:41 EDT 2007
-----------------------------------------------
***************
*** 19,22 ****
--- 19,25 ----
Allow snpp.alert to "use strict"
+ -added "-m" to http.monitor to match header/content with regex
+ by Jim Trocki
+
Changes between mon-1.0.0pre3 and mon-1.0.0pre4
|
|
From: Jim T. <tr...@us...> - 2007-05-03 19:56:21
|
Update of /cvsroot/mon/mon/mon.d
In directory sc8-pr-cvs16:/tmp/cvs-serv31786/mon.d
Modified Files:
Tag: mon-1-2-branch
mon.monitor nntp.monitor
Log Message:
snpp use strict fix, mon.cgi ack display fix, mon.monitor option fix, nntp -f fix, all from augie
Index: nntp.monitor
===================================================================
RCS file: /cvsroot/mon/mon/mon.d/nntp.monitor,v
retrieving revision 1.2
retrieving revision 1.2.2.1
diff -C2 -d -r1.2 -r1.2.2.1
*** nntp.monitor 17 Apr 2005 07:42:27 -0000 1.2
--- nntp.monitor 3 May 2007 19:55:40 -0000 1.2.2.1
***************
*** 54,58 ****
$PORT = $opt_p || 119;
$TIMEOUT = $opt_t || 30;
! $FEEDER = $opt{"f"};
$DEBUG = $opt_d || "";
$USER = $opt_u || '';
--- 54,58 ----
$PORT = $opt_p || 119;
$TIMEOUT = $opt_t || 30;
! $FEEDER = $opt_f;
$DEBUG = $opt_d || "";
$USER = $opt_u || '';
Index: mon.monitor
===================================================================
RCS file: /cvsroot/mon/mon/mon.d/mon.monitor,v
retrieving revision 1.1.1.1
retrieving revision 1.1.1.1.4.1
diff -C2 -d -r1.1.1.1 -r1.1.1.1.4.1
*** mon.monitor 9 Jun 2004 05:18:05 -0000 1.1.1.1
--- mon.monitor 3 May 2007 19:55:39 -0000 1.1.1.1.4.1
***************
*** 15,19 ****
my %opt;
! getopts ('u:p:p:t:', \%opt);
my @failures;
--- 15,19 ----
my %opt;
! getopts ('u:p:P:t:', \%opt);
my @failures;
***************
*** 47,55 ****
}
! if ($opt{"u"} && $opt{"p"})
{
if (! defined $c->login (
"username" => $opt{"u"},
! "password" => $opt{"p"},
))
{
--- 47,55 ----
}
! if ($opt{"u"} && $opt{"P"})
{
if (! defined $c->login (
"username" => $opt{"u"},
! "password" => $opt{"P"},
))
{
|
|
From: Jim T. <tr...@us...> - 2007-05-03 19:56:21
|
Update of /cvsroot/mon/mon/clients
In directory sc8-pr-cvs16:/tmp/cvs-serv31786/clients
Modified Files:
Tag: mon-1-2-branch
mon.cgi
Log Message:
snpp use strict fix, mon.cgi ack display fix, mon.monitor option fix, nntp -f fix, all from augie
Index: mon.cgi
===================================================================
RCS file: /cvsroot/mon/mon/clients/mon.cgi,v
retrieving revision 1.4
retrieving revision 1.4.2.1
diff -C2 -d -r1.4 -r1.4.2.1
*** mon.cgi 31 Jul 2005 16:59:13 -0000 1.4
--- mon.cgi 3 May 2007 19:55:38 -0000 1.4.2.1
***************
*** 1084,1088 ****
# user requested it, otherwise, just pass it on through
# as is.
! if ( $op{$group}{$service}{'ack'} == 1 ) {
if ($untaint_ack_msgs) {
#
--- 1084,1088 ----
# user requested it, otherwise, just pass it on through
# as is.
! if ( $op{$group}{$service}{'ack'} != 0 ) {
if ($untaint_ack_msgs) {
#
***************
*** 1679,1683 ****
$webpage->print("<td $ack_command_bgcolor colspan=1 width=50%>");
! if ($op{$group}{$service}{'ack'} == 1) {
# Service has already been acked, offer to re-ack
$acknowledge_string = "<font size=+1><b>Re-acknowledge this failure:</b></font><br>(changes the acknowledgement message)<br>";
--- 1679,1683 ----
$webpage->print("<td $ack_command_bgcolor colspan=1 width=50%>");
! if ($op{$group}{$service}{'ack'} != 0) {
# Service has already been acked, offer to re-ack
$acknowledge_string = "<font size=+1><b>Re-acknowledge this failure:</b></font><br>(changes the acknowledgement message)<br>";
|
|
From: Jim T. <tr...@us...> - 2007-05-03 19:56:21
|
Update of /cvsroot/mon/mon/alert.d
In directory sc8-pr-cvs16:/tmp/cvs-serv31786/alert.d
Modified Files:
Tag: mon-1-2-branch
snpp.alert
Log Message:
snpp use strict fix, mon.cgi ack display fix, mon.monitor option fix, nntp -f fix, all from augie
Index: snpp.alert
===================================================================
RCS file: /cvsroot/mon/mon/alert.d/snpp.alert,v
retrieving revision 1.1.1.1
retrieving revision 1.1.1.1.4.1
diff -C2 -d -r1.1.1.1 -r1.1.1.1.4.1
*** snpp.alert 9 Jun 2004 05:18:07 -0000 1.1.1.1
--- snpp.alert 3 May 2007 19:55:36 -0000 1.1.1.1.4.1
***************
*** 26,30 ****
#
use strict;
! use vars qw /$opt_g $opt_q $opt_s $opt_t/;
use Getopt::Std;
use Net::SNPP;
--- 26,30 ----
#
use strict;
! use vars qw /$opt_g $opt_q $opt_s $opt_t $opt_u/;
use Getopt::Std;
use Net::SNPP;
***************
*** 32,36 ****
getopts ("s:g:h:t:l:q:u");
! $opt_q ||= 'localhost';
#
--- 32,36 ----
getopts ("s:g:h:t:l:q:u");
! my $opt_q ||= 'localhost';
#
***************
*** 53,57 ****
my $snpp = Net::SNPP->new ($opt_q) or die;
! $ALERT = $opt_u ? "UPALERT" : "ALERT";
$snpp->send ( Pager => [ @ARGV ], Message => "$ALERT $opt_g/$opt_s: $summary ($wday $mon $day $tm)" );
--- 53,57 ----
my $snpp = Net::SNPP->new ($opt_q) or die;
! my $ALERT = $opt_u ? "UPALERT" : "ALERT";
$snpp->send ( Pager => [ @ARGV ], Message => "$ALERT $opt_g/$opt_s: $summary ($wday $mon $day $tm)" );
|
|
From: Jim T. <tr...@us...> - 2007-05-03 19:56:21
|
Update of /cvsroot/mon/mon
In directory sc8-pr-cvs16:/tmp/cvs-serv31786
Modified Files:
Tag: mon-1-2-branch
CHANGES
Log Message:
snpp use strict fix, mon.cgi ack display fix, mon.monitor option fix, nntp -f fix, all from augie
Index: CHANGES
===================================================================
RCS file: /cvsroot/mon/mon/CHANGES,v
retrieving revision 1.3.2.1
retrieving revision 1.3.2.2
diff -C2 -d -r1.3.2.1 -r1.3.2.2
*** CHANGES 3 May 2007 19:41:23 -0000 1.3.2.1
--- CHANGES 3 May 2007 19:55:36 -0000 1.3.2.2
***************
*** 5,15 ****
-----------------------------------------------
! -Added RPM spec update to do a "chkconfig on" in the post install,
! and fixed a path bug in S99mon
! by Augie Schwer
! -Fix config parsing of unack_summary, added docs for the option in the
! man page
! by Augie Schwer
--- 5,21 ----
-----------------------------------------------
! -Bunch of fixes from Augie Schwer:
! Added RPM spec update to do a "chkconfig on" in the post install, and fixed a path bug in S99mon
!
! Fix config parsing of unack_summary, added docs for the option in the man page
!
! Fix display of ack'd services in mon.cgi
!
! Fix -p/-P option problem in mon.monitor
!
! Fix nntp.monitor "-f" option
!
! Allow snpp.alert to "use strict"
|
|
From: Jim T. <tr...@us...> - 2007-05-03 19:42:08
|
Update of /cvsroot/mon/mon
In directory sc8-pr-cvs16:/tmp/cvs-serv1843
Modified Files:
Tag: mon-1-2-branch
CHANGES mon
Log Message:
added unack_summary fix from augie, also added documentation for this in the man page
Index: CHANGES
===================================================================
RCS file: /cvsroot/mon/mon/CHANGES,v
retrieving revision 1.3
retrieving revision 1.3.2.1
diff -C2 -d -r1.3 -r1.3.2.1
*** CHANGES 15 Nov 2004 14:45:16 -0000 1.3
--- CHANGES 3 May 2007 19:41:23 -0000 1.3.2.1
***************
*** 1,4 ****
--- 1,17 ----
$Id$
+ Changes between mon-1.2.0- and mon-1.2.0-release
+ Thu May 3 15:38:58 EDT 2007
+ -----------------------------------------------
+
+ -Added RPM spec update to do a "chkconfig on" in the post install,
+ and fixed a path bug in S99mon
+ by Augie Schwer
+
+ -Fix config parsing of unack_summary, added docs for the option in the
+ man page
+ by Augie Schwer
+
+
Changes between mon-1.0.0pre3 and mon-1.0.0pre4
Tue Aug 3 08:02:35 EDT 2004
Index: mon
===================================================================
RCS file: /cvsroot/mon/mon/mon,v
retrieving revision 1.22
retrieving revision 1.22.2.1
diff -C2 -d -r1.22 -r1.22.2.1
*** mon 13 Jul 2006 12:03:39 -0000 1.22
--- mon 3 May 2007 19:41:24 -0000 1.22.2.1
***************
*** 1133,1141 ****
if (defined $2) {
if ($2 =~ /y(es)?/i) {
! $2 = 1;
} elsif ($2 =~ /n(o)?/i) {
! $2 = 0;
! }
! if ($2 eq "0" || $2 eq "1") {
$UNACK_SUMMARY = $2;
} else {
--- 1133,1140 ----
if (defined $2) {
if ($2 =~ /y(es)?/i) {
! $UNACK_SUMMARY = 1;
} elsif ($2 =~ /n(o)?/i) {
! $UNACK_SUMMARY = 0;
! } elsif ($2 eq "0" || $2 eq "1") {
$UNACK_SUMMARY = $2;
} else {
|
|
From: Jim T. <tr...@us...> - 2007-05-03 19:42:07
|
Update of /cvsroot/mon/mon/doc
In directory sc8-pr-cvs16:/tmp/cvs-serv1843/doc
Modified Files:
Tag: mon-1-2-branch
mon.8
Log Message:
added unack_summary fix from augie, also added documentation for this in the man page
Index: mon.8
===================================================================
RCS file: /cvsroot/mon/mon/doc/mon.8,v
retrieving revision 1.6
retrieving revision 1.6.2.1
diff -C2 -d -r1.6 -r1.6.2.1
*** mon.8 31 Jul 2005 17:02:38 -0000 1.6
--- mon.8 3 May 2007 19:41:25 -0000 1.6.2.1
***************
*** 1232,1235 ****
--- 1232,1242 ----
automatically to alert programs.
+ .TP
+ .BI unack_summary
+ Remove the "acknowledged" state from a service if the summary component of the
+ failure message changes. In most common usage the summary is the list
+ of hosts that are failing, so additional hosts failing would remove an
+ ack.
+
.SS "Period Definitions"
|
|
From: Jim T. <tr...@us...> - 2007-05-03 18:50:52
|
Update of /cvsroot/mon/mon/etc
In directory sc8-pr-cvs16:/tmp/cvs-serv31770/etc
Modified Files:
Tag: mon-1-2-branch
S99mon
Log Message:
RPM fix to do chkconfig --add and path fix in S99mon from Augie Schwer
Index: S99mon
===================================================================
RCS file: /cvsroot/mon/mon/etc/S99mon,v
retrieving revision 1.1.1.1
retrieving revision 1.1.1.1.4.1
diff -C2 -d -r1.1.1.1 -r1.1.1.1.4.1
*** S99mon 9 Jun 2004 05:18:06 -0000 1.1.1.1
--- S99mon 3 May 2007 18:50:47 -0000 1.1.1.1.4.1
***************
*** 22,26 ****
start)
echo -n "Starting mon daemon: "
! daemon /usr/lib/mon/mon -f -l -c /etc/mon/mon.cf
echo
touch /var/lock/subsys/mon
--- 22,26 ----
start)
echo -n "Starting mon daemon: "
! daemon /usr/sbin/mon -f -l -c /etc/mon/mon.cf
echo
touch /var/lock/subsys/mon
|
|
From: Jim T. <tr...@us...> - 2007-05-03 18:50:51
|
Update of /cvsroot/mon/mon
In directory sc8-pr-cvs16:/tmp/cvs-serv31770
Modified Files:
Tag: mon-1-2-branch
mon.spec
Log Message:
RPM fix to do chkconfig --add and path fix in S99mon from Augie Schwer
Index: mon.spec
===================================================================
RCS file: /cvsroot/mon/mon/mon.spec,v
retrieving revision 1.3
retrieving revision 1.3.2.1
diff -C2 -d -r1.3 -r1.3.2.1
*** mon.spec 17 Apr 2005 07:42:25 -0000 1.3
--- mon.spec 3 May 2007 18:50:44 -0000 1.3.2.1
***************
*** 134,137 ****
--- 134,142 ----
touch %{_localstatedir}/log/mon_history.log
fi
+
+ if [ $1 = 1 ]; then
+ /sbin/chkconfig --add mon
+ fi
+
###################################################################
|
|
From: Jim T. <tr...@us...> - 2007-05-03 11:25:13
|
Update of /cvsroot/mon/mon/mon.d In directory sc8-pr-cvs16:/tmp/cvs-serv3652/mon.d Added Files: snmpdiskspace.monitor Log Message: added snmpdiskspace.monitor with eravin's patches --- NEW FILE: snmpdiskspace.monitor --- #!/usr/local/bin/perl # # NAME # snmpdiskspace.monitor # # # SYNOPSIS # snmpdiskspace.monitor [--list] [--timeout seconds] [--config filename] # [--community string] [--free minfree] # [--retries retries] [--usemib <mibtype>] host... # # # DESCRIPTION # This script uses the Host Resources MIB (RFC1514), and optionally # the MS Windows NT Performance MIB, or UCD-SNMP extensions # (enterprises.ucdavis.dskTable.dskEntry) to monitor diskspace on hosts # via SNMP. # # snmpdiskspace.monitor uses a config file to allow the specification of # minimum free space on a per-host and per-partition basis. The config # file allows the use of regular expressions, so it is quite flexible in # what it can allow. See the sample config file for more details and # syntax. # # The script only checks disks marked as "FixedDisks" by the Host MIB, # which should help cut down on the number of CD-ROM drives # erroneously reported as being full! Since the drive classification # portion of the UCD Host MIB isn't too great on many OS'es, though, # this won't buy you a lot. Empire's SNMP agent gets this right on # all the hosts that I checked, though. Not sure about the MS MIB. # UCD-SNMP only checks specific partition types (md, hd, sd, ida) # # snmpdiskspace.monitor is intended for use as a monitor for the mon # network monitoring package. # # # OPTIONS # --community The SNMP community string to use. Default is "public". # --config The config file to use. Default is either # /etc/mon/snmpdiskspace.cf or # /usr/lib/mon/mon.d/snmpdiskspace.cf, in that order. # --retries The number of retries to use, if we get an SNMP timeout. # Default is retry 5 times. # --timeout Seconds to wait before declaring a timeout on an SNMP get. # Default is 20 seconds. # --free The default minimum free space, in a percentage or absolute # quantity, as per the config file. Thus, arguments of, for # example, "20%", "1gb", "50mb" are all valid. # Default is 5% free on every partition checked. # # --ifree The default minimum free inode percentage, specified as # a percentage. Default is 5% free. # # --list Give a verbose listing of all partitions checked on all # specified hosts. # # --listall like --list, but also lists the thresholds defined for # each filesystem, so you can doublecheck the config file # # --usemib Choose which MIB to use: one or more of host, perf, ucd # Default tries all three, in that order # # --debug enable debug output for config file parsing and MIB fetching # # # EXIT STATUS # Exit status is as follows: # 0 No problems detected. # 1 Free space on any host was below the supplied parameter. # 2 A "soft" error occurred, either a SNMP library error, # or could not get a response from the server. # # In the case where both a soft error and a freespace violation are # detected, exit status is 1. # # BUGS # When using the net-snmp agent, you must build it with "--with-dummy-values" # or the monitor may not parse the Host Resources MIB properly. # # List of local filesystem types used when parsing the UCD MIB should be # configurable. # # # NOTES # $Id: snmpdiskspace.monitor,v 1.2 2007/05/03 11:25:07 trockij Exp $ # # * Added support for inode status via UCD-SNMP MIB. Fourth column in config # file (optional) is for inode%. # * added --debug and --usemib options. Latter needed so you can force use # of UCD mib if you want inode status. # * rearranged the error messages to be more Mon-like (hostname first) # * added code to synchronize instance numbers when using UCD MIB. This # could solve the "sparse MIB" problem usually fixed by the # --with-dummy-values option in net-snmp if needed for other agents # Ed Ravin (er...@pa...), January 2005 # # Added support for regex hostnames and partition names in the config file, # 'use strict' by andrew ryan <an...@na...>. # # Generalised to handle multible mibs by jens persson <jen...@bt...> # Changes Copyright (C) 2000, jens persson # # Modified for use with UCD-SNMP by Johannes Walch for # NWE GmbH (j....@nw...) # # Support for UCD's disk MIB added by Matt Simonsen <ma...@ca...> # # # SEE ALSO # mon: http://www.kernel.org/software/mon/ # # This requires the UCD SNMP library and G.S. Marzot's Perl SNMP # module. (http://ucd-snmp.ucdavis.edu and CPAN, respectively). # # The Empire SystemEdge SNMP agent: http://www.empire.com # # # COPYRIGHT # # 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 # use strict; use SNMP; use Getopt::Long; sub readcf; sub toBytes; sub get_values; # setup what mibs to use # $ENV{"MIBS"} = 'RFC1213-MIB:HOST-RESOURCES-MIB:WINDOWS-NT-PERFORMANCE:UCD-SNMP-MIB'; $ENV{"MIBS"} = 'RFC1213-MIB:HOST-RESOURCES-MIB:UCD-SNMP-MIB'; my %opt; # parse the commandline GetOptions (\%opt, "community=s", "timeout=i", "retries=i", "config=s", "list", "listall", "free=i", "ifree=n", "usemib=s", "debug"); die "No host arguments given!\n" if (@ARGV == 0); my $RET = 0; #exit value of script my @ERRS = (); # array holding detail output my @HOSTS = (); # array holding summary output my @cfgfile = (); #array holding contents of config file # Read in defaults my $COMM = $opt{"community"} || $ENV{"COMMUNITY"} || "public"; my $TIMEOUT = $opt{"timeout"} * 100000 || 2000000; #default timeout is 20 seconds my $RETRIES = $opt{"retries"} || 5; my $CONFIG = $opt{"config"} || (-d "/etc/mon" ? "/etc/mon" : "/usr/lib/mon/mon.d") . "/snmpdiskspace.cf"; my $DISKFREE = $opt{"free"} || -5; #default max % full is 95% my $INODEFREE = $opt{"ifree"} || 5; #default max % inode full is 95% my $USEMIB= $opt{"usemib"} || "host perf ucd"; my $LIST= $opt{"list"} || $opt{"listall"} || 0; my $LISTALL= $opt{"listall"} || 0; my $DEBUG= $opt{"debug"} || 0; my ($host, $checkval, $icheckval, %FREE, $disk, @disklist, $cfgline); # read the config file if ( !readcf ($CONFIG) ) { # not being able to read config file shouldn't be a fatal, since we # have defaults we can use. print STDERR "readcf: Could not read config file $CONFIG: $!\n"; } # now do the checks for each host foreach $host (@ARGV) { # fetch the info from the computers @disklist = get_values($host); next unless (@disklist) && (ref($disklist[0]) eq "ARRAY"); #make sure we got an OK return value from get_values before going any further # Now check each partition foreach $disk (@disklist) { undef $checkval ; undef $icheckval ; # Go through the config file line by line until we # find a match for this host/partition. Stop as soon # as we find a match. foreach $cfgline (@cfgfile) { if ( ($host =~ m/^$cfgline->[0]$/) && ($disk->[2] =~ m/^$cfgline->[1]$/) ) { print STDERR "'$host' matched /^$cfgline->[0]\$/ or '$disk->[2]' matched /^$cfgline->[1]\$/, using checkval $cfgline->[2]\n" if $DEBUG; $checkval = $cfgline->[2] ; $icheckval= $cfgline->[3] ; last; } } # Set to default otherwise $checkval = $DISKFREE unless defined($checkval); $icheckval= $INODEFREE unless defined($icheckval); $icheckval=~ s/%$//; # do the checking, first absolute and then percentage next if $checkval == 0 && $icheckval == 0; # nothing to check: ignore my $hostfailed= 0; if (($checkval > 0) && ($disk->[0] <$checkval)) { $hostfailed++; push (@ERRS,sprintf("%s: filesystem %s is (%1.1f%% full), %1.0fMB free (below threshold %1.0fMB free)", $host , $disk->[2] , $disk->[1] , $disk->[0] / 1048576, $checkval / 1048576 )); } elsif (($checkval < 0) && ($disk->[1] - $checkval >=100)) { $hostfailed++; push (@ERRS,sprintf("%s: filesystem %s is (%1.1f%% full), %1.0fMB free (below threshold %s%% free)", $host , $disk->[2] , $disk->[1] , $disk->[0] / 1048576, abs($checkval) )); } if (($icheckval > 0) && ($disk->[3] ne "N/A") && (100 - $disk->[3]) < $icheckval ) { $hostfailed++; push (@ERRS, sprintf ("%s: filesystem %s has %1.1f%% inodes free (below threshold %s%% inodes free)", $host, $disk->[2], 100 - $disk->[3], $icheckval )); } if ($hostfailed) { push (@HOSTS, $host); $RET = 1; } # if the user want a listing, then the user will get a listing :-) write if ($LIST or $LISTALL); if ($LISTALL) { printf(" Will alarm if MB free declines below threshold %1.0fMB free\n", $checkval / 1048576) if $checkval > 0; printf(" Will alarm if %%free space declines below threshold %1.1f%% free\n", abs($checkval)) if $checkval < 0; printf(" No free space alarm defined in config file.\n") if $checkval == 0; printf(" Will alarm if %%free inodes declines below %1.1f%%\n", $icheckval) if $icheckval > 0; printf(" No %%inodes free alarm defined in config file.\n") if $icheckval == 0; printf(" WARNING: Unable to alarm on inodes free, dskPercentNode not found in MIB\n") if $disk->[3] eq "N/A" and $icheckval > 0; } } } if ($LIST or $LISTALL) { print "\n\n"; } # Uniq the array of failures, so multiple failures on a single host # are reported in the details section (lines #2-infinity) but not # in the summary (line #1). # Then print out the failures, if any. my %saw; undef %saw; @saw{@HOSTS} = (); @HOSTS = keys %saw; if ($RET) { print "@HOSTS\n"; print "\n"; print join("\n", @ERRS), "\n"; } exit $RET; # # read configuration file # sub readcf { my ($f) = @_; my ($l, $host, $filesys, $free, $ifree); open (CF, $f) || return undef; while (<CF>) { next if (/^\s*#/ || /^\s*$/); chomp; ($host, $filesys, $free, $ifree) = split; # if (!defined ($FREE{$host}{$filesys} = toBytes ($free))) { if (!push (@cfgfile, [$host , $filesys , toBytes ($free), $ifree || 0]) ) { die "error free specification, config $f, line $.\n"; } print STDERR "cf: assigned host=$host, filesys=$filesys, free=$free, ifree=$ifree\n" if $DEBUG; } close (CF); } sub toBytes { # take a string and parse it as folows # N return N # N kb return N*1024 # N mb return N*1024^2 # N gb return N*1024^3 # N % return -N my ($free) = @_; my ($n, $u); if ($free =~ /^(\d+\.\d+)(kb|mb|gb|%|)$/i) { ($n, $u) = ($1, "\L$2"); } elsif ($free =~ /^(\d+)(kb|mb|gb|%|)$/i) { ($n, $u) = ($1, "\L$2"); } else { return undef; } return (int ($n * -1)) if ($u eq "%"); return (int ($n * 1024 )) if ($u eq "kb"); return (int ($n * 1024 * 1024)) if ($u eq "mb"); return (int ($n * 1024 * 1024 * 1024)) if ($u eq "gb"); int ($n); } # # Do the work of trying to get the data from the host via SNMP # sub get_values { my ($host) = @_; my (@disklist,$Type,$Descr,$AllocationUnits,$Size,$Used,$Freespace,$Percent,$InodePercent); my ($v,$s); if (!defined($s = new SNMP::Session (DestHost => $host, Timeout => $TIMEOUT, Community => $COMM, Retries => $RETRIES))) { $RET = ($RET == 1) ? 1 : 2 ; push (@HOSTS, $host); push (@ERRS, "$host: could not create session: " . $s->{ErrorStr}); return undef; } # First we try to use the Host mib (RFC1514) # supported by net-snmpd on most platforms, see http://www.net-snmp.org # # You can also use the Empire (http://www.empire.com) # SNMP agent to provide hostmib support on UNIX and NT. if ($USEMIB =~ /host/i) { $v = new SNMP::VarList ( ['hrStorageIndex'], ['hrStorageType'], ['hrStorageDescr'], ['hrStorageAllocationUnits'], ['hrStorageSize'], ['hrStorageUsed'], ); while (defined $s->getnext($v)) { last if ($v->[0]->tag !~ /hrStorageIndex/); $Type = $v->[1]->val; $Descr = $v->[2]->val; $AllocationUnits = $v->[3]->val; $Size = $v->[4]->val; $Used = $v->[5]->val; $Freespace = (($Size - $Used) * $AllocationUnits); print STDERR "Found HOST MIB filesystem: Type=$Type, Descr=$Descr, AllocationUnits=$AllocationUnits, Size=$Size, Used=$Used\n" if $DEBUG; # This next check makes sure we're only looking at storage # devices of the "FixedDevice" type (4). For comparison, Physical # RAM is 2, Virtual Memory is 3, Floppy Disk is 6, and CD-ROM is 7 # Using the Empire agent, this will eliminate drive types other # than hard disks. The UCD agent is not as good as determining # drive types under the HOST mib. next if ($Type !~ /\.1\.3\.6\.1\.2\.1\.25\.2\.1\.4/); if ($Size != 0) { $Percent= ($Used / $Size) * 100.0; } else { $Percent=0; }; push (@disklist,[$Freespace,$Percent,$Descr, "N/A"]); print STDERR "Using HOST MIB filesystem: $Descr ($Type)\n" if $DEBUG; }; if (@disklist) { return @disklist; }; }; # Then we test the perfmib from M$ NT resource kit # I'm using the agent/mib-defs from # http://www.wtcs.org/snmp4tpc/ # for somereason every second request fails, # so we fetch the variables twice and discards # the bad ones if ($USEMIB =~ /perf/i) { $v = new SNMP::VarList ( ['ldisklogicalDiskIndex'], ['ldiskPercentFreeSpace'], ['ldiskPercentFreeSpace'], ['ldiskFreeMegabytes'], ['ldiskFreeMegabytes'], ); while (defined $s->getnext($v)) { # Make sure we are still in relevant portion of MIB last if ($v->[1]->val !~ /^\.1\.3\.6\.1\.2\.1\.25\.2\.1\.4/); last if ($v->[0]->val =~ /Total/); $Descr = ( $v->[0]->val =~ /.*:.*:(\w+:)$/gi)[-1] ; $Percent = $v->[2]->val; $Freespace = $v->[4]->val * 1024 * 1024; push (@disklist,[$Freespace,$Percent,$Descr, "N/A"]); print STDERR "Using PERF MIB filesystem: $Descr, $Freespace,$Percent\n" if $DEBUG; }; if (@disklist) { return @disklist; } } #Try UCD-SNMP .enterprises.ucdavis.dskTable.dskEntry MIB extrnsion # Comes with UCD-SNMP / net-snmp if ($USEMIB =~ /ucd/i) { $v = new SNMP::VarList ( ['dskIndex'], ['dskPath'], ['dskPercent'], ['dskAvail'], ['dskDevice'], ['dskPercentNode'], ); while (defined $s->getnext($v)) { last if ($v->[0]->tag !~ /dskIndex/); # end of MIB? my $instancenum= $v->[0]->iid; # what instance number? # check for partial fetches (like swap partition) that won't # return all the MIB entries if ($v->[2]->iid != $instancenum or $v->[3]->iid != $instancenum or $v->[5]->iid != $instancenum) { # ignore this instance and try to move on to next # we wouldn't need this if use-dummy-values really worked $v = new SNMP::VarList ( ['dskIndex', $instancenum], ['dskPath', $instancenum], ['dskPercent', $instancenum], ['dskAvail', $instancenum], ['dskDevice', $instancenum], ['dskPercentNode', $instancenum], ); next; } $Descr = $v->[1]->val; $Percent = $v->[2]->val; $Freespace = $v->[3]->val; $Freespace *= 1024; #Convert from kbytes to bytes to make consistent $Type = $v->[4]->val; $InodePercent = $v->[5]->val; print STDERR "Found UCD MIB filesystem: Type=$Type, Descr=$Descr, Percent=$Percent, Freespace=$Freespace, InodePercent=$InodePercent\n" if $DEBUG; # Try to catch only local filesystems. This covers the # the basics, but probably should be configurable next unless ( $Type =~ m/\b(md|hd|wd|sd|ida|raid)/ ) ; print STDERR "Using UCD MIB filesystem: $Descr ($Type)\n" if $DEBUG; push (@disklist,[$Freespace,$Percent,$Descr, $InodePercent]); }; if (@disklist) { return @disklist; } } #Check for errors if ($s->{ErrorNum}) { push (@HOSTS, $host); push (@ERRS, "$host: could not get SNMP info: " . $s->{ErrorStr}); $RET = ($RET == 1) ? 1 : 2 ; return undef; } # Check for OID not found push (@HOSTS, $host); push (@ERRS, "$host: Disk space OIDs not found in MIB(s): $USEMIB"); $RET = ($RET == 1) ? 1 : 2 ; return undef; } # format specifications, should be able to cut, paste and edit into a config file format STDOUT_TOP = System Description % Used Free space Inode% ------------------------------------------------------------------------------- . format STDOUT = @<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<<<<<<<<<<<<< @###.# % @#######.# mb @>>>>>> $host, $disk->[2], $disk->[1], $disk->[0]/1024/1024, ( $disk->[3] ne "N/A" ? ($disk->[3] + 0) . "%" : "N/A") . |
|
From: Jim T. <tr...@us...> - 2007-05-03 11:25:09
|
Update of /cvsroot/mon/mon/doc In directory sc8-pr-cvs16:/tmp/cvs-serv3652/doc Added Files: README.snmpdiskspace.monitor Log Message: added snmpdiskspace.monitor with eravin's patches --- NEW FILE: README.snmpdiskspace.monitor --- # NAME # snmpdiskspace.monitor # # # SYNOPSIS # snmpdiskspace.monitor [--list] [--timeout seconds] [--config filename] # [--community string] [--free minfree] # [--retries retries] [--usemib <mibtype>] host... # # # DESCRIPTION # This script uses the Host Resources MIB (RFC1514), and optionally # the MS Windows NT Performance MIB, or UCD-SNMP extensions # (enterprises.ucdavis.dskTable.dskEntry) to monitor diskspace on hosts # via SNMP. # # snmpdiskspace.monitor uses a config file to allow the specification of # minimum free space on a per-host and per-partition basis. The config # file allows the use of regular expressions, so it is quite flexible in # what it can allow. See the sample config file for more details and # syntax. # # The script only checks disks marked as "FixedDisks" by the Host MIB, # which should help cut down on the number of CD-ROM drives # erroneously reported as being full! Since the drive classification # portion of the UCD Host MIB isn't too great on many OS'es, though, # this won't buy you a lot. Empire's SNMP agent gets this right on # all the hosts that I checked, though. Not sure about the MS MIB. # UCD-SNMP only checks specific partition types (md, hd, sd, ida) # # snmpdiskspace.monitor is intended for use as a monitor for the mon # network monitoring package. # # # OPTIONS # --community The SNMP community string to use. Default is "public". # --config The config file to use. Default is either # /etc/mon/snmpdiskspace.cf or # /usr/lib/mon/mon.d/snmpdiskspace.cf, in that order. # --retries The number of retries to use, if we get an SNMP timeout. # Default is retry 5 times. # --timeout Seconds to wait before declaring a timeout on an SNMP get. # Default is 20 seconds. # --free The default minimum free space, in a percentage or absolute # quantity, as per the config file. Thus, arguments of, for # example, "20%", "1gb", "50mb" are all valid. # Default is 5% free on every partition checked. # # --ifree The default minimum free inode percentage, specified as # a percentage. Default is 5% free. # # --list Give a verbose listing of all partitions checked on all # specified hosts. # # --listall like --list, but also lists the thresholds defined for # each filesystem, so you can doublecheck the config file # # --usemib Choose which MIB to use: one or more of host, perf, ucd # Default tries all three, in that order # # --debug enable debug output for config file parsing and MIB fetching # # # EXIT STATUS # Exit status is as follows: # 0 No problems detected. # 1 Free space on any host was below the supplied parameter. # 2 A "soft" error occurred, either a SNMP library error, # or could not get a response from the server. # # In the case where both a soft error and a freespace violation are # detected, exit status is 1. # # BUGS # When using the net-snmp agent, you must build it with "--with-dummy-values" # or the monitor may not parse the Host Resources MIB properly. # # List of local filesystem types used when parsing the UCD MIB should be # configurable. # # # NOTES # $Id: README.snmpdiskspace.monitor,v 1.2 2007/05/03 11:25:04 trockij Exp $ # # * Added support for inode status via UCD-SNMP MIB. Fourth column in config # file (optional) is for inode%. # * added --debug and --usemib options. Latter needed so you can force use # of UCD mib if you want inode status. # * rearranged the error messages to be more Mon-like (hostname first) # * added code to synchronize instance numbers when using UCD MIB. This # could solve the "sparse MIB" problem usually fixed by the # --with-dummy-values option in net-snmp if needed for other agents # Ed Ravin (er...@pa...), January 2005 # # Added support for regex hostnames and partition names in the config file, # 'use strict' by andrew ryan <an...@na...>. # # Generalised to handle multible mibs by jens persson <jen...@bt...> # Changes Copyright (C) 2000, jens persson # # Modified for use with UCD-SNMP by Johannes Walch for # NWE GmbH (j....@nw...) # # Support for UCD's disk MIB added by Matt Simonsen <ma...@ca...> # # # SEE ALSO # mon: http://www.kernel.org/software/mon/ # # This requires the UCD SNMP library and G.S. Marzot's Perl SNMP # module. (http://ucd-snmp.ucdavis.edu and CPAN, respectively). # # The Empire SystemEdge SNMP agent: http://www.empire.com |
|
From: Jim T. <tr...@us...> - 2007-05-03 11:25:09
|
Update of /cvsroot/mon/mon/etc In directory sc8-pr-cvs16:/tmp/cvs-serv3652/etc Added Files: snmpdiskspace.cf Log Message: added snmpdiskspace.monitor with eravin's patches --- NEW FILE: snmpdiskspace.cf --- # # snmpdiskspace.cf- configuration file for snmpdiskspace.monitor # $Id: snmpdiskspace.cf,v 1.2 2007/05/03 11:25:05 trockij Exp $ # # format: # # host filesys free ifree # # The monitor script uses a "first match" algorithm. So put your more # specific directives at top, and leave the more general directives # for the bottom. # # # host Regex describing the name of the host(s). Remember to escape # dots if you're fully qualifying hostnames, e.g., # some\.domain\.com, otherwise you might not be matching what # you think you're matching. # # filesys Regex describing the filesystem to check, as represented # in the relevant mib (after mangling by the monitor). # Remember to use regex syntax, and not file glob syntax. # # free The amount of free space which will trigger a failure, # expressed as "10", "10kb", "10MB", or "10GB" for # bytes, kilobytes, megabytes or gigabytes. The format # "10%" signifies percent of the total disk space. # "0" turns of checking for the filesystem/disk. # # ifree Percentage of free inodes, below which will trigger a failure. # Expressed as "5%". The host must support the UCD dskTable MIB. # # # BE SURE TO TEST your configuration with the "--listall" option! # This way, you will see exactly what filesystems are found by the script, # and what their alarm thresholds will be. # # Examples: # * * 5% # Give a warning when the free space goes below 5 % # (This is the default behavior of the monitor) # This should always be the last line in your config file # because it will match everything. # # * * 5% 10% # As above, but also warn if free inodes drops below 10%. # # ior * 15% # On the host ior the limit is 15% # # poo / 1gb # poo's root should have a full gig free # # www[1-4] * 500mb # any partition on the machines www1, www2, www3, and ww4 # should have at least 500mb free. # # * /cdrom/.* 0 # anything that is mounted on /cdrom will be full anyway # At least for Solaris, you need a regex like this bec. # vold mounts each new CD on a new partition, and you # won't know its name until you put it into the drive. # # # Always ignore anything on cdrom partitions * /cdrom.* 0 * /mnt 0 # # # This line always should be last because it matches everything. * * 5% |
|
From: Jim T. <tr...@us...> - 2007-05-02 23:25:12
|
Update of /cvsroot/mon/mon/mon.d
In directory sc8-pr-cvs16:/tmp/cvs-serv5137/mon.d
Added Files:
Tag: mon-1-2-branch
snmpdiskspace.monitor
Log Message:
added snmpdiskspace.monitor with eravin's patches
--- NEW FILE: snmpdiskspace.monitor ---
#!/usr/local/bin/perl
#
# NAME
# snmpdiskspace.monitor
#
#
# SYNOPSIS
# snmpdiskspace.monitor [--list] [--timeout seconds] [--config filename]
# [--community string] [--free minfree]
# [--retries retries] [--usemib <mibtype>] host...
#
#
# DESCRIPTION
# This script uses the Host Resources MIB (RFC1514), and optionally
# the MS Windows NT Performance MIB, or UCD-SNMP extensions
# (enterprises.ucdavis.dskTable.dskEntry) to monitor diskspace on hosts
# via SNMP.
#
# snmpdiskspace.monitor uses a config file to allow the specification of
# minimum free space on a per-host and per-partition basis. The config
# file allows the use of regular expressions, so it is quite flexible in
# what it can allow. See the sample config file for more details and
# syntax.
#
# The script only checks disks marked as "FixedDisks" by the Host MIB,
# which should help cut down on the number of CD-ROM drives
# erroneously reported as being full! Since the drive classification
# portion of the UCD Host MIB isn't too great on many OS'es, though,
# this won't buy you a lot. Empire's SNMP agent gets this right on
# all the hosts that I checked, though. Not sure about the MS MIB.
# UCD-SNMP only checks specific partition types (md, hd, sd, ida)
#
# snmpdiskspace.monitor is intended for use as a monitor for the mon
# network monitoring package.
#
#
# OPTIONS
# --community The SNMP community string to use. Default is "public".
# --config The config file to use. Default is either
# /etc/mon/snmpdiskspace.cf or
# /usr/lib/mon/mon.d/snmpdiskspace.cf, in that order.
# --retries The number of retries to use, if we get an SNMP timeout.
# Default is retry 5 times.
# --timeout Seconds to wait before declaring a timeout on an SNMP get.
# Default is 20 seconds.
# --free The default minimum free space, in a percentage or absolute
# quantity, as per the config file. Thus, arguments of, for
# example, "20%", "1gb", "50mb" are all valid.
# Default is 5% free on every partition checked.
#
# --ifree The default minimum free inode percentage, specified as
# a percentage. Default is 5% free.
#
# --list Give a verbose listing of all partitions checked on all
# specified hosts.
#
# --listall like --list, but also lists the thresholds defined for
# each filesystem, so you can doublecheck the config file
#
# --usemib Choose which MIB to use: one or more of host, perf, ucd
# Default tries all three, in that order
#
# --debug enable debug output for config file parsing and MIB fetching
#
#
# EXIT STATUS
# Exit status is as follows:
# 0 No problems detected.
# 1 Free space on any host was below the supplied parameter.
# 2 A "soft" error occurred, either a SNMP library error,
# or could not get a response from the server.
#
# In the case where both a soft error and a freespace violation are
# detected, exit status is 1.
#
# BUGS
# When using the net-snmp agent, you must build it with "--with-dummy-values"
# or the monitor may not parse the Host Resources MIB properly.
#
# List of local filesystem types used when parsing the UCD MIB should be
# configurable.
#
#
# NOTES
# $Id: snmpdiskspace.monitor,v 1.1.2.1 2007/05/02 23:25:07 trockij Exp $
#
# * Added support for inode status via UCD-SNMP MIB. Fourth column in config
# file (optional) is for inode%.
# * added --debug and --usemib options. Latter needed so you can force use
# of UCD mib if you want inode status.
# * rearranged the error messages to be more Mon-like (hostname first)
# * added code to synchronize instance numbers when using UCD MIB. This
# could solve the "sparse MIB" problem usually fixed by the
# --with-dummy-values option in net-snmp if needed for other agents
# Ed Ravin (er...@pa...), January 2005
#
# Added support for regex hostnames and partition names in the config file,
# 'use strict' by andrew ryan <an...@na...>.
#
# Generalised to handle multible mibs by jens persson <jen...@bt...>
# Changes Copyright (C) 2000, jens persson
#
# Modified for use with UCD-SNMP by Johannes Walch for
# NWE GmbH (j....@nw...)
#
# Support for UCD's disk MIB added by Matt Simonsen <ma...@ca...>
#
#
# SEE ALSO
# mon: http://www.kernel.org/software/mon/
#
# This requires the UCD SNMP library and G.S. Marzot's Perl SNMP
# module. (http://ucd-snmp.ucdavis.edu and CPAN, respectively).
#
# The Empire SystemEdge SNMP agent: http://www.empire.com
#
#
# COPYRIGHT
#
# 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
#
use strict;
use SNMP;
use Getopt::Long;
sub readcf;
sub toBytes;
sub get_values;
# setup what mibs to use
# $ENV{"MIBS"} = 'RFC1213-MIB:HOST-RESOURCES-MIB:WINDOWS-NT-PERFORMANCE:UCD-SNMP-MIB';
$ENV{"MIBS"} = 'RFC1213-MIB:HOST-RESOURCES-MIB:UCD-SNMP-MIB';
my %opt;
# parse the commandline
GetOptions (\%opt, "community=s", "timeout=i", "retries=i", "config=s", "list", "listall", "free=i", "ifree=n", "usemib=s", "debug");
die "No host arguments given!\n" if (@ARGV == 0);
my $RET = 0; #exit value of script
my @ERRS = (); # array holding detail output
my @HOSTS = (); # array holding summary output
my @cfgfile = (); #array holding contents of config file
# Read in defaults
my $COMM = $opt{"community"} || $ENV{"COMMUNITY"} || "public";
my $TIMEOUT = $opt{"timeout"} * 100000 || 2000000; #default timeout is 20 seconds
my $RETRIES = $opt{"retries"} || 5;
my $CONFIG = $opt{"config"} || (-d "/etc/mon" ? "/etc/mon" : "/usr/lib/mon/mon.d")
. "/snmpdiskspace.cf";
my $DISKFREE = $opt{"free"} || -5; #default max % full is 95%
my $INODEFREE = $opt{"ifree"} || 5; #default max % inode full is 95%
my $USEMIB= $opt{"usemib"} || "host perf ucd";
my $LIST= $opt{"list"} || $opt{"listall"} || 0;
my $LISTALL= $opt{"listall"} || 0;
my $DEBUG= $opt{"debug"} || 0;
my ($host, $checkval, $icheckval, %FREE, $disk, @disklist, $cfgline);
# read the config file
if ( !readcf ($CONFIG) ) {
# not being able to read config file shouldn't be a fatal, since we
# have defaults we can use.
print STDERR "readcf: Could not read config file $CONFIG: $!\n";
}
# now do the checks for each host
foreach $host (@ARGV) {
# fetch the info from the computers
@disklist = get_values($host);
next unless (@disklist) && (ref($disklist[0]) eq "ARRAY"); #make sure we got an OK return value from get_values before going any further
# Now check each partition
foreach $disk (@disklist) {
undef $checkval ;
undef $icheckval ;
# Go through the config file line by line until we
# find a match for this host/partition. Stop as soon
# as we find a match.
foreach $cfgline (@cfgfile) {
if ( ($host =~ m/^$cfgline->[0]$/) &&
($disk->[2] =~ m/^$cfgline->[1]$/)
) {
print STDERR "'$host' matched /^$cfgline->[0]\$/ or '$disk->[2]' matched /^$cfgline->[1]\$/, using checkval $cfgline->[2]\n" if $DEBUG;
$checkval = $cfgline->[2] ;
$icheckval= $cfgline->[3] ;
last;
}
}
# Set to default otherwise
$checkval = $DISKFREE unless defined($checkval);
$icheckval= $INODEFREE unless defined($icheckval);
$icheckval=~ s/%$//;
# do the checking, first absolute and then percentage
next if $checkval == 0 && $icheckval == 0; # nothing to check: ignore
my $hostfailed= 0;
if (($checkval > 0) && ($disk->[0] <$checkval)) {
$hostfailed++;
push (@ERRS,sprintf("%s: filesystem %s is (%1.1f%% full), %1.0fMB free (below threshold %1.0fMB free)",
$host , $disk->[2] , $disk->[1] , $disk->[0] / 1048576, $checkval / 1048576 ));
} elsif (($checkval < 0) && ($disk->[1] - $checkval >=100)) {
$hostfailed++;
push (@ERRS,sprintf("%s: filesystem %s is (%1.1f%% full), %1.0fMB free (below threshold %s%% free)",
$host , $disk->[2] , $disk->[1] , $disk->[0] / 1048576, abs($checkval) ));
}
if (($icheckval > 0) && ($disk->[3] ne "N/A") && (100 - $disk->[3]) < $icheckval ) {
$hostfailed++;
push (@ERRS, sprintf ("%s: filesystem %s has %1.1f%% inodes free (below threshold %s%% inodes free)",
$host, $disk->[2], 100 - $disk->[3], $icheckval ));
}
if ($hostfailed)
{
push (@HOSTS, $host);
$RET = 1;
}
# if the user want a listing, then the user will get a listing :-)
write if ($LIST or $LISTALL);
if ($LISTALL) {
printf(" Will alarm if MB free declines below threshold %1.0fMB free\n", $checkval / 1048576) if $checkval > 0;
printf(" Will alarm if %%free space declines below threshold %1.1f%% free\n", abs($checkval)) if $checkval < 0;
printf(" No free space alarm defined in config file.\n") if $checkval == 0;
printf(" Will alarm if %%free inodes declines below %1.1f%%\n", $icheckval) if $icheckval > 0;
printf(" No %%inodes free alarm defined in config file.\n") if $icheckval == 0;
printf(" WARNING: Unable to alarm on inodes free, dskPercentNode not found in MIB\n") if $disk->[3] eq "N/A" and $icheckval > 0;
}
}
}
if ($LIST or $LISTALL) {
print "\n\n";
}
# Uniq the array of failures, so multiple failures on a single host
# are reported in the details section (lines #2-infinity) but not
# in the summary (line #1).
# Then print out the failures, if any.
my %saw;
undef %saw;
@saw{@HOSTS} = ();
@HOSTS = keys %saw;
if ($RET) {
print "@HOSTS\n";
print "\n";
print join("\n", @ERRS), "\n";
}
exit $RET;
#
# read configuration file
#
sub readcf {
my ($f) = @_;
my ($l, $host, $filesys, $free, $ifree);
open (CF, $f) || return undef;
while (<CF>) {
next if (/^\s*#/ || /^\s*$/);
chomp;
($host, $filesys, $free, $ifree) = split;
# if (!defined ($FREE{$host}{$filesys} = toBytes ($free))) {
if (!push (@cfgfile, [$host , $filesys , toBytes ($free), $ifree || 0]) ) {
die "error free specification, config $f, line $.\n";
}
print STDERR "cf: assigned host=$host, filesys=$filesys, free=$free, ifree=$ifree\n" if $DEBUG;
}
close (CF);
}
sub toBytes {
# take a string and parse it as folows
# N return N
# N kb return N*1024
# N mb return N*1024^2
# N gb return N*1024^3
# N % return -N
my ($free) = @_;
my ($n, $u);
if ($free =~ /^(\d+\.\d+)(kb|mb|gb|%|)$/i) {
($n, $u) = ($1, "\L$2");
} elsif ($free =~ /^(\d+)(kb|mb|gb|%|)$/i) {
($n, $u) = ($1, "\L$2");
} else {
return undef;
}
return (int ($n * -1)) if ($u eq "%");
return (int ($n * 1024 )) if ($u eq "kb");
return (int ($n * 1024 * 1024)) if ($u eq "mb");
return (int ($n * 1024 * 1024 * 1024)) if ($u eq "gb");
int ($n);
}
#
# Do the work of trying to get the data from the host via SNMP
#
sub get_values {
my ($host) = @_;
my (@disklist,$Type,$Descr,$AllocationUnits,$Size,$Used,$Freespace,$Percent,$InodePercent);
my ($v,$s);
if (!defined($s = new SNMP::Session (DestHost => $host,
Timeout => $TIMEOUT, Community => $COMM,
Retries => $RETRIES))) {
$RET = ($RET == 1) ? 1 : 2 ;
push (@HOSTS, $host);
push (@ERRS, "$host: could not create session: " . $s->{ErrorStr});
return undef;
}
# First we try to use the Host mib (RFC1514)
# supported by net-snmpd on most platforms, see http://www.net-snmp.org
#
# You can also use the Empire (http://www.empire.com)
# SNMP agent to provide hostmib support on UNIX and NT.
if ($USEMIB =~ /host/i)
{
$v = new SNMP::VarList (
['hrStorageIndex'],
['hrStorageType'],
['hrStorageDescr'],
['hrStorageAllocationUnits'],
['hrStorageSize'],
['hrStorageUsed'],
);
while (defined $s->getnext($v)) {
last if ($v->[0]->tag !~ /hrStorageIndex/);
$Type = $v->[1]->val;
$Descr = $v->[2]->val;
$AllocationUnits = $v->[3]->val;
$Size = $v->[4]->val;
$Used = $v->[5]->val;
$Freespace = (($Size - $Used) * $AllocationUnits);
print STDERR "Found HOST MIB filesystem: Type=$Type, Descr=$Descr, AllocationUnits=$AllocationUnits, Size=$Size, Used=$Used\n" if $DEBUG;
# This next check makes sure we're only looking at storage
# devices of the "FixedDevice" type (4). For comparison, Physical
# RAM is 2, Virtual Memory is 3, Floppy Disk is 6, and CD-ROM is 7
# Using the Empire agent, this will eliminate drive types other
# than hard disks. The UCD agent is not as good as determining
# drive types under the HOST mib.
next if ($Type !~ /\.1\.3\.6\.1\.2\.1\.25\.2\.1\.4/);
if ($Size != 0) {
$Percent= ($Used / $Size) * 100.0;
} else {
$Percent=0;
};
push (@disklist,[$Freespace,$Percent,$Descr, "N/A"]);
print STDERR "Using HOST MIB filesystem: $Descr ($Type)\n" if $DEBUG;
};
if (@disklist) {
return @disklist;
};
};
# Then we test the perfmib from M$ NT resource kit
# I'm using the agent/mib-defs from
# http://www.wtcs.org/snmp4tpc/
# for somereason every second request fails,
# so we fetch the variables twice and discards
# the bad ones
if ($USEMIB =~ /perf/i)
{
$v = new SNMP::VarList (
['ldisklogicalDiskIndex'],
['ldiskPercentFreeSpace'],
['ldiskPercentFreeSpace'],
['ldiskFreeMegabytes'],
['ldiskFreeMegabytes'],
);
while (defined $s->getnext($v)) {
# Make sure we are still in relevant portion of MIB
last if ($v->[1]->val !~ /^\.1\.3\.6\.1\.2\.1\.25\.2\.1\.4/);
last if ($v->[0]->val =~ /Total/);
$Descr = ( $v->[0]->val =~ /.*:.*:(\w+:)$/gi)[-1] ;
$Percent = $v->[2]->val;
$Freespace = $v->[4]->val * 1024 * 1024;
push (@disklist,[$Freespace,$Percent,$Descr, "N/A"]);
print STDERR "Using PERF MIB filesystem: $Descr, $Freespace,$Percent\n" if $DEBUG;
};
if (@disklist) {
return @disklist;
}
}
#Try UCD-SNMP .enterprises.ucdavis.dskTable.dskEntry MIB extrnsion
# Comes with UCD-SNMP / net-snmp
if ($USEMIB =~ /ucd/i)
{
$v = new SNMP::VarList (
['dskIndex'],
['dskPath'],
['dskPercent'],
['dskAvail'],
['dskDevice'],
['dskPercentNode'],
);
while (defined $s->getnext($v)) {
last if ($v->[0]->tag !~ /dskIndex/); # end of MIB?
my $instancenum= $v->[0]->iid; # what instance number?
# check for partial fetches (like swap partition) that won't
# return all the MIB entries
if ($v->[2]->iid != $instancenum or
$v->[3]->iid != $instancenum or
$v->[5]->iid != $instancenum)
{
# ignore this instance and try to move on to next
# we wouldn't need this if use-dummy-values really worked
$v = new SNMP::VarList (
['dskIndex', $instancenum],
['dskPath', $instancenum],
['dskPercent', $instancenum],
['dskAvail', $instancenum],
['dskDevice', $instancenum],
['dskPercentNode', $instancenum],
);
next;
}
$Descr = $v->[1]->val;
$Percent = $v->[2]->val;
$Freespace = $v->[3]->val;
$Freespace *= 1024; #Convert from kbytes to bytes to make consistent
$Type = $v->[4]->val;
$InodePercent = $v->[5]->val;
print STDERR "Found UCD MIB filesystem: Type=$Type, Descr=$Descr, Percent=$Percent, Freespace=$Freespace, InodePercent=$InodePercent\n" if $DEBUG;
# Try to catch only local filesystems. This covers the
# the basics, but probably should be configurable
next unless ( $Type =~ m/\b(md|hd|wd|sd|ida|raid)/ ) ;
print STDERR "Using UCD MIB filesystem: $Descr ($Type)\n" if $DEBUG;
push (@disklist,[$Freespace,$Percent,$Descr, $InodePercent]);
};
if (@disklist) {
return @disklist;
}
}
#Check for errors
if ($s->{ErrorNum}) {
push (@HOSTS, $host);
push (@ERRS, "$host: could not get SNMP info: " . $s->{ErrorStr});
$RET = ($RET == 1) ? 1 : 2 ;
return undef;
}
# Check for OID not found
push (@HOSTS, $host);
push (@ERRS, "$host: Disk space OIDs not found in MIB(s): $USEMIB");
$RET = ($RET == 1) ? 1 : 2 ;
return undef;
}
# format specifications, should be able to cut, paste and edit into a config file
format STDOUT_TOP =
System Description % Used Free space Inode%
-------------------------------------------------------------------------------
.
format STDOUT =
@<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<<<<<<<<<<<<< @###.# % @#######.# mb @>>>>>>
$host, $disk->[2], $disk->[1], $disk->[0]/1024/1024, ( $disk->[3] ne "N/A" ? ($disk->[3] + 0) . "%" : "N/A")
.
|
|
From: Jim T. <tr...@us...> - 2007-05-02 23:25:11
|
Update of /cvsroot/mon/mon/doc
In directory sc8-pr-cvs16:/tmp/cvs-serv5137/doc
Added Files:
Tag: mon-1-2-branch
README.snmpdiskspace.monitor
Log Message:
added snmpdiskspace.monitor with eravin's patches
--- NEW FILE: README.snmpdiskspace.monitor ---
# NAME
# snmpdiskspace.monitor
#
#
# SYNOPSIS
# snmpdiskspace.monitor [--list] [--timeout seconds] [--config filename]
# [--community string] [--free minfree]
# [--retries retries] [--usemib <mibtype>] host...
#
#
# DESCRIPTION
# This script uses the Host Resources MIB (RFC1514), and optionally
# the MS Windows NT Performance MIB, or UCD-SNMP extensions
# (enterprises.ucdavis.dskTable.dskEntry) to monitor diskspace on hosts
# via SNMP.
#
# snmpdiskspace.monitor uses a config file to allow the specification of
# minimum free space on a per-host and per-partition basis. The config
# file allows the use of regular expressions, so it is quite flexible in
# what it can allow. See the sample config file for more details and
# syntax.
#
# The script only checks disks marked as "FixedDisks" by the Host MIB,
# which should help cut down on the number of CD-ROM drives
# erroneously reported as being full! Since the drive classification
# portion of the UCD Host MIB isn't too great on many OS'es, though,
# this won't buy you a lot. Empire's SNMP agent gets this right on
# all the hosts that I checked, though. Not sure about the MS MIB.
# UCD-SNMP only checks specific partition types (md, hd, sd, ida)
#
# snmpdiskspace.monitor is intended for use as a monitor for the mon
# network monitoring package.
#
#
# OPTIONS
# --community The SNMP community string to use. Default is "public".
# --config The config file to use. Default is either
# /etc/mon/snmpdiskspace.cf or
# /usr/lib/mon/mon.d/snmpdiskspace.cf, in that order.
# --retries The number of retries to use, if we get an SNMP timeout.
# Default is retry 5 times.
# --timeout Seconds to wait before declaring a timeout on an SNMP get.
# Default is 20 seconds.
# --free The default minimum free space, in a percentage or absolute
# quantity, as per the config file. Thus, arguments of, for
# example, "20%", "1gb", "50mb" are all valid.
# Default is 5% free on every partition checked.
#
# --ifree The default minimum free inode percentage, specified as
# a percentage. Default is 5% free.
#
# --list Give a verbose listing of all partitions checked on all
# specified hosts.
#
# --listall like --list, but also lists the thresholds defined for
# each filesystem, so you can doublecheck the config file
#
# --usemib Choose which MIB to use: one or more of host, perf, ucd
# Default tries all three, in that order
#
# --debug enable debug output for config file parsing and MIB fetching
#
#
# EXIT STATUS
# Exit status is as follows:
# 0 No problems detected.
# 1 Free space on any host was below the supplied parameter.
# 2 A "soft" error occurred, either a SNMP library error,
# or could not get a response from the server.
#
# In the case where both a soft error and a freespace violation are
# detected, exit status is 1.
#
# BUGS
# When using the net-snmp agent, you must build it with "--with-dummy-values"
# or the monitor may not parse the Host Resources MIB properly.
#
# List of local filesystem types used when parsing the UCD MIB should be
# configurable.
#
#
# NOTES
# $Id: README.snmpdiskspace.monitor,v 1.1.2.1 2007/05/02 23:25:06 trockij Exp $
#
# * Added support for inode status via UCD-SNMP MIB. Fourth column in config
# file (optional) is for inode%.
# * added --debug and --usemib options. Latter needed so you can force use
# of UCD mib if you want inode status.
# * rearranged the error messages to be more Mon-like (hostname first)
# * added code to synchronize instance numbers when using UCD MIB. This
# could solve the "sparse MIB" problem usually fixed by the
# --with-dummy-values option in net-snmp if needed for other agents
# Ed Ravin (er...@pa...), January 2005
#
# Added support for regex hostnames and partition names in the config file,
# 'use strict' by andrew ryan <an...@na...>.
#
# Generalised to handle multible mibs by jens persson <jen...@bt...>
# Changes Copyright (C) 2000, jens persson
#
# Modified for use with UCD-SNMP by Johannes Walch for
# NWE GmbH (j....@nw...)
#
# Support for UCD's disk MIB added by Matt Simonsen <ma...@ca...>
#
#
# SEE ALSO
# mon: http://www.kernel.org/software/mon/
#
# This requires the UCD SNMP library and G.S. Marzot's Perl SNMP
# module. (http://ucd-snmp.ucdavis.edu and CPAN, respectively).
#
# The Empire SystemEdge SNMP agent: http://www.empire.com
|
|
From: Jim T. <tr...@us...> - 2007-05-02 23:25:10
|
Update of /cvsroot/mon/mon/etc
In directory sc8-pr-cvs16:/tmp/cvs-serv5137/etc
Added Files:
Tag: mon-1-2-branch
snmpdiskspace.cf
Log Message:
added snmpdiskspace.monitor with eravin's patches
--- NEW FILE: snmpdiskspace.cf ---
#
# snmpdiskspace.cf- configuration file for snmpdiskspace.monitor
# $Id: snmpdiskspace.cf,v 1.1.2.1 2007/05/02 23:25:06 trockij Exp $
#
# format:
#
# host filesys free ifree
#
# The monitor script uses a "first match" algorithm. So put your more
# specific directives at top, and leave the more general directives
# for the bottom.
#
#
# host Regex describing the name of the host(s). Remember to escape
# dots if you're fully qualifying hostnames, e.g.,
# some\.domain\.com, otherwise you might not be matching what
# you think you're matching.
#
# filesys Regex describing the filesystem to check, as represented
# in the relevant mib (after mangling by the monitor).
# Remember to use regex syntax, and not file glob syntax.
#
# free The amount of free space which will trigger a failure,
# expressed as "10", "10kb", "10MB", or "10GB" for
# bytes, kilobytes, megabytes or gigabytes. The format
# "10%" signifies percent of the total disk space.
# "0" turns of checking for the filesystem/disk.
#
# ifree Percentage of free inodes, below which will trigger a failure.
# Expressed as "5%". The host must support the UCD dskTable MIB.
#
#
# BE SURE TO TEST your configuration with the "--listall" option!
# This way, you will see exactly what filesystems are found by the script,
# and what their alarm thresholds will be.
#
# Examples:
# * * 5%
# Give a warning when the free space goes below 5 %
# (This is the default behavior of the monitor)
# This should always be the last line in your config file
# because it will match everything.
#
# * * 5% 10%
# As above, but also warn if free inodes drops below 10%.
#
# ior * 15%
# On the host ior the limit is 15%
#
# poo / 1gb
# poo's root should have a full gig free
#
# www[1-4] * 500mb
# any partition on the machines www1, www2, www3, and ww4
# should have at least 500mb free.
#
# * /cdrom/.* 0
# anything that is mounted on /cdrom will be full anyway
# At least for Solaris, you need a regex like this bec.
# vold mounts each new CD on a new partition, and you
# won't know its name until you put it into the drive.
#
#
# Always ignore anything on cdrom partitions
* /cdrom.* 0
* /mnt 0
#
#
# This line always should be last because it matches everything.
* * 5%
|
|
From: Jim T. <tr...@us...> - 2007-04-26 10:46:55
|
Update of /cvsroot/mon/mon/mon.d
In directory sc8-pr-cvs16:/tmp/cvs-serv16425
Modified Files:
process.monitor
Log Message:
bug 1707773
Index: process.monitor
===================================================================
RCS file: /cvsroot/mon/mon/mon.d/process.monitor,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** process.monitor 9 Jun 2004 05:18:04 -0000 1.1.1.1
--- process.monitor 26 Apr 2007 10:46:45 -0000 1.2
***************
*** 86,89 ****
--- 86,90 ----
push (@failures, $host);
push (@longerr, "$host returned an SNMP error: " . $session->{"ErrorStr"});
+ $RETVAL = 1;
}
}
|
|
From: Jim T. <tr...@us...> - 2007-04-26 10:40:05
|
Update of /cvsroot/mon/mon/mon.d
In directory sc8-pr-cvs16:/tmp/cvs-serv9737
Modified Files:
Tag: mon-1-2-branch
process.monitor
Log Message:
bug 1707773
Index: process.monitor
===================================================================
RCS file: /cvsroot/mon/mon/mon.d/process.monitor,v
retrieving revision 1.1.1.1
retrieving revision 1.1.1.1.4.1
diff -C2 -d -r1.1.1.1 -r1.1.1.1.4.1
*** process.monitor 9 Jun 2004 05:18:04 -0000 1.1.1.1
--- process.monitor 26 Apr 2007 10:39:55 -0000 1.1.1.1.4.1
***************
*** 86,89 ****
--- 86,90 ----
push (@failures, $host);
push (@longerr, "$host returned an SNMP error: " . $session->{"ErrorStr"});
+ $RETVAL = 1;
}
}
|
|
From: Jim T. <tr...@us...> - 2006-12-13 16:07:05
|
Update of /cvsroot/mon/mon In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv30839 Modified Files: Tag: mon-1-0-0pre1 CHANGES mon Log Message: FL_ACKALERT and freespace.monitor Filesys::DiskFree Index: CHANGES =================================================================== RCS file: /cvsroot/mon/mon/CHANGES,v retrieving revision 1.2.2.4 retrieving revision 1.2.2.5 diff -C2 -d -r1.2.2.4 -r1.2.2.5 *** CHANGES 9 Jan 2005 03:27:55 -0000 1.2.2.4 --- CHANGES 13 Dec 2006 16:06:36 -0000 1.2.2.5 *************** *** 1,4 **** --- 1,13 ---- $Id$ + Changes between mon-1.0.0pre5 and mon-1.0.0pre6 + Wed Dec 13 11:04:27 EST 2006 trockij + ---------------------------------------------- + -added $FL_ACKALERT + + -update to freespace.monitor to use Filesys::DiskFree rather than + Filesys::DiskSpace + + Changes between mon-1.0.0pre4 and mon-1.0.0pre5 Tue Dec 14 17:22:52 EST 2004 Index: mon =================================================================== RCS file: /cvsroot/mon/mon/mon,v retrieving revision 1.4.2.19 retrieving revision 1.4.2.20 diff -C2 -d -r1.4.2.19 -r1.4.2.20 *** mon 28 Apr 2005 19:59:03 -0000 1.4.2.19 --- mon 13 Dec 2006 16:06:36 -0000 1.4.2.20 *************** *** 185,189 **** my ($FL_MONITOR, $FL_UPALERT, # alert type flags $FL_TRAP, $FL_TRAPTIMEOUT, ! $FL_STARTUPALERT, $FL_TEST); my $TRAP_PDU; --- 185,189 ---- my ($FL_MONITOR, $FL_UPALERT, # alert type flags $FL_TRAP, $FL_TRAPTIMEOUT, ! $FL_STARTUPALERT, $FL_TEST, $FL_ACKALERT); my $TRAP_PDU; *************** *** 565,572 **** # ! # skip upalerts not paired with down alerts # disable by setting "no_comp_alerts" in period section # ! if (!$pref->{"no_comp_alerts"} && ($flags & $FL_UPALERT) && !$pref->{"_alert_sent"}) { next; --- 565,572 ---- # ! # skip upalerts/ackalerts not paired with down alerts # disable by setting "no_comp_alerts" in period section # ! if (!$pref->{"no_comp_alerts"} && ($flags & ($FL_UPALERT | $FL_ACKALERT)) && !$pref->{"_alert_sent"}) { next; *************** *** 3015,3018 **** --- 3015,3022 ---- || (($tmnow - $sref->{"_first_failure"}) >= $sref->{"upalertafter"}))) { + # + # Save the last failing monitor's output for posterity + # + $sref->{"_upalertoutput"}= $sref->{"_last_output"}; do_alert ($group, $service, $sref->{"_upalertoutput"}, 0, $FL_UPALERT); } *************** *** 4330,4333 **** --- 4334,4338 ---- $FL_STARTUPALERT = 16; $FL_TEST = 32; + $FL_ACKALERT = 64; # |
|
From: Jim T. <tr...@us...> - 2006-12-13 16:07:03
|
Update of /cvsroot/mon/mon/mon.d In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv30839/mon.d Modified Files: Tag: mon-1-0-0pre1 freespace.monitor Log Message: FL_ACKALERT and freespace.monitor Filesys::DiskFree Index: freespace.monitor =================================================================== RCS file: /cvsroot/mon/mon/mon.d/freespace.monitor,v retrieving revision 1.1.1.1.2.1 retrieving revision 1.1.1.1.2.2 diff -C2 -d -r1.1.1.1.2.1 -r1.1.1.1.2.2 *** freespace.monitor 12 Apr 2005 21:28:00 -0000 1.1.1.1.2.1 --- freespace.monitor 13 Dec 2006 16:06:36 -0000 1.1.1.1.2.2 *************** *** 21,26 **** # to interrupt the stat and statfs system calls. # ! # This requires Fabien Tassin's Filesys::DiskSpace module, available from ! # your friendly neighborhood CPAN mirror. See http://www.perl.com/perl/ # # Jim Trocki, tr...@ar... --- 21,25 ---- # to interrupt the stat and statfs system calls. # ! #### Jason Castonguay jca...@so... # # Jim Trocki, tr...@ar... *************** *** 44,53 **** # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # ! use Filesys::DiskSpace; foreach (@ARGV) { ($path, $minavail) = split (/:/, $_, 2); - ($fs_type, $fs_desc, $used, $avail, $fused, $favail) = df ($path); if (!defined ($used)) { --- 43,56 ---- # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # ! use Filesys::DiskFree; foreach (@ARGV) { ($path, $minavail) = split (/:/, $_, 2); + + $handle = new Filesys::DiskFree; + $handle->df(); + $used = $handle->used($path); + $avail =$handle->avail($path); if (!defined ($used)) { *************** *** 61,65 **** if ($avail < $minavail) { ! push (@failures, sprintf ("%1.1fGB free on %s", $avail / 1024 / 1024, $path)); } --- 64,68 ---- if ($avail < $minavail) { ! push (@failures, sprintf ("%1.1fGB free on %s", $avail / 1024 / 1024 /1024, $path)); } *************** *** 72,73 **** --- 75,77 ---- exit 0; + |
Update of /cvsroot/mon/mon-contrib/monitors/snmpvar In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv28690 Removed Files: CHANGES COPYING README example.out snmpopt.cf snmpvar.cf snmpvar.def snmpvar.monitor Log Message: snmpvar.monitor moved to main distribution --- snmpopt.cf DELETED --- --- CHANGES DELETED --- --- COPYING DELETED --- --- example.out DELETED --- --- README DELETED --- --- snmpvar.monitor DELETED --- --- snmpvar.cf DELETED --- --- snmpvar.def DELETED --- |
|
From: David N. <vi...@us...> - 2006-09-18 11:48:49
|
Update of /cvsroot/mon/mon-contrib/monitors/snmpvar In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv28279 Added Files: SNMPVAR-MOVED-TO-MAIN-MON-DISTRIBUTION Log Message: Removed snmpvar.monitor from contrib, its part of the mon distribution now. --- NEW FILE: SNMPVAR-MOVED-TO-MAIN-MON-DISTRIBUTION --- |
|
From: David N. <vi...@us...> - 2006-09-18 11:45:58
|
Update of /cvsroot/mon/mon/doc In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv27124/doc Modified Files: README.snmpvar.monitor Log Message: updated readme reference to UCD snmp Index: README.snmpvar.monitor =================================================================== RCS file: /cvsroot/mon/mon/doc/README.snmpvar.monitor,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** README.snmpvar.monitor 15 Nov 2004 14:45:18 -0000 1.2 --- README.snmpvar.monitor 18 Sep 2006 11:45:51 -0000 1.3 *************** *** 25,30 **** Quick Start: ! * Make sure you have UCD SNMP 3.6.2+ (libraries) and the Perl SNMP ! module installed (http://www.cpan.org/misc/cpan-faq.html) * Copy snmpvar.mon to your mon.d directory * Copy snmpvar.def to /etc/mon, add your own variables --- 25,31 ---- Quick Start: ! * Make sure you have NET-SNMP libraries (http://www-net-snmp.org ! - Formerly UCD SNMP) and the Perl SNMP module installed ! (http://www.cpan.org/misc/cpan-faq.html) * Copy snmpvar.mon to your mon.d directory * Copy snmpvar.def to /etc/mon, add your own variables |
|
From: David N. <vi...@us...> - 2006-09-05 17:09:24
|
Update of /cvsroot/mon/mon-client/Mon In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv29238 Modified Files: Client.pm Log Message: Added list/get/set view code (experimental) Index: Client.pm =================================================================== RCS file: /cvsroot/mon/mon-client/Mon/Client.pm,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Client.pm 17 Feb 2005 20:52:49 -0000 1.2 --- Client.pm 5 Sep 2006 17:09:21 -0000 1.3 *************** *** 960,963 **** --- 960,989 ---- + sub list_views { + my $self = shift; + + undef $self->{"ERROR"}; + + if (!$self->{"CONNECTED"}) { + $self->{"ERROR"} = "not connected"; + return undef; + } + + my ($r, $l) = _do_cmd ($self->{"HANDLE"}, "list views"); + + if ($r =~ /^220/) + { + $l =~ s/^views\s+//; + return split (/\s+/, $l); + } + + else + { + $self->{"ERROR"} = $l; + return undef; + } + } + + sub start { my $self = shift; *************** *** 1139,1142 **** --- 1165,1196 ---- + sub setview { + my $self = shift; + my ($view) = @_; + + undef $self->{"ERROR"}; + + if (!$self->{"CONNECTED"}) { + $self->{"ERROR"} = "not connected"; + return undef; + } + + my ($r, $l) = _do_cmd ($self->{"HANDLE"}, "setview $view"); + + if (!defined $r) + { + $self->{"ERROR"} = $l; + return undef; + } + elsif ($r !~ /^220/) + { + $self->{"ERROR"} = $r; + return undef; + } + + return $r; + } + + sub get { my $self = shift; *************** *** 1167,1170 **** --- 1221,1248 ---- + sub getview { + my $self = shift; + + undef $self->{"ERROR"}; + + if (!$self->{"CONNECTED"}) { + $self->{"ERROR"} = "not connected"; + return undef; + } + + my ($r, $l) = _do_cmd ($self->{"HANDLE"}, "getview"); + + if (!defined $r) { + $self->{"ERROR"} = $l; + return undef; + } elsif ($r !~ /^220/) { + $self->{"ERROR"} = $r; + return undef; + } + + return $l; + } + + sub test { my $self = shift; |
|
From: David N. <vi...@us...> - 2006-09-05 12:52:43
|
Update of /cvsroot/mon/mon/mon.d In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv18267 Modified Files: dns.monitor Log Message: pulled in various CMU updates, including multiple master support, configurable timeouts, and better errors in some cases Index: dns.monitor =================================================================== RCS file: /cvsroot/mon/mon/mon.d/dns.monitor,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** dns.monitor 15 Nov 2004 14:45:19 -0000 1.2 --- dns.monitor 5 Sep 2006 12:52:37 -0000 1.3 *************** *** 2,6 **** # # Copyright (C) 1998 David Eckelkamp ! # Copyright (C) 2002 David Nolan # # This program is free software; you can redistribute it and/or modify --- 2,6 ---- # # Copyright (C) 1998 David Eckelkamp ! # Copyright (C) 2002-2006 Carnegie Mellon University # # This program is free software; you can redistribute it and/or modify *************** *** 26,34 **** =head1 SYNOPSIS ! B<dns.monitor> I<-zone zone [-zone zone ...]> I<-master master> I<[-serial_threshold num]> I<[-tcp]> I<server [server ...]> - or ! B<dns.monitor> I<-caching_only> I<[-tcp]> I<-query record[:type] [-query record[:type] ...]> I<server [server ...]> =head1 DESCRIPTION --- 26,69 ---- =head1 SYNOPSIS ! B<dns.monitor> ! =over 12 ! ! ( [ I<-zone zone [-zone zone ...]> ! ! ! =over 4 ! ! ! I<-master server [-master server ...]> ! ! I<[-serial_threshold num]> ! ! I<[-failsingle]> ] ! ! =back ! ! | [ I<-caching_only> ! ! =over 4 ! ! I<-query record[:type[:value]] [-query record[:type[:value]] ...]> ] ) ! ! =back ! ! I<[-tcp]> ! ! I<[-retry num]> ! ! I<[-retransmit num]> ! ! I<[-timeout num]> ! ! I<[-debug num]> ! ! I<server [server ...]> ! ! =back =head1 DESCRIPTION *************** *** 40,68 **** server and one or more slave servers. The I<zone> argument is the zone to check. There can be multiple I<zone> arguments. The I<master> ! argument is the master server for the I<zone>. It will be queried for ! the base information. Then each I<server> will be queried to verify ! that it has the correct answers. If the I<serial_threshold> argument ! is provided, the slave servers must return a zone whose serial number ! is no more than the threshold from the serial number of the zone on ! the master. (Zone serial numbers may not be identical during zone ! propagation, or on Dynamic DNS zones which may be updated hundreds or ! thousands of times an hour) It is assumed that each I<server> is ! supposed to be authoritative for the I<zone>. The I<-tcp> option ! will cause lookups to be done via TCP instead of the default UDP. ! In caching mode, specified via the I<-caching_only> switch, B<dns.monitor> ! will perform a set of DNS queries to one or more servers. The I<query> ! argument is the query to perform. The query may have an optional query type ! specified as I<:type> on the end of the query. I.e your.zone.com:MX will ! cause B<dns.monitor> to fetch the MX records for your.zone.com. There can be ! multiple I<query> arguments. Each I<server> will be contacted to verify ! that it returns a valid response to the query. If you wish to use ! B<dns.monitor> to verify that a caching DNS server is actually fetching fresh ! data from other servers successfully, it is recommended that the DNS records ! you query should have very short TTLs. ! The exit code of B<dns.monitor> will be the highest number of servers which ! failed on a single zone/query, 0 if no problems occurred, or -1 if an error ! with the script arguments was detected. =head1 AUTHOR --- 75,116 ---- server and one or more slave servers. The I<zone> argument is the zone to check. There can be multiple I<zone> arguments. The I<master> ! argument is the master server for the I<zone>. There can be multiple ! I<master> arguments. The master server(s) will be queried for the ! base information. If the I<serial_threshold> argument is provided, ! the serials collected from the I<master> servers are checked to be ! within I<serial_threshold>. The greatest serial of all of the ! I<master> servers is chosen for comparison. Then each I<server> will ! be queried to verify that it has the correct answers. If the ! I<serial_threshold> argument is provided, the slave servers must ! return a zone whose serial number is no more than the threshold from ! the serial number of the zone on the master. (Zone serial numbers may ! not be identical during zone propagation, or on Dynamic DNS zones ! which may be updated hundreds or thousands of times an hour) It is ! assumed that each I<server> is supposed to be authoritative for the ! I<zone>. The I<-tcp> option will cause lookups to be done via TCP ! instead of the default UDP. ! In caching mode, specified via the I<-caching_only> switch, ! B<dns.monitor> will perform a set of DNS queries to one or more ! servers. The I<query> argument is the query to perform. The query ! may have an optional query type specified as I<:type> on the end of ! the query. I.e your.zone.com:MX will cause B<dns.monitor> to fetch ! the MX records for your.zone.com. There can be multiple I<query> ! arguments. The query type may also have an optional result specified ! as I<:value> on the end of the query (type must also be specified). ! Each I<server> will be contacted to verify that it returns a valid ! response to the query. If a query result is specified B<dns.monitor> ! will return an error is the DNS query returns an answer which differs ! from the supplied result. If you wish to use B<dns.monitor> to verify ! that a caching DNS server is actually fetching fresh data from other ! servers successfully, it is recommended that the DNS records you query ! should have very short TTLs. ! The exit code of B<dns.monitor> will be the highest number of servers ! which failed on a single zone/query, 0 if no problems occurred, or -1 ! if an error with the script arguments was detected. If all of the ! I<master> servers fail, the return code will be 252. If using the ! I<failsingle> option and any I<master> server fails, the return code ! will be 251. =head1 AUTHOR *************** *** 70,78 **** The script was originally written by David Eckelkamp <da...@tr...> ! The script was modified to support Caching DNS servers and frequently updating Zone serials by David Nolan <vi...@cm...> =cut ! #use strict; use Getopt::Long; use English; --- 118,129 ---- The script was originally written by David Eckelkamp <da...@tr...> ! The script was modified to support Caching DNS servers, configurable ! retry/timeout parameters, multiple DNS Master servers, and ! configurable Zone serials by David Nolan <vi...@cm...> and Jason ! Carr <jc...@an...> from Carnegie Mellon University. =cut ! use strict; use Getopt::Long; use English; *************** *** 81,100 **** use Net::DNS::Packet; use Net::DNS::RR; my($Program) = basename($0); my(@Zones) = (); my(@Queries) = (); ! my($Master) = undef; my($SerialThreshold) = (0); my($CachingServer) = (0); my($UseTCP) = (0); ! my(%OptVars) = ("master" => \$Master, "zone" => \@Zones, "serial_threshold" => \$SerialThreshold, "caching_only" => \$CachingServer, "query" => \@Queries, ! "tcp" => \$UseTCP); ! if (!GetOptions(\%OptVars, "master=s", "zone=s@", "serial_threshold=s", "caching_only", "tcp", "query=s@")) { print STDERR "Problems with Options, sorry\n"; exit -1; --- 132,163 ---- use Net::DNS::Packet; use Net::DNS::RR; + use Data::Dumper; my($Program) = basename($0); my(@Zones) = (); my(@Queries) = (); ! my(@Master) = (); my($SerialThreshold) = (0); my($CachingServer) = (0); my($UseTCP) = (0); ! my ($retries, $retrans, $timeout) = ( 2, 5, undef ); ! my $debug = 0; ! my $failsingle = 0; ! ! my(%OptVars) = ( ! "master" => \@Master, "zone" => \@Zones, "serial_threshold" => \$SerialThreshold, "caching_only" => \$CachingServer, "query" => \@Queries, ! "retry" => \$retries, ! "retransmit" => \$retrans, ! "timeout" => \$timeout, ! "tcp" => \$UseTCP, ! "debug" => \$debug, ! "failsingle" => \$failsingle ! ); ! if (!GetOptions(\%OptVars, "master=s@", "zone=s@", "serial_threshold=s", "caching_only", "tcp", "query=s@", "retry=i", "retransmit=i", "timeout=i", "debug", "failsingle")) { print STDERR "Problems with Options, sorry\n"; exit -1; *************** *** 102,114 **** if ( $#ARGV < 0 ) { print STDERR "$Program: at least one server must be specified\n"; exit -1; } if (!$CachingServer) { ! if (!defined($Master)) { print STDERR "$Program: The zone master server must be specified\n"; exit -1; } if ( !defined(@Zones) ) { print STDERR "$Program: At least one zone must be specified\n"; exit -1; } --- 165,180 ---- if ( $#ARGV < 0 ) { print STDERR "$Program: at least one server must be specified\n"; + usage(); exit -1; } if (!$CachingServer) { ! if (!defined(@Master)) { print STDERR "$Program: The zone master server must be specified\n"; + usage(); exit -1; } if ( !defined(@Zones) ) { print STDERR "$Program: At least one zone must be specified\n"; + usage(); exit -1; } *************** *** 116,119 **** --- 182,186 ---- if ( !defined(@Queries) ) { print STDERR "$Program: At least one query must be specified\n"; + usage(); exit -1; } *************** *** 125,131 **** my($bad_servers, $reason, $failcount, @FailedZones, @FailedServers, @Reasons); my($zone, $line, $i); - $maxfailcount = 0; foreach $zone (@Zones) { ! ($bad_servers, $reason, $failcount) = dns_verify($zone, $Master, @ARGV); if (defined($bad_servers)) { $err_cnt = $failcount if ($failcount > $err_cnt); --- 192,197 ---- my($bad_servers, $reason, $failcount, @FailedZones, @FailedServers, @Reasons); my($zone, $line, $i); foreach $zone (@Zones) { ! ($bad_servers, $reason, $failcount) = dns_verify($zone, \@Master, \@ARGV); if (defined($bad_servers)) { $err_cnt = $failcount if ($failcount > $err_cnt); *************** *** 160,171 **** my($err_cnt) = 0; my($bad_servers, $reason, $failcount, @FailedQuerys, @FailedServers, @Reasons); ! my($query, $type, $line, $i); foreach (@Queries) { ! ($query, $type) = split /:/; $type = 'A' if ($type eq ""); ! ($bad_servers, $reason, $failcount) = dns_test($query, $type, @ARGV); if (defined($bad_servers)) { $err_cnt = $failcount if ($failcount > $err_cnt); ! push(@FailedQuerys, "$query $type"); push(@FailedServers, $bad_servers); push(@Reasons, $reason); --- 226,238 ---- my($err_cnt) = 0; my($bad_servers, $reason, $failcount, @FailedQuerys, @FailedServers, @Reasons); ! my($query, $type, $line, $i, $target); foreach (@Queries) { ! ($query, $type, $target) = split /:/; $type = 'A' if ($type eq ""); ! ($bad_servers, $reason, $failcount) = dns_test($query, $type, $target, @ARGV); if (defined($bad_servers)) { $err_cnt = $failcount if ($failcount > $err_cnt); ! push(@FailedQuerys, "$query $type") if (!$target); ! push(@FailedQuerys, "$query $type == $target $type") if ($target); push(@FailedServers, $bad_servers); push(@Reasons, $reason); *************** *** 197,201 **** ! # dns_verity($zone, $master, $server, ...) # This subroutine takes 3 or more arguments. The first argument is the name of --- 264,268 ---- ! # dns_verify($zone, \@master, \@Servers) # This subroutine takes 3 or more arguments. The first argument is the name of *************** *** 218,225 **** sub dns_verify { # First verify that we have enough arguments. ! my($Zone, $Master, @Servers) = @_; my($result) = undef; my(@failed, $res, $soa_req, $Serial, $error_cnt, $server); # Query the $Master for the SOA of $Zone and get the serial number. $res = new Net::DNS::Resolver; --- 285,297 ---- sub dns_verify { # First verify that we have enough arguments. ! my($Zone) = shift; ! my(@Master) = @{shift()}; ! my(@Servers) = @{shift()}; my($result) = undef; my(@failed, $res, $soa_req, $Serial, $error_cnt, $server); + my(%serials) = (); + my(%errors) = (); + # Query the $Master for the SOA of $Zone and get the serial number. $res = new Net::DNS::Resolver; *************** *** 227,258 **** $res->defnames(0); # don't append default zone $res->recurse(0); # no recursion ! $res->retry(2); # 2 retries before failure ! $res->nameservers($Master); ! $soa_req = $res->query($Zone, "SOA"); ! if (!defined($soa_req) || ($soa_req->header->ancount <= 0)) { ! return($Master, ! sprintf("SOA query for $Zone from $Master failed %s\n", ! $res->errorstring)); } ! unless ($soa_req->header->aa) { ! return($Master, ! sprintf("$Master is not authoritative for $Zone\n")); } ! unless ($soa_req->header->ancount == 1) { ! return($Master, ! sprintf("Too many answers for SOA query to %s for %s\n", ! $Master, ! $Zone)); } ! unless (($soa_req->answer)[0]->type eq "SOA") { ! return($Master, ! printf("Query for SOA for %s from %s failed: " . ! "return type = %s\n", ! $Zone, ! $Master, ! ($soa_req->answer)[0]->type), ! scalar @Servers); } ! $Serial = ($soa_req->answer)[0]->serial; # Now, foreach server given on the command line, get the serial number from --- 299,380 ---- $res->defnames(0); # don't append default zone $res->recurse(0); # no recursion ! $res->retry($retries); # retries before failure ! $res->retrans($retrans); # retransmission interval ! $res->udp_timeout($timeout); # set udp timeout ! $res->tcp_timeout($timeout); # set tcp timeout ! ! $error_cnt=0; ! ! # Loop through each master server ! foreach my $qs (@Master) { ! $res->nameservers($qs); ! $soa_req = $res->query($Zone, "SOA"); ! if (!defined($soa_req) || ($soa_req->header->ancount <= 0)) { ! $error_cnt++; ! $errors{$qs} = sprintf("SOA query for $Zone from $qs failed %s\n", $res->errorstring); ! if ($res->errorstring eq 'NOERROR') { ! $errors{$qs} .= sprintf(" Empty answer received. (No zone on server?)\n") ! } ! if ($failsingle) { return ($qs, $errors{$qs}, 251); } ! next; ! } ! unless ($soa_req->header->aa) { ! $error_cnt++; ! $errors{$qs} = sprintf("$qs is not authoritative for $Zone\n"); ! if ($failsingle) { return ($qs, $errors{$qs}, 251); } ! next; ! } ! unless ($soa_req->header->ancount == 1) { ! $error_cnt++; ! $errors{$qs} = sprintf("Too many answers for SOA query to %s for %s\n", $qs, $Zone); ! if ($failsingle) { return ($qs, $errors{$qs}, 251); } ! next; ! } ! unless (($soa_req->answer)[0]->type eq "SOA") { ! $error_cnt++; ! $errors{$qs} = printf("Query for SOA for %s from %s failed: " . "return type = %s\n", $Zone, $qs, ($soa_req->answer)[0]->type); ! if ($failsingle) { return ($qs, $errors{$qs}, 251); } ! next; ! } ! ! $serials{$qs} = ($soa_req->answer)[0]->serial; } ! ! ! if ($debug >= 2) { ! print Data::Dumper->Dump([\%serials], ['serials']); } ! ! ! if ($error_cnt == scalar @Master) { ! # all masters errored ! return("", values %errors, 251); } ! ! my $maxvalue = undef; ! my $minvalue = undef; ! my $maxkey = undef; ! my $minkey = undef; ! ! foreach my $key (keys %serials) { ! if ($serials{$key} > $maxvalue) { ! $maxvalue = $serials{$key}; ! $maxkey = $key; ! } ! ! if (($serials{$key} < $minvalue) || (!defined $minkey)) { ! $minvalue = $serials{$key}; ! $minkey = $key; ! } ! } ! ! if (abs($maxvalue - $minvalue) > $SerialThreshold) { ! return ($minkey, "\nQuery to $minkey about $Zone failed\n" . ! "Serial number = $minvalue, should have been $maxvalue\n", 252) } ! ! $Serial = $maxvalue; ! ! return ("", "\nNo SOA Serial found for $Zone!?!?", 252) if (!$Serial); # Now, foreach server given on the command line, get the serial number from *************** *** 264,268 **** $res->defnames(0); # don't append default zone $res->recurse(0); # no recursion ! $res->retry(2); # 2 retries before failure $res->nameservers($server); $soa_req = $res->query($Zone, "SOA"); --- 386,394 ---- $res->defnames(0); # don't append default zone $res->recurse(0); # no recursion ! $res->retry($retries); ! $res->retrans($retrans); ! $res->udp_timeout($timeout); ! $res->tcp_timeout($timeout); ! $res->nameservers($server); $soa_req = $res->query($Zone, "SOA"); *************** *** 272,281 **** $result .= sprintf("\nSOA query for $Zone from $server failed %s\n", $res->errorstring); next; } ! unless(($soa_req->header->aa || $CachingServer) && $soa_req->header->ancount == 1 && ! ($soa_req->answer)[0]->type eq "SOA" && ! ((abs(($soa_req->answer)[0]->serial - $Serial)) ! <= $SerialThreshold)) { $error_cnt++; push(@failed, $server); --- 398,410 ---- $result .= sprintf("\nSOA query for $Zone from $server failed %s\n", $res->errorstring); + if ($res->errorstring eq 'NOERROR') { + $result .= sprintf(" Empty answer received. (No zone on server?)\n"); + } next; } ! unless($soa_req->header->aa ! && $soa_req->header->ancount == 1 ! && ($soa_req->answer)[0]->type eq "SOA" ! && ((abs(($soa_req->answer)[0]->serial - $Serial)) <= $SerialThreshold)) { $error_cnt++; push(@failed, $server); *************** *** 301,310 **** ! # dns_test($query, $type, $server, ...) ! # This subroutine takes 3 or more arguments. The first argument is the name of # the DNS record to query. The second argument is the type of the DNS ! # query to perform. The third and rest of the arguments are taken as ! # names of caching DNS servers. Each server will be queried for the # given record and type --- 430,440 ---- ! # dns_test($query, $type, $target, $server, ...) ! # This subroutine takes 4 or more arguments. The first argument is the name of # the DNS record to query. The second argument is the type of the DNS ! # query to perform. The third argument is the name of a second DNS record to query, ! # whose results should match the first query. The fourth and rest of the arguments are ! # taken as names of caching DNS servers. Each server will be queried for the # given record and type *************** *** 317,323 **** sub dns_test { # First verify that we have enough arguments. ! my($Query, $Master, @Servers) = @_; my($result) = undef; ! my(@failed, $res, $soa_req, $Serial, $error_cnt, $server); # Now, foreach server given on the command line, --- 447,453 ---- sub dns_test { # First verify that we have enough arguments. ! my($Query, $type, $target, @Servers) = @_; my($result) = undef; ! my(@failed, $res, $req, $treq, $Serial, $error_cnt, $server); # Now, foreach server given on the command line, *************** *** 325,347 **** $error_cnt = 0; foreach $server (@Servers) { ! $res = new Net::DNS::Resolver; ! $res->usevc(1) if ($UseTCP); ! $res->defnames(0); # don't append default zone ! $res->recurse(0); # no recursion ! $res->retry(2); # 2 retries before failure ! $res->nameservers($server); ! $soa_req = $res->query($Query, $type); ! if (!defined($soa_req) || ($soa_req->header->ancount <= 0)) { ! $error_cnt++; ! push(@failed, $server); ! $result .= sprintf("\n$type query for $Query from $server failed %s\n", ! $res->errorstring); ! next; ! } ! } if ($error_cnt == 0) { ! return(undef, undef, undef); } else { ! return("@failed", $result, $error_cnt); } } --- 455,519 ---- $error_cnt = 0; foreach $server (@Servers) { ! $res = new Net::DNS::Resolver; ! $res->defnames(0); # don't append default zone ! $res->retry($retries); # 2 retries before failure ! $res->retrans($retrans); ! $res->udp_timeout($timeout); ! $res->tcp_timeout($timeout); ! $res->nameservers($server); ! $req = $res->query($Query, $type); ! if (!defined($req) || ($req->header->ancount <= 0)) { ! $error_cnt++; ! push(@failed, $server); ! $result .= sprintf("\n$type query for $Query from $server failed %s\n", ! $res->errorstring); ! next; ! } elsif ($target) { ! $treq = $res->query($target, $type); ! my $status = 0; ! foreach my $qans ($req->answer) { ! print STDERR $qans->string."\n" if ($debug); ! print STDERR $qans->rdatastr."\n" if ($debug); ! foreach my $tans ($treq->answer) { ! print STDERR "target\n" if ($debug); ! print STDERR $tans->string."\n" if ($debug); ! print STDERR $tans->rdatastr."\n" if ($debug); ! if ($tans->rdatastr eq $qans->rdatastr) { ! print STDERR "match found\n" if ($debug); ! $status = 1; ! last; ! } ! } ! last if ($status); ! } ! if (!$status) { ! $error_cnt++; ! push @failed, $server; ! $result .= "Query $Query:$type failed to match $target\n"; ! } ! } ! } if ($error_cnt == 0) { ! return(undef, undef, undef); } else { ! return("@failed", $result, $error_cnt); } } + + sub usage { + print STDERR <<END_USAGE; + Usage: dns.monitor -zone zone [-zone zone ...] + -master master + [-serial_threshold num] + server [server ...] + or: dns.monitor -caching_only + -query record[:type] [-query record[:type] ...] + server [server ...] + Optional Arguments for either mode: + -retry num + -retransmit num + -timeout num + -debug num + + END_USAGE + } |
|
From: David N. <vi...@us...> - 2006-09-01 11:51:39
|
Update of /cvsroot/mon/mon-contrib/monitors/tftp In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv3092 Added Files: tftp.monitor.README Log Message: oops, never commited the readme --- NEW FILE: tftp.monitor.README --- # This TFTP test script will attempt to fetch a file from a tftp server, # and will verify it receives a non-empty file. # # Requires Net::TFTP # # Arguments: '-f filename hostname [...]' # # Author: David Nolan, Carnegie Mellon University, Computing Services # Contact: ne...@an... |