diff -ruBNx HTML /home/hostedsites/www.jeremykister.com/data/argus/argus-dev-20071231/CHANGES /home/hostedsites/www.jeremykister.com/data/argus/argus-dev-20080202/CHANGES --- /home/hostedsites/www.jeremykister.com/data/argus/argus-dev-20071231/CHANGES 2007-12-30 20:33:32.000000000 -0500 +++ /home/hostedsites/www.jeremykister.com/data/argus/argus-dev-20080202/CHANGES 2008-02-02 16:24:04.000000000 -0500 @@ -8,6 +8,9 @@ new data directory structure show test results on webpage overview webpage + friendlier notification messages + bugfixes + => some config file changes may be needed * Version 3.5 [2007 June 14] SNMPv2c diff -ruBNx HTML /home/hostedsites/www.jeremykister.com/data/argus/argus-dev-20071231/Configure /home/hostedsites/www.jeremykister.com/data/argus/argus-dev-20080202/Configure --- /home/hostedsites/www.jeremykister.com/data/argus/argus-dev-20071231/Configure 2007-01-15 21:40:51.000000000 -0500 +++ /home/hostedsites/www.jeremykister.com/data/argus/argus-dev-20080202/Configure 2008-02-02 22:00:40.000000000 -0500 @@ -5,7 +5,7 @@ # Date: 2002-Apr-19 16:44 (EDT) # Function: discover configuration info # -# $Id: Configure,v 1.24 2007/01/16 02:40:51 jaw Exp $ +# $Id: Configure,v 1.25 2008/02/03 03:00:40 jaw Exp $ cat</dev/null 2>&1; then + # nb. fping might be a symlink. just try running it + $path_fping 127.0.0.1 >/dev/null 2>&1 + if [ $? != 0 ] ; then echo '* but it is not installed setuid' echo '* argus ping tests will fail unless argus runs as root' echo '* or fping is fixed' diff -ruBNx HTML /home/hostedsites/www.jeremykister.com/data/argus/argus-dev-20071231/Makefile.tplt /home/hostedsites/www.jeremykister.com/data/argus/argus-dev-20080202/Makefile.tplt --- /home/hostedsites/www.jeremykister.com/data/argus/argus-dev-20071231/Makefile.tplt 2007-12-31 17:20:31.000000000 -0500 +++ /home/hostedsites/www.jeremykister.com/data/argus/argus-dev-20080202/Makefile.tplt 2008-02-02 22:00:40.000000000 -0500 @@ -3,9 +3,9 @@ # Created: 2002-Jun-27 # Function: Makefile template # -# $Id: Makefile.tplt,v 1.169 2007/12/31 22:20:31 jaw Exp $ +# $Id: Makefile.tplt,v 1.170 2008/02/03 03:00:40 jaw Exp $ -VERSION = dev-20071231 +VERSION = dev-20080202 MESSAGE = This is unstable development code INSTALL = please see the INSTALL document for the next steps UPGRADE1 = be sure to install the new misc/argus.css and misc/argus.js files @@ -27,7 +27,7 @@ NotMe.pm Override.pm Server.pm Service.pm Stats.pm \ Web.pm NullConf.pm Error.pm Argus::Ctl.pm Argus::Encode.pm \ NullCtl.pm UserCron.pm TestPort.pm Resolv.pm \ - misc.pl localization.pl \ + misc.pl localization.pl Argus::HashDir.pm \ Argus::MonEl::Expand.pm Argus::MonEl::Noise.pm Argus::MonEl::Trans.pm \ Argus::Archivist.pm Argus::Archive.pm Argus::Web::Overview.pm diff -ruBNx HTML /home/hostedsites/www.jeremykister.com/data/argus/argus-dev-20071231/misc/argus.css /home/hostedsites/www.jeremykister.com/data/argus/argus-dev-20080202/misc/argus.css --- /home/hostedsites/www.jeremykister.com/data/argus/argus-dev-20071231/misc/argus.css 2007-12-30 20:24:30.000000000 -0500 +++ /home/hostedsites/www.jeremykister.com/data/argus/argus-dev-20080202/misc/argus.css 2008-02-03 00:23:32.000000000 -0500 @@ -4,7 +4,7 @@ Created: 2007-Jan-10 23:20 (EST) Function: argus css - $Id: argus.css,v 1.4 2007/12/31 01:24:30 jaw Exp $ + $Id: argus.css,v 1.6 2008/02/03 05:23:32 jaw Exp $ */ diff -ruBNx HTML /home/hostedsites/www.jeremykister.com/data/argus/argus-dev-20071231/src/Argus::HashDir.pm /home/hostedsites/www.jeremykister.com/data/argus/argus-dev-20080202/src/Argus::HashDir.pm --- /home/hostedsites/www.jeremykister.com/data/argus/argus-dev-20071231/src/Argus::HashDir.pm 1969-12-31 19:00:00.000000000 -0500 +++ /home/hostedsites/www.jeremykister.com/data/argus/argus-dev-20080202/src/Argus::HashDir.pm 2008-01-21 12:21:02.000000000 -0500 @@ -0,0 +1,39 @@ +# -*- perl -*- + +# Copyright (c) 2008 by Jeff Weisberg +# Author: Jeff Weisberg +# Created: 2008-Jan-21 12:18 (EST) +# Function: +# +# $Id$ + +package Argus::HashDir; +use strict; + +# quickly pick a 2 level directory for the file +sub hashed_directory { + my $file = shift; + + my $h = 5381; + for my $c (split '', $file){ + $h = (33*$h) + ord($c); + $h &= 0xFFFFFF; + } + + my $a = ($h % 26) + 65; + $h >>= 5; + my $b = ($h % 26) + 65; + + sprintf '%c/%c', $a, $b; +} + +sub import { + my $pkg = shift; + my $caller = caller; + + no strict; + *{$caller . '::hashed_directory'} = \&hashed_directory; +} + + +1; diff -ruBNx HTML /home/hostedsites/www.jeremykister.com/data/argus/argus-dev-20071231/src/Argus::MonEl::Expand.pm /home/hostedsites/www.jeremykister.com/data/argus/argus-dev-20080202/src/Argus::MonEl::Expand.pm --- /home/hostedsites/www.jeremykister.com/data/argus/argus-dev-20071231/src/Argus::MonEl::Expand.pm 2007-01-27 16:34:34.000000000 -0500 +++ /home/hostedsites/www.jeremykister.com/data/argus/argus-dev-20080202/src/Argus::MonEl::Expand.pm 2008-02-02 22:00:41.000000000 -0500 @@ -5,7 +5,7 @@ # Created: 2007-Jan-27 10:28 (EST) # Function: expand % sequences # -# $Id: Argus::MonEl::Expand.pm,v 1.2 2007/01/27 21:34:34 jaw Exp $ +# $Id: Argus::MonEl::Expand.pm,v 1.3 2008/02/03 03:00:41 jaw Exp $ package MonEl; use POSIX ('strftime', 'tzset'); @@ -85,7 +85,7 @@ # specified mappings before standard ones, so they can override my $l = join('', keys %$data); $fmt =~ s/%([$l])/$enc->($data->{$1})/ges if $l; - + $fmt =~ s/%d/$enc->($DARP::info->{tag})/ges if defined $DARP::info; $fmt =~ s/%r/$enc->($me->{srvc}{reason})/ges; $fmt =~ s/%s/uc($enc->($me->{ovstatus}))/ges; diff -ruBNx HTML /home/hostedsites/www.jeremykister.com/data/argus/argus-dev-20071231/src/Argus::SNMP.pm /home/hostedsites/www.jeremykister.com/data/argus/argus-dev-20080202/src/Argus::SNMP.pm --- /home/hostedsites/www.jeremykister.com/data/argus/argus-dev-20071231/src/Argus::SNMP.pm 2007-06-30 14:38:42.000000000 -0400 +++ /home/hostedsites/www.jeremykister.com/data/argus/argus-dev-20080202/src/Argus::SNMP.pm 2008-02-02 22:00:41.000000000 -0500 @@ -5,7 +5,7 @@ # Date: 2002-Apr-03 18:59 (EST) # Function: testing of SNMP things - support for both v1, v2c and v3 # -# $Id: Argus::SNMP.pm,v 1.3 2007/06/30 18:38:42 jaw Exp $ +# $Id: Argus::SNMP.pm,v 1.4 2008/02/03 03:00:41 jaw Exp $ # SNMP v1 => RFC 1157 # SNMP v2 => RFC 1905 @@ -288,6 +288,7 @@ $me->{label_right_maybe} ||= $me->{snmp}{oid}; $me->{udp}{port} ||= 161; $me->SUPER::config($cf); + $me->{friendlyname} = "$me->{snmp}{oid} on $me->{ip}{hostname}"; $me->snmp_oid_init($cf); $me; diff -ruBNx HTML /home/hostedsites/www.jeremykister.com/data/argus/argus-dev-20071231/src/Argus::Web::Overview.pm /home/hostedsites/www.jeremykister.com/data/argus/argus-dev-20080202/src/Argus::Web::Overview.pm --- /home/hostedsites/www.jeremykister.com/data/argus/argus-dev-20071231/src/Argus::Web::Overview.pm 2007-12-30 20:24:31.000000000 -0500 +++ /home/hostedsites/www.jeremykister.com/data/argus/argus-dev-20080202/src/Argus::Web::Overview.pm 2008-02-02 22:00:42.000000000 -0500 @@ -5,7 +5,7 @@ # Created: 2007-Dec-30 15:42 (EST) # Function: web page overview # -# $Id: Argus::Web::Overview.pm,v 1.1 2007/12/31 01:24:31 jaw Exp $ +# $Id: Argus::Web::Overview.pm,v 1.2 2008/02/03 03:00:42 jaw Exp $ package MonEl; use strict; @@ -25,11 +25,11 @@ unless open( $fh, "> $file" ) ; $top->{web}{buildtimeov} = $^T; - $top->web_header($fh); + $top->web_header($fh, 'Overview', 'Overview' ); print $fh "\n"; - $top->web_show_has_errors($fh) if $Conf::has_errors; + $top->web_show_has_errors($fh, 3) if $Conf::has_errors; my $color = $Conf::has_errors ? 'FF8888' : 'AAAAFF'; @@ -73,6 +73,8 @@ for my $x (sort { $b->{transtime} <=> $a->{transtime} } @obj){ next unless $x; next unless $x->{interesting}; + next if $x->{anc_in_ov}; + next if $x->{ovstatus} eq 'depends'; my $url = $x->url('func=page'); my $label = $x->{label_overview} || $x->unique(); my $color = MonEl::web_color($x->{ovstatus}, $x->{currseverity}); @@ -125,6 +127,7 @@ for my $p (sort {$a->{created} <=> $b->{created}} values %$unacked){ my $color = ($p->{status} eq 'acked') ? '88FF88' : 'FF8888'; my $txt = $p->{msg}; + $txt =~ s/\n/
\n/gs; my $url = "__BASEURL__?func=ntfydetail;idno=$p->{idno}"; print $fh "\n"; diff -ruBNx HTML /home/hostedsites/www.jeremykister.com/data/argus/argus-dev-20071231/src/Conf.pm /home/hostedsites/www.jeremykister.com/data/argus/argus-dev-20080202/src/Conf.pm --- /home/hostedsites/www.jeremykister.com/data/argus/argus-dev-20071231/src/Conf.pm 2007-12-30 20:24:31.000000000 -0500 +++ /home/hostedsites/www.jeremykister.com/data/argus/argus-dev-20080202/src/Conf.pm 2008-02-02 22:00:42.000000000 -0500 @@ -5,7 +5,7 @@ # Date: 2002-Apr-03 09:13 (EST) # Function: config file reading # -# $Id: Conf.pm,v 1.61 2007/12/31 01:24:31 jaw Exp $ +# $Id: Conf.pm,v 1.62 2008/02/03 03:00:42 jaw Exp $ # some bozo put a Config.pm in the standard perl dist package Conf; @@ -101,12 +101,6 @@ default => ($^O eq 'solaris' ? 250 : undef), versn => '3.6', }, - - newdirs => { # XXX? - attrs => ['config', 'top'], - versn => '3.6', - }, - ################################################################ # experimental, undocumented features - for author's use only diff -ruBNx HTML /home/hostedsites/www.jeremykister.com/data/argus/argus-dev-20071231/src/Configable.pm /home/hostedsites/www.jeremykister.com/data/argus/argus-dev-20080202/src/Configable.pm --- /home/hostedsites/www.jeremykister.com/data/argus/argus-dev-20071231/src/Configable.pm 2007-12-22 12:22:13.000000000 -0500 +++ /home/hostedsites/www.jeremykister.com/data/argus/argus-dev-20080202/src/Configable.pm 2008-02-02 22:00:42.000000000 -0500 @@ -5,7 +5,7 @@ # Date: 2002-Dec-30 23:29 (EST) # Function: configurable objects # -# $Id: Configable.pm,v 1.25 2007/12/22 17:22:13 jaw Exp $ +# $Id: Configable.pm,v 1.26 2008/02/03 03:00:42 jaw Exp $ package Configable; @@ -401,6 +401,7 @@ next if ($k =~ /^_/) && ::topconf('_hide_expr'); $v =~ s/\#/\\\#/g; $v =~ s/\n/\\n\\\n/g; + $v =~ s/\r/\\r/g; $r .= "\t$k:\t$v"; $r .= "\t# unused parameter - typo?" unless $me->{confck}{$k} || $d->{conf}{notypos}; diff -ruBNx HTML /home/hostedsites/www.jeremykister.com/data/argus/argus-dev-20071231/src/DNS.pm /home/hostedsites/www.jeremykister.com/data/argus/argus-dev-20080202/src/DNS.pm --- /home/hostedsites/www.jeremykister.com/data/argus/argus-dev-20071231/src/DNS.pm 2007-01-08 00:30:04.000000000 -0500 +++ /home/hostedsites/www.jeremykister.com/data/argus/argus-dev-20080202/src/DNS.pm 2008-02-02 22:00:42.000000000 -0500 @@ -5,7 +5,7 @@ # Date: 2002-Nov-13 10:53 (EST) # Function: a swiss-army DNS tester # -# $Id: DNS.pm,v 1.25 2007/01/08 05:30:04 jaw Exp $ +# $Id: DNS.pm,v 1.26 2008/02/03 03:00:42 jaw Exp $ # it seems that there is no end to the DNS server mis-configurations # and failure modes that are available. this is an attempt to stay one step ahead. @@ -158,6 +158,7 @@ $cf->warning("unknown DNS test method '$me->{dns}{test}") unless grep {$_ eq $me->{dns}{test}} qw(none noerror authok serial answer nanswers); + $me->{friendlyname} = "DNS for $me->{dns}{zone} on $me->{ip}{hostname}"; $me; } diff -ruBNx HTML /home/hostedsites/www.jeremykister.com/data/argus/argus-dev-20071231/src/MonEl.pm /home/hostedsites/www.jeremykister.com/data/argus/argus-dev-20080202/src/MonEl.pm --- /home/hostedsites/www.jeremykister.com/data/argus/argus-dev-20071231/src/MonEl.pm 2007-12-30 20:50:37.000000000 -0500 +++ /home/hostedsites/www.jeremykister.com/data/argus/argus-dev-20080202/src/MonEl.pm 2008-02-03 09:52:34.000000000 -0500 @@ -5,7 +5,7 @@ # Date: 2002-Apr-02 17:11 (EST) # Function: Monitor Element class # -# $Id: MonEl.pm,v 1.154 2007/12/31 01:50:37 jaw Exp $ +# $Id: MonEl.pm,v 1.156 2008/02/03 05:23:33 jaw Exp $ package MonEl; @ISA = qw(Configable); @@ -65,6 +65,9 @@ # uname: HTTP-2 # } }, + friendlyname => { + descr => 'a friendlier name for this object', + }, unique => { descr => 'full unique name of this object', }, @@ -248,7 +251,7 @@ descr => 'format for notification messages', attrs => ['config', 'inherit'], # message{up,dn} => %m - default => '%i %m - %t', + default => '%i %t - %m', versn => '3.3', }, notify::message_fmtup => { @@ -296,15 +299,24 @@ versn => '3.5', # was 'no' }, notify::shortmessages => { - descr => 'use shorter default notification messages', - attrs => ['config', 'inherit', 'bool'], + descr => 'deprecated, use message_style: short', + attrs => ['config', 'bool', 'deprecated'], versn => '3.2', default => 'no', html => 'notif', }, + notify::message_style => { + descr => 'what style of message to send by default', + attrs => ['config', 'inherit'], + vals => ['long', 'short', 'friendly'], + versn => '3.6', + default => 'friendly', + html => 'notif', + }, notify::notify => { - descr => 'list of addresses to notify: method:address method:address ...', + descr => 'list of addresses to notify', + exmpl => 'mail:user@example.com qpage:sysop aim:joeysmith vxml:2155551234', attrs => ['config', 'inherit'], html => 'notif', }, @@ -332,26 +344,8 @@ html => 'notif', versn => '3.2', }, - 'notify::notify.critical' => { - descr => 'list of addresses to notify when down/critical', - attrs => ['config', 'inherit'], - html => 'notif', - versn => '3.6', - }, - 'notify::notify.major' => { - descr => 'list of addresses to notify when down/major', - attrs => ['config', 'inherit'], - html => 'notif', - versn => '3.6', - }, - 'notify::notify.minor' => { - descr => 'list of addresses to notify when down/minor', - attrs => ['config', 'inherit'], - html => 'notif', - versn => '3.6', - }, - 'notify::notify.warning' => { - descr => 'list of addresses to notify when down/warning', + 'notify::notify.clear' => { # == notifyup + descr => 'list of addresses to notify when up', attrs => ['config', 'inherit'], html => 'notif', versn => '3.6', @@ -371,6 +365,13 @@ versn => '3.5', html => 'notif', }, + notify::unack_timeout => { + descr => 'automatically ack notification if it is up and this much time has passed', + attrs => ['config', 'inherit', 'timespec'], + default => 3600, + versn => '3.6', + html => 'notif', + }, notify::autoack => { descr => 'do notifications not require ack', attrs => ['config', 'inherit', 'bool'], @@ -383,8 +384,21 @@ default => 'no', versn => '3.2', }, + notify::ack_on_better => { + descr => 'automatically ack notifications when severity level improves', + attrs => ['config', 'inherit', 'bool'], + versn => '3.6', + html => 'notif', + }, + notify::ack_on_worse => { + descr => 'automatically ack notifications when severity level worsens', + attrs => ['config', 'inherit', 'bool'], + versn => '3.6', + html => 'notif', + }, + notify::escalate => { - descr => 'list of times (in minutes or as a timespec) and addresses for notification escalation: time method:address ...; time method:address ...', + descr => 'list of times (in minutes or as a timespec) and addresses for notification escalation', attrs => ['config', 'inherit'], exmpl => '30 qpage:manager qpage:noc; 60 qpage:ceo', versn => '3.5', @@ -926,6 +940,20 @@ }, }; +# add in severity based notification params +for my $sev qw(critical major minor warning){ + for my $nt qw(notify renotify autoack escalate sendnotify ack_on_better ack_on_worse){ + # none of these are applicable for 'up/clear' + my %d = %{ $doc->{fields}{"notify::$nt"} }; + $d{versn} = '3.6'; + $d{descr} .= " when down/$sev"; + delete $d{default}; + $doc->{fields}{"notify::$nt.$sev"} = \%d; + } +} +delete $doc->{fields}{'notify::ack_on_worse.critical'}; + + # what is my name? sub unique { my $me = shift; @@ -1008,13 +1036,28 @@ $me->{alarm} = 0; $me->{transtime} = $^T; $me->{sirentime} = $^T; - - $me->{notify}{messageup} = ($me->{notify}{shortmessages} ? - $me->{uname} : $me->unique()) . ' is UP' - unless defined $me->{notify}{messageup}; - $me->{notify}{messagedn} = ($me->{notify}{shortmessages} ? - $me->{uname} : $me->unique()) . ' is DOWN' - unless defined $me->{notify}{messagedn}; + $me->{friendlyname} ||= $me->{uname}; + + # if messages are not specified, pick defaults based on style preference + my $msgstyle = $me->{notify}{message_style}; + unless( defined $me->{notify}{messageup} ){ + if( $msgstyle eq 'long' ){ + $me->{notify}{messageup} = '%o{unique} is %s'; + }elsif( $msgstyle eq 'short' ){ + $me->{notify}{messageup} = '%o{uname} is %s'; + }else{ + $me->{notify}{messageup} = $me->friendly_messageup() || '%o{friendlyname} is %s'; + } + } + unless( defined $me->{notify}{messagedn} ){ + if( $msgstyle eq 'long' ){ + $me->{notify}{messagedn} = '%o{unique} is %s/%y'; + }elsif( $msgstyle eq 'short' ){ + $me->{notify}{messagedn} = '%o{uname} is %s'; + }else{ + $me->{notify}{messagedn} = $me->friendly_messagedn() || '%o{friendlyname} is %s/%y'; + } + } $me->{image}{title} = $me->{label_right} unless defined $me->{image}{title}; @@ -1055,6 +1098,12 @@ 1; } + +# overridden in subclasses +sub friendly_messageup {} +sub friendly_messagedn {} + + END { deconfigure(); } @@ -1147,6 +1196,7 @@ foreach my $c ( @{$me->{children}} ){ my $cc = $c; $cc = $c->aliaslookup() if $c->can('aliaslookup'); + next unless $cc; # skip broken alias if( $cc->{children} && @{$cc->{children}} ){ $cc->jiggle_lightly(); @@ -1927,7 +1977,9 @@ } foreach my $x (@all){ next unless $x->isa('Service'); + next if exists $x->{compute}; $n++; + next if $x->{srvc}{state} && $x->{srvc}{state} ne 'done'; next if $sc{ $x->unique() }; $ctl->write( $x->unique() . "\n" ); } diff -ruBNx HTML /home/hostedsites/www.jeremykister.com/data/argus/argus-dev-20071231/src/Notify.pm /home/hostedsites/www.jeremykister.com/data/argus/argus-dev-20080202/src/Notify.pm --- /home/hostedsites/www.jeremykister.com/data/argus/argus-dev-20071231/src/Notify.pm 2007-12-31 17:20:34.000000000 -0500 +++ /home/hostedsites/www.jeremykister.com/data/argus/argus-dev-20080202/src/Notify.pm 2008-02-03 00:37:08.000000000 -0500 @@ -5,7 +5,7 @@ # Date: 2002-Apr-12 20:06 (EDT) # Function: Tell someone what happened # -# $Id: Notify.pm,v 1.69 2007/12/31 22:20:34 jaw Exp $ +# $Id: Notify.pm,v 1.72 2008/02/03 05:37:08 jaw Exp $ package Notify; use NotMe; @@ -26,9 +26,6 @@ # can be overridden in user-defined notification methods via 'qtime: 1234' my $QUEUETIME = 120; -# we keep re-sending, but if it comes up, give up after this long -my $UNACK_TO = 1800; - # if older than this, and no longer active, throw them away my $OLD_AGE = 3600 * 24 * 5; @@ -38,7 +35,8 @@ # fields which get saved in save file (and then re-loaded) my @SAVE_FIELDS = qw(created msg sentcnt state objstate objovstate priority autoack ackonup period ackedby ackedat - escalated lastsent audit detail severity reason); + escalated lastsent audit detail severity reason + ackonbetter ackonworse); sub new { my $obj = shift; @@ -51,7 +49,7 @@ if( $obj->{status} eq 'down' ){ $msg = $obj->{notify}{messagedn}; $fmt = $obj->{notify}{message_fmtdn}; - $aa = $obj->{notify}{autoack}; + $aa = value_at_severity('autoack', $obj); }else{ $msg = $obj->{notify}{messageup}; $fmt = $obj->{notify}{message_fmtup}; @@ -70,25 +68,27 @@ return unless $msg; $me = { - obj => $obj, - created => $^T, - idno => newid(), - sentcnt => 0, - escalated => 0, - state => 'active', # active, supressed, acked - objstate => $obj->{status}, - objovstate => $obj->{ovstatus}, - priority => $obj->{notify}{priority}, - autoack => $aa, - period => $obj->{notify}{renotify}, - ackonup => $obj->{notify}{ackonup}, - status => {}, - sendto => [], - log => [], - audit => $param{audit}, # bool - detail => $param{detail}, - severity => $obj->{currseverity}, - reason => $obj->{srvc}{reason}, + obj => $obj, + created => $^T, + idno => newid(), + sentcnt => 0, + escalated => 0, + state => 'active', # active, supressed, acked + objstate => $obj->{status}, + objovstate => $obj->{ovstatus}, + priority => value_at_severity('priority', $obj), + autoack => $aa, + period => value_at_severity('renotify', $obj), + ackonup => value_at_severity('ackonup', $obj), + ackonbetter => value_at_severity('ack_on_better', $obj), + ackonworse => value_at_severity('ack_on_worse', $obj), + status => {}, + sendto => [], + log => [], + audit => $param{audit}, # bool + detail => $param{detail}, + severity => $obj->{currseverity}, + reason => $obj->{srvc}{reason}, }; bless $me; # gesundheit @@ -104,6 +104,20 @@ $me->notify(); } + +sub value_at_severity { + my $fld = shift; + my $obj = shift; + my $sev = shift; + + $sev ||= $obj->{currseverity}; + + return $obj->{notify}{$fld} if $sev eq 'clear'; + my $v = $obj->{notify}{"$fld.$sev"}; + return $v if defined $v; + return $obj->{notify}{$fld} +} + sub init { my $me = shift; my $obj = shift; @@ -158,8 +172,9 @@ # -- proverbs 13:17 { my $n = 1; - if( $obj->{notify}{escalate} ){ - foreach my $esc ( split /\;\s+/, $obj->{notify}{escalate} ){ + my $esc = value_at_severity('escalate', $obj, $me->{severity}); + if( $esc ){ + foreach my $esc ( split /\;\s+/, $esc ){ # each is of form N dest dest dest ... # previously, N was number of pages to escalate # then, it was elapsed-time in minutes @@ -195,6 +210,7 @@ $me->{acl_ntfydetail} = $obj->{acl_ntfydetail}; $me->{timezone} = $obj->{notify}{timezone}; $me->{mailfrom} = $obj->{notify}{mail_from}; + $me->{unack_to} = $obj->{notify}{unack_timeout}; 1; } @@ -486,15 +502,27 @@ next; } # auto-ack if no longer down and TO - if( $p->{obj}->{status} ne 'down' && $^T - $p->{obj}->{transtime} > $UNACK_TO ){ + if( $p->{obj}->{status} ne 'down' && $p->{unack_to} && $^T - $p->{obj}->{transtime} > $p->{unack_to} ){ $p->ack('timeout'); next; } # auto-ack if not down and ackonup is set if( $p->{objstate} eq 'down' && $p->{obj}->{status} ne 'down' && $p->{ackonup} ){ - $p->ack('up'); + $p->ack('ackonup'); + } + # auto-ack on severity changes + if( $p->{severity} ne $p->{obj}->{currseverity} ){ + my $old = $MonEl::severity_sort{ $p->{severity} }; + my $new = $MonEl::severity_sort{ $p->{obj}->{currseverity} }; + + if( $old > $new && $p->{ackonbetter} ){ + $p->ack('ack_on_better'); + } + if( $old < $new && $p->{ackonworse} ){ + # hopefully, the user has configured a new notification at this severity + $p->ack('ack_on_worse'); + } } - if( $p->{period} && ($p->{lastsent} + $p->{period} <= $^T) ){ # time to resend $p->renotify(); @@ -603,7 +631,15 @@ if( $nolots ){ # list all messages, don't summarize into Lots UP/DOWN - $msg = join("\n", map { $_->{msg} } @more); + + my $j; + if( grep { /\n/s } $msg, @more ){ + $j = "\n\n"; + }else{ + $j = "\n"; + } + + $msg = join($j, map { $_->{msg} } $msg, @more); } }else{ @@ -644,6 +680,15 @@ # interpolate message 1st, it may contain additional % sequences... $fmt =~ s/%m/$msg/g; + # pretify value + my $v = $obj->{srvc} ? $obj->{srvc}{result} : undef; + if( length($v) > 40 ){ + $v = substr($v,0,40); + $v .= ' [...]'; + } + $v =~ s/\r/\\r/gs; + $v =~ s/\n/\\n/gs; + my $res = $obj->expand($fmt, localtime => 1, dtformat => "%d/%b %R", # dd/Mon hh:mm @@ -653,6 +698,7 @@ o => $obj->{uname}, p => $me->{priority}, s => uc($me->{objstate}), + v => $v, y => $me->{severity}, }, ); @@ -713,40 +759,48 @@ sub cmd_detail { my $ctl = shift; my $param = shift; - my( $p, $k, $v, $ww, $n ); - $p = $param->{idno}; - if( exists $byid{$p} ){ - $p = $byid{$p}; - $ctl->ok(); - foreach $k (sort keys %$p){ - $v = $p->{$k}; - if( ref($v) ){ - $v = "#"; - }else{ - $v = encode( $v ); - } - $ctl->write( "$k:\t$v\n" ); + my $idno = $param->{idno}; + unless( exists $byid{$idno} ){ + $ctl->bummer(404, 'Notification Not Found'); + return; + } + + my $p = $byid{$idno}; + $ctl->ok(); + foreach my $k (sort keys %$p){ + my $v = $p->{$k}; + if( ref($v) ){ + $v = "#"; + }else{ + $v = encode( $v ); } - $ctl->write( "object: " . encode( $p->{obj}->unique() ) . "\n" ); + $ctl->write( "$k:\t$v\n" ); + } + $ctl->write( "object: " . encode( $p->{obj}->unique() ) . "\n" ); + + for my $e qw(style_sheet javascript bkgimage icon icon_up icon_down){ + my $v = $p->{obj}->{web}{$e}; + next unless $v; + $ctl->write("web $e: " . encode($v) . "\n"); + } - foreach my $w (sort keys %{$p->{status}}){ - my $we = encode($w); - $ww .= " $we"; - $ctl->write("status $we: " . $p->{status}{$w} . "\n" ); - } - $ctl->write("statuswho: $ww\n"); - $n = 0; - foreach my $l (@{$p->{log}}){ - $ctl->write( "log $n: $l->{time} " . ($l->{who}? encode($l->{who}) : '_') . - ' ' . encode($l->{msg}) . "\n" ); - $n++; - } - $ctl->write( "loglines: $n\n"); - $ctl->final(); - }else{ - $ctl->bummer(404, 'Notification Not Found'); + my $ww; + foreach my $w (sort keys %{$p->{status}}){ + my $we = encode($w); + $ww .= " $we"; + $ctl->write("status $we: " . $p->{status}{$w} . "\n" ); + } + $ctl->write("statuswho: $ww\n"); + + my $n = 0; + foreach my $l (@{$p->{log}}){ + $ctl->write( "log $n: $l->{time} " . ($l->{who}? encode($l->{who}) : '_') . + ' ' . encode($l->{msg}) . "\n" ); + $n++; } + $ctl->write( "loglines: $n\n"); + $ctl->final(); } sub cmd_ack { diff -ruBNx HTML /home/hostedsites/www.jeremykister.com/data/argus/argus-dev-20071231/src/Ping.pm /home/hostedsites/www.jeremykister.com/data/argus/argus-dev-20080202/src/Ping.pm --- /home/hostedsites/www.jeremykister.com/data/argus/argus-dev-20071231/src/Ping.pm 2007-03-04 10:51:49.000000000 -0500 +++ /home/hostedsites/www.jeremykister.com/data/argus/argus-dev-20080202/src/Ping.pm 2008-02-02 22:00:43.000000000 -0500 @@ -5,7 +5,7 @@ # Date: 2002-Apr-03 23:24 (EST) # Function: ping service test # -# $Id: Ping.pm,v 1.51 2007/03/04 15:51:49 jaw Exp $ +# $Id: Ping.pm,v 1.52 2008/02/03 03:00:43 jaw Exp $ package Ping; @ISA = qw(Service); @@ -374,6 +374,7 @@ $x->isup(); } }else{ + s/$ip\s+//; $x->isdown( $_ ); } } @@ -406,6 +407,16 @@ $pending[$fn] = undef; } +sub friendly_messagesup { + my $me = shift; + '%o{ping::hostname} is UP (pingable)'; +} +sub friendly_messagesdn { + my $me = shift; + + '%o{ping::hostname} is %s/%y (NOT PINGABLE)'; +} + sub about_more { my $me = shift; my $ctl = shift; diff -ruBNx HTML /home/hostedsites/www.jeremykister.com/data/argus/argus-dev-20071231/src/Prog.pm /home/hostedsites/www.jeremykister.com/data/argus/argus-dev-20080202/src/Prog.pm --- /home/hostedsites/www.jeremykister.com/data/argus/argus-dev-20071231/src/Prog.pm 2007-09-01 12:51:38.000000000 -0400 +++ /home/hostedsites/www.jeremykister.com/data/argus/argus-dev-20080202/src/Prog.pm 2008-02-02 22:00:43.000000000 -0500 @@ -5,7 +5,7 @@ # Date: 2002-Apr-03 19:27 (EST) # Function: test exececution of a program # -# $Id: Prog.pm,v 1.40 2007/09/01 16:51:38 jaw Exp $ +# $Id: Prog.pm,v 1.41 2008/02/03 03:00:43 jaw Exp $ package Prog; @ISA = qw(Service); @@ -146,6 +146,7 @@ # fork failed my $m = "fork failed: $!"; close W; + close $fh; ::sysproblem( "PROG $m" ); $me->debug( $m ); return $me->done(); diff -ruBNx HTML /home/hostedsites/www.jeremykister.com/data/argus/argus-dev-20071231/src/Resolv.pm /home/hostedsites/www.jeremykister.com/data/argus/argus-dev-20080202/src/Resolv.pm --- /home/hostedsites/www.jeremykister.com/data/argus/argus-dev-20071231/src/Resolv.pm 2007-09-01 12:51:38.000000000 -0400 +++ /home/hostedsites/www.jeremykister.com/data/argus/argus-dev-20080202/src/Resolv.pm 2008-02-02 22:00:44.000000000 -0500 @@ -5,7 +5,7 @@ # Date: 2003-May-22 21:46 (EDT) # Function: caching async resolver + re-resolver # -# $Id: Resolv.pm,v 1.23 2007/09/01 16:51:38 jaw Exp $ +# $Id: Resolv.pm,v 1.24 2008/02/03 03:00:44 jaw Exp $ # Wise to resolve, and patient to perform. # -- Homer, Odyssey @@ -41,7 +41,7 @@ isa => [qw(Service MonEl BaseIO)], methods => {}, versn => '3.4', - html => 'resolv', + html => 'advanced', fields => { resolv::conf => { descr => 'location of resolv.conf', diff -ruBNx HTML /home/hostedsites/www.jeremykister.com/data/argus/argus-dev-20071231/src/Service.pm /home/hostedsites/www.jeremykister.com/data/argus/argus-dev-20080202/src/Service.pm --- /home/hostedsites/www.jeremykister.com/data/argus/argus-dev-20071231/src/Service.pm 2007-12-30 20:50:37.000000000 -0500 +++ /home/hostedsites/www.jeremykister.com/data/argus/argus-dev-20080202/src/Service.pm 2008-02-02 22:00:44.000000000 -0500 @@ -5,7 +5,7 @@ # Date: 2002-Apr-03 08:56 (EST) # Function: the service class # -# $Id: Service.pm,v 1.113 2007/12/31 01:50:37 jaw Exp $ +# $Id: Service.pm,v 1.114 2008/02/03 03:00:44 jaw Exp $ package Service; @ISA = qw(MonEl BaseIO); @@ -410,6 +410,8 @@ sub me_start { my $me = shift; + # is checknow running? + return if $me->{srvc}{state} && $me->{srvc}{state} ne 'done'; $me->pre_start_check(); } diff -ruBNx HTML /home/hostedsites/www.jeremykister.com/data/argus/argus-dev-20071231/src/TCP.pm /home/hostedsites/www.jeremykister.com/data/argus/argus-dev-20080202/src/TCP.pm --- /home/hostedsites/www.jeremykister.com/data/argus/argus-dev-20071231/src/TCP.pm 2007-03-18 16:43:14.000000000 -0400 +++ /home/hostedsites/www.jeremykister.com/data/argus/argus-dev-20080202/src/TCP.pm 2008-02-02 22:00:44.000000000 -0500 @@ -5,7 +5,7 @@ # Date: 2002-Apr-03 15:59 (EST) # Function: testing of TCP services # -# $Id: TCP.pm,v 1.76 2007/03/18 20:43:14 jaw Exp $ +# $Id: TCP.pm,v 1.77 2008/02/03 03:00:44 jaw Exp $ package TCP; @@ -227,7 +227,6 @@ $me->{tcp}{port} ||= $config{$name}{port}; $me->{tcp}{send} ||= $config{$name}{send}; - $me->{test}{expect} ||= $config{$name}{expect}; $me->{tcp}{readhow} ||= $config{$name}{readhow}; $me->{tcp}{ssl} ||= $config{$name}{ssl}; @@ -235,6 +234,11 @@ $me->Argus::IP::init( $cf ); $me->init_from_config( $cf, $doc, 'tcp' ); + + if( !defined($me->{test}{expect}) && !($me->{test}{pluck} || $me->{test}{unpack}) ){ + # don't use default expect, if expected value will not be there + $me->{test}{expect} = $config{$name}{expect}; + } if( $name =~ /^(HTTP|HTTPS|SSL)$/ ){ my $http = http_request($me); @@ -245,7 +249,7 @@ $me->{tcp}{ssl} = $me->{tcp}{url} =~ /https:/ ? 1 : undef; $me->{tcp}{port} = $port ||= ($me->{tcp}{ssl} ? 443 : 80); $file ||= '/'; - $me->{ip}{hostname} = $host; + $me->{ip}{hostname} ||= $host; $me->{uname} = "URL_$host:$port$file"; unless( $host ){ return $cf->error( 'invalid URL' ); @@ -268,10 +272,13 @@ $me->Argus::IP::config( $cf ); + $me->{friendlyname} = ($config{$name} ? $name : "TCP/$me->{udp}{port}") . " on $me->{ip}{hostname}"; + if( $name eq 'URL' ){ - # nop + $me->{friendlyname} = "URL $me->{tcp}{url}"; }elsif( $name =~ /NFS/ ){ $me->{uname} = "TCP_${name}_$me->{ip}{hostname}"; + $me->{friendlyname} = "TCP/$name on $me->{ip}{hostname}"; }else{ if( $name ){ $me->{uname} = "${name}_$me->{ip}{hostname}"; diff -ruBNx HTML /home/hostedsites/www.jeremykister.com/data/argus/argus-dev-20071231/src/UDP.pm /home/hostedsites/www.jeremykister.com/data/argus/argus-dev-20080202/src/UDP.pm --- /home/hostedsites/www.jeremykister.com/data/argus/argus-dev-20071231/src/UDP.pm 2007-06-30 14:38:44.000000000 -0400 +++ /home/hostedsites/www.jeremykister.com/data/argus/argus-dev-20080202/src/UDP.pm 2008-02-02 22:00:45.000000000 -0500 @@ -5,7 +5,7 @@ # Date: 2002-Apr-03 18:25 (EST) # Function: testing of UDP services # -# $Id: UDP.pm,v 1.68 2007/06/30 18:38:44 jaw Exp $ +# $Id: UDP.pm,v 1.69 2008/02/03 03:00:45 jaw Exp $ package UDP; @@ -158,6 +158,8 @@ $me->Argus::IP::config( $cf ); $me->init_from_config( $cf, $doc, 'udp' ); + $me->{friendlyname} = ($config{$base} ? $base : "UDP/$me->{udp}{port}") . " on $me->{ip}{hostname}"; + if( $name ){ $me->{uname} = "${name}_$me->{ip}{hostname}"; }else{ diff -ruBNx HTML /home/hostedsites/www.jeremykister.com/data/argus/argus-dev-20071231/src/Web.pm /home/hostedsites/www.jeremykister.com/data/argus/argus-dev-20080202/src/Web.pm --- /home/hostedsites/www.jeremykister.com/data/argus/argus-dev-20071231/src/Web.pm 2007-12-31 17:20:34.000000000 -0500 +++ /home/hostedsites/www.jeremykister.com/data/argus/argus-dev-20080202/src/Web.pm 2008-02-02 22:00:45.000000000 -0500 @@ -5,7 +5,7 @@ # Date: 2002-Apr-06 21:30 (EST) # Function: web page stuff # -# $Id: Web.pm,v 1.65 2007/12/31 22:20:34 jaw Exp $ +# $Id: Web.pm,v 1.66 2008/02/03 03:00:45 jaw Exp $ package MonEl; use strict; @@ -53,11 +53,13 @@ } sub web_header { - my $me = shift; - my $fh = shift; - - my $n = $me->unique(); - my $file = $me->filename(); + my $me = shift; + my $fh = shift; + my $title = shift; + my $id = shift; + + $title ||= $me->unique(); + $id ||= $me->filename(); my $icon; my $refresh = $me->{web}{refresh}; @@ -67,7 +69,7 @@ print $fh "\n"; print $fh "\n"; print $fh "\n"; - print $fh "Argus - $n\n"; + print $fh "Argus - $title\n"; print $fh "\n" if $refresh; if( $me->{ovstatus} eq 'up' ){ $icon = $me->{web}{icon_up}; @@ -85,7 +87,7 @@ for my $js ( split /\s+/, $me->{web}{javascript} ){ print $fh "\n"; } - print $fh "\n"; + print $fh "\n"; print $fh "
\n"; print $fh "$me->{web}{header_all}\n" if $me->{web}{header_all}; @@ -98,14 +100,16 @@ sub web_show_has_errors { my $me = shift; my $fh = shift; + my $nc = shift; + print $fh <
X @@ -141,7 +145,7 @@ print $fh "
+

