mon-commit Mailing List for mon (Page 14)
Brought to you by:
trockij
You can subscribe to this list here.
2004 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(36) |
Jul
(21) |
Aug
(9) |
Sep
(1) |
Oct
(2) |
Nov
(12) |
Dec
(6) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2005 |
Jan
(4) |
Feb
(10) |
Mar
(5) |
Apr
(22) |
May
(17) |
Jun
(3) |
Jul
(4) |
Aug
(10) |
Sep
(2) |
Oct
(1) |
Nov
(2) |
Dec
(2) |
2006 |
Jan
|
Feb
(4) |
Mar
|
Apr
|
May
|
Jun
|
Jul
(2) |
Aug
|
Sep
(6) |
Oct
|
Nov
|
Dec
(2) |
2007 |
Jan
|
Feb
|
Mar
|
Apr
(2) |
May
(22) |
Jun
(19) |
Jul
(7) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(6) |
2008 |
Jan
(1) |
Feb
(1) |
Mar
(3) |
Apr
(1) |
May
|
Jun
|
Jul
|
Aug
(4) |
Sep
|
Oct
(7) |
Nov
(1) |
Dec
|
2009 |
Jan
(2) |
Feb
(9) |
Mar
(1) |
Apr
|
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(5) |
2010 |
Jan
(2) |
Feb
(1) |
Mar
|
Apr
|
May
(4) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2011 |
Jan
|
Feb
|
Mar
(2) |
Apr
(1) |
May
(2) |
Jun
(2) |
Jul
(65) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Jim T. <tr...@us...> - 2004-06-24 14:02:57
|
Update of /cvsroot/mon/mon In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20141 Modified Files: Tag: mon-1-0-0pre1 mon Log Message: fixed a bug which would prevent alerts or upalerts from being sent when call alerts is passed the "output" argument whose value is undef Index: mon =================================================================== RCS file: /cvsroot/mon/mon/mon,v retrieving revision 1.4.2.4 retrieving revision 1.4.2.5 diff -C2 -d -r1.4.2.4 -r1.4.2.5 *** mon 18 Jun 2004 20:31:29 -0000 1.4.2.4 --- mon 24 Jun 2004 14:02:49 -0000 1.4.2.5 *************** *** 4528,4532 **** retval alert output )) { ! return (undef) if (!defined $args{$mandatory_arg}); } --- 4528,4536 ---- retval alert output )) { ! if (!exists $args{$mandatory_arg}) ! { ! debug (1, "returning from call_alert because of missing arg $mandatory_arg\n"); ! return (undef); ! } } |
From: Jim T. <tr...@us...> - 2004-06-23 13:25:40
|
Update of /cvsroot/mon/mon/mon.d In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30450 Added Files: Tag: mon-1-0-0pre1 ntpdate.monitor Log Message: from meekj with a couple changes from trockij to make it more verbose for non-failures --- NEW FILE: ntpdate.monitor --- #!/usr/bin/perl # # ntpdate.monitor Verify that NTP is running and times are within tolerance # ntpdate will do most of the work for us # =head1 NAME B<ntpdate.monitor> - ntp monitor using ntpdate to do most of the work =head1 DESCRIPTION A mon monitor to verify that ntp is running on multiple servers, those servers have synchronized time, and that the times are within specified limits. The mon server should be running ntp since the times are reported relative to the system performing the query. =head1 SYNOPSIS B<ntpdate.monitor -d -l log_file_YYYYMM.log --maxstratum nn --maxoffset n.nn> =head1 OPTIONS =over 5 =item B<--maxstratum> Maximum stratum number, default is 10. Stratum 16 indicates that ntp is running on a system, but the clock is not synchronized. An alarm will be triggered if this value is exceeded. =item B<--maxoffset> Maximum value of the clock offset in seconds, default is 0.8 s (a large value, ntp typically keeps clocks within milliseconds of each other). An alarm will be triggered if this value is exceeded. =item B<-l log_file_template> or B<--log log_file_template> /path/to/logs/internet_web_YYYYMM.log Current year & month are substituted for YYYYMM, that is the only possible template at this time. The format of the log file is: =item B<-d> Debug/Test, for manual testing only. =back =head1 MON CONFIGURATION EXAMPLE hostgroup ntp ntp1.somedomain.org ntp2.somedomain.org ntp3.somedomain.org watch ntp service ntpdate interval 30m monitor ntpdate.monitor --maxoffset 0.1 --log /usr/local/mon/logs/gv-ntp-YYYYMM.log period wd {Sun-Sat} alert mail.alert us...@so... alertevery 1h summary =head1 BUGS The location of ntpdate is hardcoded to be /usr/sbin/ntpdate. This works for Solaris 8 and RedHat Linux 7.x, at least, but it should be configurable. Check the first line of this file to be sure that it points to an appropriate perl executable. =head1 AUTHOR Jon Meek, me...@ie... =head1 SEE ALSO ntp.monitor by Daniel Hagerty <ha...@li...> =cut $RCSid = q{$Id: ntpdate.monitor,v 1.1.2.1 2004/06/23 13:25:32 trockij Exp $ }; # # Jon Meek # Lawrenceville, NJ # me...@ie... # # # $Id: ntpdate.monitor,v 1.1.2.1 2004/06/23 13:25:32 trockij Exp $ # # Copyright (C) 2002, Jon Meek # # 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::Long; use Data::Dumper; GetOptions( "maxstratum=i" => \$MaxStratum, "maxoffset=f" => \$MaxOffset, # "dns" => \$UseDNS, "d" => \$opt_d, "l=s" => \$opt_l, "log=s" => \$opt_l, ); use Net::DNS; # # Set Defaults # # ntpdate reports stratum 16 if ntp is running, but time is not synchronized # stratum 0 will be reported if ntp is not running # $MaxStratum = 10 unless $MaxStratum; $MinStratum = 1; # # Trigger alarm if the time is ever off by this much # $MaxOffset = 0.800 unless $MaxOffset; # Seconds $NTPDATE = '/usr/sbin/ntpdate'; @Failures = (); @Hosts = @ARGV; # Host names are left on the command line after Getopt %NameByIP = &DNSlookups(\@Hosts); $TimeOfDay = time; # Current time print "TimeOfDay: $TimeOfDay\n" if $opt_d; $cmd = qq{$NTPDATE -q @Hosts |}; $pid = open(NTP, $cmd) || die "Couldn't run $cmd\n"; while ($in = <NTP>) { # print $in if $opt_d; chomp $in; # # Pick out server strings # if ($in =~ /^server\s+([\d\.]+),\s+stratum\s+(\d+),\s+offset\s+([\d\.\-\+]+),\s+delay\s+([\d\.\-\+]+)/) { $ip = $1; $stratum = $2; $offset = $3; $delay = $4; $name = $NameByIP{$ip}; print "$in $name\n" if $opt_d; # # Prepare log entries # if (exists $NameByIP{$ip}) { $hostnameforlog = $NameByIP{$ip}; } else { $hostnameforlog = $ip; } if ($opt_l or $opt_d) { $LogString{$ip} = qq{$TimeOfDay $hostnameforlog $stratum $offset $delay}; } # # Check alarm limits # if (($stratum > $MaxStratum) || ($stratum < $MinStratum) || (abs($offset) > $MaxOffset)) { $FailureDetail{$ip} = $in; print "Fail: $ip $stratum $offset $delay $name\n" if $opt_d; } else { $SuccessDetail{$ip} = sprintf ("%-20s %-7d %-2.5f %-2.5f", $hostnameforlog, $stratum, $offset, $delay); } } # Ignore the final line for now, probably not needed at all # # if ($in =~ / adjust time server\s+([\d\.]+)\s+offset\s+([\d\.\-\+]+)\s+/) { # $ip = $1; # $offset = $2; # if (abs($offset) > $MaxOffset) { # $FailureDetail{$ip} = $in; # print "Fail: $ip $offset\n" if $opt_d; # } # } } # # Write results to logfile, if -l # if ($opt_l) { $LogFile = $opt_l; ($sec, $min, $hour, $mday, $Month, $Year, $wday, $yday, $isdst) = localtime($TimeOfDay); $Month++; $Year += 1900; $YYYYMM = sprintf('%04d%02d', $Year, $Month); $LogFile =~ s/YYYYMM/$YYYYMM/; # Fill in current year and month if (-e $LogFile) { # Check for existing log file $NewLogFile = 0; } else { $NewLogFile = 1; } open(LOG, ">>$LogFile") || warn "$0 Can't open logfile: $LogFile\n"; foreach $ip (sort keys %LogString) { print LOG "$LogString{$ip}\n"; } close LOG; } if ($opt_d) { foreach $ip (sort keys %LogString) { print "LOG: $LogString{$ip}\n"; } } foreach $ip (sort keys %FailureDetail) { push(@FailureIP, $FailureDetail{$ip}); push(@FailuresIP, $ip); } # # Otherwise we have one or more failures # foreach $ip (@FailuresIP) { if (exists $NameByIP{$ip}) { push(@FailuresName, $NameByIP{$ip}); } else { push(@FailuresName, $ip); } } @SortedFailures = sort @FailuresName; print "@SortedFailures\n"; if (@FailuresIP) { print "servers which have a failure:\n\n"; foreach $ip (sort keys %FailureDetail) { print "$NameByIP{$ip} $ip $FailureDetail{$ip}\n"; } print "\n\n"; } # # show details for non-failed hosts # print "servers which have no failures:\n\n"; printf ("%-20s %-2s %-8s %-8s\n", "server", "stratum", "offset", "delay"); print "-" x 50 . "\n"; foreach my $k (sort keys %SuccessDetail) { print "$SuccessDetail{$k}\n"; } if (@FailuresIP == 0) { # Indicate "all OK" to mon exit 0; } exit 1; # Indicate failure to mon # # Get the IP addresses for the hosts (because ntpdate returns IP addresses) # sub DNSlookups { my ($Hosts) = @_; $res = new Net::DNS::Resolver; for (my $i = 0; $i < @$Hosts; $i++) { $target = $Hosts->[$i]; $query = $res->search($target); if ($query) { foreach $rr ($query->answer) { #print "$target Type: ", $rr->type, "\n" if $opt_d; if ($rr->type eq "A") { print $rr->address . ' ' if $opt_d; $NameByIP{$rr->address} = $target; } } } } return %NameByIP; } |
From: Jim T. <tr...@us...> - 2004-06-23 12:20:14
|
Update of /cvsroot/mon/mon/mon.d In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17644 Modified Files: Tag: mon-1-0-0pre1 up_rtt.monitor Log Message: added -r to log individual rtts better error reporting for tcp and udp check Index: up_rtt.monitor =================================================================== RCS file: /cvsroot/mon/mon/mon.d/up_rtt.monitor,v retrieving revision 1.1.1.1 retrieving revision 1.1.1.1.2.1 diff -C2 -d -r1.1.1.1 -r1.1.1.1.2.1 *** up_rtt.monitor 9 Jun 2004 05:18:04 -0000 1.1.1.1 --- up_rtt.monitor 23 Jun 2004 12:19:55 -0000 1.1.1.1.2.1 *************** *** 8,12 **** # Requires Perl Modules "Time::HiRes" and "Statistics::Descriptive" # ! # # # $Id$ --- 8,12 ---- # Requires Perl Modules "Time::HiRes" and "Statistics::Descriptive" # ! # # # $Id$ *************** *** 48,52 **** use Statistics::Descriptive; ! getopts ("dt:T:l:U:"); # -d Debug mode --- 48,52 ---- use Statistics::Descriptive; ! getopts ("drt:T:l:U:"); # -d Debug mode *************** *** 56,67 **** # -l file Log file name with optional YYYYMM part that will be transformed to current month # -U num Number of UDP packets to send $TimeOut = $opt_t || 10; # Timeout in seconds ! $NUM_UDP_TRYS = $opt_U || 5; # Number of UDP packet to send # Solaris MSG_WAITALL 0x40 /* Wait for complete recv or error */ #linux/socket.h:#define MSG_WAITALL 0x100 /* Wait for a full request */ ! # $RecvRet = recv($S, $Echo, $DataLength, 64); # Solaris & older versions of Linux #$RecvFlags = 0; # May work on all systems due to small packets used here --- 56,68 ---- # -l file Log file name with optional YYYYMM part that will be transformed to current month # -U num Number of UDP packets to send + # -r Log individual raw RTTs $TimeOut = $opt_t || 10; # Timeout in seconds ! $NUM_UDP_TRYS = $opt_U || 5; # Number of UDP packets to send # Solaris MSG_WAITALL 0x40 /* Wait for complete recv or error */ #linux/socket.h:#define MSG_WAITALL 0x100 /* Wait for a full request */ ! # $RecvRet = recv($S, $Echo, $DataLength, 64); # Solaris & older versions of Linux #$RecvFlags = 0; # May work on all systems due to small packets used here *************** *** 81,84 **** --- 82,87 ---- foreach $TargetHost (@Hosts) { + undef @RawRTT; + $stat = Statistics::Descriptive::Full->new(); *************** *** 104,113 **** $count = $stat->count(); ! $ResultString{$TargetHost} = sprintf "%d %s %0.4f %0.4f %0.4f %d", ! $TimeOfDay, $TargetHost, $min, $mean, $max, $count; if ($opt_T) { # Check minimum RTT for alarm limit if ($min > $opt_T) { ! push (@Failures, $TargetHost); } } --- 107,125 ---- $count = $stat->count(); ! if ($opt_r && (defined @RawRTT)) { ! $ResultString{$TargetHost} = sprintf "%d %s", ! $TimeOfDay, $TargetHost; ! foreach $rtt (@RawRTT) { ! $ResultString{$TargetHost} .= sprintf " %0.4f", $rtt; ! } ! } else { ! $ResultString{$TargetHost} = sprintf "%d %s %0.4f %0.4f %0.4f %d", ! $TimeOfDay, $TargetHost, $min, $mean, $max, $count; ! } if ($opt_T) { # Check minimum RTT for alarm limit if ($min > $opt_T) { ! print "Minimum RTT pushing $host\n" if $opt_d; ! push (@Failures, $TargetHost); } } *************** *** 139,149 **** if (@Failures == 0) { # Indicate "all OK" to mon ! exit 0; } ! print "@Failures\n"; ! foreach $host (sort @Failures) { ! print "$host: $ResultString{$host} "; } print "\n"; --- 151,165 ---- if (@Failures == 0) { # Indicate "all OK" to mon ! print "\n--------- No Failures ---------\n" if $opt_d; ! exit 0; } ! print "\n--------- Have Failures - mon Data Below ---------\n" if $opt_d; ! @SortedFailures = sort @Failures; ! print "@SortedFailures\n"; ! ! foreach $host (@SortedFailures) { ! print "$ResultString{$host}\n"; } print "\n"; *************** *** 155,159 **** # ! sub UDPcheck { my($TargetHost) = @_; my($DroppedPackets, $GoodPackets); --- 171,175 ---- # ! sub UDPcheck { # Send multiple UDP packets my($TargetHost) = @_; my($DroppedPackets, $GoodPackets); *************** *** 161,164 **** --- 177,181 ---- $DroppedPackets = 0; $GoodPackets = 0; + $dt = -1; # Will report -1 on failure $S = new IO::Socket::INET (PeerAddr => $TargetHost, *************** *** 167,171 **** ); do { ! &LeaveError($TargetHost, "Can't open UDP socket to $TargetHost\n"); return 0; } unless ($S); --- 184,188 ---- ); do { ! &udpLeaveError($TargetHost, "Can't open UDP socket to $TargetHost\n"); return 0; } unless ($S); *************** *** 177,180 **** --- 194,198 ---- # $Out .= ' 'x52; # Make a 56+ byte packet $DataLength = length($Out); + $Echo = ''; # Clear input buffer $t1 = [gettimeofday]; *************** *** 199,202 **** --- 217,221 ---- if ($Echo eq $Out) { $stat->add_data($dt); + push(@RawRTT, $dt); if ($opt_d) { print "$i - $DataLength - $dt -$Echo-\n"; *************** *** 208,212 **** } } - } } --- 227,230 ---- *************** *** 215,223 **** } ! sub TCPcheck { my($TargetHost) = @_; my($DroppedPackets, $GoodPackets, $dt); $S = new IO::Socket::INET (PeerAddr => $TargetHost, PeerPort => 7, --- 233,245 ---- } ! sub TCPcheck { # Send a single TCP packet my($TargetHost) = @_; my($DroppedPackets, $GoodPackets, $dt); + $GoodPackets = 0; + $i = 1; + $dt = -1; # Will report -1 on failure + $S = new IO::Socket::INET (PeerAddr => $TargetHost, PeerPort => 7, *************** *** 225,235 **** ); do { ! &LeaveError($TargetHost, "Can't open TCP socket to $TargetHost\n"); ! return 0; } unless ($S); - $GoodPackets = 0; - $i = 1; - $dt = -1; # Will report -1 on failure $Out = "TCP$i"; $DataLength = length($Out); --- 247,254 ---- ); do { ! &tcpLeaveError($TargetHost, "Can't open TCP socket to $TargetHost\n"); ! return $GoodPackets, $dt; } unless ($S); $Out = "TCP$i"; $DataLength = length($Out); *************** *** 270,279 **** } ! sub LeaveError { my ($host, $reason) = @_; push (@Failures, $host); - # $ResultString{$host} .= $reason; - # push (@FailReasons, $reason); - # print "$reason\n"; } --- 289,301 ---- } ! sub udpLeaveError { # Don't call this one a failure, TCP might work my ($host, $reason) = @_; + print "udpLeaveError $host\n" if $opt_d; + } + + sub tcpLeaveError { # If we get here, it was a failure + my ($host, $reason) = @_; + print "tcpLeaveError pushing $host\n" if $opt_d; push (@Failures, $host); } |
From: Jim T. <tr...@us...> - 2004-06-22 15:31:14
|
Update of /cvsroot/mon/mon/mon.d In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24410 Modified Files: Tag: mon-1-0-0pre1 smtp3.monitor Log Message: added logging, mx lookup, diagnostics, tls checking, --nofail, and --port Index: smtp3.monitor =================================================================== RCS file: /cvsroot/mon/mon/mon.d/smtp3.monitor,v retrieving revision 1.1.1.1 retrieving revision 1.1.1.1.2.1 diff -C2 -d -r1.1.1.1 -r1.1.1.1.2.1 *** smtp3.monitor 9 Jun 2004 05:18:05 -0000 1.1.1.1 --- smtp3.monitor 22 Jun 2004 15:31:00 -0000 1.1.1.1.2.1 *************** *** 1,3 **** ! #!/usr/bin/perl # Yet another smtp monitor using IO::Socket with timing and logging --- 1,3 ---- ! #!/usr/local/bin/perl # Yet another smtp monitor using IO::Socket with timing and logging *************** *** 6,10 **** # $Id$ # ! # Copyright (C) 2001, Jon Meek, me...@ie... # # This program is free software; you can redistribute it and/or modify --- 6,10 ---- # $Id$ # ! # Copyright (C) 2001-2003, Jon Meek, me...@ie... # # This program is free software; you can redistribute it and/or modify *************** *** 25,40 **** =head1 NAME ! B<smtp3.monitor> - smtp monitor for mon with timing and logging =head1 DESCRIPTION A SMTP monitor using IO::Socket with connection response timing and ! optional logging. This test is simple, as soon as the greeting banner ! is received from the SMTP server the monitor client closes the session ! with a QUIT command. =head1 SYNOPSIS ! B<smtp3.monitor> -l log_file_YYYYMM.log -t timeout_seconds -T alarm_time host host1 host2 ... =head1 OPTIONS --- 25,46 ---- =head1 NAME ! B<smtp3.monitor> - smtp monitor for mon with timing, logging, optional MX lookup, and diagnostic capability. =head1 DESCRIPTION A SMTP monitor using IO::Socket with connection response timing and ! optional logging. This test is reasonably complete. Following the ! greeting banner from the SMTP server the monitor client issues the ! HELO and MAIL commands then closes the session with a QUIT ! command. Early versions of this monitor simply looked at the initial ! greeting banner, but that did not detect certain temporary failure ! conditions. ! ! While configuring mon for this monitor keep in mind that a busy mail ! server may reject new connections. =head1 SYNOPSIS ! B<smtp3.monitor> [-d] [-l log_file_YYYYMM.log] [--timeout timeout_seconds] [--alarmtime alarm_time] [--mx] [--esmtp] [--requiretls] [--nofail] [--from us...@do...] [--to r1...@d1...,r2...@d2...] [--size nnnnn] [--port nn] host host1 host2 ... =head1 OPTIONS *************** *** 42,51 **** =over 5 ! =item B<-d> Debug/Test ! =item B<-t timeout> Connect timeout in seconds ! =item B<-T alarm_timeout> Alarm if connect is successful but took ! longer than alarm_timeout seconds =item B<-l log_file_template> /path/to/logs/smtp_YYYYMM.log --- 48,59 ---- =over 5 ! =item B<-d> Debug/Diagnostic mode. Useful for manual command line use ! for diagnosing mail delivery problems. To determine if a mail destination ! will accept mail the --mx flag will useful. ! =item B<--timeout timeout> Connect timeout in seconds. ! =item B<--alarmtime alarm_timeout> Alarm if connect is successful but took ! longer than alarm_timeout seconds. =item B<-l log_file_template> /path/to/logs/smtp_YYYYMM.log *************** *** 53,56 **** --- 61,90 ---- possible template at this time. + =item B<--mx> Lookup the MX records for the domains/hosts and test + them in preference order. The first successful test will be + considered a success for that domain. This was originally devised for + manual command line use as a tool to verify that mail stuck in + outbound queues really can not be delivered. It could be used with mon + as well, however you are usually going to want to test ALL of your + smtp servers, not just be sure that one of them is OK. --mx applies to + all of the domains/hosts listed on the command line. + + =item B<--esmtp> + + Try ESMTP before SMTP. + + =item B<--requiretls> + + Check that STARTTLS is offered, fail if it is not. This option forces B<--esmtp>. + + =item B<--nofail> + + Never provide a failure return to mon. Useful in certain testing envrionments + when logging. + + =item B<--port nnn> + + Specify a port to use. Defaults to 25. + =back *************** *** 63,67 **** service smtp_check interval 5m ! monitor smtp3.monitor -t 70 -T 30 -l /n/na1/logs/wan/smtp_YYYYMM.log period wd {Sun-Sat} alert mail.alert me...@my... --- 97,101 ---- service smtp_check interval 5m ! monitor smtp3.monitor --timeout 70 --alarmtime 30 -l /n/na1/logs/wan/smtp_YYYYMM.log period wd {Sun-Sat} alert mail.alert me...@my... *************** *** 83,93 **** F<measurement_time> - Is the time of the connection attempt in seconds since 1970 ! F<smtp_host_name> - Is the name of the smtp server that was tested F<connect_time> - Is the time from the connect request until the SMTP ! greeting appeared in seconds with 100 microsecond resolution F<smtp_code_and_banner> - Should have the SMTP response code integer ! followed by the greeting banner F<connect_error> - If present may indicate "Connect failed" meaning --- 117,131 ---- F<measurement_time> - Is the time of the connection attempt in seconds since 1970 ! F<smtp_host_name> - Is the name of the smtp server that was tested. If ! --mx was selected then this field is servername=MX_record where ! MX_record is the mail domain (host) from the command line. F<connect_time> - Is the time from the connect request until the SMTP ! greeting appeared in seconds with 100 microsecond resolution. If the ! connection failed the time spent waiting for the connection will be a ! negative number. F<smtp_code_and_banner> - Should have the SMTP response code integer ! followed by the greeting banner if there was a problem. F<connect_error> - If present may indicate "Connect failed" meaning *************** *** 99,110 **** =head1 BUGS ! A SMTP temporary failure code should cause the monitor to retry the connection. ! This initial release has seen less than one day of testing. ! =head1 REQUIRED PERL MODULES IO::Socket Time::HiRes If you do not have Time::HiRes you can choose to comment out the lines --- 137,153 ---- =head1 BUGS ! It should be possible to specify --esmtp and --requiretls on a per-host basis. ! A SMTP temporary failure code could cause the monitor to retry the connection ! a certain number of times. ! It is not yet possible to specify the username / domain for the HELO and ! MAIL commands, but it would be very simple to add. ! ! =head1 REQUIRED NON-STANDARD PERL MODULES IO::Socket Time::HiRes + Net::DNS (only if --mx option will be used) If you do not have Time::HiRes you can choose to comment out the lines *************** *** 116,196 **** =cut ! ! use Getopt::Std; use IO::Socket; use Time::HiRes qw( gettimeofday tv_interval ); ! $RCSid = q{$Id$}; ! getopts ("ds:t:T:l:"); # s not used yet, may be optional smtp command ! $TimeOut = $opt_t || 30; # Default timeout in seconds ! $dt = 0; # Initialize connect time variable ! @Failures = (); ! $TimeOfDay = time; print "TimeOfDay: $TimeOfDay\n" if $opt_d; - foreach $host (@ARGV) { # Check each host - - print "Check: $host\n" if $opt_d; - push(@HostNames, $host); - $TestTime{$host} = time; # ! # Use eval/alarm to handle timeout # ! eval { ! local $SIG{ALRM} = sub { die "timeout\n" }; # Alarm handler ! ! alarm($TimeOut); # Do a SIG_ALRM in $TimeOut seconds ! $t1 = [gettimeofday]; # Start connection timer, then connect ! $sock = IO::Socket::INET->new(PeerAddr => $host, ! PeerPort => 'smtp(25)', ! Proto => 'tcp'); ! if (defined $sock) { # Connection succeded ! $in = <$sock>; # Get banner ! $t2 = [gettimeofday]; # Stop clock ! chomp $in; # Clean up banner EOL ! $ResponseBanner{$host} = $in; ! print "banner: $in\n" if $opt_d; ! # print $sock "NOOP\r\n"; # may want to add optional command later ! print $sock "QUIT\r\n"; # Shutdown connection ! close $sock; ! $dt = tv_interval ($t1, $t2); # Compute connection time ! if ($in !~ /^220\s+/) { # Consider "220 Service ready" to be only valid ! push(@Failures, $host); # Note failure ! $FailureDetail{$host} = $in; # Save failure banner } ! $ConnectTime{$host} = sprintf("%0.4f", $dt); # Format to 100us resolution ! if ($opt_T) { # Check for slow response ! if ($dt > $opt_T) { ! push(@Failures, $host); # Call it a failure ! $FailureDetail{$host} = "Slow Connect"; } } ! ! } else { # Connection failed ! ! print "Connect to $host failed\n" if $opt_d; ! push(@Failures, $host); # Save failed host ! $FailureDetail{$host} = "Connect failed"; ! $ConnectTime{$host} = -1; } - }; - alarm(0); # Stop alarm countdown - if ($@ =~ /timeout/) { # Detect timeout failures - push(@Failures, $host); - $FailureDetail{$host} = "Connect timeout"; - $ConnectTime{$host} = -1; } } if ($opt_d) { foreach $host (sort @HostNames) { ! print "$TestTime{$host} $host $ConnectTime{$host} $ResponseBanner{$host}\n"; } } --- 159,297 ---- =cut ! use English; ! use Sys::Hostname; ! use Getopt::Long; use IO::Socket; use Time::HiRes qw( gettimeofday tv_interval ); ! $RCSid = q{$Id$ }; ! $ESMTP = 0; ! $RequireTLS = 0; ! GetOptions ('mx' => \$UseMX, ! 'd' => \$opt_d, ! 'esmtp' => \$ESMTP, ! 'requiretls' => \$RequireTLS, ! 'timeout=i' => \$TimeOut, ! 't=i' => \$TimeOut, ! 'alarmtime=i' => \$opt_T, ! 'T=i' => \$opt_T, ! 'logfile=s' => \$opt_l, ! 'l=s' => \$opt_l, ! 'nofail' => \$NoFail, ! 'size=i' => \$MessageSize, ! 'port=i' => \$Port, ! 'from=s' => \$FromAddress, ! 'to=s' => \$ToAddresses, ! ); ! $ESMTP = 1 if $RequireTLS; ! if ($UseMX) { # Will need Net::DNS Module, but don't require the module if it won't be used ! eval "use Net::DNS"; ! do { ! warn "Couldn't load Net::DNS: $@"; ! undef $UseMX; ! } unless ($@ eq ''); ! $Resolver = new Net::DNS::Resolver; ! } ! ! $Port = 'smtp(25)' unless $Port; ! $TimeOut = 30 unless $TimeOut; # Default timeout in seconds ! $dt = 0; # Initialize connect time variable ! ! @Failures = (); # Initialize failure list ! ! $TimeOfDay = time; # Current time print "TimeOfDay: $TimeOfDay\n" if $opt_d; # ! # Get the process username and the hostname of the monitor machine # ! $MonitorUsername = getpwuid($UID); ! $MonitorHostname = hostname; ! $host_address = gethostbyname($MonitorHostname); ! $MonitorHostname = gethostbyaddr($host_address, AF_INET); ! $FromAddress = qq{$MonitorUsername\@$MonitorHostname} unless $FromAddress; ! print " From: $FromAddress\n" if $opt_d; ! print " TimeOut: $TimeOut\n" if $opt_d; ! ! # ! # Check each host, or MX record ! # ! foreach $host (@ARGV) { ! print "Check: $host\n" if $opt_d; ! # ! # Get the MX records, if we need them ! # ! if ($UseMX) { ! undef %MXval; ! undef @MXorder; ! @mx = mx($Resolver, $host); ! if (@mx) { ! foreach $rr (@mx) { ! $preference = $rr->preference; ! $mxrecord = $rr->exchange; ! $MXval{$mxrecord} = $preference; } ! } else { ! print "can't find MX records for $host: ", $Resolver->errorstring, "\n" if $opt_d; ! push(@Failures, $host); # Call it a failure ! $FailureDetail{$host} = "Can't find MX records"; ! next; ! } ! # ! # Sort the MX records into preference order ! # ! print "MX records for $host:\n" if $opt_d; ! foreach $k (sort {$MXval{$a} <=> $MXval{$b}} keys %MXval) { ! $Arecord = ''; # Clear for this MX ! push(@MXorder, $k); ! if ($opt_d) { # If in debug/verbose mode lookup A record ! $name = $k . '.'; # Append dot for absolute lookup ! if ($packet = $Resolver->search($name)) { ! @answer = $packet->answer; ! foreach $rr (@answer) { ! $address = ''; ! $name = $rr->name; ! $type = $rr->type; ! $address = $rr->address if ($type eq 'A'); ! $Arecord .= "$type: $address "; # Append, in case some other records are found ! } ! } else { ! $arecord = "Could not find A record for $name"; } } ! printf " %3d - %s %s\n", $MXval{$k}, $k, $Arecord if $opt_d; } } + # + # Now actually do the smtp check + # + if ($UseMX && @mx) { # Check MX records, stop after first success + foreach $mx (@MXorder) { + $HostPlusMX = "$host=$mx"; + push(@HostNames, $HostPlusMX); + $TestTime{$HostPlusMX} = time; + print "Checking $HostPlusMX\n" if $opt_d; + $result = &CheckSMTP($HostPlusMX); + last if ($result); + } + } else { # Regular host check + push(@HostNames, $host); + $TestTime{$host} = time; + $result = &CheckSMTP($host); + } } if ($opt_d) { foreach $host (sort @HostNames) { ! print "$TestTime{$host} $host $ConnectTime{$host} $InitialBanner{$host}\n"; ! # ($shortfail, $rest) = split(/\n/, $InitialBanner{$host}, 2); ! # print "$TestTime{$host} $host $ConnectTime{$host} $shortfail\n"; } } *************** *** 207,213 **** $YYYYMM = sprintf('%04d%02d', $Year, $Month); $LogFile =~ s/YYYYMM/$YYYYMM/; # Fill in current year and month ! open(LOG, ">>$LogFile") || warn "$0 Can't open logfile: $LogFile\n"; foreach $host (sort @HostNames) { print LOG "$TestTime{$host} $host $ConnectTime{$host} $FailureDetail{$host}\n"; } --- 308,318 ---- $YYYYMM = sprintf('%04d%02d', $Year, $Month); $LogFile =~ s/YYYYMM/$YYYYMM/; # Fill in current year and month ! open(LOG, ">>$LogFile") || warn "$0 Can't open logfile: $LogFile\n"; foreach $host (sort @HostNames) { + $FailureDetail{$host} =~ s/\n/ /g; # Put it on one line, but result may be too long + $FailureDetail{$host} =~ s/ $//; # Trim final space + # ($shortfail, $rest) = split(/\n/, $FailureDetail{$host}, 2); + # print LOG "$TestTime{$host} $host $ConnectTime{$host} $shortfail\n"; print LOG "$TestTime{$host} $host $ConnectTime{$host} $FailureDetail{$host}\n"; } *************** *** 231,239 **** print "\n"; ! exit 1; # Indicate failure to mon __END__ ! SMTP Reply Codes From RFC-821 - may use in the future --- 336,525 ---- print "\n"; ! exit 0 if $NoFail; # Never indicate failure if $NoFail is set ! exit 1; # Indicate failure to mon ! ! sub CheckSMTP { ! my $host = shift; ! my $t1, $t2, $dt, $mx_name, $stripped_host; ! my $Failure = 0; # Flag to indicate failure for return code ! # return 0 may not be working inside eval ! ! my $buflength = 1024; ! ! if ($host =~ /=/) { # Have MX data ! ($mx_name, $stripped_host) = split(/=/, $host); ! } else { ! $stripped_host = $host; ! } + # + # Use eval/alarm to handle timeout + # + eval { + local $SIG{ALRM} = sub { die "timeout\n" }; # Alarm handler + + alarm($TimeOut); # Do a SIG_ALRM in $TimeOut seconds + $t1 = [gettimeofday]; # Start connection timer, then connect + my $sock = IO::Socket::INET->new(PeerAddr => $stripped_host, + PeerPort => $Port, + Proto => 'tcp'); + + if (defined $sock) { # Connection succeded + + $in = ''; + $bytes = sysread($sock, $in, $buflength); # Handle multi-line banners + $InitialBanner{$host} = $in; + + $t2 = [gettimeofday]; # Stop clock + print " Banner: $InitialBanner{$host}\n" if $opt_d; + + if ($InitialBanner{$host} !~ /^220/) { # Consider "220 Service ready" to be only valid + push(@Failures, $host); # Note failure + if (length($InitialBanner{$host}) == 0) { # Note empty banner + $InitialBanner{$host} = 'null'; + } + $FailureDetail{$host} = "BANNER: " . $InitialBanner{$host}; # Save failure banner + $ConnectTime{$host} = -1; + # last; + $Failure = 1; + print "QUIT\r\n" if $opt_d; + print $sock "QUIT\r\n"; # Shutdown connection + close $sock; + return 0; + } + + if ($ESMTP) { # Try EHLO first + print "EHLO $MonitorHostname\r\n" if $opt_d; + print $sock "EHLO $MonitorHostname\r\n"; + + $in = ''; + $bytes = sysread($sock, $in, $buflength); # Handle multi-line banners + $EhloResponse{$host} = $in; + + print " EHLO resp: $EhloResponse{$host}\n" if $opt_d; + if ($EhloResponse{$host} !~ /^250/) { # Consider "250 Requested mail action okay, completed" to be only valid + push(@Failures, $host); # Note failure + print "EHLO Failure!\n" if $opt_d; + $FailureDetail{$host} = "EHLO: " . $EhloResponse{$host}; # Save failure banner + #last; + $Failure = 1; + print "QUIT\r\n" if $opt_d; + print $sock "QUIT\r\n"; # Shutdown connection + close $sock; + return 0 if $RequireESMTP; + } + + if ($RequireTLS && ($EhloResponse{$host} !~ /STARTTLS/)){ # Check TLS advertisement + push(@Failures, $host); # Note failure + $FailureDetail{$host} = "STARTTLS Not Offered "; + print "STARTTLS Not Offered!\n" if $opt_d; + print $sock "QUIT\r\n"; # Shutdown connection + close $sock; + return 0; + } + + } + + if (!$ESMTP or ($ESMTP && $Failure)) { + print $sock "HELO $MonitorHostname\r\n"; + + $in = ''; + $bytes = sysread($sock, $in, $buflength); # Handle multi-line banners + $HeloResponse{$host} = $in; + + print " HELO resp: $HeloResponse{$host}\n" if $opt_d; + if ($HeloResponse{$host} !~ /^250/) { # Consider "250 Requested mail action okay, completed" to be only valid + push(@Failures, $host); # Note failure + print "HELO Failure!\n" if $opt_d; + $FailureDetail{$host} = "HELO: " . $HeloResponse{$host}; # Save failure banner + #last; + $Failure = 1; + print "QUIT\r\n" if $opt_d; + print $sock "QUIT\r\n"; # Shutdown connection + close $sock; + return 0; + } + } + + $FromLine = qq{MAIL From:<$FromAddress>}; + if ($MessageSize) { + $FromLine .= qq{ SIZE=$MessageSize}; + } + $FromLine .= qq{\r\n}; + print $FromLine if $opt_d; + print $sock $FromLine; + + chomp($MailResponse{$host} = <$sock>); + print " MAIL resp: $MailResponse{$host}\n" if $opt_d; + if ($MailResponse{$host} !~ /^250\s+/) { # Consider "250 Requested mail action okay, completed" to be only valid + push(@Failures, $host); # Note failure + $FailureDetail{$host} = "MAIL: " . $MailResponse{$host}; # Save failure banner + #last; + $Failure = 1; + print "QUIT\r\n" if $opt_d; + print $sock "QUIT\r\n"; # Shutdown connection + close $sock; + return 0; + } + + if ($ToAddresses) { # Addresses given on command line + (@to_addrs) = split(/,/, $ToAddresses); + foreach $to (@to_addrs) { + $RcptCommand = qq{RCPT TO:<$to>}; + print "$RcptCommand\r\n" if $opt_d; + print $sock "$RcptCommand\r\n"; + chomp($RcptResponse = <$sock>); + print " RCPT resp: $RcptResponse\n" if $opt_d; + } + } + + print "QUIT\r\n" if $opt_d; + print $sock "QUIT\r\n"; # Shutdown connection + close $sock; + + $dt = tv_interval ($t1, $t2); # Compute connection time + $ConnectTime{$host} = sprintf("%0.4f", $dt); # Format to 100us resolution + + if ($opt_T) { # Check for slow response + if ($dt > $opt_T) { + push(@Failures, $host); # Call it a failure + $FailureDetail{$host} = "Slow Connect"; + $Failure = 1; + return 0; + } + } + + } else { # Connection failed + $t2 = [gettimeofday]; # Stop clock + $dt = tv_interval ($t1, $t2); # Compute connection time + $ConnectTime{$host} = sprintf("-%0.4f", $dt); # Format to 100us resolution, -val if failure + print " Connect to $host failed\n" if $opt_d; + push(@Failures, $host); # Save failed host + $FailureDetail{$host} = "Connect failed"; + $Failure = 1; + return 0; + } + }; + alarm(0); # Stop alarm countdown + if ($@ =~ /timeout/) { # Detect timeout failures + $t2 = [gettimeofday]; # Stop clock + $dt = tv_interval ($t1, $t2); # Compute connection time + $ConnectTime{$host} = sprintf("-%0.4f", $dt); # Format to 100us resolution, -val if timeout + push(@Failures, $host); + print " Connect to $host timed-out\n" if $opt_d; + $FailureDetail{$host} = "Connect timeout"; + $Failure = 1; + return 0; + } + + if ($Failure) { # Important when an MX record list is being checked + return 0; + } else { + return 1; + } + } __END__ ! SMTP Reply Codes From RFC-821 - may use in the future *************** *** 247,253 **** 250 Requested mail action okay, completed 251 User not local; will forward to <forward-path> ! 354 Start mail input; end with <CRLF>.<CRLF> ! 421 <domain> Service not available, closing transmission channel --- 533,539 ---- 250 Requested mail action okay, completed 251 User not local; will forward to <forward-path> ! 354 Start mail input; end with <CRLF>.<CRLF> ! 421 <domain> Service not available, closing transmission channel *************** *** 258,262 **** 451 Requested action aborted: local error in processing 452 Requested action not taken: insufficient system storage ! 500 Syntax error, command unrecognized [This may include errors such as command line too long] --- 544,548 ---- 451 Requested action aborted: local error in processing 452 Requested action not taken: insufficient system storage ! 500 Syntax error, command unrecognized [This may include errors such as command line too long] |
From: Jim T. <tr...@us...> - 2004-06-22 12:24:30
|
Update of /cvsroot/mon/mon/mon.d In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19754 Modified Files: Tag: mon-1-0-0pre1 traceroute.monitor Log Message: fixed crlf problem Index: traceroute.monitor =================================================================== RCS file: /cvsroot/mon/mon/mon.d/traceroute.monitor,v retrieving revision 1.1.1.1.2.1 retrieving revision 1.1.1.1.2.2 diff -C2 -d -r1.1.1.1.2.1 -r1.1.1.1.2.2 *** traceroute.monitor 22 Jun 2004 12:11:52 -0000 1.1.1.1.2.1 --- traceroute.monitor 22 Jun 2004 12:24:19 -0000 1.1.1.1.2.2 *************** *** 1,516 **** ! #!/usr/bin/perl ! # ! # mon monitor to watch for route changes ! # ! ! # There is currently a hardcoded path to the traceroute binary, see $TRACEROUTE ! # but it can be overriden in the config file. ! ! # ! # Jon Meek - 31-May-1999 (original code) [...1003 lines suppressed...] ! (@current_ips) = split(/\-/, $current_route); ! (@prev_ips) = split(/\-/, $prev_route); ! ! if ($#current_ips != $#prev_ips) { # Another simple case, different number of hops ! return 1; # Fail ! } ! ! for ($i = 0; $i <= $#current_ips; $i++) { ! $ip1 = $current_ips[$i]; ! $ip2 = $prev_ips[$i]; ! next if ($ip1 eq $ip2); ! $equiv_check = grep /^$ip2$/, @{ $EquivIP{$ip1} }; ! if ($equiv_check == 0) { # Not same, or equivalent, route different, fail ! return 1; ! } ! print "$i $ip1 $ip2 $equiv_check\n" if $opt_d; ! } ! return 0; # Good, no route change ! } ! |
From: Jim T. <tr...@us...> - 2004-06-22 12:12:03
|
Update of /cvsroot/mon/mon/mon.d In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10458 Modified Files: Tag: mon-1-0-0pre1 traceroute.monitor Log Message: patch to traceroute.monitor from meekj added StateDir, TracerouteOptions, StopAt config options some bugfixes to config file parsing reap children to avoid defunct processes added timeout alarm Index: traceroute.monitor =================================================================== RCS file: /cvsroot/mon/mon/mon.d/traceroute.monitor,v retrieving revision 1.1.1.1 retrieving revision 1.1.1.1.2.1 diff -C2 -d -r1.1.1.1 -r1.1.1.1.2.1 *** traceroute.monitor 9 Jun 2004 05:18:05 -0000 1.1.1.1 --- traceroute.monitor 22 Jun 2004 12:11:52 -0000 1.1.1.1.2.1 *************** *** 1,431 **** ! #!/usr/bin/perl ! # ! # mon monitor to watch for route changes ! # ! ! # There is currently a hardcoded path to the traceroute binary, see $TRACEROUTE ! # but it can be overriden in the config file. ! ! # ! # Jon Meek - 31-May-1999 (original code) ! # ! ! # ! # Jon Meek ! # Lawrenceville, NJ ! # me...@ie... ! # ! # $Id$ ! # ! # Copyright (C) 2001, Jon Meek ! # ! # 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 ! # ! ! =head1 NAME ! ! B<traceroute.monitor> - Route monitor for mon. ! ! =head1 DESCRIPTION ! ! Monitor routes from monitor machine to a remote system using traceroute. Alarm and log ! when changes are detected. ! ! =head1 SYNOPSIS ! ! B<traceroute.monitor -d -t 20 -c /path/to/traceroute.cf -l /usr/local/mon/logs/routes_YYYYMM.log> ! ! The logfile template is usually specified in the configuration file. ! ! =head1 OPTIONS ! ! =over 5 ! ! =item B<-d> Debug/Test ! ! =item B<-c config.cfg> Configuration file for this monitor, see example below ! ! =item B<-t timeout> Timeout for traceroute to run in seconds default is 20s ! ! =item B<-l log_file_template> /path/to/logs/internet_web_YYYYMM.log ! Current year & month are substituted for YYYYMM, that is the only ! possible template at this time. ! ! =back ! ! =head1 MON CONFIGURATION EXAMPLE ! ! hostgroup route1 rt-tb-paris-26 rt-tb-london-18 rt-tta-pr01r00-4 ! rt-cam-cer001-5 rt-tta-pn01r00-4 ! ! watch route1 ! service traceroute ! interval 15m ! monitor traceroute.monitor -c /usr/local/mon/traceroute.cf ! period wd {Sun-Sat} ! alert mail.alert meekj ! alertevery 1h summary ! ! =head1 CONFIGURATION FILE EXAMPLE ! ! # tracreoute.monitor Config File ! RouteLogFile /usr/local/mon/logs/routes_YYYYMM.log ! RouterList /usr/local/mon/rt.list ! Traceroute /usr/sbin/traceroute ! StateDir /usr/local/mon/state.d ! EquivIP 10.22.4.254 10.22.5.254 10.22.6.254 ! EquivIP 10.28.4.254 10.28.5.254 10.28.6.254 ! ! Lines with '#' in the first column are ignored. ! ! RouteLogFile - A new log file will be created each month in the above ! example the files will be of the form routes_199810.log The YYYYMM ! format is the only date string possible in the current version The logs contain ! time stamped route changes. ! ! RouterList - Optional IP address to router name translation in ! /etc/hosts format (IP_address router_bame). Supplying this list will ! provide considerably more meaningful alarm messages, especially if the ! router names contain geographical information. Without this list the ! extended alarm is just a list of interface IP addresses. ! ! Traceroute - Overrides the default of /usr/sbin/traceroute ! ! StateDir - Overrides the default path of the mon environment variable MON_STATEDIR. ! Files named F<lastroute.router_name> contain the last observed route. ! ! EquivIP - A space separated list of IP addresses that should be ! considered equivalent for the purposes of determining route ! changes. Likely used where there are secondary addresses on router or ! switch interfaces. ! ! =head1 BUGS ! ! There probably are some. ! ! =head1 AUTHOR ! ! Jon Meek, me...@ie... ! ! =head1 SEE ALSO ! ! F<traceroute.anal> - A CGI script to display route change information. ! ! =cut ! ! use Getopt::Std; ! ! getopts ("vdt:l:c:"); ! ! # -l file Log file name with optional YYYYMM part that will be transformed to current month ! ! $TimeOut = $opt_t || 20; # Set default timeout in seconds ! ! # Usual Linux config ! $TRACEROUTE = '/usr/sbin/traceroute'; ! #$STATE_DIR = '/usr/local/mon/state.d'; ! ! if (defined $ENV{MON_STATEDIR}) { # Are we running under mon? ! $STATE_DIR = $ENV{MON_STATEDIR}; ! $RunningUnderMon = 1; ! } else { ! $RunningUnderMon = 0; ! } ! ! if ($opt_c) { # Read configuration file ! ! $ConfigFile = $opt_c; ! ! if (open(C, $ConfigFile)) { ! while ($in = <C>) { ! last if ($in =~ /^Exit/i); ! next if ($in =~ /^\#/); # Comments ! chomp $in; ! ! if ($in =~ /^RouteLogFile/i) { ! ($tag, $LogFile) = split(' ', $in, 2); ! next; ! } ! ! if ($in =~ /^Traceroute/i) { ! ($tag, $TRACEROUTE) = split(' ', $in, 2); ! next; ! } ! ! if ($in =~ /^RouterList/i) { ! ($tag, $RouterListFile) = split(' ', $in, 2); ! next; ! } ! ! if ($in =~ /^StateDir/i) { # If the mon environment variable needs to be overriden ! ($tag, $STATE_DIR) = split(' ', $in, 2); ! next; ! } ! ! if ($in =~ /^EquivIP/i) { ! ($tag, $ips) = split(' ', $in, 2); ! (@ip_list) = split(' ', $ips); ! # $ip_string = " $ips "; # Each IP is surrounded by whitespace ! foreach $ip (@ip_list) { ! $EquivIP{$ip} = [ @ip_list ]; ! } ! next; ! } ! ! } ! } else { ! print "traceroute.monitor: Couldn't open $ConfigFile configuration file\n"; ! exit 1; ! ! } ! } ! ! if ($opt_l) { # Command line overrides config file ! $LogFile = $opt_l; ! } ! ! if ((defined $RouterListFile) && $opt_v) { # Read the router names now ! open(F, $RouterListFile); ! while ($in = <F>) { ! chomp $in; ! ($ip, $name) = split(' ', $in, 2); ! $RouterByIP{$ip} = $name; ! } ! close F; ! } ! ! @Failures = (); ! @Hosts = @ARGV; # Host names are left on the command line after Getopt ! ! ! if ($TestOnly) { ! foreach $h (@Hosts) { ! print "Host: $h\n"; ! ! if (defined $EquivIP{$h}) { ! print " Has equivalent IP\n"; ! } ! } ! ! $ip1 = $Hosts[0]; ! $ip2 = $Hosts[1]; ! ! $equiv_check = grep /^$ip2$/, @{ $EquivIP{$ip1} }; ! print "$ip1 $ip2 $equiv_check\n"; ! ! @equiv_arr = grep /^$ip2$/, @{ $EquivIP{$ip1} }; ! print "$ip1 $ip2 @equiv_arr\n"; ! foreach $ip (@equiv_arr) { ! print " $ip\n"; ! } ! ! exit; ! } ! ! # ! # Run traceroute for each destination, collect route ! # ! foreach $TargetHost (@Hosts) { ! ! $TimeOfDay = time; ! $route = ''; ! ! $SIG{ALRM} = sub {die "timeout" }; ! ! eval { ! alarm($TimeOut); ! # discard STDERR data from traceroute ! $pid = open(TR, "$TRACEROUTE -n $TargetHost 2>/dev/null |") ! || die "Couldn't run traceroute\n"; ! while ($in = <TR>) { ! print $in if $opt_d; ! if ($in =~ /\*\s+\*\s+\*/) { # Get * * * then give up ! $route .= '*'; ! kill 13, $pid; # 13 = PIPE, prevents Broken Pipe Error, at least on Solaris ! last; ! } ! ! # We will only pick up the first IP address listed on a line for now ! # Get IP address into $1 ! $in =~ /\s+(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})\s+/; ! $ThisHopIP = $1; ! $route .= $ThisHopIP . '-'; # Build route string ! ! if ($opt_v) { ! chomp $in; ! print "$in $RouterByIP{$ThisHopIP}\n"; ! } ! } ! alarm(0); ! }; ! ! if ($@) { # Check for SIG ! if ($@ =~ /timeout/) { # It was a traceroute timeout ! $route .= '*'; ! kill 13, $pid; # 13 = PIPE, prevents Broken Pipe Error, at least on Solaris ! } else { ! die; # Some other problem ! } ! } ! ! close TR; ! $route =~ s/\-$//; # Remove trailing '-' from route string ! $ResultString{$TargetHost} = "$TimeOfDay $TargetHost $route"; ! ! } ! ! # ! # Compare just measured routes with previous route stored in state file ! # or just make the state file if this is the first time for a destination ! # ! ! # TODO: if new destination (no state file), then log route to log file ! # add IP to name translation for mail messages ! ! foreach $k (sort keys %ResultString) { ! print "$ResultString{$k}\n" if $opt_d; ! $state_file = "$STATE_DIR/lastroute.$k"; ! ! if (-e $state_file) { # We have checked this route before, compare current ! ($t2, $host2, $current_route) = split(' ', $ResultString{$k}); ! open(S, $state_file) || warn "Can't open $state_file for reading\n"; ! $in = <S>; ! chomp $in; ! ($t1, $host1, $prev_route) = split(' ', $in); ! close S; ! ! if ($opt_d) { ! print "Previous route for $host1 -$prev_route-\n"; ! print "Current route for $host2 -$current_route-\n"; ! } ! ! if (&RouteChanged($current_route, $prev_route)) { # Route changed, alarm and record ! if ($RunningUnderMon) { # Write results ! open(S, ">$state_file") || warn "Can't open $state_file for writing\n"; ! print S "$ResultString{$k}\n"; ! close S; ! } ! push (@Failures, $k); ! print " Alarm\n" if $opt_d; ! } ! ! } else { # The state file does not yet exist, so make it ! ! if ($RunningUnderMon) { # Write results ! open(S, ">$state_file") || warn "Can't open $state_file for writing\n"; ! print S "$ResultString{$k}\n"; ! close S; ! } ! push (@Failures, $k); # Call it a failure so it will be logged and notification will be sent ! print " New route added to check: $k\n" if $opt_d; ! } ! ! } ! ! # Write results to logfile, if -l ! ! if ($RunningUnderMon && $LogFile) { ! ! ($sec,$min,$hour,$mday,$Month,$Year,$wday,$yday,$isdst) = ! localtime($TimeOfDay); ! $Month++; $Year += 1900; ! $YYYYMM = sprintf('%04d%02d', $Year, $Month); ! $LogFile =~ s/YYYYMM/$YYYYMM/; # Fill in current year and month ! ! if (-e $LogFile) { # Check for existing log file ! $NewLogFile = 0; ! } else { ! $NewLogFile = 1; ! } ! ! if ($NewLogFile || (@Failures > 0)) { # Only log if new log file, or if route changes ! open(LOG, ">>$LogFile") || warn "$0 Can't open logfile: $LogFile\n"; ! ! if ($NewLogFile) { # New log file, record all routes being tested ! foreach $host (sort keys %ResultString) { ! print LOG "$ResultString{$host}\n"; ! } ! } ! ! if (($NewLogFile == 0) && (@Failures > 0)) { # Just record changes ! foreach $host (sort @Failures) { ! print LOG "$ResultString{$host}\n"; ! } ! } ! ! close LOG; ! } ! } ! ! if (@Failures == 0) { # Exit if there were no failures ! exit 0; ! } ! ! ! if (defined $RouterListFile) { # Read the router names if we have a failure ! open(F, $RouterListFile); ! while ($in = <F>) { ! chomp $in; ! ($ip, $name) = split(' ', $in, 2); ! $RouterByIP{$ip} = $name; ! } ! close F; ! } ! ! @SortedFailures = sort @Failures; # To make summary mode in mon happy ! ! print "@SortedFailures\n"; ! ! foreach $host (@SortedFailures) { ! print "$host:\n"; ! ($t, $target, $rest) = split(' ', $ResultString{$host}); ! (@hop_ips) = split(/\-/, $rest); ! foreach $hop_ip (@hop_ips) { ! printf " %-15s %s\n", $hop_ip, $RouterByIP{$hop_ip}; ! } ! print "\n"; ! } ! ! exit 1; ! ! ! sub RouteChanged { ! my ($current_route, $prev_route) = @_; ! my(@current_ips, @prev_ips); ! ! if ($current_route eq $prev_route) { # Simple case, same string, no change ! return 0; ! } ! ! (@current_ips) = split(/\-/, $current_route); ! (@prev_ips) = split(/\-/, $prev_route); ! ! if ($#current_ips != $#prev_ips) { # Another simple case, different number of hops ! return 1; # Fail ! } ! ! for ($i = 0; $i <= $#current_ips; $i++) { ! $ip1 = $current_ips[$i]; ! $ip2 = $prev_ips[$i]; ! next if ($ip1 eq $ip2); ! $equiv_check = grep /^$ip2$/, @{ $EquivIP{$ip1} }; ! if ($equiv_check == 0) { # Not same, or equivalent, route different, fail ! return 1; ! } ! print "$i $ip1 $ip2 $equiv_check\n" if $opt_d; ! } ! return 0; # Good, no route change ! } ! --- 1,516 ---- ! #!/usr/bin/perl ! # ! # mon monitor to watch for route changes ! # ! ! # There is currently a hardcoded path to the traceroute binary, see $TRACEROUTE ! # but it can be overriden in the config file. ! ! # ! # Jon Meek - 31-May-1999 (original code) ! # ! ! # ! # Jon Meek ! # Lawrenceville, NJ ! # me...@ie... ! # ! # $Id$ ! # ! # Copyright (C) 2001, Jon Meek ! # ! # 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 ! # ! ! =head1 NAME ! ! B<traceroute.monitor> - Route monitor for mon. ! ! =head1 DESCRIPTION ! ! Monitor routes from monitor machine to a remote system using traceroute. Alarm and log ! when changes are detected. ! ! =head1 SYNOPSIS ! ! B<traceroute.monitor -d -t 20 -c /path/to/traceroute.cf -l /usr/local/mon/logs/routes_YYYYMM.log> ! ! The logfile template is usually specified in the configuration file. ! ! =head1 OPTIONS ! ! =over 5 ! ! =item B<-d> Debug/Test ! ! =item B<-c config.cfg> Configuration file for this monitor, see example below ! ! =item B<-t timeout> Timeout for traceroute to run in seconds default is 20s ! ! =item B<-l log_file_template> /path/to/logs/internet_web_YYYYMM.log ! Current year & month are substituted for YYYYMM, that is the only ! possible template at this time. ! ! =back ! ! =head1 MON CONFIGURATION EXAMPLE ! ! hostgroup route1 rt-tb-paris-26 rt-tb-london-18 rt-tta-pr01r00-4 ! rt-cam-cer001-5 rt-tta-pn01r00-4 ! ! watch route1 ! service traceroute ! interval 15m ! monitor traceroute.monitor -c /usr/local/mon/traceroute.cf ! period wd {Sun-Sat} ! alert mail.alert meekj ! alertevery 1h summary ! ! =head1 CONFIGURATION FILE EXAMPLE ! ! # tracreoute.monitor Config File ! RouteLogFile /usr/local/mon/logs/routes_YYYYMM.log ! RouterList /usr/local/mon/rt.list ! Traceroute /usr/sbin/traceroute ! TracerouteOptions -I ! StateDir /usr/local/mon/state.d ! EquivIP 10.22.4.254 10.22.5.254 10.22.6.254 ! EquivIP 10.28.4.254 10.28.5.254 10.28.6.254 ! StopAt 172.30.124.17 A firewall ! StopAt 172.31.124.17 Another firewall ! ! Lines with '#' in the first column are ignored. ! ! RouteLogFile - A new log file will be created each month in the above ! example the files will be of the form routes_199810.log The YYYYMM ! format is the only date string possible in the current version The logs contain ! time stamped route changes. ! ! RouterList - Optional IP address to router name translation in ! /etc/hosts format (IP_address router_bame). Supplying this list will ! provide considerably more meaningful alarm messages, especially if the ! router names contain geographical information. Without this list the ! extended alarm is just a list of interface IP addresses. ! ! Traceroute - Overrides the default of /usr/sbin/traceroute ! ! TracerouteOptions - Supply additional options to traceroute. -I tells ! traceroute to use ICMP rather than UDP on some systems. Note that -n ! is always supplied so that no DNS lookups are performed. ! ! StateDir - Overrides the default path of the mon environment variable ! MON_STATEDIR. Files named F<lastroute.router_name> contain the last ! observed route. ! ! EquivIP - A space separated list of IP addresses that should be ! considered equivalent for the purposes of determining route ! changes. Likely used where there are secondary addresses on router or ! switch interfaces. ! ! StopAt - A single IP address followed by an optional comment. The ! traceroute will be terminated when this address is seen. This allows a ! route check to a system on another network, such as the Internet, ! without tracking the route on a network that you do not control. A ! common use would be to put your firewall address in a StopAt ! directive. There can be multiple StopAt lines. ! ! =head1 BUGS ! ! There probably are some. ! ! =head1 AUTHOR ! ! Jon Meek, me...@ie... ! ! =head1 SEE ALSO ! ! F<traceroute.anal> - A CGI script to display route change information. ! ! =cut ! ! use Getopt::Std; ! use POSIX qw(:signal_h WNOHANG); ! use POSIX qw(strftime); ! ! getopts ("vdt:l:c:"); ! ! # -l file Log file name with optional YYYYMM part that will be transformed to current month ! ! $TimeOut = $opt_t || 20; # Set default timeout in seconds ! ! # Usual Linux config ! $TRACEROUTE = '/usr/sbin/traceroute'; ! #$STATE_DIR = '/usr/local/mon/state.d'; ! ! if (defined $ENV{MON_STATEDIR}) { # Are we running under mon? ! $STATE_DIR = $ENV{MON_STATEDIR}; ! $RunningUnderMon = 1; ! } else { ! $RunningUnderMon = 0; ! } ! ! if ($opt_c) { # Read configuration file ! ! $ConfigFile = $opt_c; ! ! if (open(C, $ConfigFile)) { ! while ($in = <C>) { ! last if ($in =~ /^Exit/i); ! next if ($in =~ /^\#/); # Comments ! chomp $in; ! ! if ($in =~ /^RouteLogFile\s+/i) { ! ($tag, $LogFile) = split(' ', $in, 2); ! next; ! } ! ! if ($in =~ /^Traceroute\s+/i) { # Need whitespace to distinguish this option ! ($tag, $TRACEROUTE) = split(' ', $in, 2); ! next; ! } ! ! if ($in =~ /^TracerouteOptions\s+/i) { ! ($tag, $TracerouteOptions) = split(' ', $in, 2); ! next; ! } ! ! if ($in =~ /^RouterList\s+/i) { ! ($tag, $RouterListFile) = split(' ', $in, 2); ! next; ! } ! ! if ($in =~ /^StateDir\s+/i) { # If the mon environment variable needs to be overriden ! ($tag, $STATE_DIR) = split(' ', $in, 2); ! next; ! } ! ! if ($in =~ /^EquivIP\s+/i) { ! ($tag, $ips) = split(' ', $in, 2); ! (@ip_list) = split(' ', $ips); ! # $ip_string = " $ips "; # Each IP is surrounded by whitespace ! foreach $ip (@ip_list) { ! $EquivIP{$ip} = [ @ip_list ]; ! } ! next; ! } ! ! if ($in =~ /^StopAt\s+/i) { ! ($tag, $stop_addr, $stop_comment) = split(' ', $in, 3); ! $StopAddress{$stop_addr}++; ! $StopComment{$stop_addr} = $stop_comment; ! next; ! } ! ! } ! } else { ! print "traceroute.monitor: Couldn't open $ConfigFile configuration file\n"; ! exit 1; ! ! } ! } ! ! if ($opt_l) { # Command line overrides config file ! $LogFile = $opt_l; ! } ! ! if ((defined $RouterListFile) && $opt_v) { # Read the router names now ! open(F, $RouterListFile); ! while ($in = <F>) { ! chomp $in; ! ($ip, $name) = split(' ', $in, 2); ! $RouterByIP{$ip} = $name; ! } ! close F; ! } ! ! @Failures = (); ! @Hosts = @ARGV; # Host names are left on the command line after Getopt ! ! ! if ($TestOnly) { ! foreach $h (@Hosts) { ! print "Host: $h\n"; ! ! if (defined $EquivIP{$h}) { ! print " Has equivalent IP\n"; ! } ! } ! ! $ip1 = $Hosts[0]; ! $ip2 = $Hosts[1]; ! ! $equiv_check = grep /^$ip2$/, @{ $EquivIP{$ip1} }; ! print "$ip1 $ip2 $equiv_check\n"; ! ! @equiv_arr = grep /^$ip2$/, @{ $EquivIP{$ip1} }; ! print "$ip1 $ip2 @equiv_arr\n"; ! foreach $ip (@equiv_arr) { ! print " $ip\n"; ! } ! ! exit; ! } ! ! # ! # Reap children to avoid defunct processes / zombies ! # See "Network Programming with Perl" by Lincoln Stein ! # ! sub Reaper { ! while ((my $child_pid = waitpid(-1, WNOHANG)) > 0) { ! print "Reaped child: $child_pid\n" if $opt_d; ! } ! } ! ! sub OtherSIGs { ! print "traceroute.monitor Exiting on Signal\n"; ! exit 1; ! } ! ! $SIG{CHLD} = \&Reaper; ! ! $SIG{HUP} = $SIG{INT} = $SIG{QUIT} = $SIG{TERM} = \&OtherSIGs; ! ! # ! # Run traceroute for each destination, collect route ! # ! foreach $TargetHost (@Hosts) { ! ! $TimeOfDay = time; ! $FmtTimeOfDay = strftime("%A %d-%b-%Y %H:%M:%S %Z", localtime($TimeOfDay)); ! ! @HopList = (); # Initialize hop list for this traceroute to $TargetHost ! ! $cmd = qq{$TRACEROUTE -n $TracerouteOptions $TargetHost 2>/dev/null |}; ! print "Options: ->$TracerouteOptions<-\nCommand: $cmd\n" if $opt_d; ! ! eval { ! $SIG{ALRM} = sub {die "timeout" }; ! print "Setting timeout to $TimeOut s\n" if $opt_d; ! alarm($TimeOut); ! ! eval { ! ! # discard STDERR data from traceroute ! $pid = open(TR, $cmd) || die "Couldn't run traceroute\n"; ! print "$FmtTimeOfDay Traceroute to $TargetHost pid: $pid\n" if $opt_d; ! while ($in = <TR>) { ! print $in if $opt_d; ! if ($in =~ /\*\s+\*\s+\*/) { # Get * * * then give up ! push(@HopList, '*'); # Indicate that the traceroute did not complete ! kill 13, $pid; # 13 = PIPE, prevents Broken Pipe Error, at least on Solaris ! last; ! } ! ! # We will only pick up the first IP address listed on a line for now ! # Get IP address into $1 ! $in =~ /\s+(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})\s+/; ! $ThisHopIP = $1; ! push(@HopList, $ThisHopIP); # Build route hop list ! ! if ($opt_v) { ! chomp $in; ! print "$in $RouterByIP{$ThisHopIP}\n"; ! } ! ! if (exists $StopAddress{$ThisHopIP}) { ! print "Stopping at $ThisHopIP $StopComment{$ThisHopIP}\n\n" if $opt_v; ! kill 'TERM', $pid; # Terminate the traceroute ! alarm(0); ! return; # May be correct way to leave eval, instead of last ! } ! } ! alarm(0); ! }; ! alarm(0); ! }; ! ! if ($@) { # Check for SIG ! if ($@ =~ /timeout/) { # It was a traceroute timeout ! print "Traceroute timeout\n" if $opt_d; ! push(@HopList, '*'); # Indicate that the traceroute did not complete ! kill 13, $pid; # 13 = PIPE, prevents Broken Pipe Error, at least on Solaris ! } else { ! print "Exiting due to some other alarm\n" if $opt_d; ! die; # Some other problem ! } ! } ! ! close TR; ! $route =~ s/\-$//; # Remove trailing '-' from route string ! ! $previous_hop = ''; ! $route = ''; ! foreach $h (@HopList) { ! $route .= "$h-" unless ($h eq $previous_hop); ! $previous_hop = $h; ! } ! $route =~ s/\-$//; # Remove trailing '-' from route string ! ! ! $ResultString{$TargetHost} = "$TimeOfDay $TargetHost $route"; ! ! if ($opt_d) { ! print "$TargetHost: $ResultString{$TargetHost}\n"; ! print " $route\n"; ! } ! } ! ! $FmtTimeOfDay = strftime("%A %d-%b-%Y %H:%M:%S %Z", localtime(time)); ! print "$FmtTimeOfDay finish $TargetHost pid: $pid\n\n" if $opt_d; ! ! # ! # Compare just measured routes with previous route stored in state file ! # or just make the state file if this is the first time for a destination ! # ! ! # TODO: if new destination (no state file), then log route to log file ! # add IP to name translation for mail messages ! ! foreach $k (sort keys %ResultString) { ! print "$ResultString{$k}\n" if $opt_d; ! $state_file = "$STATE_DIR/lastroute.$k"; ! ! if (-e $state_file) { # We have checked this route before, compare current ! ($t2, $host2, $current_route) = split(' ', $ResultString{$k}); ! open(S, $state_file) || warn "Can't open $state_file for reading\n"; ! $in = <S>; ! chomp $in; ! ($t1, $host1, $prev_route) = split(' ', $in); ! close S; ! ! if ($opt_d) { ! print "Previous route for $host1 -$prev_route-\n"; ! print "Current route for $host2 -$current_route-\n"; ! } ! ! if (&RouteChanged($current_route, $prev_route)) { # Route changed, alarm and record ! if ($RunningUnderMon) { # Write results ! open(S, ">$state_file") || warn "Can't open $state_file for writing\n"; ! print S "$ResultString{$k}\n"; ! close S; ! } ! push (@Failures, $k); ! print " Alarm\n" if $opt_d; ! } ! ! } else { # The state file does not yet exist, so make it ! ! if ($RunningUnderMon) { # Write results ! open(S, ">$state_file") || warn "Can't open $state_file for writing\n"; ! print S "$ResultString{$k}\n"; ! close S; ! } ! push (@Failures, $k); # Call it a failure so it will be logged and notification will be sent ! print " New route added to check: $k\n" if $opt_d; ! } ! ! } ! ! # Write results to logfile, if -l ! ! #if ($RunningUnderMon && $LogFile) { ! if ($LogFile) { ! ! ($sec,$min,$hour,$mday,$Month,$Year,$wday,$yday,$isdst) = ! localtime($TimeOfDay); ! $Month++; $Year += 1900; ! $YYYYMM = sprintf('%04d%02d', $Year, $Month); ! $LogFile =~ s/YYYYMM/$YYYYMM/; # Fill in current year and month ! ! if (-e $LogFile) { # Check for existing log file ! $NewLogFile = 0; ! } else { ! $NewLogFile = 1; ! } ! ! if ($NewLogFile || (@Failures > 0)) { # Only log if new log file, or if route changes ! open(LOG, ">>$LogFile") || warn "$0 Can't open logfile: $LogFile\n"; ! ! if ($NewLogFile) { # New log file, record all routes being tested ! foreach $host (sort keys %ResultString) { ! print LOG "$ResultString{$host}\n"; ! } ! } ! ! if (($NewLogFile == 0) && (@Failures > 0)) { # Just record changes ! foreach $host (sort @Failures) { ! print LOG "$ResultString{$host}\n"; ! } ! } ! ! close LOG; ! } ! } ! ! if (@Failures == 0) { # Exit if there were no failures ! exit 0; ! } ! ! ! if (defined $RouterListFile) { # Read the router names if we have a failure ! open(F, $RouterListFile); ! while ($in = <F>) { ! chomp $in; ! ($ip, $name) = split(' ', $in, 2); ! $RouterByIP{$ip} = $name; ! } ! close F; ! } ! ! @SortedFailures = sort @Failures; # To make summary mode in mon happy ! ! print "@SortedFailures\n"; ! ! foreach $host (@SortedFailures) { ! print "$host:\n"; ! ($t, $target, $rest) = split(' ', $ResultString{$host}); ! (@hop_ips) = split(/\-/, $rest); ! foreach $hop_ip (@hop_ips) { ! printf " %-15s %s\n", $hop_ip, $RouterByIP{$hop_ip}; ! } ! print "\n"; ! } ! ! exit 1; ! ! ! sub RouteChanged { ! my ($current_route, $prev_route) = @_; ! my(@current_ips, @prev_ips); ! ! if ($current_route eq $prev_route) { # Simple case, same string, no change ! return 0; ! } ! ! (@current_ips) = split(/\-/, $current_route); ! (@prev_ips) = split(/\-/, $prev_route); ! ! if ($#current_ips != $#prev_ips) { # Another simple case, different number of hops ! return 1; # Fail ! } ! ! for ($i = 0; $i <= $#current_ips; $i++) { ! $ip1 = $current_ips[$i]; ! $ip2 = $prev_ips[$i]; ! next if ($ip1 eq $ip2); ! $equiv_check = grep /^$ip2$/, @{ $EquivIP{$ip1} }; ! if ($equiv_check == 0) { # Not same, or equivalent, route different, fail ! return 1; ! } ! print "$i $ip1 $ip2 $equiv_check\n" if $opt_d; ! } ! return 0; # Good, no route change ! } ! |
From: David N. <vi...@us...> - 2004-06-18 20:31:40
|
Update of /cvsroot/mon/mon In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27938 Modified Files: Tag: mon-1-0-0pre1 mon Log Message: remove usage of parse_line in trap processing (backported from mon 1.1 code) Index: mon =================================================================== RCS file: /cvsroot/mon/mon/mon,v retrieving revision 1.4.2.3 retrieving revision 1.4.2.4 diff -C2 -d -r1.4.2.3 -r1.4.2.4 *** mon 18 Jun 2004 00:51:51 -0000 1.4.2.3 --- mon 18 Jun 2004 20:31:29 -0000 1.4.2.4 *************** *** 3732,3747 **** # ! foreach my $l (split (/\n/, $buf)) { ! if ($l =~ /^(\w+)=(.*)/) { my $trap_val = $2; chomp $trap_val; ! $trap{$1} = un_esc_str ((parse_line ('\s+', 0, $trap_val))[0]); } ! else { ! syslog ('err', "unspecified tag in trap: $l"); } } --- 3732,3749 ---- # ! foreach my $line (split (/\n/, $buf)) { ! if ($line =~ /^(\w+)=(.*)/) { + my $trap_name = $1; my $trap_val = $2; chomp $trap_val; ! $trap_val =~ s/^\'(.*)\'$/\1/; ! $trap{$trap_name} = un_esc_str ($trap_val); } ! else { ! syslog ('err', "unspecified tag in trap: $line"); } } |
From: David N. <vi...@us...> - 2004-06-18 20:27:58
|
Update of /cvsroot/mon/mon/alert.d In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25535 Modified Files: Tag: mon-1-0-0pre1 trap.alert Log Message: merging rewritten version into mon-1-0-0pre2 branch Index: trap.alert =================================================================== RCS file: /cvsroot/mon/mon/alert.d/trap.alert,v retrieving revision 1.1.1.1 retrieving revision 1.1.1.1.2.1 diff -C2 -d -r1.1.1.1 -r1.1.1.1.2.1 *** trap.alert 9 Jun 2004 05:18:07 -0000 1.1.1.1 --- trap.alert 18 Jun 2004 20:27:49 -0000 1.1.1.1.2.1 *************** *** 26,33 **** # use Getopt::Std; use Socket; - getopts ("s:g:h:t:l:o:uU:P:"); ! $TRAP_PRO_VERSION = 0.3807; $summary=<STDIN>; --- 26,34 ---- # use Getopt::Std; + use Mon::Client; use Socket; ! getopts ("s:g:h:t:l:o:uU:P:T:"); ! $summary=<STDIN>; *************** *** 50,81 **** } ! $pkt = ""; ! $pkt .= "pro=$TRAP_PRO_VERSION\n"; ! $pkt .= "usr=$USER\n" . "pas=$PASS\n" if ($USER ne ""); ! $pkt .= "typ=$ENV{MON_ALERTTYPE}\n"; ! $pkt .= "seq=0\n"; ! $pkt .= "grp=$ENV{MON_GROUP}\n"; ! $pkt .= "svc=$ENV{MON_SERVICE}\n"; ! $pkt .= "sta=$ENV{MON_RETVAL}\n"; ! $pkt .= "spc=$OPST\n"; ! $pkt .= "tsp=$t\n"; ! $pkt .= "sum=$summary\n"; ! $pkt .= "dtl=$detail\n.\n"; ! ! $proto = getprotobyname ("udp") || die "could not get proto\n"; ! socket (TRAP, AF_INET, SOCK_DGRAM, $proto) || ! die "could not create UDP socket: $!\n"; ! $port = getservbyname ('mon', 'udp') || 2583; foreach $host (@ARGV) { ! my $paddr = sockaddr_in ($port, inet_aton ($host)); ! if (!defined (send (TRAP, $pkt, 0, $paddr))) { ! print STDERR "could not send trap to $host: $!\n"; ! next; ! } ! } ! close (TRAP); exit; --- 51,78 ---- } ! foreach $op (keys %Mon::Client::OPSTAT) { ! $OPSTATUS = $op if ($Mon::Client::OPSTAT{$op} == $OPST); ! } ! $c = new Mon::Client ( ! port => getservbyname ('mon', 'udp') || 2583, ! ); + $c->user($USER) if ($USER); + $c->password($PASS) if ($PASS); foreach $host (@ARGV) { ! $c->host($host); ! ! $res = $c->send_trap( group => $ENV{MON_GROUP}, ! service => $ENV{MON_SERVICE}, ! retval => $ENV{MON_RETVAL}, ! opstatus => $OPSTATUS, ! summary => $summary, ! detail => $detail, ! ); ! print STDERR "Error sending trap to $host\n" if (!$res); ! print STDERR "Error is: ". $c->error() . "\n" if (!$res); ! } exit; |
From: Jim T. <tr...@us...> - 2004-06-18 14:40:19
|
Update of /cvsroot/mon/mon In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31875 Modified Files: Tag: mon-1-0-0pre1 CHANGES INSTALL Log Message: changed README to refer to the new, more sensible name for the perl module client, which is mon-client Index: CHANGES =================================================================== RCS file: /cvsroot/mon/mon/CHANGES,v retrieving revision 1.2 retrieving revision 1.2.2.1 diff -C2 -d -r1.2 -r1.2.2.1 *** CHANGES 11 Jun 2004 14:55:55 -0000 1.2 --- CHANGES 18 Jun 2004 14:40:10 -0000 1.2.2.1 *************** *** 1,4 **** --- 1,17 ---- $Id$ + Changes between mon-0.99.3-47 and mon-1.0.0pre1 + ----------------------------------------------- + Fri Jun 18 10:35:18 EDT 2004 + + -removed nonsensical unless statement which would conditionally set the op + status to STAT_OK. it should be set unconditionally + + -added "strict" option to alertevery + + -changed protocol to escape spaces to coincide with the change in Mon::Client + + + Changes between mon-0.99.2 and mon-0.99.3 Fri Jun 11 10:55:27 EDT 2004 *************** *** 172,178 **** the "all" directive in auth.cf - -removed nonsensical unless statement which would conditionally set the op - status to STAT_OK. it should be set unconditionally - Changes between mon-0.99.1 and mon-0.99.2 --- 185,188 ---- Index: INSTALL =================================================================== RCS file: /cvsroot/mon/mon/INSTALL,v retrieving revision 1.1.1.1.2.1 retrieving revision 1.1.1.1.2.2 diff -C2 -d -r1.1.1.1.2.1 -r1.1.1.1.2.2 *** INSTALL 17 Jun 2004 20:28:54 -0000 1.1.1.1.2.1 --- INSTALL 18 Jun 2004 14:40:10 -0000 1.1.1.1.2.2 *************** *** 87,102 **** ------------------------------------ ! As of 0.38.8, the Perl client module is distributed as a separate ! package. It is named "Mon-*.tar.gz". As of 1-Aug-2001, the most ! recent distribution is Mon-0.99.1.tar.gz. Refer to that for ! installation instructions. This module is available in both CPAN ! (http://www.perl.com/CPAN/) and on kernel.org mirrors in the ! /pub/software/admin/mon directory. If you are using a CVS release of the mon server, you will want to be sure to match it with the corresponding version from the ! "monperl" module. At this time, branch "mon-1-0-0pre1" of the ! mon CVS module matches the "monperl-1-0-0pre1" branch of the ! monperl CVS module. See http://sourceforge.net/projects/mon/ for information on CVS access. --- 87,102 ---- ------------------------------------ ! The Perl client module is distributed as a separate package. It is named ! "mon-client-*.tar.gz". Refer to that for installation instructions. This ! module is available in CPAN (http://www.perl.com/CPAN/), on kernel.org mirrors ! in the /pub/software/admin/mon directory, and in CVS on sourceforge.net. ! Be sure to match the version of mon-client with the version of mon you ! are using. If you are using a CVS release of the mon server, you will want to be sure to match it with the corresponding version from the ! "mon-client" module. At this time, branch "mon-1-0-0pre1" of the ! mon CVS module matches the "mon-client-1-0-0pre1" branch of the ! mon-client CVS module. See http://sourceforge.net/projects/mon/ for information on CVS access. *************** *** 110,114 **** cd doc ! nroff -man mon.1 | more -read the "READMEs" in the doc/ directory for some useful --- 110,114 ---- cd doc ! nroff -man mon.8 | more -read the "READMEs" in the doc/ directory for some useful |
From: Jim T. <tr...@us...> - 2004-06-18 13:43:56
|
Update of /cvsroot/mon/monperl/Mon In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19713/Mon Modified Files: Tag: monperl-1-0-0pre1 Client.pm Config.pm Protocol.pm SNMP.pm Log Message: updated version to 1.0000 Index: Protocol.pm =================================================================== RCS file: /cvsroot/mon/monperl/Mon/Protocol.pm,v retrieving revision 1.2 retrieving revision 1.2.2.1 diff -C2 -d -r1.2 -r1.2.2.1 *** Protocol.pm 14 Jun 2004 13:25:03 -0000 1.2 --- Protocol.pm 18 Jun 2004 13:43:46 -0000 1.2.2.1 *************** *** 119,123 **** @EXPORT_OK = qw($VERSION @); ! $VERSION = "0.9903"; @TYPES = qw(cmd_monitor cmd_alert cmd_logger res_monitor res_alert res_logger); --- 119,123 ---- @EXPORT_OK = qw($VERSION @); ! $VERSION = "1.0000"; @TYPES = qw(cmd_monitor cmd_alert cmd_logger res_monitor res_alert res_logger); Index: SNMP.pm =================================================================== RCS file: /cvsroot/mon/monperl/Mon/SNMP.pm,v retrieving revision 1.1.1.1 retrieving revision 1.1.1.1.2.1 diff -C2 -d -r1.1.1.1 -r1.1.1.1.2.1 *** SNMP.pm 14 Jun 2004 12:51:05 -0000 1.1.1.1 --- SNMP.pm 18 Jun 2004 13:43:46 -0000 1.1.1.1.2.1 *************** *** 22,25 **** --- 22,28 ---- SNMP trap handling to "mon". + It is not complete, so don't bother trying to use it unless you are + ready to debug and write some code. + =head1 METHODS *************** *** 120,124 **** @EXPORT_OK = qw(@traptypes @ASN_DEFS $VERSION); ! $VERSION = "0.9903"; @traptypes = ("COLDSTART", "WARMSTART", "LINKDOWN", "LINKUP", "AUTHFAIL", --- 123,127 ---- @EXPORT_OK = qw(@traptypes @ASN_DEFS $VERSION); ! $VERSION = "1.0000"; @traptypes = ("COLDSTART", "WARMSTART", "LINKDOWN", "LINKUP", "AUTHFAIL", Index: Client.pm =================================================================== RCS file: /cvsroot/mon/monperl/Mon/Client.pm,v retrieving revision 1.2 retrieving revision 1.2.2.1 diff -C2 -d -r1.2 -r1.2.2.1 *** Client.pm 14 Jun 2004 13:25:03 -0000 1.2 --- Client.pm 18 Jun 2004 13:43:45 -0000 1.2.2.1 *************** *** 38,42 **** use vars grep { /^\W/ } @EXPORT_OK; ! $VERSION = "0.9903"; my ($STAT_FAIL, $STAT_OK, $STAT_COLDSTART, $STAT_WARMSTART, $STAT_LINKDOWN, --- 38,42 ---- use vars grep { /^\W/ } @EXPORT_OK; ! $VERSION = "1.0000"; my ($STAT_FAIL, $STAT_OK, $STAT_COLDSTART, $STAT_WARMSTART, $STAT_LINKDOWN, Index: Config.pm =================================================================== RCS file: /cvsroot/mon/monperl/Mon/Config.pm,v retrieving revision 1.1.1.1 retrieving revision 1.1.1.1.2.1 diff -C2 -d -r1.1.1.1 -r1.1.1.1.2.1 *** Config.pm 14 Jun 2004 12:51:05 -0000 1.1.1.1 --- Config.pm 18 Jun 2004 13:43:46 -0000 1.1.1.1.2.1 *************** *** 29,33 **** @EXPORT_OK = qw($VERSION); ! $VERSION = "0.9903"; sub new --- 29,33 ---- @EXPORT_OK = qw($VERSION); ! $VERSION = "1.0000"; sub new |
From: Jim T. <tr...@us...> - 2004-06-18 13:43:55
|
Update of /cvsroot/mon/monperl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19713 Modified Files: Tag: monperl-1-0-0pre1 CHANGES Makefile.PL Removed Files: Tag: monperl-1-0-0pre1 monperl.prj Log Message: updated version to 1.0000 --- monperl.prj DELETED --- Index: CHANGES =================================================================== RCS file: /cvsroot/mon/monperl/CHANGES,v retrieving revision 1.1.1.1 retrieving revision 1.1.1.1.2.1 diff -C2 -d -r1.1.1.1 -r1.1.1.1.2.1 *** CHANGES 14 Jun 2004 12:51:05 -0000 1.1.1.1 --- CHANGES 18 Jun 2004 13:43:40 -0000 1.1.1.1.2.1 *************** *** 4,7 **** --- 4,16 ---- CHANGELOG + Differences between 0.9901 and 1.0000: + Fri Jun 18 09:38:01 EDT 2004 + -------------------------------------- + + -slight change in _esc_str and _un_esc_str to allow opstatus to + be handled by split on whitespace instead of requiring Text::Parsewords, + which has in the past shown to be buggy. + + Differences between Mon-0.11 and 0.9901: Fri Apr 5 12:17:49 EST 2002 Index: Makefile.PL =================================================================== RCS file: /cvsroot/mon/monperl/Makefile.PL,v retrieving revision 1.1.1.1 retrieving revision 1.1.1.1.2.1 diff -C2 -d -r1.1.1.1 -r1.1.1.1.2.1 *** Makefile.PL 14 Jun 2004 12:51:05 -0000 1.1.1.1 --- Makefile.PL 18 Jun 2004 13:43:45 -0000 1.1.1.1.2.1 *************** *** 7,10 **** WriteMakefile( 'NAME' => 'Mon', ! 'VERSION' => "0.9903", ); --- 7,16 ---- WriteMakefile( 'NAME' => 'Mon', ! 'VERSION' => "1.0000", ); + + # version 1.0000 == 1.0.0 + # ^^^^ + # | | + # | 3rd digit in 1.0.x + # 2nd digit in 1.x.0 |
From: Jim T. <tr...@us...> - 2004-06-18 00:52:02
|
Update of /cvsroot/mon/mon In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13617 Modified Files: Tag: mon-1-0-0pre1 mon Log Message: make esc_str escape spaces in order to be compatible with monperl-1-0-0pre1 Index: mon =================================================================== RCS file: /cvsroot/mon/mon/mon,v retrieving revision 1.4.2.2 retrieving revision 1.4.2.3 diff -C2 -d -r1.4.2.2 -r1.4.2.3 *** mon 17 Jun 2004 20:28:54 -0000 1.4.2.2 --- mon 18 Jun 2004 00:51:51 -0000 1.4.2.3 *************** *** 4852,4860 **** my $escstr = ""; for (my $i = 0; $i < length ($str); $i++) { my $c = substr ($str, $i, 1); ! if (ord ($c) < 32 || ord ($c) > 126 || $c eq "\"" || --- 4852,4862 ---- my $escstr = ""; + return $escstr if (!defined $str); + for (my $i = 0; $i < length ($str); $i++) { my $c = substr ($str, $i, 1); ! if (ord ($c) <= 32 || ord ($c) > 126 || $c eq "\"" || |
From: Jim T. <tr...@us...> - 2004-06-17 20:29:04
|
Update of /cvsroot/mon/mon In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10597 Modified Files: Tag: mon-1-0-0pre1 CREDITS INSTALL README mon Log Message: added 'alertevery strict' code and docs, updated the README and INSTALL to mention CVS, updated CREDITS Index: README =================================================================== RCS file: /cvsroot/mon/mon/README,v retrieving revision 1.1.1.1.2.1 retrieving revision 1.1.1.1.2.2 diff -C2 -d -r1.1.1.1.2.1 -r1.1.1.1.2.2 *** README 12 Jun 2004 18:17:57 -0000 1.1.1.1.2.1 --- README 17 Jun 2004 20:28:54 -0000 1.1.1.1.2.2 *************** *** 55,59 **** ------------ ! The latest version of mon is available from kernel.org in pub/software/admin/mon/. Please choose a mirror from --- 55,59 ---- ------------ ! The latest release of mon is available from kernel.org in pub/software/admin/mon/. Please choose a mirror from *************** *** 65,68 **** --- 65,81 ---- + CVS + --- + + CVS trees of both the development trunk and stable release branches are + available from anonymous CVS access on sourceforge.net. To check out the latest + stable branch, do the following: + + $ cvs -d:pserver:ano...@cv...:/cvsroot/mon login + $ cvs -z3 -d:pserver:ano...@cv...:/cvsroot/mon co -r mon-1-0-0pre1 mon + + The "development" branch may be checked out by omitting the "-r mon-1-0-0pre1". + + INSTALLATION ------------ Index: CREDITS =================================================================== RCS file: /cvsroot/mon/mon/CREDITS,v retrieving revision 1.1.1.1 retrieving revision 1.1.1.1.2.1 diff -C2 -d -r1.1.1.1 -r1.1.1.1.2.1 *** CREDITS 9 Jun 2004 05:18:03 -0000 1.1.1.1 --- CREDITS 17 Jun 2004 20:28:49 -0000 1.1.1.1.2.1 *************** *** 8,11 **** --- 8,21 ---- Lots of ideas, inital testing under Solaris, and http.monitor code. + David Nolan + vit...@cm... + Many bug fixes and feature additions. David probably runs the largest + mon installation in existence. + + Ed Ravin + er...@pa... + Bug fixes, many enhancements to monitors, feature additions, and fixes + for BSD-isms. + Martin J. Laubach mj...@em... Index: mon =================================================================== RCS file: /cvsroot/mon/mon/mon,v retrieving revision 1.4.2.1 retrieving revision 1.4.2.2 diff -C2 -d -r1.4.2.1 -r1.4.2.2 *** mon 12 Jun 2004 18:17:57 -0000 1.4.2.1 --- mon 17 Jun 2004 20:28:54 -0000 1.4.2.2 *************** *** 587,591 **** # # only alert once every "alertevery" seconds, unless ! # output from monitor is different # my ($prevsumm) = split("\n", $sref->{"_failure_output"}); --- 587,591 ---- # # only alert once every "alertevery" seconds, unless ! # output from monitor is different or if strict alertevery # my ($prevsumm) = split("\n", $sref->{"_failure_output"}); *************** *** 595,598 **** --- 595,599 ---- ($tmnow - $pref->{"_last_alert"} < $pref->{"alertevery"}) && ( + ($pref->{"_alertevery_strict"}) || ($pref->{"_observe_detail"} && $sref->{"_failure_output"} eq $output) || (!$pref->{"_observe_detail"} && $prevsumm eq $summary) *************** *** 1274,1282 **** elsif ($var eq "alertevery") { ! my $observe_detail = 0; if ($args =~ /(\S+) \s+ observe_detail \s*$/ix) { ! $observe_detail = 1; $args = $1; } --- 1275,1284 ---- elsif ($var eq "alertevery") { ! $pref->{"_observe_detail"} = 0; ! $pref->{"_alertevery_strict"} = 0; if ($args =~ /(\S+) \s+ observe_detail \s*$/ix) { ! $pref->{"_observe_detail"} = 1; $args = $1; } *************** *** 1290,1300 **** } if (!($args = dhmstos ($args))) { close (CFG); ! return "cf error: invalid time interval '$args' (syntax: alertevery {positive number}{smhd}), line $line_num"; } $pref->{"alertevery"} = $args; - $pref->{"_observe_detail"} = $observe_detail; next; } --- 1292,1310 ---- } + # + # strict + # + elsif ($args =~ /(\S+) \s+ strict \s*$/ix) + { + $args = $1; + $pref->{"_alertevery_strict"} = 1; + } + if (!($args = dhmstos ($args))) { close (CFG); ! return "cf error: invalid time interval '$args' (syntax: alertevery {positive number}{smhd} [ strict | observe_detail ]), line $line_num"; } $pref->{"alertevery"} = $args; next; } *************** *** 2942,2946 **** foreach my $period (keys %{$sref->{"periods"}}) { ! $sref->{"periods"}->{$period}->{"_last_alert"} = 0; $sref->{"periods"}->{$period}->{"_1stfailtime"} = 0; $sref->{"periods"}->{$period}->{"_alert_sent"} = 0; --- 2952,2963 ---- foreach my $period (keys %{$sref->{"periods"}}) { ! # ! # "alertevery strict" should not reset _last_alert ! # ! if (!$sref->{"periods"}->{$period}->{"_alertevery_strict"}) ! { ! $sref->{"periods"}->{$period}->{"_last_alert"} = 0; ! } ! $sref->{"periods"}->{$period}->{"_1stfailtime"} = 0; $sref->{"periods"}->{$period}->{"_alert_sent"} = 0; Index: INSTALL =================================================================== RCS file: /cvsroot/mon/mon/INSTALL,v retrieving revision 1.1.1.1 retrieving revision 1.1.1.1.2.1 diff -C2 -d -r1.1.1.1 -r1.1.1.1.2.1 *** INSTALL 9 Jun 2004 05:18:03 -0000 1.1.1.1 --- INSTALL 17 Jun 2004 20:28:54 -0000 1.1.1.1.2.1 *************** *** 94,97 **** --- 94,104 ---- /pub/software/admin/mon directory. + If you are using a CVS release of the mon server, you will want + to be sure to match it with the corresponding version from the + "monperl" module. At this time, branch "mon-1-0-0pre1" of the + mon CVS module matches the "monperl-1-0-0pre1" branch of the + monperl CVS module. See http://sourceforge.net/projects/mon/ for + information on CVS access. + 2. MON SERVER INSTALLATION |
From: Jim T. <tr...@us...> - 2004-06-17 20:29:03
|
Update of /cvsroot/mon/mon/doc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10597/doc Modified Files: Tag: mon-1-0-0pre1 mon.8 Log Message: added 'alertevery strict' code and docs, updated the README and INSTALL to mention CVS, updated CREDITS Index: mon.8 =================================================================== RCS file: /cvsroot/mon/mon/doc/mon.8,v retrieving revision 1.1.1.1 retrieving revision 1.1.1.1.2.1 diff -C2 -d -r1.1.1.1 -r1.1.1.1.2.1 *** mon.8 9 Jun 2004 05:18:06 -0000 1.1.1.1 --- mon.8 17 Jun 2004 20:28:54 -0000 1.1.1.1.2.1 *************** *** 363,367 **** .I unless the summary output from the current monitor program differs from the last ! monitor process. Otherwise, send an alert using each alert program listed for that period. The .B "observe_detail" --- 363,368 ---- .I unless the summary output from the current monitor program differs from the last ! monitor process. ! Otherwise, send an alert using each alert program listed for that period. The .B "observe_detail" *************** *** 376,379 **** --- 377,387 ---- The reasoning is that if the summary output changes, then a significant event occurred and the user should be alerted. + The "strict" argument to alertevery will suppress both + comparing the output from the previous monitor run to the current + and prevent a successful return value of the monitor from + resetting the alertevery timer. For example, "alertevery 24h strict" + will only send out an alert once every 24 hours, regardless of + whether the monitor output changes, or if the service stops and then + starts failing. .SH ALERT\ PROGRAMS *************** *** 1113,1117 **** .TP ! .BI alertevery " timeval [observe_detail]" The .B alertevery --- 1121,1125 ---- .TP ! .BI alertevery " timeval [observe_detail | strict]" The .B alertevery *************** *** 1135,1139 **** "observe_detail" is the last argument, then both the summary and detail output lines will be considered when comparing the ! output of successive failures. Please refer to the .B "ALERT DECISION LOGIC" section for a detailed explanation of how alerts are suppressed. --- 1143,1152 ---- "observe_detail" is the last argument, then both the summary and detail output lines will be considered when comparing the ! output of successive failures. ! If the string "strict" is the last argument, then the output ! of the monitor or the state change of the service will have ! no effect on when alerts are sent. That is, "alertevery 24h strict" ! will send only one alert every 24 hours, no matter what. ! Please refer to the .B "ALERT DECISION LOGIC" section for a detailed explanation of how alerts are suppressed. |
From: David N. <vi...@us...> - 2004-06-14 13:25:12
|
Update of /cvsroot/mon/monperl/Mon In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8926 Modified Files: Client.pm Protocol.pm Log Message: Removed all usage of Text::ParseWords, and changed the escaping helper functions to escape the space character (ASCII 32). Index: Protocol.pm =================================================================== RCS file: /cvsroot/mon/monperl/Mon/Protocol.pm,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** Protocol.pm 14 Jun 2004 12:51:05 -0000 1.1.1.1 --- Protocol.pm 14 Jun 2004 13:25:03 -0000 1.2 *************** *** 101,105 **** use IO::File; use Socket; - use Text::ParseWords; sub new; --- 101,104 ---- *************** *** 326,330 **** # if $inquotes is true, backslashes are doubled, making # the escaped string suitable to be enclosed in ! # single quotes and later passed to Text::quotewords. # For example, var='quoted value' # --- 325,329 ---- # if $inquotes is true, backslashes are doubled, making # the escaped string suitable to be enclosed in ! # single quotes and later passed to split # For example, var='quoted value' # *************** *** 339,343 **** my $c = substr ($str, $i, 1); ! if (ord ($c) < 32 || ord ($c) > 126 || $c eq "\"" || --- 338,342 ---- my $c = substr ($str, $i, 1); ! if (ord ($c) <= 32 || ord ($c) > 126 || $c eq "\"" || Index: Client.pm =================================================================== RCS file: /cvsroot/mon/monperl/Mon/Client.pm,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** Client.pm 14 Jun 2004 12:51:05 -0000 1.1.1.1 --- Client.pm 14 Jun 2004 13:25:03 -0000 1.2 *************** *** 29,33 **** use IO::File; use Socket; - use Text::ParseWords; use vars qw(@ISA @EXPORT_OK); --- 29,32 ---- *************** *** 596,600 **** ($group, $service, $desc) = split (/\s+/, $d, 3); $desc{$group}{$service} = ! _un_esc_str ((parse_line ('\s+', 0, $desc))[0]); } --- 595,599 ---- ($group, $service, $desc) = split (/\s+/, $d, 3); $desc{$group}{$service} = ! _un_esc_str (split /\s+/, $desc, 1); } *************** *** 632,636 **** if ($what eq "exp") { $dep{$group}->{$service}->{"expression"} = ! _un_esc_str ((parse_line ('\s+', 0, $l))[0]); } elsif ($what eq "cmp") { --- 631,635 ---- if ($what eq "exp") { $dep{$group}->{$service}->{"expression"} = ! _un_esc_str (split /\s+/, $l, 1); } elsif ($what eq "cmp") { *************** *** 1164,1168 **** $var =~ s/^[^=]*=//; ! return _un_esc_str ((parse_line ('\s+', 0, $var))[0]); } --- 1163,1167 ---- $var =~ s/^[^=]*=//; ! return _un_esc_str (split /\s+/, $var, 1); } *************** *** 1654,1658 **** my $c = substr ($str, $i, 1); ! if (ord ($c) < 32 || ord ($c) > 126 || $c eq "\"" || --- 1653,1657 ---- my $c = substr ($str, $i, 1); ! if (ord ($c) <= 32 || ord ($c) > 126 || $c eq "\"" || |
From: Jim T. <tr...@us...> - 2004-06-14 12:57:57
|
Update of /cvsroot/mon/monperl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19688 Modified Files: README VERSION Log Message: updated the version and "where to get more information" in the README Index: README =================================================================== RCS file: /cvsroot/mon/monperl/README,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** README 14 Jun 2004 12:51:05 -0000 1.1.1.1 --- README 14 Jun 2004 12:57:48 -0000 1.2 *************** *** 10,14 **** "mon" is a tool for monitoring the availability of services. ! More information can be found at http://www.kernel.org/software/mon/. To install: --- 10,15 ---- "mon" is a tool for monitoring the availability of services. ! More information can be found at http://www.kernel.org/software/mon/ ! and https://sourceforge.net/projects/mon/. To install: Index: VERSION =================================================================== RCS file: /cvsroot/mon/monperl/VERSION,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** VERSION 14 Jun 2004 12:51:05 -0000 1.1.1.1 --- VERSION 14 Jun 2004 12:57:48 -0000 1.2 *************** *** 1,2 **** ! $ProjectVersion: monperl-0-99-1.6 $ ! $ProjectDate: Tue, 20 May 2003 08:15:27 -0400 $ --- 1,6 ---- ! $Name$ ! ! $Log$ ! Revision 1.2 2004/06/14 12:57:48 trockij ! updated the version and "where to get more information" in the README ! |
From: David N. <vi...@us...> - 2004-06-14 11:30:01
|
Update of /cvsroot/mon/mon In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13223 Modified Files: mon Log Message: Massive amounts of changes, imported from CMU Mon code. Many new features, not all of them are documented yet. Many bug fixes. Details below: Add "redistribute" as a config file option. This goes at the service level, not the period level. Its arguments are the same as an alert config option. (Script name plus optional arguments). Documented. Better support for Mon traps. Lots of little details weren't being handled quite right. And the parsing of the 'trap section' of auth.cf was completely broken Added syslog calls for all the possible reasons an alert could be suppressed, instead of just for 'alertevery'. Added support for a new auth type "trustlocal" which means that all client connections from localhost are trusted to identify themselves without a password. This is most useful when using any of the various Apache authentication mechanism to control access to the CGI scripts. Documented. Fixed a bug (or was it a feature?) which was causing testing intervals to back off very heavily when forced test runs were done. Added the mon client's username to the comment when ack'ing a failure. It turns out mon.cgi was already doing this, but I feel this should be the responsibility of the mon server, not the mon client. Changed upalert behavior to use the output of the successful monitor run, instead of the output of the last failure. We find this leads to less confusion, as seeing an UPALERT with failure information in it can be confusing. Fixed a bug where op_status wasn't being set to OK before calling the upalert, which only causes a problem when generating a upalert trap to another Mon server, as the trap alert script would grab the contents of the MON_OPSTATUS environment variable, which would still be STAT_FAIL, so the first OK trap to the remote Mon server would actually still be a failure trap, causing failures to appear longer on the other server then they actually were. Added full support for saving/loading full opstatus information. Added support for specifying which type(s) of state to load when mon is started with the -l switch. Documented. Added new dependency behavior type 'hm', for per-host monitor suppression. Documented. Added the ability to have multiple dependency expressions associated with a single watch/service. This added three new mon.cfg keywords 'alertdepend', 'monitordepend', and 'hostdepend'. Documented. Fixed some bugs with trap authentication checking where traps from any host were being allowed. Fixed a couple bugs that was preventing traptimeouts from sending alerts when there was a dependency involved, or an alertafter statement. *Lots* of little changes to make 'perl -w' happy with mon. As a side effect of this, the memory leak problems I was having seem to have gone away. Added code to track what host a trap comes from. Fixed a couple bugs where things weren't getting reset after an up trap. Added support for remote mon updates via the monremote config option. Documented. Added non-alert alerts (i.e. logging only alerts that you don't want to cause the service to go red in mon.cgi). Not yet documented. Changed syslog log levels for lots of things to lower levels. Fixed a bug that was allowing bogus options in periods. Started writing support for ackalert/disablealert, not yet complete/tested/documented. Added unack_summary support, which causes an acked failure to un-ack if the summary changes. alert timers are reset when an ack is removed. Not yet documented. Added code to export group/service to monitor scripts, and to export ack messages to alerts. Added some debugging for tracking down issues with unack_summary behavior. Don't alert on disabled groups, in addition to not calling monitor scripts. (Traps were still alerting) Eliminated usage of parse_line during trap processing, to avoid a perl regexp segfault. Stop calling waitpid for alerts, let the waitpid elsewhere handle it. Start setting _exitval when a trap is received. Changed behavior of disabled groups, to still monitor, but not alert. Fixed a bug which caused alerts to be sent on traps, even when the scheduler was stopped. Added support for dependency memory, with two new config file statements 'dep_memory = timeval' in both the global and per service config blocks. Also added initial support for storing a timestamp on acks. added support for 'ignore_summary' flag on alertevery statements. Wrapped a fork around the alert sending routine, to avoid hangs. Disabling a host which is the only host in its group now disables the whole watchgroup instead. (So the monitoring will still happen, so you can see the current state, even though it won't alert.) Better error reporting on dependency error. Added 'alertexitrange' config option, to apply an exit range filter to all alerts in this period Don't treat disabled watches & services special in dependencies. Just look at their status. (Though I'm tempted to treat them special in the opposite way, i.e. always fail the dependency check.) Index: mon =================================================================== RCS file: /cvsroot/mon/mon/mon,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** mon 11 Jun 2004 17:03:47 -0000 1.4 --- mon 14 Jun 2004 11:29:47 -0000 1.5 *************** *** 71,74 **** --- 71,75 ---- sub debug_dir; sub dep_ok; + sub dep_summary; sub depend; sub dhmstos; *************** *** 87,90 **** --- 88,92 ---- sub handle_trap_timeout; [...2773 lines suppressed...] } } + + # Perl's "system" function blocks. We don't want the mon process to + # ever block. So we fork then call system. Mon will handle the + # child process cleanup elsewhere. + sub mysystem { + my @args = @_; + my $pid; + print STDERR "mysystem called: @args\n"; + if ($pid = fork()) { ## parent + return; + } elsif (defined($pid)) { ## child + system(@args); + exit(0) + } else { ## parent - fork failed + print STDERR "You lose!\n"; + } + print STDERR "mysystem returning\n"; + }; |
From: David N. <vi...@us...> - 2004-06-14 11:08:31
|
Update of /cvsroot/mon/mon/doc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29517/doc Modified Files: mon.8 Log Message: Added documentation for various new features that will be in Mon 1.1: '-l' commandline option now supports saving/loading opstatus new dependency type, 'host' multiple simultaneous dependency types now possible 'trustlocal' authorization type dependency memory 'monremote' config option, for propagating client requests to other servers Index: mon.8 =================================================================== RCS file: /cvsroot/mon/mon/doc/mon.8,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** mon.8 9 Jun 2004 05:18:06 -0000 1.1.1.1 --- mon.8 14 Jun 2004 11:08:21 -0000 1.2 *************** *** 23,26 **** --- 23,28 ---- .IR num ] .RB [ \-l + .IR [ statetype ] ] + .RB [ \-L .IR dir ] .RB [ \-m *************** *** 106,112 **** to 100. .TP ! .BI \-l ! Load state from the last saved state file. Currently the only ! supported saved state is disabled watches, services, and hosts. .TP .BI \-L\ dir --- 108,124 ---- to 100. .TP ! .BI \-l\ statetype ! Load state from the last saved state file. The ! supported saved state types are ! .B disabled ! for disabled watches, services, and hosts, ! .B opstatus ! for failure/alert/ack status of ! all services, ! and ! .B all ! for both. If no statetype is provided, ! .B disabled ! is assumed. .TP .BI \-L\ dir *************** *** 347,351 **** is set to .IR "'a'" , ! and a parent dependency is failing, then suppress the alert. If the alert has previously been acknowledged, do not send the alert, unless it is an upalert. --- 359,365 ---- is set to .IR "'a'" , ! or ! .B alertdepend ! is set, and a parent dependency is failing, then suppress the alert. If the alert has previously been acknowledged, do not send the alert, unless it is an upalert. *************** *** 632,635 **** --- 646,658 ---- service will be used. + If + .I type + is + .BR trustlocal , + then if the client connection comes from locahost, the username passed from + the client will be trusted, and the password will be ignored. This can be used + when you want the client to handle the authentication for you. I.e. a CGI script + using one of the many apache authentication methods. + .TP .BI "userfile = " file *************** *** 830,840 **** .TP ! .BI "dep_behavior = " {a|m} .B dep_behavior controls whether the dependency expression ! suppresses either the running of alerts or monitors ! when a node in the dependency graph fails. Read more ! about the behavior in the "Service Definitions" section ! below. This is a global setting which controls the default --- 853,877 ---- .TP ! .BI "dep_behavior = " {a|m|hm} .B dep_behavior controls whether the dependency expression ! suppresses one of: the running of alerts, the running of ! monitors, or the passing of individual hosts to the monitors. ! Read more about the behavior in the "Service Definitions" ! section below. ! ! This is a global setting which controls the default ! settings for the service-specified variable. ! ! .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 ! normal state. This can be used to prevent over-eager alerting when a ! machine is rebooting, for example. See the explanation of ! .I interval ! in the "Service Definitions" section ! for a description of ! .IR timeval . This is a global setting which controls the default *************** *** 847,850 **** --- 884,889 ---- is the default. + + .TP .BI "startupalerts_on_reset = " {yes|no} *************** *** 854,857 **** --- 893,905 ---- client command is executed. The default is "no". + .TP + .BI "monremote = " program + + If set, this external program will be called by Mon when various + client requests are processed. This can be used to propagate those + changes from one Mon server to another, if you have multiple + monitoring machines. An example script, + .B monremote.pl + is available in the clients directory. .SS "Hostgroup Entries" *************** *** 1054,1061 **** .TP ! .BI dep_behavior " {a|m}" ! The evaluation of dependency graphs can control the ! suppression of either alert or monitor invocations. .BR "Alert suppression" . --- 1102,1112 ---- .TP ! .BI dep_behavior " {a|m|hm}" ! The evaluation of the dependency graphs specified via the ! .B depend ! keyword can control the ! suppression of alert or monitor invocations, or the suppression ! of individual hosts passed to the monitor. .BR "Alert suppression" . *************** *** 1079,1082 **** --- 1130,1177 ---- the same. + .BR "Host suppression" . + If it is set to "hm" then Mon will extract the list of "parent" + services from the dependency expression. (In fact the expression can + be just a list of services.) Then when the monitor for the service is + about to be run, for each host in the current hostgroup Mon will + search all the parent services which are currently failing and look + for the hostname in the current summary output. If the hostname is + found, this host will be excluded from this run of the monitor. This + can be used to e.g. allow an SMTP test on a group of hosts to still be run + even when a single host is not ping-reachable. If all the rest of the + hosts are working fine, the service will be in an OK state, but if + another host fails the SMTP test Mon can still alert about that host + even though the parent dependency was failing. The dependency + expression will + .B not + be used recursively in this case. + + .TP + .BI alertdepend " dependexpression" + .TP + .BI monitordepend " dependexpression" + .TP + .BI hostdepend " dependexpression" + These keywords allow you to specify multiple dependency expressions of + different types. Each one corresponds to the different + .B dep_behavior + settings listed above. They will be evaluated independently in the different + contexts as listed above. If + .B depend + is present, it takes precedence over the matching keyword, depending on the + .B dep_behavior + setting. + + .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 + normal state. This can be used to prevent over-eager alerting when a + machine is rebooting, for example. See the explanation of + .I interval + in the "Service Definitions" section + for a description of + .IR timeval . + .SS "Period Definitions" |
From: David N. <vi...@us...> - 2004-06-14 10:57:23
|
Update of /cvsroot/mon/mon/clients In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22651/clients Added Files: monremote.pl Log Message: Adding monremote.pl, as an example for the new 'monremote' configuration option. --- NEW FILE: monremote.pl --- #!/usr/bin/perl -w # # monremote.pl - Propagates client (user) requests from one mon process to another, # via mon.cgi # # David Nolan, vi...@cm... # # $Id: monremote.pl,v 1.1 2004/06/14 10:57:14 vitroth Exp $ # # Copyright (C) 2002 Carnegie Mellon University # # 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 # # monremote.pl will issue HTTPS requests to a remote Mon server. You must provide it with an # SSL certificate & key, and tell it where mon.cgi is running on the remote server. # Configuration block # SSL Key. You can use your apache server's key for simplicity $crt = '/usr/local/apache/conf/ssl.crt/server.crt'; $key = '/usr/local/apache/conf/ssl.key/server.key'; # List of servers to propagate changes to @hosts = ('monserver1.example.com', 'monserver2.example.com'); # Name of your master Mon server, to prevent propagations from any other hosts $mon_master = "mon-master.example.com"; # URI of mon.cgi on the remote servers. If its different on individual servers # you'll need to do extra work. (Make the hosts list a hash, with the URLS.) $path = '/cbin/mon.cgi'; # Set this to non-zero to enable debugging $debug = 0; # Comment this out once you've edited the config block above. die "monremote.pl must be customized for your environment! Please edit the configuration block."; # You shouldn't need to change anything below here. use LWP::UserAgent; use Sys::Hostname; if (!defined $ARGV[0]) { print "Usage: monremote.pl (enable|disable) (watch <groupname>|host <hostname>|service <group> <service>)\n"; exit; } # Make sure we're running on the master. $hostname = hostname; $hostname =~ tr/a-z/A-Z/; $mon_master =~ tr/a-z/A-Z/; if ($hostname ne $mon_master) { print STDERR "No propagation from servers other then the master!\n"; exit -1; } # Figure out what the argument portions of the URL need to be. if ($ARGV[0] eq 'disable') { $args = "?command=mon_disable"; if ($ARGV[1] eq 'watch') { $args .= "&args=watch,$ARGV[2]&rt=none"; } elsif ($ARGV[1] eq 'service') { $args .= "&args=service,$ARGV[2],$ARGV[3]&rt=none"; } elsif ($ARGV[1] eq 'host') { $args .= "&args=host,$ARGV[2]&rt=none"; } } elsif ($ARGV[0] eq 'enable') { $args = "?command=mon_enable"; if ($ARGV[1] eq 'watch') { $args .= "&args=watch,$ARGV[2]&rt=none"; } elsif ($ARGV[1] eq 'service') { $args .= "&args=service,$ARGV[2],$ARGV[3]&rt=none"; } elsif ($ARGV[1] eq 'host') { $args .= "&args=host,$ARGV[2]&rt=none"; } } elsif ($ARGV[0] eq 'test') { $args = "?command=mon_test_service&args=$ARGV[1],$ARGV[2]"; } else { print STDERR "Unknown command $ARGV[0]\n"; exit -1; } $ENV{HTTPS_CERT_FILE} = $crt; $ENV{HTTPS_KEY_FILE} = $key; # Now fork and do the work. # We fork so that we don't wait for each individual request to finish. # We fork twice so that the kernel will take care of process cleanup for us. $pid = fork; if ($pid) { waitpid ($pid, 0); print STDERR "Parent exiting\n" if ($debug); exit 0; } else { foreach $host (@hosts) { if (fork) { next; } my $ua = LWP::UserAgent->new; $ua->agent("MonRemote/0.1"); print STDERR "@ARGV\n" if ($debug); print STDERR "$args\n" if ($debug); my $req = HTTP::Request->new(GET => "https://$host/$path$args"); $req ->content_type('application/x-www-form-urlencoded'); my $res = $ua->request($req); if ($res->is_success) { print STDERR "Worker exiting\n" if ($debug); exit 0; } else { print STDERR "\n$host\n@ARGV\nRequest to remote server failed\n"; exit 0; } } print STDERR "Child exiting\n" if ($debug); exit 0; } |
From: David N. <vi...@us...> - 2004-06-14 10:54:03
|
Update of /cvsroot/mon/mon/alert.d In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19671 Modified Files: trap.alert Log Message: Rewrote trap.alert to use Mon::Client instead of trying to encode the trap directly. Index: trap.alert =================================================================== RCS file: /cvsroot/mon/mon/alert.d/trap.alert,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** trap.alert 9 Jun 2004 05:18:07 -0000 1.1.1.1 --- trap.alert 14 Jun 2004 10:53:54 -0000 1.2 *************** *** 26,33 **** # use Getopt::Std; use Socket; - getopts ("s:g:h:t:l:o:uU:P:"); ! $TRAP_PRO_VERSION = 0.3807; $summary=<STDIN>; --- 26,34 ---- # use Getopt::Std; + use Mon::Client; use Socket; ! getopts ("s:g:h:t:l:o:uU:P:T:"); ! $summary=<STDIN>; *************** *** 50,81 **** } ! $pkt = ""; ! $pkt .= "pro=$TRAP_PRO_VERSION\n"; ! $pkt .= "usr=$USER\n" . "pas=$PASS\n" if ($USER ne ""); ! $pkt .= "typ=$ENV{MON_ALERTTYPE}\n"; ! $pkt .= "seq=0\n"; ! $pkt .= "grp=$ENV{MON_GROUP}\n"; ! $pkt .= "svc=$ENV{MON_SERVICE}\n"; ! $pkt .= "sta=$ENV{MON_RETVAL}\n"; ! $pkt .= "spc=$OPST\n"; ! $pkt .= "tsp=$t\n"; ! $pkt .= "sum=$summary\n"; ! $pkt .= "dtl=$detail\n.\n"; ! ! $proto = getprotobyname ("udp") || die "could not get proto\n"; ! socket (TRAP, AF_INET, SOCK_DGRAM, $proto) || ! die "could not create UDP socket: $!\n"; ! $port = getservbyname ('mon', 'udp') || 2583; foreach $host (@ARGV) { ! my $paddr = sockaddr_in ($port, inet_aton ($host)); ! if (!defined (send (TRAP, $pkt, 0, $paddr))) { ! print STDERR "could not send trap to $host: $!\n"; ! next; ! } ! } ! close (TRAP); exit; --- 51,78 ---- } ! foreach $op (keys %Mon::Client::OPSTAT) { ! $OPSTATUS = $op if ($Mon::Client::OPSTAT{$op} == $OPST); ! } ! $c = new Mon::Client ( ! port => getservbyname ('mon', 'udp') || 2583, ! ); + $c->user($USER) if ($USER); + $c->password($PASS) if ($PASS); foreach $host (@ARGV) { ! $c->host($host); ! ! $res = $c->send_trap( group => $ENV{MON_GROUP}, ! service => $ENV{MON_SERVICE}, ! retval => $ENV{MON_RETVAL}, ! opstatus => $OPSTATUS, ! summary => $summary, ! detail => $detail, ! ); ! print STDERR "Error sending trap to $host\n" if (!$res); ! print STDERR "Error is: ". $c->error() . "\n" if (!$res); ! } exit; |
From: Jim T. <tr...@us...> - 2004-06-12 18:18:06
|
Update of /cvsroot/mon/mon In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7128 Modified Files: Tag: mon-1-0-0pre1 KNOWN-PROBLEMS README VERSION mon Log Message: added some rcs tags to identify the file versions Index: README =================================================================== RCS file: /cvsroot/mon/mon/README,v retrieving revision 1.1.1.1 retrieving revision 1.1.1.1.2.1 diff -C2 -d -r1.1.1.1 -r1.1.1.1.2.1 *** README 9 Jun 2004 05:18:03 -0000 1.1.1.1 --- README 12 Jun 2004 18:17:57 -0000 1.1.1.1.2.1 *************** *** 1,2 **** --- 1,3 ---- + $Name$ $Id$ Index: KNOWN-PROBLEMS =================================================================== RCS file: /cvsroot/mon/mon/KNOWN-PROBLEMS,v retrieving revision 1.1.1.1 retrieving revision 1.1.1.1.2.1 diff -C2 -d -r1.1.1.1 -r1.1.1.1.2.1 *** KNOWN-PROBLEMS 9 Jun 2004 05:18:03 -0000 1.1.1.1 --- KNOWN-PROBLEMS 12 Jun 2004 18:17:56 -0000 1.1.1.1.2.1 *************** *** 1,9 **** # ! # $Id$ ! # Release $Name$ # ! KNOWN PROBLEMS in 0.99.3 devel ! -------------------------- clients/skymon has not yet been updated to work with the new Mon::Client --- 1,8 ---- # ! # $Name$ # ! KNOWN PROBLEMS in $Name$ ! ------------------------------ clients/skymon has not yet been updated to work with the new Mon::Client Index: VERSION =================================================================== RCS file: /cvsroot/mon/mon/VERSION,v retrieving revision 1.1.1.1 retrieving revision 1.1.1.1.2.1 diff -C2 -d -r1.1.1.1 -r1.1.1.1.2.1 *** VERSION 9 Jun 2004 05:18:03 -0000 1.1.1.1 --- VERSION 12 Jun 2004 18:17:57 -0000 1.1.1.1.2.1 *************** *** 1,2 **** ! $ProjectVersion: mon-0-99-3.47 $ ! $ProjectDate: Mon, 07 Jun 2004 13:56:49 -0400 $ --- 1,6 ---- ! $Name$ ! ! $Log$ ! Revision 1.1.1.1.2.1 2004/06/12 18:17:57 trockij ! added some rcs tags to identify the file versions ! Index: mon =================================================================== RCS file: /cvsroot/mon/mon/mon,v retrieving revision 1.4 retrieving revision 1.4.2.1 diff -C2 -d -r1.4 -r1.4.2.1 *** mon 11 Jun 2004 17:03:47 -0000 1.4 --- mon 12 Jun 2004 18:17:57 -0000 1.4.2.1 *************** *** 28,32 **** my $RCSID='$Id$'; my $AUTHOR='tr...@tr...'; ! my $RELEASE='$ProjectVersion: mon-0-99-3.47 $'; # --- 28,32 ---- my $RCSID='$Id$'; my $AUTHOR='tr...@tr...'; ! my $RELEASE='$Name$'; # |
From: David N. <vi...@us...> - 2004-06-11 17:03:56
|
Update of /cvsroot/mon/mon In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25402 Modified Files: mon Log Message: Reverting upalertafter behavior back to the documented behavior. (And fixing a bug in that behavior.) upalertafter statements mean "only send an upalert if the service was down for more than X", as documented. The alternate behavior of "only send an upalert after the service has been back up for X" would be nice to add, but can not be added as the patch from Adrian Chung attempted to do, as it will lead to user confusion when looking at the current status ("But I fixed that!") and will conflict with the soon to be released 'redistribute' feature, for propagating service status to other Mon servers or to other monitoring systems. Index: mon =================================================================== RCS file: /cvsroot/mon/mon/mon,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** mon 11 Jun 2004 15:50:38 -0000 1.3 --- mon 11 Jun 2004 17:03:47 -0000 1.4 *************** *** 1361,1365 **** } ! $pref->{"upalertafterinterval"} = $args; } --- 1361,1365 ---- } ! $pref->{"upalertafter"} = $args; } *************** *** 2764,2768 **** select (STDOUT); ! if (!open (STDIN, "/dev/null") { syslog ("err", 'could not open STDIN from /dev/null: %m'); --- 2764,2768 ---- select (STDOUT); ! if (!open (STDIN, "/dev/null")) { syslog ("err", 'could not open STDIN from /dev/null: %m'); *************** *** 2903,2906 **** --- 2903,2907 ---- } + my $old_status = $sref->{"_op_status"}; set_op_status ($group, $service, $STAT_OK); *************** *** 2910,2920 **** # let someone know # ! my $diff = ($tmnow - $sref->{"_upalerttime"}); ! if ($sref->{"_upalertafterinterval"} > 0) { ! if (defined($sref->{"_upalert"}) && ($diff > $sref->{"_upalertafterinterval"})) ! { ! do_alert ($group, $service, $sref->{"_upalertoutput"}, 0, $FL_UPALERT); ! } } --- 2911,2921 ---- # let someone know # ! if ((defined ($sref->{"_op_status"})) && ! ($old_status == $STAT_FAIL) && ! (defined($sref->{"_upalert"})) && ! (!defined($sref->{"upalertafter"}) ! || (($tmnow - $sref->{"_first_failure"}) >= $sref->{"upalertafter"}))) { ! do_alert ($group, $service, $sref->{"_upalertoutput"}, 0, $FL_UPALERT); } *************** *** 2943,2950 **** $sref->{"periods"}->{$period}->{"_last_alert"} = 0; $sref->{"periods"}->{$period}->{"_1stfailtime"} = 0; ! unless ( $diff > $sref->{"_upalertafterinterval"} ) ! { ! $sref->{"periods"}->{$period}->{"_alert_sent"} = 0; ! } } --- 2944,2948 ---- $sref->{"periods"}->{$period}->{"_last_alert"} = 0; $sref->{"periods"}->{$period}->{"_1stfailtime"} = 0; ! $sref->{"periods"}->{$period}->{"_alert_sent"} = 0; } *************** *** 4555,4564 **** } else { $alerttype = "alert"; - # - # Save these variables for when we call an upalertafter - # - $sref->{"_upalertafterinterval"} = $pref->{upalertafterinterval}; - $sref->{"_upalerttime"} = scalar time; - $sref->{"_upalertoutput"} = $args{"output"}; } --- 4553,4556 ---- |
From: David N. <vi...@us...> - 2004-06-11 15:50:51
|
Update of /cvsroot/mon/mon In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24096 Modified Files: mon Log Message: Moving set_op_status call to before do_alert, so upalerts will get the correct information in the MON_OPSTATUS environment variable. Also, re-adding an else clause during auth.cf parsing that prevents bogus entries from being read into the configuration. Index: mon =================================================================== RCS file: /cvsroot/mon/mon/mon,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** mon 11 Jun 2004 14:55:55 -0000 1.2 --- mon 11 Jun 2004 15:50:38 -0000 1.3 *************** *** 2903,2906 **** --- 2903,2908 ---- } + set_op_status ($group, $service, $STAT_OK); + # # if this service has just come back up and *************** *** 2960,2964 **** $sref->{"_last_success"} = $tmnow; - set_op_status ($group, $service, $STAT_OK); } --- 2962,2965 ---- *************** *** 3540,3543 **** --- 3541,3547 ---- syslog ('err', "invalid host in $CF{AUTHFILE}, line $."); next; + } else { + syslog ('err', "invalid host in $CF{AUTHFILE}, line $."); + next; } |
From: Jim T. <tr...@us...> - 2004-06-11 14:56:05
|
Update of /cvsroot/mon/mon In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14305 Modified Files: CHANGES mon Log Message: removed nonsensical unless statement which would conditionally set the op status to STAT_OK. it should be set unconditionally Index: CHANGES =================================================================== RCS file: /cvsroot/mon/mon/CHANGES,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** CHANGES 9 Jun 2004 05:18:04 -0000 1.1.1.1 --- CHANGES 11 Jun 2004 14:55:55 -0000 1.2 *************** *** 2,6 **** Changes between mon-0.99.2 and mon-0.99.3 ! Mon Jun 7 13:52:56 EDT 2004 -------------------------------------------- --- 2,6 ---- Changes between mon-0.99.2 and mon-0.99.3 ! Fri Jun 11 10:55:27 EDT 2004 -------------------------------------------- *************** *** 172,175 **** --- 172,177 ---- the "all" directive in auth.cf + -removed nonsensical unless statement which would conditionally set the op + status to STAT_OK. it should be set unconditionally Index: mon =================================================================== RCS file: /cvsroot/mon/mon/mon,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** mon 9 Jun 2004 05:18:03 -0000 1.1.1.1 --- mon 11 Jun 2004 14:55:55 -0000 1.2 *************** *** 2960,2967 **** $sref->{"_last_success"} = $tmnow; ! unless (defined($sref->{"_upalert"}) && ( $diff < $sref->{"_upalertafterinterval"}) ) ! { ! set_op_status ($group, $service, $STAT_OK); ! } } --- 2960,2964 ---- $sref->{"_last_success"} = $tmnow; ! set_op_status ($group, $service, $STAT_OK); } |