mon-commit Mailing List for mon (Page 9)
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: David N. <vi...@us...> - 2005-07-31 16:20:22
|
Update of /cvsroot/mon/mon In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2976 Modified Files: mon Log Message: Finished code for views internal to mon. Changed some debugging output. Slight timing change for scheduling of the next monitor test. Index: mon =================================================================== RCS file: /cvsroot/mon/mon/mon,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** mon 28 Apr 2005 20:00:48 -0000 1.15 --- mon 31 Jul 2005 16:20:02 -0000 1.16 *************** *** 130,133 **** --- 130,134 ---- my %groups; # hostgroups, indexed by group my %views; # view lists, indexed by name + my %view_users; # view preferences, per user # *************** *** 337,342 **** # load_auth (1); ! #%view_users=(); ! #load_view_users(1); # --- 338,342 ---- # load_auth (1); ! load_view_users(1); # *************** *** 1169,1172 **** --- 1169,1173 ---- $inwatch = 0; $period = 0; + $inview = 0; $curgroup = ""; *************** *** 1258,1262 **** # view record # ! if ($l =~ /^view\s+([a-zA-Z0-9_.-]+)\s*$/) { $inview = 1; --- 1259,1263 ---- # view record # ! if ($l =~ /^view\s+([a-zA-Z0-9_.-]+)\s+(.*)$/) { $inview = 1; *************** *** 1268,1271 **** --- 1269,1276 ---- $curview = $1; $new_views{$curview}={}; + + foreach (split(/\s+/, $2)) { + $new_views{$curview}->{$_} = 1; + }; next; } *************** *** 1273,1281 **** if ($inview) { ! if ($l =~ /\A(.*)\Z/) ! { ! $new_views{$curview}->{$1}=1; ! next; ! } } --- 1278,1285 ---- if ($inview) { ! foreach (split(/\s+/, $l)) { ! $new_views{$curview}->{$_} = 1; ! }; ! next; } *************** *** 2158,2169 **** if ($l !~ /^(dump|login|disable|enable|quit|list|set|get|setview|getview| stop|start|loadstate|savestate|reset|clear|checkauth| ! reload|term|test|servertime|ack|version|protid)\s*(.*)?$/ix) { sock_write ($fh, "520 invalid command\n"); return; } ! ($cmd, $args) = ("\L$1", $2); $stchanged = 0; # # quit command --- 2162,2174 ---- if ($l !~ /^(dump|login|disable|enable|quit|list|set|get|setview|getview| stop|start|loadstate|savestate|reset|clear|checkauth| ! reload|term|test|servertime|ack|version|protid)(\s+(.*))?$/ix) { sock_write ($fh, "520 invalid command\n"); return; } ! ($cmd, $args) = ("\L$1", $3); $stchanged = 0; + print STDERR "client command $cmd\nclient args $args\n"; # # quit command *************** *** 2780,2783 **** --- 2785,2797 ---- } + # + # list available views + # + } elsif ($cmd eq "views") { + sock_write ($fh, "views ".join(' ',sort(keys %views))."\n"); + sock_write ($fh, "220 list group completed\n"); + + + # unknown list command } else { sock_write ($fh, "520 unknown list command\n"); *************** *** 2967,2971 **** } else { ! sock_write ($fh, "520 command could not be executed\n"); } --- 2981,2985 ---- } else { ! sock_write ($fh, "520 command could not be executed, unknown command\n"); } *************** *** 3609,3622 **** } ! if (!$sref->{"_next_check"}) ! { ! $sref->{"_next_check"} = ! $sref->{"_last_check"} + $sref->{"interval"}; ! } ! ! else { $sref->{"_next_check"} += $sref->{"interval"}; } } --- 3623,3636 ---- } ! if ($sref->{"_next_check"}) { $sref->{"_next_check"} += $sref->{"interval"}; + } else { + $sref->{"_next_check"} = time() + $sref->{"interval"}; } + + + + } *************** *** 4084,4099 **** } ! sub load_views {} sub view_match { ! my ($view, $group, $service); ! return 1 unless (defined($view)); ! ! return 1 if (defined($views{$view}->{$group})); ! if (not defined($service)) { ! return defined($views{$view}->{$service.":*"}); } - return defined($views{$view}->{$service.":".$group}); } --- 4098,4119 ---- } ! sub load_view_users {} sub view_match { ! my ($view, $group, $service) = @_; ! if (!defined($view)) { ! # print STDERR "No view in use\n"; ! return 1; } + if (defined($group) && defined($views{$view}->{$group})) { + # print STDERR "View $view contains $group\n"; + return 1; + } + if (defined($views{$view}->{$group.":".$service})) { + # print STDERR "View $view contains $group:$service\n"; + return 1; + } + return 0; } *************** *** 5104,5108 **** sub depend { my ($depend, $depth, $deptype) = @_; ! debug (1, "checking DEP [$depend]\n"); if ($depth > $CF{"DEP_RECUR_LIMIT"}) { --- 5124,5128 ---- sub depend { my ($depend, $depth, $deptype) = @_; ! debug (2, "checking DEP [$depend]\n"); if ($depth > $CF{"DEP_RECUR_LIMIT"}) { *************** *** 5145,5149 **** if ($subdepend eq "") { ! debug (1, " found root dep $group,$service\n"); $depval = $SUCCESS{$sref->{"_op_status"}} && ($sref->{"_last_failure_time"} < (time - $sref->{"dep_memory"})); --- 5165,5169 ---- if ($subdepend eq "") { ! debug (2, " found root dep $group,$service\n"); $depval = $SUCCESS{$sref->{"_op_status"}} && ($sref->{"_last_failure_time"} < (time - $sref->{"dep_memory"})); *************** *** 5159,5163 **** # my $dstatus = depend ($subdepend, $depth + 1, $deptype); ! debug (1, "recur depth $depth returned $dstatus->{status},$dstatus->{depend}\n"); --- 5179,5183 ---- # my $dstatus = depend ($subdepend, $depth + 1, $deptype); ! debug (2, "recur depth $depth returned $dstatus->{status},$dstatus->{depend}\n"); *************** *** 5167,5171 **** if ($dstatus->{"status"} ne "O") { ! debug (1, "recursive dep failure for $group,$service (status=$dstatus->{status})\n"); return $dstatus; --- 5187,5191 ---- if ($dstatus->{"status"} ne "O") { ! debug (2, "recursive dep failure for $group,$service (status=$dstatus->{status})\n"); return $dstatus; *************** *** 5177,5188 **** my $v = int ($depval); ! debug (1, " ($group,$service) $depth depend=[$v][$depend]"); $depend =~ s/\b$depstr\b/$v/g; ! debug (1, " depend=[$depend]\n"); } ! debug (1, " before eval: [$depend]"); my $e = eval("$DEP_EVAL_SANDBOX $depend"); ! debug (1, " after eval: [$e]\n"); if ($@ eq "") --- 5197,5208 ---- my $v = int ($depval); ! debug (2, " ($group,$service) $depth depend=[$v][$depend]"); $depend =~ s/\b$depstr\b/$v/g; ! debug (2, " depend=[$depend]\n"); } ! debug (2, " before eval: [$depend]"); my $e = eval("$DEP_EVAL_SANDBOX $depend"); ! debug (2, " after eval: [$e]\n"); if ($@ eq "") *************** *** 5231,5235 **** if ($s->{"status"} eq "D") { ! debug (1, "dep recursion too deep\n"); return undef; --- 5251,5255 ---- if ($s->{"status"} eq "D") { ! debug (2, "dep recursion too deep\n"); return undef; |
From: David N. <vi...@us...> - 2005-07-31 15:49:35
|
Update of /cvsroot/mon/mon/doc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29200 Modified Files: mon.8 Log Message: Clarified the meaning of some variables passed to alert scripts. Added redistribute documentation. Index: mon.8 =================================================================== RCS file: /cvsroot/mon/mon/doc/mon.8,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** mon.8 17 Apr 2005 07:42:27 -0000 1.4 --- mon.8 31 Jul 2005 15:49:23 -0000 1.5 *************** *** 284,294 **** .TP .B MON_LAST_SUMMARY ! The first line of the output from the last time the ! monitor exited. .TP .B MON_LAST_OUTPUT ! The entire output of the monitor from the last time it ! exited. .TP --- 284,299 ---- .TP .B MON_LAST_SUMMARY ! The first line of the output from the last time the monitor exited. ! This is not the summary of the current monitor run, but the previous ! one. This may be used by an alert script to provide historical ! context in an alert. .TP .B MON_LAST_OUTPUT ! The entire output of the monitor from the last time it exited. This ! is not the output of the current monitor run, but the previous one. ! This may be used by an alert script to provide historical context in ! an alert. ! .TP *************** *** 1181,1185 **** .TP ! .BI "dep_memory = " timeval If set, dep_memory will cause dependencies to continue to prevent alerts/monitoring for a period of time after the service returns to a --- 1186,1190 ---- .TP ! .BI "dep_memory " timeval If set, dep_memory will cause dependencies to continue to prevent alerts/monitoring for a period of time after the service returns to a *************** *** 1191,1194 **** --- 1196,1210 ---- .IR timeval . + .TP + .BI redistribute " alert [arg...]" + A service may have one redistribute option, which is a special form of an + an alert definition. This alert will be called on every service status + update, even sequential success status updates. This can be used to + integrate Mon with another monitoring system, or to link together multiple + Mon servers via an alert script that generates Mon traps. See the "ALERT + PROGRAMS" section above for a list of the parameters mon will pass + automatically to alert programs. + + .SS "Period Definitions" |
From: Jim T. <tr...@us...> - 2005-06-29 15:36:23
|
Update of /cvsroot/mon/mon-contrib/monitors/citrix In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13209/monitors/citrix Added Files: citrix.monitor Log Message: Date: Tue, 28 Jun 2005 17:32:38 +0200 From: Jeroen Moors <Je...@Ho...> To: mo...@li... Subject: Citrix monitor Hi list, We have some citrix servers over here we want to monitor. Below you can find the code of our citrix.monitor Jeroen --- NEW FILE: citrix.monitor --- #!/usr/bin/perl -w # # try to connect to a citrix server and wait for the ica prompt. # # Arguments are "host [host...]" # # Jeroen Moors, Jer...@Ce... # # Copyright (C) 2005, Jeroen Moors # # 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 Getopt::Std; use Socket; my %opt; getopts ("t:", \%opt); my $PORT = 1494; my $TIMEOUT = $opt{"t"} || 10; my @failures = (); my @detail = (); my $ALARM = 0; foreach my $host (@ARGV) { my $pro = getprotobyname ('tcp'); if (!defined $pro) { die "could not getprotobyname\n"; } if (!defined socket (S, PF_INET, SOCK_STREAM, $pro)) { die "could not create socket: $!\n"; } my $a = inet_aton ($host); if (!defined $a) { push @failures, $host; push @detail, "$host could not inet_aton"; close (S); next; } my $sin = sockaddr_in ($PORT, $a); if (!defined $sin) { push @failures, $host; push @detail, "$host could not sockaddr_in"; close (S); next; } my $r; eval { local $SIG{"ALRM"} = sub { die "alarm\n" }; alarm $TIMEOUT; $r = connect (S, $sin); my $return_string; while (my $char = getc(S)) { $return_string .= $char; if ( $return_string =~ /ICA/) { alarm 0; last; } } }; if ($@) { push @failures, $host; if ($@ eq "alarm\n") { push @detail, "$host timeout"; } else { push @detail, "$host interrupted syscall: $!"; } close (S); next; } if (!defined $r) { push @failures, $host; push @detail, "$host could not connect: $!"; close (S); next; } if (!defined close (S)) { push @failures, $host; push @detail, "$host could not close socket: $!"; next; } } if (@failures == 0) { exit 0; } print join (" ", sort @failures), "\n"; print "\n", join ("\n", @detail), "\n"; exit 1; |
From: Jim T. <tr...@us...> - 2005-06-29 15:35:31
|
Update of /cvsroot/mon/mon-contrib/monitors/citrix In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12640/citrix Log Message: Directory /cvsroot/mon/mon-contrib/monitors/citrix added to the repository |
From: Jim T. <tr...@us...> - 2005-06-03 12:39:59
|
Update of /cvsroot/mon/mon-contrib/monitors/raid In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14923/monitors/raid Added Files: softraid.monitor Log Message: linux software raid monitor --- NEW FILE: softraid.monitor --- #!/bin/bash # softraid.monitor # Linux Software RAID check with mon compatible output/return values # Call without arguments. # The reference file $md_ref must exist. To generate it: # softraid.monitor learn # [ cat /proc/mdstat > /path/to/dir/mdstat.reference ] # no administrative permissions needed for this script. # Return values: 3 /proc/mdstat missing, no Software RAID? # 2 reference file missing # 1 RAID not okay # 0 alles okay # # Date: Thu, 07 Apr 2005 17:28:02 +0200 # From: Kevin Ivory <Iv...@Se...> # To: mo...@li... # Subject: Re: Monitoring software raid? # mdstat="/proc/mdstat" # THIS NEEDS TO BE SOMEWHERE THE CHECKING USER CAN WRITE md_ref="/var/something/mdstat.reference" if [ ! -r "$mdstat" ]; then echo -e "$HOSTNAME:$0 Missing RAID status file: $mdstat Perhaps no software RAID?" exit 3 fi if [ "$1" = "learn" ]; then cat "$mdstat" > "$md_ref" fi if [ ! -r "$md_ref" ]; then echo -e "$HOSTNAME:$0 Missing RAID reference file: $md_ref Generate with: $0 learn > $md_ref" exit 2 fi md_out="Complete contents of $mdstat:\n\n$(cat $mdstat)" diff=$(diff -u -U 0 $md_ref $mdstat) stat=$? if [ $stat -eq 0 ]; then echo -e "$HOSTNAME\nSoftware RAID ok:\n$md_out" else echo -e "$HOSTNAME\nSoftware RAID not ok:\n$diff\n\n$md_out" exit 1 fi # end of softraid.monitor |
From: Jim T. <tr...@us...> - 2005-05-29 13:35:11
|
Update of /cvsroot/mon/mon-contrib/monitors/raid In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22102/raid Log Message: Directory /cvsroot/mon/mon-contrib/monitors/raid added to the repository |
From: Jim T. <tr...@us...> - 2005-05-02 12:24:14
|
Update of /cvsroot/mon/mon-contrib/alerts/sms/sms In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11752/sms/sms Added Files: sms.alert Log Message: added Peter Holzleitner's sms alerts. his sms.alert conflicted in name with the existing sms.alert (which calls gnokii instead of sendsms), so i plopped peter's in its own directory called just sms --- NEW FILE: sms.alert --- #!/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.H...@co... # Jim Trocki, tr...@tr... # # 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=<STDIN>; $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; } |
From: Jim T. <tr...@us...> - 2005-05-02 12:23:58
|
Update of /cvsroot/mon/mon-contrib/alerts/sms/sendsms In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11752/sms/sendsms Added Files: sendsms Log Message: added Peter Holzleitner's sms alerts. his sms.alert conflicted in name with the existing sms.alert (which calls gnokii instead of sendsms), so i plopped peter's in its own directory called just sms --- NEW FILE: sendsms --- #!/usr/bin/perl # ############################################################################ ## ## ## sendsms Version 1.5.0 ## ## 2005-02-01 ## ## Copyright (C) 1999-2005 ## ## Peter Holzleitner (pe...@ho...) ## ## ## ############################################################################ # # This script sends an SMS message to a GSM phone using a GSM # modem connected to the local host. This is independent of the # GSM provider in question and does not rely on any infrastructure # except the GSM network itself and the local host and modem. # # Arguments: # # --number=+436641234567 # [--modem=ttyS3] specify without /dev/ prefix # [--pin=9999] # [--text="message text"] supply message text as cmdline arg # [--subject] extract subject from mail msg on stdin # [--qpage=pagerid@server] if SMS fails, send message via QPAGE # [--verbose] show interaction with modem step by step # [--debug] set Expect debug level # # The message text is expected on standard input unless --text is present. # # Requirements: # # Perl modules Expect, IO::Stty and IO::Tty, # available from CPAN (http://www.cpan.org) # # License: # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; 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.0 on error, register on home network (Erik B.) # 1.3.0 added fallback to qpage # 1.2.3 added delays for compatibility with Siemens modem # 1.2.2 locking converted to sysopen(); syslog() added # 1.2.1 message corrections # 1.2.0 device locking added # 1.1.0 addition of --subject option # 1.0.0 initial release; tested with FALCOM A2 # use English; use Getopt::Long; use Fcntl qw(:DEFAULT :flock); use IO::Handle; use Expect; use Sys::Syslog qw(:DEFAULT setlogsock); # ################# user configurable parameters ###################### $stdpin = "9999"; $stddev = "ttyS0"; # without /dev/ $ttymodes = 'raw -echo 9600 cs8 -parenb -cstopb'; # raw, 9600/8N1 $lockretry = 20; # number of retries $locksleep = 5; # number of seconds between retries $lockrand = 5; # max number of seconds added to above randomly $qpagebin = '/usr/bin/qpage'; # ############## end of user configurable parameters ################## ($^O eq "linux" || $^O eq "openbsd") && setlogsock ('unix'); openlog('sendsms', '', 'user'); GetOptions(\%opt, "modem=s", "number=s", "pin=s", "text=s", "qpage=s", "debug:i", "subject", "verbose"); $pin = $opt{"PIN"} || $stdpin; $device = $opt{"modem"} || $stddev; $verbose = $opt{"verbose"}; $qpage = $opt{"qpage"}; ($qpserver, $qpager) = ($2, $1) if $qpage =~ /(.+)@(.+)/; $lock = "/var/lock/LCK.." . $device; $device = "/dev/" . $device; $name = getpwent(); $expectpin = 0; $Expect::Debug = $opt{"debug"}; # default 0 assigned by getopt ":i" $Expect::Manual_Stty = 1; $Expect::Log_Stdout = 1; $number = $opt{"number"} or die "usage: sendsms --number=destination-number [--modem=/dev/modem] [--pin=9999] [--text=\"message\"] [--verbose] < message\n"; $number = '"' . $number . '"'; if($opt{"text"}) { $message = $opt{"text"}; } elsif($opt{"subject"}) { $message = '(no subject)'; while(<>) { $message = $1 if /^Subject: (.*)$/i; } print STDERR "MAIL mode: message=$message\n" if $verbose; } else { @message = <>; $message = join '', @message; } syslog('debug', "sending \"$message\" to $number"); eval { print STDERR "SENDSMS: sending \"$message\" to $number\n\n" if $verbose; print STDERR "Checking for Lock $lock ...\n" if $verbose; $retry = $lockretry; while($retry > 0 && -e $lock) { open(LOCK, "<$lock"); $line = <LOCK>; close(LOCK); $pid = ""; $pid = $1 if $line =~ /([0-9]+)/; $ERRNO = 0; $prio = getpriority(PRIO_PROCESS, $pid); if(($pid eq "") || ($ERRNO != 0)) { # process doesn't exist anymore syslog('warning', "Lock $lock by PID $pid is stale, removing"); print STDERR "Lock $lock by PID $pid is stale, removing ...\n" if $verbose; unlink($lock); next; } # valid lock, wait for removal $secs = $locksleep + int(rand($lockrand)); syslog('warning', "Lock $lock held by PID $pid, waiting $secs s ($retry)"); print STDERR "Lock $lock held by PID $pid, waiting $secs s ($retry) ...\n" if $verbose; sleep($secs); $retry--; } if ( -e $lock ) { syslog('error', "cannot get lock $lock"); die "cannot get lock $lock"; } print STDERR "Obtaining Lock $lock ... " if $verbose; sysopen(LOCK, $lock, O_WRONLY|O_CREAT|O_EXCL) or die "cannot create lock $lock"; syswrite(LOCK, "$PID $PROGRAM_NAME $name\n"); print STDERR "done\n" if $verbose; print STDERR "Opening $device ... " if $verbose; open(DEVICE, "+>$device") || die "Couldn't open $device, $!\n"; $modem = Expect->exp_init(\*DEVICE); # 'objectify' device for Expect module print STDERR "OK\nSetting device mode ..." if $verbose; $res = $modem->exp_stty($ttymodes) or die "error setting tty mode"; # throw residual input characters away $modem->expect(0); print $modem "\r"; select(undef, undef, undef, 0.2); print $modem "AT\r"; select(undef, undef, undef, 0.5); print STDERR "OK\n" if $verbose; print $modem "ATS18=1\r"; select(undef, undef, undef, 0.5); print STDERR "testing PIN ... " if $verbose; print $modem "AT+CPIN?\r"; $res = $modem->expect(10, 'CPIN: READY', 'CPIN: SIM') || die "AT+CPIN?: no response!\n"; if($res == 2) # expects SIM PIN { $expectpin = 1; print STDERR "sending PIN ...\n" if $verbose; print $modem "AT+CPIN=$pin\r"; ($res, $err, $match, $before, $after) = $modem->expect(10, 'OK', '+CME ERROR') || die "AT+CPIN=****: no response!\n"; die "error sending PIN code: $after" if $res != 1; print STDERR "PIN sent, waiting for network ...\n" if $verbose; sleep(30); # let modem register on SMS network after setting PIN } else { print STDERR "PIN OK\n" if $verbose; } print STDERR "checking network ... " if $verbose; print $modem "AT+CREG?\r"; $res = $modem->expect(10, '+CREG: 0,1', '+CREG: 0,2', '+CREG: 0,0', '+CME ERROR') || die "AT+CREG?: no response!\n"; if($res != 1) { print STDERR "error from AT+CREG" if $verbose; if($expectpin == 1) { print STDERR "re-setting PIN\n" if $verbose; print $modem "AT+CPIN=$pin\r"; print STDERR "delaying ...\n" if $verbose; sleep(20); } print STDERR "trying to register on home network\n" if $verbose; print $modem "AT+COPS=0\r"; $res = $modem->expect(10, 'OK', '+CME ERROR') || die "AT+COPS=0: no response!\n"; print STDERR "delaying ...\n" if $verbose; sleep(6); print STDERR "re-checking network ... " if $verbose; print $modem "AT+CREG?\r"; $res = $modem->expect(10, '+CREG: 0,1', '+CREG: 0,2', '+CREG: 0,0', '+CME ERROR') || die "AT+CREG?: no response!\n"; die "error from AT+CREG?: $after" if $res == 3 || res == 4; die "GSM modem not registered on network" if $res != 1; } print STDERR "OK, online\n" if $verbose; print STDERR "checking SMS status ... " if $verbose; print $modem "AT+CSMS?\r"; $res = $modem->expect(10, '+CSMS: 0,1,1', '+CME ERROR') || die "AT+CSMS?: no response!\n"; die "error from AT+CSMS?: $after" if $res != 1; print STDERR "OK, SMS active\n" if $verbose; print STDERR "setting SMS text mode ... " if $verbose; print $modem "AT+CMGF=1\r"; $res = $modem->expect(10, 'OK', 'ERROR') || die "AT+CMGF=1: no response!\n"; die "error from AT+CMGF=1: $after" if $res != 1; print STDERR "OK\n" if $verbose; select(undef, undef, undef, 1.0); print STDERR "sending message ... " if $verbose; #$modem->debug(2); print $modem "AT+CMGS=$number\r"; $res = $modem->expect(60, '> ') || die "AT+CMGS=...: no prompt!\n"; select(undef, undef, undef, 0.5); print $modem "$message\032"; # \032 = 0x1A = ^Z $res = $modem->expect(60, '-re', '\+CMGS: [0-9]+', 'ERROR') || die "AT+CMGS=...: no response!\n"; die "error from AT+CMGS=..." if $res != 1; #$modem->debug(0); $match = $modem->exp_match(); $match =~ /CMGS: ([0-9]+)/; # extract sent message number print STDERR "OK, Message #$1 sent\n" if $verbose; syslog('info', "Message sent successfully to $number: \"$message\""); print STDERR "Closing\n" if $verbose; $modem->expect(0); # throw rest of output away $modem->hard_close(); # bye. print STDERR "Removing Lock $lock ... " if $verbose; close(LOCK); unlink($lock); }; # end eval{} if($@) { syslog('warning', "SENDSMS to $number failed"); if( $qpager ) { syslog('warning', "forwarding message to QPAGE"); print STDERR "\nSENDSMS failed, forwarding message to QPAGE\n" if $verbose; system("$qpagebin -s $qpserver -p $qpager '$message'"); } } print STDERR "$@" if $verbose; print STDERR "done.\n" if $verbose; exit 0; |
From: Jim T. <tr...@us...> - 2005-05-02 12:21:23
|
Update of /cvsroot/mon/mon-contrib/alerts/sms/sms In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11405/sms Log Message: Directory /cvsroot/mon/mon-contrib/alerts/sms/sms added to the repository |
From: Jim T. <tr...@us...> - 2005-05-02 12:01:35
|
Update of /cvsroot/mon/mon-contrib/alerts/sms/sendsms In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7310/sendsms Log Message: Directory /cvsroot/mon/mon-contrib/alerts/sms/sendsms added to the repository |
From: Jim T. <tr...@us...> - 2005-05-02 12:00:03
|
Update of /cvsroot/mon/mon-contrib/monitors/netware/netwarefree In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6937 Modified Files: netwarefree.monitor Added Files: CHANGES README Removed Files: netwarefree.README Log Message: updated netwarefree.monitor to 1.2.0 --- NEW FILE: README --- Quick Start: Make sure SERVINST.NLM is loaded on Novell server Make sure you have UCD SNMP 3.6.2+ and the Perl SNMP module installed Copy netwarefree.mon to your mon.d directory Copy netwarefree.cf to /etc/mon and edit to match your needs Test from mon.d directory with ./netwarefree.monitor -l host1 host2 ... Add watch/service to mon.cf, using netwarefree.monitor Common commandline options: --config=/path/to/netwarefree.cf if neither /etc/mon nor /usr/lib/mon/etc --community=your_SNMP_read_community if not 'public' Basic Troubleshooting: use netwarefree.monitor --list option to see variable values use snmpwalk your_hostname public .1 | less to verify SNMP agent Index: netwarefree.monitor =================================================================== RCS file: /cvsroot/mon/mon-contrib/monitors/netware/netwarefree/netwarefree.monitor,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** netwarefree.monitor 18 Feb 2005 17:52:23 -0000 1.1.1.1 --- netwarefree.monitor 2 May 2005 11:59:50 -0000 1.2 *************** *** 1,44 **** #!/usr/bin/perl # ! # netwarefree.monitor # ! # Use SNMP to get free disk space from a Novell NetWare server. # ! # Exits with value of 1 if free space on any host drops below ! # the configured value, or exits with the value of 2 if ! # there is a "soft" error (SNMP library error, or could not get a ! # response from the server). # # Requirements: # ! # Requires the UCD SNMP library and G.S. Marzot's Perl SNMP module. ! # (Avoid UCSD SNMP 3.6.1, it will cause segfaults. Use 3.6.2+) # ! # The NetWare server needs to have the SERVINST.NLM loaded, which is ! # the SNMP extension implementing the Netware-Server-MIB. # (Version 1.00 of SERVINST.NLM has a 4GB overflow problem; upgrade # to 1.01 dated 2/12/98, contained in Novell patch mwnma4a.exe, or higher.) # # Written by Peter Holzleitner ! # based heavily on netappfree.monitor by Jim Trocki # - # Copyright (C) 1999, 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 # use SNMP; use Getopt::Long; --- 1,85 ---- #!/usr/bin/perl # ! ##################################################################### ! ## ## ! ## netwarefree.monitor Version 1.2.0 ## ! ## 2001-03-28 ## ! ## Copyright (C) 2000-2001 ## ! ## Peter Holzleitner (pe...@ho...) ## ! ## ## ! ##################################################################### # ! # Synopsis: # ! # Uses SNMP to check available disk space on Novell NetWare servers. ! # ! # Exits with value of 1 if available space on any host drops below ! # the configured value, or exits with the value of 2 if there is a ! # connection or configuration error. # # Requirements: # ! # Requires the UCD SNMP library (3.6.2 or higher) ! # and G.S. Marzot's Perl SNMP module (from CPAN). # ! # The NetWare server needs to have the SERVINST.NLM loaded, which ! # is the SNMP agent extension implementing the Netware-Server-MIB. # (Version 1.00 of SERVINST.NLM has a 4GB overflow problem; upgrade # to 1.01 dated 2/12/98, contained in Novell patch mwnma4a.exe, or higher.) # + # + # Arguments: + # + # [--community=cmn] [--timeout=n] [--retries=n] + # [--config=configfile] [--list[=linesperpage]] serverlist + # + # For every host name passed on the command line, netwarefee.monitor + # walks the nwFSVolTable MIB subtree and compares the amount of available + # space (available := free + freeable) to the values configured in + # netwarefree.cf. + # + # This monitor looks for configuration files in the current directory, + # in /etc/mon and /usr/lib/mon/etc. Command line option --config + # overrides the location of the configuration file. + # + # For the configuration file format, please refer to the sample file. + # + # When invoked with the --list option, the output format is changed + # into a more human-readable form used to check and troubleshoot the + # configuration. This option must not be used from within MON as + # no status and summary output are provided. + # + # # Written by Peter Holzleitner ! # (originally based on netappfree.monitor by Jim Trocki) # # ! # History: # ! # 1.2.0 28 Mar 2001 P.H. MIB no longer needed; extended error checking ! # 1.1.0 27 Jan 2000 P.H. initial public release ! # 1.0.0 15 Jan 2000 P.H. internal test version ! # ! # ! # License: ! # ! # This program is free software; you can redistribute it and/or modify ! # it under the terms of the GNU General Public License as published by ! # the Free Software Foundation; 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 SNMP; + use English; use Getopt::Long; *************** *** 47,54 **** sub toKB; ! # load only the necessary MIBs: ! $ENV{"MIBS"} = 'RFC1213-MIB:HOST-RESOURCES-MIB:NetWare-Server-MIB'; ! GetOptions (\%opt, "community=s", "timeout=i", "retries=i", "config=s", "list"); die "no host arguments\n" if (@ARGV == 0); --- 88,96 ---- sub toKB; ! # no MIB needed, we're using numeric OIDs ! $ENV{"MIBS"} = ''; ! GetOptions (\%opt, "community=s", "timeout=i", "retries=i", "config=s", ! "list:i", "debug"); die "no host arguments\n" if (@ARGV == 0); *************** *** 58,120 **** @HOSTS = (); ! $COMM = $opt{"community"} || "public"; ! $TIMEOUT = $opt{"timeout"} * 1000 * 1000 || 2000000; ! $RETRIES = $opt{"retries"} || 5; ! $CONFIG = $opt{"config"} || (-d "/etc/mon" ? "/etc/mon" : "/usr/lib/mon/etc") ! . "/netwarefree.cf"; ! list (@ARGV) if ($opt{"list"}); ($nwID, $nwName, $nwSize, $nwFree, $nwFreeable) = (0..4); readcf ($CONFIG) || die "could not read config: $!\n"; foreach $host (@ARGV) { ! next if (!defined $FREE{$host}); if (!defined($s = new SNMP::Session (DestHost => $host, Timeout => $TIMEOUT, Community => $COMM, Retries => $RETRIES))) { ! $RET = ($RET == 1) ? 1 : 2; push (@HOSTS, $host); ! push (@ERRS, "could not create session to $host: " . $SNMP::Session::ErrorStr); next; ! } $v = new SNMP::VarList ( ! ['nwVolID'], # ! ['nwVolPhysicalName'], # ! ['nwVolSize'], # ! ['nwVolFree'], ! ['nwVolFreeable'], ! ); while (defined $s->getnext($v)) { ! last if ($v->[$nwID]->tag !~ /nwVolID/); ! ! my $size = $v->[$nwSize]->val; ! my $free = $v->[$nwFree]->val + $v->[$nwFreeable]->val; ! my $fsname = $v->[$nwName]->val; ! if ( $free < $FREE{$host}{$fsname}) { push (@HOSTS, $host); ! push (@ERRS, sprintf ("%1.1fMB free on %s", $free / 1024, $fsname)); ! $RET = 1; ! } ! } if ($s->{ErrorNum}) { push (@HOSTS, $host); ! push (@ERRS, "could not get nwVolID for $host: " . $s->{ErrorStr}); ! $RET = ($RET == 1) ? 1 : 2; } ! } if ($RET) { ! print "@HOSTS\n"; ! print "\n"; ! print join("\n", @ERRS), "\n"; ! } exit $RET; --- 100,208 ---- @HOSTS = (); ! $COMM = $opt{"community"} || "public"; ! $TIMEOUT = $opt{"timeout"} * 1000 * 1000 || 5000000; ! $RETRIES = $opt{"retries"} || 8; ! $CONFIG = $opt{"config"} || (-d "/etc/mon" ? "/etc/mon" : "/usr/lib/mon/etc") ! . "/netwarefree.cf"; ! # pick up local configuration file for testing ! $CONFIG = "./netwarefree.cf" if -e "./netwarefree.cf"; ! $LIST = defined $opt{"list"}; ! $FORMAT_LINES_PER_PAGE = $opt{'list'} || 25; ! $DEBUG = $opt{"debug"}; ! ! print STDERR "Using configuration file $CONFIG\n" if $DEBUG; ($nwID, $nwName, $nwSize, $nwFree, $nwFreeable) = (0..4); + $nwVolID = '.1.3.6.1.4.1.23.2.28.2.14.1.1'; + $nwVolPhysicalName = '.1.3.6.1.4.1.23.2.28.2.14.1.2'; + $nwVolSize = '.1.3.6.1.4.1.23.2.28.2.14.1.3'; + $nwVolFree = '.1.3.6.1.4.1.23.2.28.2.14.1.4'; + $nwVolFreeable = '.1.3.6.1.4.1.23.2.28.2.14.1.5'; + readcf ($CONFIG) || die "could not read config: $!\n"; foreach $host (@ARGV) { ! $size = $free = '---'; $ok = 'ERR'; ! ! if (!defined $FREE{$host}) { ! $RET = 2 unless $RET > 2; ! push (@HOSTS, $host); ! push (@ERRS, "$host: Host not configured"); ! $fsname = 'not configured'; write if($LIST); ! next; ! } if (!defined($s = new SNMP::Session (DestHost => $host, Timeout => $TIMEOUT, Community => $COMM, Retries => $RETRIES))) { ! $RET = 2 unless $RET > 2; push (@HOSTS, $host); ! push (@ERRS, "$host: Could not create session " . $SNMP::Session::ErrorStr); ! delete $FREE{$host}; ! $fsname = 'session error'; write if($LIST); next; ! } $v = new SNMP::VarList ( ! [$nwVolID], ! [$nwVolPhysicalName], ! [$nwVolSize], ! [$nwVolFree], ! [$nwVolFreeable], ! ); while (defined $s->getnext($v)) { + $tag = $v->[$nwID]->tag; + $sizeK = $v->[$nwSize]->val; + $size = int($sizeK / 1024); + $freeK = $v->[$nwFree]->val + $v->[$nwFreeable]->val; + $free = int($freeK / 1024); + $fsname = $v->[$nwName]->val; + $ok = $freeK < $FREE{$host}{$fsname} ? "LOW" : "OK"; + $ok = "n/c" unless defined $FREE{$host}{$fsname}; + + print "DEBUG: HOST=$host TAG=$tag FS=$fsname SIZE=$size FREE=$free\n" if $DEBUG; + last if $tag !~ /$nwVolID/; ! write if $LIST; ! if ( $freeK < $FREE{$host}{$fsname}) { ! $RET = 1 unless $RET > 1; push (@HOSTS, $host); ! push (@ERRS, sprintf ("%s/%s: Space LOW (%.0fMB free)", $host, $fsname, $free)); ! } ! delete $FREE{$host}{$fsname}; ! } if ($s->{ErrorNum}) { + $RET = 2 unless $RET > 2; push (@HOSTS, $host); ! push (@ERRS, "$host: Could not get nwVolID; " . $s->{ErrorStr}); ! } ! ! } # foreach $host(@ARGV) ! ! ! # check for leftover configured volumes that haven't been seen yet ! foreach $host (keys %FREE) { ! $vols = $FREE{$host}; ! push (@HOSTS, $host) if (scalar keys %$vols) && ! !(scalar grep /^$host$/, @HOSTS); ! foreach $fsname (keys %$vols) { ! $size = $free = 'NOT FOUND'; $ok = 'ERR'; ! write if $LIST; ! push (@ERRS, "$host/$fsname: Volume not found"); ! } } ! ! exit $RET if $LIST; if ($RET) { ! my @H = sort @HOSTS; ! my $e = join("\n", sort @ERRS); ! print "@H\n\n$e\n"; ! } exit $RET; *************** *** 133,142 **** chomp; ($host, $filesys, $free) = split; if (!defined ($FREE{$host}{$filesys} = toKB ($free))) { ! die "error free specification, config $f, line $.\n"; } - } close (CF); ! } --- 221,234 ---- chomp; ($host, $filesys, $free) = split; + + # ignore hosts not tested this time + next unless (scalar grep /^$host$/, @ARGV); + if (!defined ($FREE{$host}{$filesys} = toKB ($free))) { ! die "error in free space specification, config $f, line $.\n"; ! } } close (CF); ! } *************** *** 147,200 **** 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 * 1024)) if ($u eq "mb"); return (int ($n * 1024 * 1024)) if ($u eq "gb"); int ($n); - } - - sub list { - my (@hosts) = @_; - - - foreach $host (@hosts) { - - if (!defined($s = new SNMP::Session (DestHost => $host, - Timeout => $TIMEOUT, - Community => $COMM, - Retries => $RETRIES))) { - print STDERR "could not create session to $host: " . $SNMP::Session::ErrorStr, "\n"; - next; - } - - $v = new SNMP::VarList ( - ['nwVolID'], # - ['nwVolPhysicalName'], # - ['nwVolSize'], # - ['nwVolFree'], - ['nwVolFreeable'], - ); - - while (defined $s->getnext($v)) { - - my $tag = $v->[0]->tag; - last if ($v->[0]->tag !~ /nwVolID/); - write; - } } ! exit 0; ! } format STDOUT_TOP = ! Server Volume KB total KB free ! ----------------------------------------------------------------- . format STDOUT = ! @<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<<<<< @>>>>>>>>>> @>>>>>>>>>> ! $host, $v->[1]->[2], $v->[2]->[2], ($v->[3]->[2] + $v->[4]->[2]) . --- 239,263 ---- 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 * 1024)) if ($u eq "mb"); return (int ($n * 1024 * 1024)) if ($u eq "gb"); int ($n); } ! format STDOUT_TOP = ! Server Volume MB total MB free Status ! ------------------------------------------------------------------------- . format STDOUT = ! @<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<<<<< @>>>>>>>>>> @>>>>>>>>>> @>>>>> ! $host, $fsname, $size, $free, $ok . --- NEW FILE: CHANGES --- Version 1.2.0 P.Holzleitner Changed to numeric OIDs so the MIB file is no longer needed Merged regular and --list processing Made error messages consistent (host[/volume]: problem) Improved error handling, now checks for 'missing' volumes etc. Uses ./netwarefree.cf if present for easy testing Version 1.1.0 P.Holzleitner initial public release --- netwarefree.README DELETED --- |
From: Jim T. <tr...@us...> - 2005-05-02 11:57:20
|
Update of /cvsroot/mon/mon-contrib/monitors/netsnmp/netsnmp-proc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6394/netsnmp/netsnmp-proc Added Files: netsnmp-proc.monitor netsnmp-proc.monitor.README Log Message: fixed initial import error for netsnmp-proc.monitor --- NEW FILE: netsnmp-proc.monitor.README --- # Monitor processes via SNMP # (based on process.monitor by Brian Moore) # # Modified Oct 2001 by Dan Urist <du...@wo...> # Changes: added usage, SNMP v.3 support, -P processes option # unique-ified errors # # Modified Feb 2002 by Dan Urist <du...@wo...> # Changes: added -C config file option; cleaned up code # # This script will exit with value 1 if any prErrorFlag is greater # than 0. The summary output line will be the host names and # processes that failed in the format host1:proc1,proc2;host2:proc3... # The detail lines are what UCD snmp returns for a prErrMessage. 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 -P process list # option is used, only the listed processes will be monitored. If a # process given with -P is not being monitored, the script will exit # with a warning and a value of 2. --- NEW FILE: netsnmp-proc.monitor --- #!/usr/bin/perl # # Monitor processes via SNMP # (based on process.monitor by Brian Moore) # # Modified Oct 2001 by Dan Urist <du...@wo...> # Changes: added usage, SNMP v.3 support, -P processes option # unique-ified errors # # Modified Feb 2002 by Dan Urist <du...@wo...> # Changes: added -C config file option; cleaned up code # # This script will exit with value 1 if any prErrorFlag is greater # than 0. The summary output line will be the host names and # processes that failed in the format host1:proc1,proc2;host2:proc3... # The detail lines are what UCD snmp returns for a prErrMessage. 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 -P process list # option is used, only the listed processes will be monitored. If a # process given with -P is not being monitored, the script will exit # with a warning and a value of 2. # # # Copyright (C) 2001 Daniel J. Urist <du...@wo...> # # 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 SNMP; use Getopt::Std; $ENV{'MIBS'} = "UCD-SNMP-MIB"; getopts("hP:" . &SNMPconfig("getopts")); my $VERSION = "0.3"; if( $opt_h || (scalar @ARGV == 0) ){ print join("\n", "$0 Version $VERSION; original version by Brian Moore,", "SNMP v.3 support by Daniel J. Urist <durist\@world.std.com>.", "\n", ); print "Usage: $0 OPTIONS host [host ...]\n"; print "Options:\n"; print join("\n\t", "\t-h # Usage", "[-P proc[,proc...]]] # Processes to look for", &SNMPconfig("usage"), "\n"); exit 2; } # Get SNMP options my %SNMPARGS = &SNMPconfig; # Get process list my @Processes = split(',', $opt_P) if defined $opt_P; my $RETVAL = 0; my %Failures; my %Longerr; my $Session; 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 push @{$Failures{$host}}, "session error"; $Longerr{"$host could not get SNMP session"} = ""; next; } my $v = new SNMP::Varbind (["prIndex"]); $Session->getnext ($v); my @Found; while (!$Session->{"ErrorStr"} && $v->tag eq "prIndex") { my @q = $Session->get ([ ["prNames", $v->iid], # 0 ["prMin", $v->iid], # 1 ["prMax", $v->iid], # 2 ["prCount", $v->iid], # 3 ["prErrorFlag", $v->iid], # 4 ["prErrMessage", $v->iid], # 5 ["prErrFix", $v->iid], # 6 ]); last if ($Session->{"ErrorStr"}); if(@Processes){ if( grep(/^$q[0]$/, @Processes) ){ # Keep track of which processes from the list we actually found push(@Found, $q[0]); } else{ $Session->getnext ($v); next; } } if ($q[4] > 0) { $RETVAL = 1; push @{$Failures{$host}}, $q[0]; $Longerr{"$host:$q[0] Count=$q[3] Min=$q[1] Max=$q[2]"} = ""; } $Session->getnext ($v); } if ($Session->{"ErrorStr"}) { $RETVAL = 2 if $RETVAL == 0; # Other errors take precedence over SNMP error push @{$Failures{$host}}, "SNMP error"; $Longerr{"$host returned an SNMP error: " . $Session->{"ErrorStr"}} = ""; } if(@Processes){ my $p; foreach $p (@Processes){ if( !grep(/^$p$/, @Found)){ $RETVAL = 2 if $RETVAL == 0; push @{$Failures{$host}}, "process \"$p\" not monitored"; $Longerr{"process \"$p\" not monitored on host $host"} = ""; } } } } if (scalar keys %Failures) { my $f; my @m; foreach $f (keys %Failures){ push(@m, $f . ":" .join(",", @{$Failures{$f}})); } print join(";", @m), "\n\n"; print join ("\n", sort keys %Longerr), "\n"; } exit $RETVAL; # # Manage the standard SNMP options # Arguments are same as netsnmp utils # # If called with "getopts", returns a string for "getopts" # If called with "usage", returns an array of usage information # Otherwise, returns a hash of SNMP config vars # # Overloading this sub like this is kinda hoakey, # but keeps everything in one place sub SNMPconfig { my($action) = @_; if($action eq "getopts"){ return "C:t:r:p:v:u:l:A:e:E:n:a:x:X:"; } elsif($action eq "usage"){ return( "[-C configfile] # SNMP vars config file", "[-t Timeout] # Timeout in ms (default: 1000000)", "[-r Retries] # Retries before failure (default: 5)", "[-p RemotePort] # Remote UDP port (default 161)", "[-v Version] # 1,2,2c or 3 (default: 1)", "[-c Community] # v.1,2,2c Community Name (default: public)", "[-u SecName] # v.3 Security Name (default: initial)", "[-l SecLevel] # v.3 Security Level (default: noAuthNoPriv)", "[-A AuthPass] # v.3 Authentication Passphrase (default: none)", "[-e SecEngineId] # v.3 security engineID (default: none)", "[-E ContextEngineId] # v.3 context engineID (default: none)", "[-n Context] # v.3 context name (default: none)", "[-a AuthProto] # authentication protocol (MD5|SHA; default MD5)", "[-x PrivProto] # privacy protocol (DES)", "[-X PrivPass] # privacy passphrase (default: none)", ); } # Read config file my %Conf; if($opt_C){ unless( open(CONF, $opt_C) ){ print "$0: Could not open config file $opt_C\n"; exit 2; } my $line; my @fields; foreach $line (<CONF>){ chomp $line; @fields = split(/=/, $line); $Conf{ lc $fields[0] } = $fields[1]; } close CONF; } my %SNMPARGS; # Common options $SNMPARGS{Timeout} = $opt_t || $Conf{timeout} || 1000000; $SNMPARGS{Retries} = $opt_r || $Conf{retries} || 5; $SNMPARGS{RemotePort} = $opt_p || $Conf{remoteport} || 161; $SNMPARGS{Version} = $opt_v || $Conf{version} || 1; # v. 3 options if ($SNMPARGS{Version} eq "3"){ $SNMPARGS{SecName} = $opt_u || $Conf{secname} || 'initial'; $SNMPARGS{SecLevel} = $opt_l || $Conf{seclevel} || 'noAuthNoPriv'; $SNMPARGS{AuthPass} = $opt_A || $Conf{authpass} || ''; $SNMPARGS{SecEngineId} = $opt_e || $Conf{secengineid} || ''; $SNMPARGS{ContextEngineId} = $opt_E || $Conf{contextengineid} || ''; $SNMPARGS{Context} = $opt_n || $Conf{context} || ''; $SNMPARGS{AuthProto} = $opt_a || $Conf{authproto} || ''; $SNMPARGS{PrivProto} = $opt_x || $Conf{privproto} || ''; $SNMPARGS{PrivPass} = $opt_X || $Conf{privpass} || ''; } # v. 1,2 options else{ $SNMPARGS{Community} = $opt_c || $Conf{community} || 'public'; } return %SNMPARGS; } |
From: Jim T. <tr...@us...> - 2005-05-02 11:57:15
|
Update of /cvsroot/mon/mon-contrib/monitors/netsnmp/process-full-command-line In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6394/netsnmp/process-full-command-line Removed Files: netsnmp-proc.monitor.README Log Message: fixed initial import error for netsnmp-proc.monitor --- netsnmp-proc.monitor.README DELETED --- |
From: Jim T. <tr...@us...> - 2005-05-02 11:55:12
|
Update of /cvsroot/mon/mon-contrib/monitors/netsnmp/netsnmp-proc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6191/netsnmp-proc Log Message: Directory /cvsroot/mon/mon-contrib/monitors/netsnmp/netsnmp-proc added to the repository |
From: Jim T. <tr...@us...> - 2005-05-02 11:50:42
|
Update of /cvsroot/mon/mon-contrib/monitors/snmpvar/snmpvar.monitor-1.4.0/ms-perfmib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5149/snmpvar.monitor-1.4.0/ms-perfmib Removed Files: perfmib-setup.cmd Log Message: updated snmpvar.monitor to 1.6.0 --- perfmib-setup.cmd DELETED --- |
Update of /cvsroot/mon/mon-contrib/monitors/snmpvar In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5149 Added Files: CHANGES COPYING README example.out snmpopt.cf snmpvar.cf snmpvar.def snmpvar.monitor Log Message: updated snmpvar.monitor to 1.6.0 --- NEW FILE: COPYING --- GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. <one line to give the program's name and a brief idea of what it does.> Copyright (C) <year> <name of author> 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 Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. <signature of Ty Coon>, 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. --- NEW FILE: snmpopt.cf --- # # snmpopt.cf # # (default values shown) # common options # Version = 1 # Port = 161 # Retries = 8 # Timeout = 5 # SNMPv1/v2 options # Community = public # SNMPv3 options # SecName = initial # SecLevel = noAuthNoPriv # AuthPass = # SecEngineId = # ContextEngineId = # Context # AuthProto = MD5 # PrivProto = DES # PrivPass = --- NEW FILE: example.out --- [example output in --list mode] Host Variable min value max stat ---------------------------------------------------------------------------- ethsw1 A1: Server LAUREL up(1) up(1) up(1) OK ethsw1 A3: Server HARDY up(1) up(1) up(1) OK ethsw1 C1: Server TITAN (1000SX) up(1) up(1) up(1) OK ethsw1 D1: Server MERCURY (1000SX) up(1) up(1) up(1) OK ethsw1 I1: Switch D1017:G1 (1000TX) up(1) up(1) up(1) OK ethsw1 Fan Status good(4 good(4) good(4 OK ethsw1 PSU Status [2] good(4 good(4) good(4 OK ethsw1 PSU Status [3] good(4 good(4) good(4 OK srvups1 Battery Temperature 32 C 45 OK srvups1 Humidity 10 32 % 90 OK srvups1 Diesel Generator Status OK(2) OK(2) OK(2) OK srvups1 Temperature 21 C 32 OK srvups1 Recent Max Line Voltage 232 V 245 OK srvups1 Recent Min Line Voltage 205 230 V OK srvups1 Output Load 31 % 90 OK srvups1 UPS Status Online Online( Online OK ntserv1 Ctl0Ch0 Phys Drive Status [0] online online( online OK ntserv1 Ctl0Ch0 Phys Drive Status [1] online online( online OK ntserv1 Ctl0Ch0 Phys Drive Status [2] online online( online OK ntserv1 Ctl0Ch0 Phys Drive Status [3] online online( online OK ntserv1 Ctl0Ch0 Phys Drive Status [4] online online( online OK ntserv1 Ctl0Ch0 Phys Drive Status [5] online online( online OK ntserv1 RAID Ctl0 Volume Status [0] normal normal( normal OK ntserv1 Fan Speed Chassis 1 1000 2167 rpm 10000 OK ntserv1 Fan Speed Chassis 3 1000 2217 rpm 10000 OK ntserv1 Fan Speed Top PSU 1000 3110 rpm 10000 OK ntserv1 Fan Speed Bottom PSU 1000 3061 rpm 10000 OK ntserv1 DC Current (+12V) Top PSU 3.5 A 50 OK ntserv1 DC Current (+12V) Bottom PSU 3.4 A 50 OK ntserv1 DC Current (+3.3V) Top PSU 0.7 A 50 OK ntserv1 DC Current (+3.3V) Bottom PSU 0.6 A 50 OK ntserv1 DC Current (+5V) Top PSU 5.2 A 50 OK ntserv1 DC Current (+5V) Bottom PSU 5.2 A 50 OK ntserv1 Temperature Ambient 30.5 C 35 OK ntserv1 Temperature Panel 22.5 C 35 OK ntserv1 Temperature Backplane Top 22 C 35 OK ntserv1 Temperature Backplane Bottom 24.5 C 35 OK ntserv1 CPU Temperature [1] 31 C 40 OK ntserv1 CPU Temperature [2] 35.5 C 40 OK ntserv1 Power Supply Status [1] OK(3) OK(3) OK(3) OK ntserv1 Power Supply Status [2] OK(3) OK(3) OK(3) OK ntserv1 Free Disk Space on drive C 50 490 MB OK ntserv1 Free Disk Space on drive D 50 1957 MB OK ntserv1 Committed Memory 332.386 MB 400 OK --- NEW FILE: README --- snmpvar.monitor by P.Holzleitner What does it do? snmpvar.monitor is a plug-in for the "mon" systems monitoring package written by Jim Trockij (http://www.kernel.org/software/mon). Called by mon, it queries freely configurable values using SNMP, compares them against specified limits and reports any violation. Some parameters that can be monitored (just to give you an idea): Equipment operational status (temperature, fan rotation) UPS Status (line power / battery, minimum line voltage, load % ...) Switch/Router status (interface up, BGP session up, ...) Server status (redundant power supply OK, disk array OK, ...) Status of services (process running, mail queue length, ...) License GNU GPLv2 (http://www.fsf.org/licenses/gpl.txt) - See file COPYING 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 * Copy snmpvar.cf to /etc/mon and edit to match your needs * Test from mon.d directory with ./snmpvar.monitor -l host1 host2 ... * Test again from mon.d directory with ./snmpvar.monitor host1 host2 ... * Add watch/service to mon.cf, using snmpvar.monitor Commandline options: --varconf=/path/to/snmpvar.def if neither /etc/mon nor /usr/lib/mon/etc --config=/path/to/snmpvar.cf if neither /etc/mon nor /usr/lib/mon/etc --community=your_SNMP_read_community if not 'public' --groups=Power,Disks test only a subset of variables for a host group --timeout=n SNMP GET timeout in seconds --retries=n number of times to retry the SNMP GET --debug tell what config is being useed --mibs='mib1:mib2:mibn' load specified MIBs --list[=linesperpage]] produce human-readable listing, not alarms For every host name passed on the command line, snmpval.monitor looks up the list of variables and corresponding limits in the configuration file (snmpmon.cf). If a --groups option is present, only those variables are checked which are in one of the specified groups. To specify more than one group, separate group names with commas. You can also exclude groups by prefixing the group name(s) with '-'. Don't mix in- and exclusion. Examples: --groups=Power only vars in the Power group --groups=Power,Env vars in the Power or Env group --groups=-Power,-Env all vars except those in Power or Env groups --groups=Power,-Env won't work (only the exclusions) For every such variable, it looks up the OID, description etc. from the variable definition file (snmpvar.def). This monitor looks for configuration files in the current directory, in /etc/mon and /usr/lib/mon/etc. Command line option --varconf overrides the location of the variable definition file, option --config sets the configuration file name. When invoked with the --list option, the output format is changed into a more human-readable form used to check and troubleshoot the configuration. This option must not be used from within MON. Exit values: 0 if everything is OK 1 if any observed value is outside the specified interval 2 in case of an SNMP error (e.g. no response from host) Basic Troubleshooting: use snmpvar.monitor --list option to see variable values use snmpwalk your_hostname public .1 | less to verify SNMP agent The snmpvar.def File: In this file we define variables that can be retrieved via SNMP. In a way, the .def file is snmpvar.monitor's idea of a MIB. Entries consist of a "Variable variable-name" declaration Variable PE4300_TEMP_MB [NOTE: The variable name cannot be "Host" or "FriendlyName"] followed by the mandatory specification of Object ID and Description: OID .1.3.6.1.4.1.674.10891.300.1.5.2.2.1.3 Description Motherboard Temperature It is suggested that OIDs be entered numerically as shown above in order to eliminate the need for having the SNMP libraries compile the relevant MIB files on every invocation of the monitor. By default, this monitor loads no MIBs. If you want to use symbolic OIDs, use the --mibs commandline option to specify which MIBs you need. By the author's convention, an OID describing an array of values, like ifOperStat which takes the interface number as an index, is written with a trailing dot, while OIDs of scalars end in a number. As of version 1.1.1, the monitor will insert the dot before the index if you forgot it in the .def file. Optional Elements of a Variable definition: DefaultIndex 3 4 5 A list of indices to test by default. Let's say the OID is .1.2.3. and DefaultIndex is "18 22 36", then the monitor will retrieve the values of .1.2.3.18, .1.2.3.22 and .1.2.3.36 when testing this variable, and will compare them all against the limits. Where necessary, the DefaultIndex can be overridden for one host/variable combination, using the Index statement in the .cf file. FriendlyName 3 Disk Fan 1 This lets you replace the standard display of "Variable [Index]", e.g. "Fan Speed [5]", with individual labels for each index. The FriendlyName option is typically specified in the .def file for items that have the same name for every use, e.g. component names like in the case of fans, power supplies etc. The same option exists in the .cf file to name a particular variable on a particular host, e.g. to display a line name instead of an interface number on a router. If the FriendlyName string begins with "@", the Description is substituted for the "@". Scale / 10.0 A formula to re-scale the value returned from the host. The expression is appended to the raw value and the resulting expression is evaluated by Perl. The raw value is available as $rawval if necessary. Unit C Used in value display / messages, Decode 1 unknown Decode 2 OK Decode 3 FAILURE Values retrieved through SNMP are often enumerations of status codes. The Decode statement lets you put text labels on these values. DefaultGroup Environment Defines that all, by default, instances of this variable go into the specified group. Individual overrides possible in .cf file. DefaultMin 300 DefaultMax 2000 DefaultEQ 1000 DefaultNEQ 1000 Default alarm limits. See description of Min/Max/EQ/NEQ below. The snmpvar.cf File: In here, you "call up" the variables to be retrieved for a particular host. Entries consist of a "Host host-name" declaration followed by at least one "variable-name [options ...]" line. Host ntserv1 This hostname corresponds to the hostname on the command line, i.e. the hostname you used in MON's hostgroup statement. FOO_FAN_RPM Min 1000 Max 5000 MaxValid 10000 Index 1 2 3 4 This example uses almost all options. It instructs the monitor to retrieve the OID specified under "FOO_FAN_RPM" in the .def file. Min 300 specifies a minimum value, measured >= minimum Max 2000 specifies a maximum value, measured <= maximum EQ 1000 specifies a exact value, measured == maximum NEQ 1000 specifies a exact value, measured != maximum If the measured value is outside of these limits, a failure is reported. To test for "Value = X", use "Min X Max X". MinValid -1 MaxValid 10000 Some monitoring hardware occasionally measures garbage. To avoid triggering an alarm when this happens, you can use MinValid/MaxValid to specify the range (inclusive) of plausible values for this variable. If the measured value exceeds these limits, only a warning will be generated, but no failure will be reported to MON. Group Environment Puts this particular variable into the specified group. Groups are used to test a partial set of the variables specified for a host, by using the --groups= command line option. Index 1 2 3 This tells the monitor which object instances (array elements) to test in case of a non-scalar object. Since the list of indices can be as long as necessary, the Index option must be the last one on the line (after Min X, Max Y etc.) The list specified as DefaultIndex in the .def file entry for this variable is used unless Index is pecified here. When retrieving a non-scalar value, the snmpvar.monitor will normally display the instances (array elements) by appending their index to the description, as in "Line Status [3]". Often, it is desirable to label individual instances in a more mnemonic way. To do this, you can add a number of FriendlyName directives after a variable request, like this: Host firewall IF_OPERSTAT Index 1 2 3 FriendlyName 1 1: Leased Line FriendlyName 2 2: DMZ FriendlyName 3 3: Internal Router In this case, the monitor checks the ifOperStat for interfaces 1, 2, and 3 on host "firewall". If interface 3 were not "up", the monitor would signal a failure of "Internal Router" instead of "ifOperStat [3]". If the FriendlyName string begins with "@", the Description is substituted for the "@". If all instances of this variable having the same index have the same meaning regardless of what host they are on, you can put the FriendlyName statement into te respective variable definition in the .def file instead. The snmpopt.cf File: This optional file is used to pass parameters to the SNMP library. For SNMPv1, this is generally not necessary unless the target's SNMP port differs from the default (161). Note that SNMPv1 community string, timeout and retries can also be specified on the snmpvar.monitor command line, overriding whatever default or configuration file setting. You will need to edit this file in order to use SNMPv3. --- NEW FILE: CHANGES --- Version 1.6.0 P. Holzleitner Equal and Non-Equal tests in addition to > and < Useful for cases where you want to supply additional info on failure - make a script that says "OK" on success, otherwise prints an error message, and plug into the SNMP extensions. Then test for eq "OK". Miscellaneous small fixes. Version 1.5.1 P. Holzleitner Fix to allow indices containing ".", e.g. IP Addresses (see BGP_PEERSTATE example in config files) Version 1.5.0 R. VanderBijl, P. Holzleitner per-host SNMP options --list shows all hosts if none specified more output with --debug option Version 1.4.0 D.Urist, P.Holzleitner Implemented extended SNMP options per Dan's suggestions. (Config file only to avoid commandline option conflicts) Version 1.3.0 Dave Alden, P.Holzleitner Permit non-integer limit values (e.g. 2.5) Added DefaultMin/DefaultMax/DefaultMinVal/DefaultMaxVal options so that common limits can be specified in the .def file. Added variable-group concept. Useful e.g. for monitoring one host's variables at different intervals (1 min for port up/down, 15 min for temperatures, ...) A default group can be assigned in the .def file, or specified/overriden individually per (host,oid) in the .cf file. Groups are optional. Without --groups= option on the command line, all variables are checked as in previous versions. One or more Groups can be specified for inclusion or exclusion: --groups=Power only vars in the Power group --groups=Power,Env vars in the Power or Env group --groups=-Power,-Env all vars except those in Power or Env groups --groups=Power,-Env won't work (only the exclusions are recognized) Version 1.2.0 P.Holzleitner Added ability to replace array entries with friendly names, e.g. "Engineering Ethernet" instead of "Port Status [3]" Version 1.1.2 P.Holzleitner Fixed -l output with plausibility checks Version 1.1.1 P.Holzleitner Automatically append the previously required trailing dot on OIDs that are indexed. Version 1.1.0 P.Holzleitner Configurable upper and lower plausibility limits added for agents that occasionally report an off-scale reading, e.g. 1200 amps current on the +5V supply ;-) PE4300_PSU1_5V_CURRENT Max 25 MaxValid 100 MinValid -1 This would cause snmpvar.monitor to ignore readings below -1 or above 100 for this variable and NOT signal an error. However, it writes a message to syslog. Version 1.0.1 P.Holzleitner Fixed a bug in reading Decode definitions where only the first digit of the value would be picked up Version 1.0.0 P.Holzleitner initial release --- NEW FILE: snmpvar.monitor --- #!/usr/bin/perl # ############################################################################ ## ## ## snmpvar.monitor Version 1.6.0 ## ## 2003-05-21 ## ## Copyright (C) 2000-2003 ## ## Peter Holzleitner (pe...@ho...) ## ## ## ############################################################################ # # A MON plug-in monitor to test numeric values retrieved via SNMP # against configured limits. # # Arguments: # # [--community=cmn] [--group=groups] [--timeout=n] [--retries=n] [--debug] # [--varconf=filename] [--config=filename] [--snmpconf=filename] # [--mibs='mib1:mib2:mibn'] [--list[=linesperpage]] host [host ...] # # For every host name passed on the command line, snmpval.monitor looks # up the list of variables and corresponding limits in the configuration # file (snmpmon.cf). # # If a --groups option is present, only those variables are checked # which are in one of the specified groups. To specify more than one # group, separate group names with commas. You can also exclude groups # by prefixing the group name(s) with '-'. Don't mix in- and exclusion. # Examples: # --groups=Power only vars in the Power group # --groups=Power,Env vars in the Power or Env group # --groups=-Power,-Env all vars except those in Power or Env groups # --groups=Power,-Env won't work (only the exclusions) # # For every such variable, it looks up the OID, description etc. from # the variable definition file (snmpvar.def). # # This monitor looks for configuration files in the current directory, # in /etc/mon and /usr/lib/mon/etc. Command line option --varconf # overrides the location of the variable definition file, option # --config sets the configuration file name. # # For formats, please refer to the sample configuration files. # # By default, this monitor does not load any MIB, and OIDs are specified # numerically in the configuration files. Use the option --mibs # to force certain MIBs to be loaded. # # When invoked with the --list option, the output format is changed # into a more human-readable form used to check and troubleshoot the # configuration. This option must not be used from within MON. # # # Exit values: # 0 if everything is OK # 1 if any observed value is outside the specified interval # 2 in case of an SNMP error (e.g. no response from host) # # Requirements: # # UCD SNMP library (3.6.2 or higher) # G.S. Marzot's Perl SNMP module (from CPAN). # # # License: # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; 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.6.0 21 May 2003 Equal and Non-Equal tests in addition to < and > (P.H.) # 1.5.1 09 Apr 2003 change \w to ^\s in FriendlyName detection to allow # indices containing "." like IP Addresses # 1.5.0 04 Dec 2002 per-host SNMP options (Ryan VanderBijl + P.H.) # --list shows all hosts if none specified (Ryan V.) # more output with --debug option (P.H.) # 1.4.0 10 Sep 2002 extended SNMP configuration (Dan Urist) # 1.3.0 15 May 2002 added GROUP option (Dave Alden) # added DEFAULTGROUP, group exclusion (P.H.) # decimals OK in limits (britcey) # added DefaultMin/Max (P.H.) # 1.2.0 21 Mar 2001 added FriendlyName option (P.H.) # 1.1.2 10 Jul 2000 fixed -l output with plausibility checks (P.H.) # 1.1.1 04 Apr 2000 automatically add dot between OID and index (P.H.) # 1.1.0 30 Mar 2000 added upper and lower plausibility limits (P.H.) # 1.0.1 24 Jan 2000 bugfix: reading Decode definitions (P.H.) # 1.0.0 13 Jan 2000 initial release (P.H.) # use SNMP; use Getopt::Long; use Sys::Syslog; sub ReadVarDef; sub ReadVarList; sub ReadSNMPConf; sub GetSNMPArgs; sub Decode; GetOptions (\%opt, "config=s", "groups=s", "varconf=s", "snmpconf=s", "community=s", "port=i", "timeout=i", "retries=i", "mibs=s", "list:i", "debug"); die "no host arguments\n" if ( (@ARGV == 0) && !exists($opt{'list'}) ); $RET = 0; @ERRS = (); @HOSTS = (); ($^O eq "linux" || $^O eq "openbsd") && Sys::Syslog::setlogsock('unix'); openlog('snmpvar.mon', 'cons,pid', 'daemon'); # find config files $CF1 = '/etc/mon'; $CF2 = '/usr/lib/mon/etc'; $VARCONF_FILE = (-d $CF1 ? $CF1 : $CF2) . '/snmpvar.def'; $MONCONF_FILE = (-d $CF1 ? $CF1 : $CF2) . '/snmpvar.cf'; $SNMPCONF_FILE = (-d $CF1 ? $CF1 : $CF2) . '/snmpopt.cf'; # pick up local config files for testing $VARCONF_FILE = './snmpvar.def' if -e './snmpvar.def'; $MONCONF_FILE = './snmpvar.cf' if -e './snmpvar.cf'; $SNMPCONF_FILE = './snmpopt.cf' if -e './snmpopt.cf'; # commandline ovverides ini any case $VARCONF_FILE = $opt{'varconf'} || $VARCONF_FILE; $MONCONF_FILE = $opt{'config'} || $MONCONF_FILE; $SNMPCONF_FILE = $opt{'snmpconf'} || $SNMPCONF_FILE; print STDERR "\nsnmpvar.monitor: configured from $VARCONF_FILE, $MONCONF_FILE\n\n" if $opt{'debug'}; ReadVarDef($VARCONF_FILE) || die "could not read variable definition: $!\n"; ReadVarList($MONCONF_FILE) || die "could not read config: $!\n"; ReadSNMPConf($SNMPCONF_FILE); # this is optional stuff # load only the necessary MIBs: $ENV{'MIBS'} = $opt{'mibs'} || ''; $FORMAT_LINES_PER_PAGE = $opt{'list'} || 25; $GROUPS = "," . $opt{'groups'} . "," if ($opt{'groups'}); @ARGV = keys %VARLIST if ( exists($opt{'list'}) && @ARGV == 0 ); foreach $host (@ARGV) { $VARS = $VARLIST{$host}; # %VARLIST{$host}{$var}{'MIN'|'MAX'} next unless $VARS; my $SNMPARGS = &GetSNMPArgs($host); if($opt{'debug'}) { print STDERR "$host SNMP Parameters:\n"; foreach $so (keys %SNMPARGS) { print " $so = $SNMPARGS{$so}\n"; } print STDERR "\n"; } if (!defined($s = new SNMP::Session(DestHost => $host, %SNMPARGS))) { $RET = 2 unless $RET > 2; $errmsg = "could not create session to $host: " . $SNMP::Session::ErrorStr; print STDERR "$errmsg\n" if $opt{'debug'}; push (@HOSTS, $host); push (@ERRS, $errmsg); next; } @HE = (); # list of errors for THIS host foreach $var (sort keys %$VARS) { # skip vars that are not in selected group, if any: if($GROUPS ne '') { $g = $$VARS{$var}{'GROUP'}; # assigned group of this variable next if $GROUPS =~ /,-$g,/i; # excluded group next if !($GROUPS =~ /-/) && !($GROUPS =~ /,$g,/i); # included group } $oid = $VARDEF{$var}{'OID'}; @IDX = split(/ +/, $$VARS{$var}{'IDX'}); if(@IDX == ()) { @IDX = (''); } else { $oid .= '.' unless $oid =~ /.+\.$/; } foreach $i (@IDX) { $ioid = $oid . $i; $pi = $i ne '' ? " [$i]" : ''; $descr = $VARDEF{$var}{'DESCR'}; $fn = $FRIENDLYNAME{$host}{$var}{$i} || $VARDEF{$var}{'FNAME'}{$i}; $fn =~ s/^@/$descr /; $vardescr = $fn || $descr . $pi; $rawval = $s->get($ioid); if ($s->{ErrorNum}) { $RET = 2 unless $RET > 2; $errmsg = "error retrieving $host:$var$pi($ioid): " . $s->{ErrorStr}; print STDERR "$errmsg\n" if $opt{'debug'}; push (@HE, $errmsg); next; } $val = eval ($rawval . $VARDEF{$var}{'SCALE'}); $min = $$VARS{$var}{'MIN'}; $max = $$VARS{$var}{'MAX'}; $eq = $$VARS{$var}{'EQ'}; $neq = $$VARS{$var}{'NEQ'}; $minvalid = $$VARS{$var}{'MINVALID'}; $maxvalid = $$VARS{$var}{'MAXVALID'}; $stat = 'OK'; $DEC = $VARDEF{$var}{'DEC'}; $pval = Decode($DEC, $val); $pmin = Decode($DEC, $min); $pmax = Decode($DEC, $max); $peq = Decode($DEC, $eq); $pneq = Decode($DEC, $neq); $pmin = $pmax = $peq if defined($eq); $pmin = $pmax = '!' . $pneq if defined($neq); if(defined($minvalid) && ($val < $minvalid)) { $stat = 'INV<'; syslog('warning', "$host: $vardescr less than lower plausibility limit: $pval"); write if defined $opt{'list'}; next; } if(defined($maxvalid) && ($val > $maxvalid)) { $stat = 'INV>'; syslog('warning', "$host: $vardescr larger than upper plausibility limit: $pval"); write if defined $opt{'list'}; next; } if(defined($min) && ($val < $min)) { $stat = 'FAIL<'; push (@HE, "$vardescr LOW: $pval $VARDEF{$var}{'UNIT'} (<$pmin)"); } if(defined($max) && ($val > $max)) { $stat = 'FAIL>'; push (@HE, "$vardescr HIGH: $pval $VARDEF{$var}{'UNIT'} (>$pmax)"); } if(defined($eq) && ($val != $eq)) { $stat = 'FAIL<>'; push (@HE, "$vardescr: $pval $VARDEF{$var}{'UNIT'} (<> $peq)"); } if(defined($neq) && ($val == $neq)) { $stat = 'FAIL='; push (@HE, "$vardescr: $pval $VARDEF{$var}{'UNIT'} (== $pneq)"); } write if defined $opt{'list'}; } # foreach(index) } # foreach(var) if (@HE) { push (@HOSTS, $host); push (@ERRS, $host . ":\n" . join("\n", @HE)); $RET = 1 unless $RET > 1; # previous error level 2 takes precedence } } # foreach(host) # in case of list output, suppress error listing by exiting here: exit 0 if defined $opt{'list'}; if ($RET) { print "@HOSTS\n\n"; print join("\n", @ERRS), "\n"; } exit $RET; # ---------------------------------------------------------------------- # subroutines begin # ---------------------------------------------------------------------- # # decode enumerations # sub Decode { my ($D, $v) = @_; my $dv; return $v unless $D; # can only decode with valid decoder hash $dv = $$D{$v} || '?'; # look up value return "$dv($v)"; } # # read variable definitions from file # sub ReadVarDef { my ($f) = @_; my ($curvar, $keyword, $param); $curvar = ''; open (CF, $f) || return undef; while (<CF>) { next if (/^\s*#/ || /^\s*$/); chomp; /^\s*(\w*)\s*(.*)/; $keyword = $1; $param = $2; $curvar = $param if $keyword =~ /Variable/i; if($curvar ne '') { $VARDEF{$curvar}{'OID'} = $param if $keyword =~ /OID/i; $VARDEF{$curvar}{'DESCR'} = $param if $keyword =~ /Descr.*/i; $VARDEF{$curvar}{'UNIT'} = $param if $keyword =~ /Unit/i; $VARDEF{$curvar}{'SCALE'} = $param if $keyword =~ /Scale/i; $VARDEF{$curvar}{'DEFIDX'} = $param if $keyword =~ /DefaultIndex/i; $VARDEF{$curvar}{'DEFGRP'} = $param if $keyword =~ /DefaultGroup/i; $VARDEF{$curvar}{'DEFMIN'} = $param if $keyword =~ /DefaultMin/i; $VARDEF{$curvar}{'DEFMAX'} = $param if $keyword =~ /DefaultMax/i; $VARDEF{$curvar}{'DEFEQ'} = $param if $keyword =~ /DefaultEq/i; $VARDEF{$curvar}{'DEFNEQ'} = $param if $keyword =~ /DefaultNEq/i; $VARDEF{$curvar}{'DEFMINVAL'} = $param if $keyword =~ /DefaultMinValid/i; $VARDEF{$curvar}{'DEFMAXVAL'} = $param if $keyword =~ /DefaultMaxValid/i; if($keyword =~ /Decode/i) { $param =~ /\s*([^\s]+)\s+(.*)$/; $VARDEF{$curvar}{'DEC'}{$1} = $2; } if($keyword =~ /FriendlyName/i) { $param =~ /\s*([^\s]+)\s+(.*)$/; $VARDEF{$curvar}{'FNAME'}{$1} = $2; } } } # while(<CF>) close (CF); return 1; } # # read list of variables to be monitored # sub ReadVarList { my ($f) = @_; my ($curhost, $curvar, $var, $param); $curhost = ''; open (CF, $f) || return undef; while (<CF>) { next if (/^\s*#/ || /^\s*$/); chomp; if(/Host\s+(\S+)/i) { $curhost = $1; $curvar = ''; next; } if(/\s+SNMP\s+(\S+)\s+(.+)/i) { next unless $curhost; print "READVARLIST($curhost): SNMP: $1 $2\n"; $SNMP{$curhost}{lc $1} = $2; next; } if(/\s+FriendlyName\s+([^\s]+)\s+(.+)/i) { next unless $curhost; next unless $curvar; $FRIENDLYNAME{$curhost}{$curvar}{$1} = $2; next; } /^\s+(\S+)\s*(.*)$/; $curvar = $1; $param = $2; if($curhost) { $VARLIST{$curhost}{$curvar}{'MIN'} = $VARDEF{$curvar}{'DEFMIN'}; $VARLIST{$curhost}{$curvar}{'MIN'} = $1 if $param =~ /Min\s+([\d\.]+)/i; $VARLIST{$curhost}{$curvar}{'MAX'} = $VARDEF{$curvar}{'DEFMAX'}; $VARLIST{$curhost}{$curvar}{'MAX'} = $1 if $param =~ /Max\s+([\d\.]+)/i; $VARLIST{$curhost}{$curvar}{'EQ'} = $VARDEF{$curvar}{'DEFEQ'}; $VARLIST{$curhost}{$curvar}{'EQ'} = $1 if $param =~ /Eq\s+([\d\.]+)/i; $VARLIST{$curhost}{$curvar}{'NEQ'} = $VARDEF{$curvar}{'DEFNEQ'}; $VARLIST{$curhost}{$curvar}{'NEQ'} = $1 if $param =~ /NEq\s+([\d\.]+)/i; $VARLIST{$curhost}{$curvar}{'MINVALID'} = $VARDEF{$curvar}{'DEFMINVAL'}; $VARLIST{$curhost}{$curvar}{'MINVALID'} = $1 if $param =~ /MinValid\s+([\d\.]+)/i; $VARLIST{$curhost}{$curvar}{'MAXVALID'} = $VARDEF{$curvar}{'DEFMAXVAL'}; $VARLIST{$curhost}{$curvar}{'MAXVALID'} = $1 if $param =~ /MaxValid\s+([\d\.]+)/i; $VARLIST{$curhost}{$curvar}{'IDX'} = $VARDEF{$curvar}{'DEFIDX'}; $VARLIST{$curhost}{$curvar}{'IDX'} = $1 if $param =~ /Index\s+(.+)$/i; $VARLIST{$curhost}{$curvar}{'GROUP'} = $VARDEF{$curvar}{'DEFGRP'}; $VARLIST{$curhost}{$curvar}{'GROUP'} = $1 if $param =~ /Group\s+(.+)$/i; } } # while(<CF>) close (CF); return 1; } sub ReadSNMPConf { my ($f) = @_; my $tag; my $val; if (-r $f) { print STDERR "\nsnmpvar.monitor: reading SNMP options from $f\n" if $opt{'debug'}; open(SNMPCONF, $f) or die "Huh? $f readable but open fails?"; while(<SNMPCONF>) { chomp; next if (/^\s*#/ || /^\s*$/); next unless /^\s*(\S+)\s*=\s*(.+)$/; $SNMPDEF{ lc $1 } = $2; print STDERR "snmpvar.monitor: $1 = $2\n" if $opt{'debug'}; } close SNMPCONF; } print STDERR "\n\n" if $opt{'debug'}; } sub GetSNMPArgs { my ($host) = @_; my $SNMPARGS; # Common options $SNMPARGS{Version} = $SNMP{$host}{version} || $SNMPDEF{version} || 1; $SNMPARGS{RemotePort} = $SNMP{$host}{port} || $opt{'port'} || $SNMPDEF{remoteport} || 161; $SNMPARGS{Retries} = $SNMP{$host}{retries} || $opt{'retries'} || $SNMPDEF{retries} || 8; $SNMPARGS{Timeout} = $SNMP{$host}{timeout} || $opt{'timeout'} || $SNMPDEF{timeout} || 5; # some people may prefer microseconds, but small values should mean seconds: $SNMPARGS{Timeout} *= 1000000 if $SNMPARGS{Timeout} < 1000; # SNMP v.1/v.2 options if ($SNMPARGS{Version} < 3) { $SNMPARGS{Community} = $SNMP{$host}{community} || $opt{'community'} || $SNMPDEF{community} || 'public'; } # SNMP v.3 options if ($SNMPARGS{Version} == 3) { $SNMPARGS{SecName} = $SNMP{$host}{secname} || $SNMPDEF{secname} || 'initial'; $SNMPARGS{SecLevel} = $SNMP{$host}{seclevel} || $SNMPDEF{seclevel} || 'noAuthNoPriv'; $SNMPARGS{AuthPass} = $SNMP{$host}{authpass} || $SNMPDEF{authpass} || ''; $SNMPARGS{SecEngineId} = $SNMP{$host}{secengineid} || $SNMPDEF{secengineid} || ''; $SNMPARGS{ContextEngineId} = $SNMP{$host}{contextengineid} || $SNMPDEF{contextengineid} || ''; $SNMPARGS{Context} = $SNMP{$host}{context} || $SNMPDEF{context} || ''; $SNMPARGS{AuthProto} = $SNMP{$host}{authproto} || $SNMPDEF{authproto} || 'MD5'; $SNMPARGS{PrivProto} = $SNMP{$host}{privproto} || $SNMPDEF{privproto} || 'DES'; $SNMPARGS{PrivPass} = $SNMP{$host}{privpass} || $SNMPDEF{privpass} || ''; } return %SNMPARGS; } format STDOUT_TOP = Host Variable min value max stat ---------------------------------------------------------------------------- . format STDOUT = @<<<<<<<<< @<<<<<<<<<<<<<<<<<<<<<<<<<<<< @>>>>> @>>>>>> @<<< @>>>>> @<<<<< $host, $vardescr, $pmin, $pval, $VARDEF{$var}{'UNIT'}, $pmax, $stat . --- NEW FILE: snmpvar.cf --- # # snmpvar.cf # # list of variables and ranges to be monitored by snmpvar.monitor # refers to variables defined in snmpvar.def # # a Dell server, RAID instrumentation only: Host nov-1 MEGARAID0_LOGICAL_STATUS Min 2 Max 2 Index 0 MEGARAID0_PHYS_STATUS Min 3 Max 3 Index 0 1 2 3 4 5 # a Compaq server: Host nov-2 # has 1 RAID volume, 6 physical disks CPQARRAY_LOG_STATUS Index 1 CPQARRAY_PHYS_STATUS Index 0 1 2 3 4 5 PROLIANT_TEMP_STATUS PROLIANT_PSU_STATUS PROLIANT_FAN_STATUS Index 2 4 5 # a Dell server running NT 4 with perfmib Host ntserv1 WINNT_MEM_COMMITTED Max 700 WINNT_LOGICAL_C_FREE Min 50 WINNT_LOGICAL_D_FREE Min 50 MEGARAID_C0_LOGICAL_STATUS Index 0 MEGARAID_C0_CH0_PHYS_STATUS Index 0 1 2 3 4 PE4300_TEMP_CPU PE4300_TEMP PE4300_5V_CURRENT PE4300_12V_CURRENT PE4300_3V_CURRENT PE4300_FAN_CPU_RPM PE4300_FAN_DISK_RPM PE4X00_PSU_STATUS # an APC UPS (with SNMP adapter or through controlling server running PowerNet) Host srvups1 APCUPS_OUTPUT_STAT APCUPS_LINEVOLT_MAX APCUPS_LINEVOLT_MIN # here, we override the default maximum specified in snmpvar.def: APCUPS_LOAD Max 75 APCUPS_BATT_TEMP # these are the MeasureUPS parameters (external sensor) APCUPS_EXT_TEMP Max 32 APCUPS_EXT_HUMID Min 10 Max 90 APCUPS_EXT_SWITCH_STAT Min 2 Max 2 Index 1 FriendlyName 1 Diesel Generator Status # an HP ProCurve 4000 switch Host hp4000-servers HP_ICF_FAN_STATE # has redundant PSU HP_ICF_PSU_STATE Index 2 3 IF_OPERSTAT Index 1 3 17 25 65 73 FriendlyName 1 A1: Server LAUREL FriendlyName 3 A3: Server HARDY FriendlyName 17 C1: Server TITAN (1000SX) FriendlyName 25 D1: Server MERCURY (1000SX) FriendlyName 65 I1: Switch D1017:G1 (1000TX) FriendlyName 73 J1: Switch SERVERS1:H1 (1000SX) # an IBM8272 Token Ring switch Host trsw1 IBM8272_LINK_STATE Min 1 Max 1 Index 1 2 3 4 5 6 7 9 11 12 13 14 15 16 17 18 21 22 23 24 FriendlyName 1 1: Floor 10 Ring FriendlyName 2 2: Floor 12 Ring FriendlyName 3 3: Floor 13 Ring FriendlyName 9 9: Server NOV-1 FriendlyName 13 13: Server ntserv1 FriendlyName 18 18: Switch 2 Interlink Fibre IBM8272_TEMP_SYS Min 1 Max 1 # a cisco router Host cisco1 IF_OPERSTAT Index 1 2 3 4 FriendlyName 1 1: Internal Ethernet FriendlyName 2 2: Internal TokenRing FriendlyName 3 3: Firewall BGP_PEERSTATE Index 10.1.1.1 10.2.1.1 FriendlyName 10.1.1.1 iBGP Session: myotherrouter FriendlyName 10.2.1.1 eBGP Session: Provider X CISCO_TEMP_STATE # a Nokia IP series firewall appliance Host firewall IF_OPERSTAT Index 1 2 3 FriendlyName 1 1: Leased Line FriendlyName 2 2: DMZ FriendlyName 3 3: Internal Router NOKIA_IP_CHASSIS_TEMP NOKIA_IP_FAN_STAT NOKIA_IP_PSU_STAT NOKIA_IP_PSU_TEMP # a Linux server with some private SNMP extensions Host mailserver LINUX_MAILQUEUE Max 80 --- NEW FILE: snmpvar.def --- # # snmpvar.def # # Definitions of variables to be monitored using snmpvar.monitor # # generic host (router/switch/...) Variable IF_OPERSTAT OID .1.3.6.1.2.1.2.2.1.8 Description ifOperStatus DefaultEQ 1 Decode 1 up Decode 2 down Decode 3 testing Decode 4 unknown Decode 5 dormant # generic router Variable BGP_PEERSTATE OID .1.3.6.1.2.1.15.3.1.2 Description bgpPeerState DefaultEQ 6 Decode 1 idle Decode 2 connect Decode 3 active Decode 4 opensent Decode 5 openconfirm Decode 6 established # generic Host Resources MIB implementation Variable HR_DEVICE_STATUS OID .1.3.6.1.2.1.25.3.2.1.5. Description Device Status DefaultEQ 2 Decode 1 unknown Decode 2 running Decode 3 warning Decode 4 testing Decode 5 down # some variables from a Windows NT "perfmib" configuration # see ms-perfmib directory for NT side configuration Variable WINNT_CPU_TOTAL OID .1.3.6.1.4.1.311.1.1.3.1.1.1.9.0 Description CPU Load Total Unit % Variable WINNT_CPU_SYS OID .1.3.6.1.4.1.311.1.1.3.1.1.1.11.0 Description CPU Load System Unit % Variable WINNT_MEM_COMMITTED OID .1.3.6.1.4.1.311.1.1.3.1.1.2.2.0 Description Committed Memory Scale / 1024 / 1024 # the Scale expression is used as (eval($rawval . $scale)) Unit MB Variable WINNT_MEM_AVAILABLE OID .1.3.6.1.4.1.311.1.1.3.1.1.2.1.0 Description Available Memory Scale / 1024 /1024 Unit MB Variable WINNT_LOGICAL_C_FREE OID .1.3.6.1.4.1.311.1.1.3.1.1.6.1.4.6.48.58.48.58.67.58 Description Free Disk Space on drive C Unit MB Variable WINNT_LOGICAL_D_FREE OID .1.3.6.1.4.1.311.1.1.3.1.1.6.1.4.6.48.58.48.58.68.58 Description Free Disk Space on drive D Unit MB # Dell PowerEdge 2550 Server Instrumentation Variable PE2550_FAN_SYS_RPM OID .1.3.6.1.4.1.674.10892.1.700.12.1.6.1. Description System Fan Speed DefaultIndex 1 2 3 Unit rpm DefaultMin 600 DefaultMax 6000 DefaultMaxValid 10000 DefaultGroup Environment Variable PE2550_FAN_DISK_RPM OID .1.3.6.1.4.1.674.10892.1.700.12.1.6.1.4 Description Disk Fan Speed Unit rpm DefaultMin 6000 DefaultMax 14000 DefaultMaxValid 15000 DefaultGroup Environment Variable PE2550_TEMP_CPU OID .1.3.6.1.4.1.674.10892.1.700.20.1.6.1. Description CPU Temperature DefaultIndex 1 2 Unit C Scale / 10.0 DefaultMax 50 DefaultGroup Environment Variable PE2550_TEMP OID .1.3.6.1.4.1.674.10892.1.700.20.1.6.1. Description Temperature DefaultIndex 3 4 5 FriendlyName 3 Motherboard FriendlyName 4 Backplane 1 FriendlyName 5 Backplane 2 Unit C Scale / 10.0 DefaultMax 40 DefaultGroup Environment Variable PE2550_PSU_STATUS DefaultIndex 1 2 OID .1.3.6.1.4.1.674.10892.1.600.12.1.5.1. Description Power Supply Status DefaultEQ 3 Decode 1 other Decode 2 unknown Decode 3 OK Decode 4 noncrit Decode 5 critical Decode 6 nonrecoverable DefaultGroup Power # Dell PowerEdge 4300 Server Instrumentation Variable PE4300_TEMP_CPU OID .1.3.6.1.4.1.674.10891.300.1.5.2.2.1. Description CPU Temperature DefaultIndex 1 2 Scale / 10.0 Unit C DefaultMax 40 DefaultGroup Environment Variable PE4300_TEMP OID .1.3.6.1.4.1.674.10891.300.1.5.2.2.1. Description Temperature DefaultIndex 3 4 5 6 FriendlyName 3 @Motherboard FriendlyName 4 @Ambient FriendlyName 5 @Backplane 1 FriendlyName 6 @Backplane 2 Scale / 10.0 Unit C DefaultMax 40 DefaultGroup Environment Variable PE4300_5V_CURRENT OID .1.3.6.1.4.1.674.10891.303.1.5.2.5.1. Description DC Current (+5V) DefaultIndex 1 4 7 Scale / 1000.0 Unit A DefaultMax 25 DefaultMaxValid 100 DefaultGroup Power Variable PE4300_12V_CURRENT OID .1.3.6.1.4.1.674.10891.303.1.5.2.5.1. Description DC Current (+12V) DefaultIndex 2 5 8 Scale / 1000.0 Unit A DefaultMax 10 DefaultMaxValid 100 DefaultGroup Power Variable PE4300_3V_CURRENT OID .1.3.6.1.4.1.674.10891.303.1.5.2.5.1. Description DC Current (+3V) DefaultIndex 3 6 9 Scale / 1000.0 Unit A DefaultMax 10 DefaultMaxValid 100 DefaultGroup Power Variable PE4300_FAN_CPU_RPM OID .1.3.6.1.4.1.674.10891.301.1.5.2.3.1. Description CPU Fan Speed Unit rpm DefaultIndex 1 2 DefaultMin 1000 DefaultMax 5000 DefaultMaxValid 10000 DefaultGroup Environment # really the same as above, other index ranges only; different des... [truncated message content] |
Update of /cvsroot/mon/mon-contrib/monitors/snmpvar/snmpvar.monitor-1.4.0 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5149/snmpvar.monitor-1.4.0 Removed Files: CHANGES README example.out snmpopt.cf snmpvar.cf snmpvar.def snmpvar.monitor Log Message: updated snmpvar.monitor to 1.6.0 --- snmpopt.cf DELETED --- --- example.out DELETED --- --- README DELETED --- --- CHANGES DELETED --- --- snmpvar.monitor DELETED --- --- snmpvar.cf DELETED --- --- snmpvar.def DELETED --- |
From: Jim T. <tr...@us...> - 2005-05-02 11:50:41
|
Update of /cvsroot/mon/mon-contrib/monitors/snmpvar/ms-perfmib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5149/ms-perfmib Added Files: perfmib-setup.cmd Log Message: updated snmpvar.monitor to 1.6.0 --- NEW FILE: perfmib-setup.cmd --- rem rem Easy setup for Microsoft NT/Win2K PERFMIB SNMP extensions rem rem Requires MS PERFMIB kit (from Server Resource Kit) rem rem See KB Article Q195336 for required update version rem (ftp://ftp.microsoft.com/bussys/winnt/winnt-public/reskit/nt40/i386/) rem rem See also http://snmpboy.msft.net/asp/perfmibhack.asp rem rem rem perf2mib perfmib.mib perfmib.ini System 1 ntsys Memory 2 mem Processor 3 CPU Server 4 server PhysicalDisk 5 pdisk LogicalDisk 6 ldisk "Paging File" 7 pagefile Telephony 8 telephony rem rem other potentially interesting chapters - include on line above if desired rem "RAS Port" 9 rasport rem "RAS Total" 10 rastot rem net stop SNMP regini perfmib.reg copy perfmib.dll %systemroot%\system32\perfmib.dll copy perfmib.ini %systemroot%\system32\perfmib.ini net start SNMP |
From: Jim T. <tr...@us...> - 2005-05-02 11:50:41
|
Update of /cvsroot/mon/mon-contrib/monitors/snmpvar/ucd-snmp In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5149/ucd-snmp Added Files: mqueue snmpd.conf Log Message: updated snmpvar.monitor to 1.6.0 --- NEW FILE: mqueue --- #!/usr/bin/perl require "find.pl"; # Traverse desired filesystems $counter = 0; &find('/var/spool/mqueue/'); sub wanted { /^qf.*$/ && $counter++; } chomp $counter; print "$counter"; --- NEW FILE: snmpd.conf --- ############################################################################### # # snmpd.conf # ############################################################################### [... bulk of config file omitted ...] ############################################################################### # Extension Execs ############################################################################### # Index 1 exec mqueue /usr/bin/perl /etc/snmp/mqueue # Index 2 # ... |
From: Jim T. <tr...@us...> - 2005-05-02 11:50:41
|
Update of /cvsroot/mon/mon-contrib/monitors/snmpvar/snmpvar.monitor-1.4.0/ucd-snmp In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5149/snmpvar.monitor-1.4.0/ucd-snmp Removed Files: mqueue snmpd.conf Log Message: updated snmpvar.monitor to 1.6.0 --- mqueue DELETED --- --- snmpd.conf DELETED --- |
From: Jim T. <tr...@us...> - 2005-05-02 11:49:01
|
Update of /cvsroot/mon/mon-contrib/monitors/snmpvar/ucd-snmp In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4761/ucd-snmp Log Message: Directory /cvsroot/mon/mon-contrib/monitors/snmpvar/ucd-snmp added to the repository |
From: Jim T. <tr...@us...> - 2005-05-02 11:48:48
|
Update of /cvsroot/mon/mon-contrib/monitors/snmpvar/ms-perfmib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4707/ms-perfmib Log Message: Directory /cvsroot/mon/mon-contrib/monitors/snmpvar/ms-perfmib added to the repository |
From: Jim T. <tr...@us...> - 2005-04-28 20:00:57
|
Update of /cvsroot/mon/mon In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17159 Modified Files: mon Log Message: solaris needs setlogsock ('stream'), from ed ravin Index: mon =================================================================== RCS file: /cvsroot/mon/mon/mon,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** mon 28 Apr 2005 19:07:58 -0000 1.14 --- mon 28 Apr 2005 20:00:48 -0000 1.15 *************** *** 265,268 **** --- 265,273 ---- } + elsif ($^O eq "solaris") + { + Sys::Syslog::setlogsock ('stream'); + } + openlog ("mon", "cons,pid", $CF{"SYSLOG_FACILITY"}); |
From: Jim T. <tr...@us...> - 2005-04-28 19:59:12
|
Update of /cvsroot/mon/mon In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16283 Modified Files: Tag: mon-1-0-0pre1 mon Log Message: solaris needs setlogsock ('stream'), from ed ravin Index: mon =================================================================== RCS file: /cvsroot/mon/mon/mon,v retrieving revision 1.4.2.18 retrieving revision 1.4.2.19 diff -C2 -d -r1.4.2.18 -r1.4.2.19 *** mon 12 Apr 2005 21:27:56 -0000 1.4.2.18 --- mon 28 Apr 2005 19:59:03 -0000 1.4.2.19 *************** *** 230,233 **** --- 230,238 ---- } + elsif ($^O eq "solaris") + { + Sys::Syslog::setlogsock ('stream'); + } + openlog ("mon", "cons,pid", $CF{"SYSLOG_FACILITY"}); |
From: David N. <vi...@us...> - 2005-04-28 19:08:07
|
Update of /cvsroot/mon/mon In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19303 Modified Files: mon Log Message: Added missing argument to dep_ok to make alert suppression dependencies work again. Index: mon =================================================================== RCS file: /cvsroot/mon/mon/mon,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** mon 17 Apr 2005 07:42:25 -0000 1.13 --- mon 28 Apr 2005 19:07:58 -0000 1.14 *************** *** 3239,3243 **** $sref->{"dep_behavior"} eq "a") { ! dep_ok ($sref); } --- 3239,3243 ---- $sref->{"dep_behavior"} eq "a") { ! dep_ok ($sref, 'a'); } |