Warning     

Errors detected during startup
Attempting to run anyway
- Examine the Error Log for details + Examine the Error Log for details
\n"; if( $Conf::has_errors && $topp ){ - $me->web_show_has_errors($fh); + $me->web_show_has_errors($fh, 2); } if( $Conf::has_errors ){ @@ -417,7 +421,7 @@ print $fh "\n"; print $fh $me->web_button_no('Error Log', $Conf::has_errors ? 'FF8888' : undef, - 'func=logfile', + 'func=logfile', 'abridge=1', ); print $fh "\n"; diff -ruBNx HTML /home/hostedsites/www.jeremykister.com/data/argus/argus-dev-20071231/src/cgi /home/hostedsites/www.jeremykister.com/data/argus/argus-dev-20080202/src/cgi --- /home/hostedsites/www.jeremykister.com/data/argus/argus-dev-20071231/src/cgi 2007-12-30 20:24:34.000000000 -0500 +++ /home/hostedsites/www.jeremykister.com/data/argus/argus-dev-20080202/src/cgi 2008-02-02 22:00:45.000000000 -0500 @@ -6,7 +6,7 @@ # Date: 2002-Apr-02 23:12 (EST) # Function: cgi frontend (will run as cgi-bin or as mod_perl) # -# $Id: cgi,v 1.86 2007/12/31 01:24:34 jaw Exp $ +# $Id: cgi,v 1.87 2008/02/03 03:00:45 jaw Exp $ use lib('__LIBDIR__'); @@ -15,12 +15,12 @@ package Argus::Web; use Argus::Ctl; use Argus::Encode; +use Argus::HashDir; use Fcntl; use Socket; use POSIX; use __DATABASE__; require "conf.pl"; -require "misc.pl"; require "web_misc.pl"; require "web_acl.pl"; require "web_notify.pl"; @@ -290,13 +290,31 @@ chop @l; close F; + my $partial = $me->{q}->param('abridge'); + my ($date, $proc); + print "
\n";
     foreach (reverse @l){
+	if( $partial ){
+	    my($d, $p) = /^([^\]]+\]) ([^\]]+\])/;
+	    $d =~ s/\s.*//;
+	    $date ||= $d;
+	    $proc ||= $p;
+
+	    last if $d ne $date;
+	    last if $p ne $proc;
+	}
+	
 	s/(.*(?:ERROR|WARNING).*)/$1<\/FONT>/;
 	print "$_\n";
     }
     print "
\n"; + if( $partial ){ + my $url = $me->{q}->url() . "?func=logfile"; + print qq{
More...
\n}; + } + $me->endpage(); } diff -ruBNx HTML /home/hostedsites/www.jeremykister.com/data/argus/argus-dev-20071231/src/graphd.pl /home/hostedsites/www.jeremykister.com/data/argus/argus-dev-20080202/src/graphd.pl --- /home/hostedsites/www.jeremykister.com/data/argus/argus-dev-20071231/src/graphd.pl 2007-09-01 12:51:39.000000000 -0400 +++ /home/hostedsites/www.jeremykister.com/data/argus/argus-dev-20080202/src/graphd.pl 2008-02-02 22:00:46.000000000 -0500 @@ -6,7 +6,7 @@ # Date: 2002-Oct-31 15:45 (EST) # Function: server side of graph data collector # -# $Id: graphd.pl,v 1.13 2007/09/01 16:51:39 jaw Exp $ +# $Id: graphd.pl,v 1.14 2008/02/03 03:00:46 jaw Exp $ # read in data from argusd, save to data files # uses a large number of file descriptors, be sure @@ -22,6 +22,7 @@ use POSIX qw(:errno_h); use strict; +my $DEBUG = 1; my %obj = (); my @lru = (); my $nopen; @@ -213,22 +213,19 @@ $i --; next unless $lru[$i]; - # loggit("close file lrui=$i files=" . scalar(@{$lru[$i]}) . " nop=$nopen"); - while( @close <= $nopen/4 && @{$lru[$i]} ){ - my $o = pop @{$lru[$i]}; - push @close, $o; - } - + debug("close file lrui=$i files=" . scalar(@{$lru[$i]}) . " nop=$nopen"); + push @close, @{$lru[$i]}; + $lru[$i] = undef; last if @close > $nopen/4; } for my $obj (@close){ my $fd = $obj->{fd}; next unless $fd; - # loggit( "closed file $obj->{name}" ); close $fd; delete $obj->{fd}; $nopen --; + debug( "closed file $obj->{name} nop=$nopen" ); } } @@ -247,16 +244,30 @@ $me->{need_init} = 1; } - for my $n (0 .. 1){ - if( open( $fh, $x ) ){ - $me->{fd} = $fh; - $nopen ++; - return; - } - $err = $!; + for my $i (0 .. 1){ + for my $n (0 .. 1){ + if( open( $fh, $x ) ){ + $me->{fd} = $fh; + $nopen ++; + return; + } + $err = $!; - # close something - close_lru(); + # close something + close_lru(); + } + + # close everything + debug("close everything"); + for my $obj (values %obj){ + my $fd = $obj->{fd}; + next unless $fd; + close $fd; + delete $obj->{fd}; + $nopen --; + debug( "closed file $obj->{name} nop=$nopen" ); + } + @lru = (); } loggit( "$name on too tight, won't open: $err" ); @@ -373,3 +384,7 @@ print STDERR "GRAPHD: $msg\n"; } +sub debug { + return unless $DEBUG; + loggit(@_); +} diff -ruBNx HTML /home/hostedsites/www.jeremykister.com/data/argus/argus-dev-20071231/src/main.pl /home/hostedsites/www.jeremykister.com/data/argus/argus-dev-20080202/src/main.pl --- /home/hostedsites/www.jeremykister.com/data/argus/argus-dev-20071231/src/main.pl 2007-12-30 20:24:34.000000000 -0500 +++ /home/hostedsites/www.jeremykister.com/data/argus/argus-dev-20080202/src/main.pl 2008-02-02 22:00:46.000000000 -0500 @@ -6,7 +6,7 @@ # Date: 2002-Apr-02 12:09 (EST) # Function: argus startup and glue # -# $Id: main.pl,v 1.67 2007/12/31 01:24:34 jaw Exp $ +# $Id: main.pl,v 1.68 2008/02/03 03:00:46 jaw Exp $ # In God we trust, everyone else we monitor. # -- U2 pilot motto @@ -37,6 +37,7 @@ use UserCron; use TestPort; use Argus::Ctl; +use Argus::HashDir; use Resolv; use DARP; diff -ruBNx HTML /home/hostedsites/www.jeremykister.com/data/argus/argus-dev-20071231/src/misc.pl /home/hostedsites/www.jeremykister.com/data/argus/argus-dev-20080202/src/misc.pl --- /home/hostedsites/www.jeremykister.com/data/argus/argus-dev-20071231/src/misc.pl 2007-12-30 20:24:34.000000000 -0500 +++ /home/hostedsites/www.jeremykister.com/data/argus/argus-dev-20080202/src/misc.pl 2008-02-02 22:00:46.000000000 -0500 @@ -5,7 +5,7 @@ # Date: 2002-Apr-02 11:06 (EST) # Function: misc code # -# $Id: misc.pl,v 1.16 2007/12/31 01:24:34 jaw Exp $ +# $Id: misc.pl,v 1.17 2008/02/03 03:00:46 jaw Exp $ use Socket; BEGIN{ eval{ require Socket6; import Socket6; $HAVE_S6 = 1; }} @@ -210,6 +210,7 @@ sub expand_conditionals { my $txt = shift; + # print STDERR "expand: <$txt>\n"; while( $txt =~ /%\(([^\)]*)\)/s ){ my $pat = $1; # do not split on \? and \: @@ -221,7 +222,7 @@ $x =~ s/\\\:/\:/sg; } - # print STDERR "=> $pat, $cond, $repl, $then, $else\n"; + # print STDERR " => pat<$pat>, cond<$cond>, repl<$repl>, then<$then>, else<$else>\n"; # Now go and see what their condition is. # -- Dante, Divine Comedy @@ -242,8 +243,10 @@ } $txt =~ s/%\([^\)]*\)/$repl/s; + # print STDERR " => txt<$txt>\n"; } + # print STDERR " => final: $txt\n"; return $txt; } @@ -312,22 +315,5 @@ return $lo; # not found - return item to the right } -# quickly pick a 2 level directory for the file -sub hashed_directory { - my $file = shift; - - my $h = 5381; - for my $c (split '', $file){ - $h = (33*$h) + ord($c); - $h &= 0xFFFFFF; - } - - my $a = ($h % 26) + 65; - $h >>= 5; - my $b = ($h % 26) + 65; - - sprintf '%c/%c', $a, $b; -} - 1; diff -ruBNx HTML /home/hostedsites/www.jeremykister.com/data/argus/argus-dev-20071231/src/web_misc.pl /home/hostedsites/www.jeremykister.com/data/argus/argus-dev-20080202/src/web_misc.pl --- /home/hostedsites/www.jeremykister.com/data/argus/argus-dev-20071231/src/web_misc.pl 2007-01-14 18:00:02.000000000 -0500 +++ /home/hostedsites/www.jeremykister.com/data/argus/argus-dev-20080202/src/web_misc.pl 2008-02-02 22:00:46.000000000 -0500 @@ -5,7 +5,7 @@ # Date: 2002-Apr-02 23:39 (EST) # Function: misc web stuff # -# $Id: web_misc.pl,v 1.22 2007/01/14 23:00:02 jaw Exp $ +# $Id: web_misc.pl,v 1.23 2008/02/03 03:00:46 jaw Exp $ package Argus::Web; @@ -42,9 +42,15 @@ print "$p{title}\n"; print "\n" if $p{refresh}; print "\n" if $p{icon}; - print "\n" if $p{style}; print "\n" if $p{rss}; + for my $ss ( split /\s+/, $p{style} ){ + print "\n"; + } + for my $js ( split /\s+/, $p{javascript} ){ + print "\n"; + } + print "\n"; $me->header(); } @@ -91,7 +97,7 @@ $a = "please explain" if $faq; - $url = $me->{q}->url() . "?func=logfile"; + $url = $me->{q}->url() . "?func=logfile;abridge=1"; print <
diff -ruBNx HTML /home/hostedsites/www.jeremykister.com/data/argus/argus-dev-20071231/src/web_notify.pl /home/hostedsites/www.jeremykister.com/data/argus/argus-dev-20080202/src/web_notify.pl --- /home/hostedsites/www.jeremykister.com/data/argus/argus-dev-20071231/src/web_notify.pl 2007-01-14 18:00:02.000000000 -0500 +++ /home/hostedsites/www.jeremykister.com/data/argus/argus-dev-20080202/src/web_notify.pl 2008-02-03 00:23:34.000000000 -0500 @@ -5,12 +5,21 @@ # Created: 2005-Dec-10 12:46 (EST) # Function: cgi notify related functions # -# $Id: web_notify.pl,v 1.4 2007/01/14 23:00:02 jaw Exp $ +# $Id: web_notify.pl,v 1.6 2008/02/03 05:23:34 jaw Exp $ package Argus::Web; use strict; use vars qw($argusd); +my %NOTECOLOR = ( + clear => '88FF88', + critical => 'FF8888', + major => 'FFAA66', + minor => 'FFFF88', + warning => '8888FF', +); + + sub web_ntfylist { my $me = shift; $me->notify_list( 'Notifications', 0 ); @@ -37,10 +46,10 @@ # QQQ - check ACL for every object listed??? my $url = $q->url(); - my $r = notify_list_data($me, $ackp); + my $res = notify_list_data($me, $ackp); - return $me->error( "unable to connect to server" ) unless $r; - return $me->error( "Unable to access notify list
$r->{error}" ) if $r->{error}; + return $me->error( "unable to connect to server" ) unless $res; + return $me->error( "Unable to access notify list
$res->{error}" ) if $res->{error}; $me->startpage( title => l10n($title), refresh => 60, @@ -50,18 +59,19 @@ print $q->startform(-method=>'get'), "\n" if $ackp; print "\n"; - foreach my $nd (@{$r->{data}}){ + foreach my $nd (@{$res->{data}}){ $n++; my $dt = strftime "%d/%b %R", localtime($nd->{create}); $dt =~ s/\s+/ \;/g; my $id = $nd->{id}; my $obj = decode($nd->{obj}); my $msg = decode($nd->{msg}); + $msg =~ s/\n/
\n/gs; my $durl = "url() . "?func=ntfydetail;idno=$id\">$id"; my $aurl = "url() . "?func=ntfyack;idno=$id\">Ack"; my $objl = "url() . "?object=$obj;func=page\">Object"; # QQQ - or base color on whether it is acked or not? - my $clr = ($nd->{status} eq 'down') ? 'FF8888' : '88FF88'; + my $clr = $NOTECOLOR{ $nd->{seve} }; if( $ackp ){ print "", @@ -92,7 +102,7 @@ sub web_ntfyack { my $me = shift; - my( $q, @id, $r ); + my( $q, @id, $res ); $q = $me->{q}; @@ -107,12 +117,12 @@ return unless $me->check_acl_ack($id, 1); - $r = $argusd->command( func => 'notify_ack', - user => $me->{auth}{user}, - idno => $id ); - return $me->error( "unable to connect to server" ) unless $r; - return $me->error( "Unable to access $id
$r->{resultcode} $r->{resultmsg}" ) - unless $r->{resultcode} == 200; + $res = $argusd->command( func => 'notify_ack', + user => $me->{auth}{user}, + idno => $id ); + return $me->error( "unable to connect to server" ) unless $res; + return $me->error( "Unable to access $id
$res->{resultcode} $res->{resultmsg}" ) + unless $res->{resultcode} == 200; } if( $q->request_method() eq 'POST'){ @@ -124,65 +134,77 @@ sub web_ntfydetail { my $me = shift; - my( $r, $n, $esc ); + my( $res, $n, $esc ); my $q = $me->{q}; my $id = $q->param('idno'); return $me->error( 'invalid notification' ) unless $id =~ /^\d+$/; - $r = $argusd->command( func => 'notify_detail', - idno => $id ); + $res = $argusd->command( func => 'notify_detail', + idno => $id ); - return $me->error( "unable to connect to server" ) unless $r; - return $me->error( "Unable to access $id
$r->{resultcode} $r->{resultmsg}" ) - unless $r->{resultcode} == 200; + return $me->error( "unable to connect to server" ) unless $res; + return $me->error( "Unable to access $id
$res->{resultcode} $res->{resultmsg}" ) + unless $res->{resultcode} == 200; # check ACL - unless( $me->check_acl( decode($r->{acl_ntfydetail})) ){ + unless( $me->check_acl( decode($res->{acl_ntfydetail})) ){ return $me->web_acl_error( 'ntfydetail' ); } + + my $icon = ($res->{objstate} eq 'up') ? 'web icon_up' : 'web icon_down'; - $me->startpage( title => "Details for $id", - refresh => 60 ); + $me->startpage( title => "Details for $id", + refresh => 60, + style => decode($res->{'web style_sheet'}), + javascript => decode($res->{'web javascript'}), + bkgimg => decode($res->{'web bkgimage'}), + icon => decode($res->{$icon} || $res->{'web icon'}), + ); print "

Details for $id

\n"; - print "
$aurl
\n"; + print "
\n"; print "\n"; - print "\n"; - print "\n"; - print "\n" if $r->{reason}; - print "\n"; - $esc = " / Escalated" if $r->{escalated}; - print "\n"; - print "\n" if $r->{severity}; - print "\n" if $r->{priority}; - print "\n" if $r->{detail}; - - if( $r->{ackedby} ){ - print "\n"; - print "\n"; + print "\n"; + + my $msg = decode($res->{msg}); + $msg =~ s/\n/
\n/gs; + my $clr = $NOTECOLOR{ $res->{severity} }; + + print "\n"; + print "\n" if $res->{reason}; + print "\n"; + $esc = " / Escalated" if $res->{escalated}; + print "\n"; + print "\n" if $res->{severity}; + print "\n" if $res->{priority}; + print "\n" if $res->{detail}; + + if( $res->{ackedby} ){ + print "\n"; + print "\n"; } print "
ID$id", - ($r->{state} eq 'active' ? "   url(). + ($res->{state} eq 'active' ? "   url(). "?func=ntfyack;idno=$id\">[ Ack ]" : ''), "
Objecturl(), "?object=$r->{object};func=page\">", - decode($r->{object}), "
Message", decode($r->{msg}), "
Reason", decode($r->{reason}), "
Created", l10n_localtime($r->{created}), "
Status$r->{state}$esc
Severity$r->{severity}
Priority$r->{priority}
Audit Detail$r->{detail}
Acked By$r->{ackedby}
Acked At", l10n_localtime($r->{ackedat}), "
Objecturl(), "?object=$res->{object};func=page\">", + decode($res->{object}), "
Message", $msg, "
Reason", decode($res->{reason}), "
Created", l10n_localtime($res->{created}), "
Status$res->{state}$esc
Severity$res->{severity}
Priority$res->{priority}
Audit Detail$res->{detail}
Acked By$res->{ackedby}
Acked At", l10n_localtime($res->{ackedat}), "
\n
\n"; print "Per User Status
\n"; print "\n\n"; - foreach my $dst (split /\s+/, $r->{statuswho}){ + foreach my $dst (split /\s+/, $res->{statuswho}){ my $w = decode($dst); - my $s = $r->{"status $dst"}; + my $s = $res->{"status $dst"}; print "\n"; } print "\n
$w
$s
\n
\n"; print "Audit Trail
\n"; print "\n"; - $n = $r->{loglines} - 1; + $n = $res->{loglines} - 1; foreach my $i (0..$n){ - my($t, $w, $m) = split /\s+/, $r->{"log $i"}; + my($t, $w, $m) = split /\s+/, $res->{"log $i"}; $w = ($w eq '_') ? '' : decode($w); $m = decode($m); @@ -198,12 +220,12 @@ my $ackp = shift; - my $r = $argusd->command_raw( func => 'notify_list', - which => $ackp ? 'unacked' : '' - ); + my $res = $argusd->command_raw( func => 'notify_list', + which => $ackp ? 'unacked' : '' + ); - return unless $r; - return { error => $r } unless $r =~ /200/; + return unless $res; + return { error => $res } unless $res =~ /200/; my @d; while( $_ = $argusd->nextline() ){ diff -ruBNx HTML /home/hostedsites/www.jeremykister.com/data/argus/argus-dev-20071231/src/web_page.pl /home/hostedsites/www.jeremykister.com/data/argus/argus-dev-20080202/src/web_page.pl --- /home/hostedsites/www.jeremykister.com/data/argus/argus-dev-20071231/src/web_page.pl 2007-12-30 20:24:35.000000000 -0500 +++ /home/hostedsites/www.jeremykister.com/data/argus/argus-dev-20080202/src/web_page.pl 2008-02-02 22:00:47.000000000 -0500 @@ -5,7 +5,7 @@ # Created: 2005-Dec-10 12:53 (EST) # Function: cgi main page display # -# $Id: web_page.pl,v 1.4 2007/12/31 01:24:35 jaw Exp $ +# $Id: web_page.pl,v 1.5 2008/02/03 03:00:47 jaw Exp $ package Argus::Web; use strict; @@ -42,7 +42,8 @@ # could not connect to server, try to serve cached data print STDERR "[$$] connect to argusd failed (again)\n"; my $enc = encode($obj); - $file = "$WEBCACHE/" . hashed_directory($enc) . "/$enc" . ($topp? '.top' : '.base'); + $file = "$WEBCACHE/" . hashed_directory($enc) . "/$enc"; + $file .= ($topp? '.top' : '.base') if $obj =~ /^Top/; if( -f $file ){ # Soon her eye fell on a little glass box that was lying under