Commit 42481caa authored by thomas.forbriger's avatar thomas.forbriger Committed by thomas.forbriger
Browse files

had to completely reorganize difference evaluation between previous

This is a legacy commit from before 2015-05-18.
It may be incomplete as well as inconsistent.
See COPYING.legacy and README.history for details.
and current status summary


SVN Path:     http://gpitrsvn.gpi.uni-karlsruhe.de/repos/TFSoftware/trunk
SVN Revision: 53
SVN UUID:     67feda4a-a26e-11df-9d6e-31afc202ad0c
parent 2dea224b
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
# ---------------------------------------------------------------------------- # ----------------------------------------------------------------------------
# #
# $Source: /home/tforb/svnbuild/cvssource/CVS/thof/scr/adm/observer/observer.pl,v $ # $Source: /home/tforb/svnbuild/cvssource/CVS/thof/scr/adm/observer/observer.pl,v $
# $Id: observer.pl,v 1.1 2000-02-21 15:06:58 thof Exp $ # $Id: observer.pl,v 1.2 2000-02-21 15:32:29 thof Exp $
# #
# 17/01/00 by Thomas Forbriger (IfG Stuttgart) # 17/01/00 by Thomas Forbriger (IfG Stuttgart)
# #
...@@ -17,13 +17,15 @@ ...@@ -17,13 +17,15 @@
# 19/01/00 V1.0 first released Version # 19/01/00 V1.0 first released Version
# 21/01/00 V1.1 introduced report level check for mail # 21/01/00 V1.1 introduced report level check for mail
# 25/01/00 V1.2 changed reporting scheme # 25/01/00 V1.2 changed reporting scheme
# 21/02/00 V1.3 changed differences reporting scheme
# (was not working in former version)
# #
# ============================================================================ # ============================================================================
# #
# we aren't using Sys::Syslog as I did not managed to get any message through # we aren't using Sys::Syslog as I did not managed to get any message through
#use Sys::Syslog; #use Sys::Syslog;
$VERSION="OBSERVER V1.2 central service"; $VERSION="OBSERVER V1.3 central service";
# called program name # called program name
# ------------------- # -------------------
...@@ -380,16 +382,30 @@ if (-r $LOG_PREVSTATUS) { ...@@ -380,16 +382,30 @@ if (-r $LOG_PREVSTATUS) {
@PREVIOUS_STATUS=(<PREVSTATUS>); @PREVIOUS_STATUS=(<PREVSTATUS>);
close(PREVSTATUS); close(PREVSTATUS);
chomp(@PREVIOUS_STATUS); chomp(@PREVIOUS_STATUS);
# compare # create a working copy of the current status
foreach $stline (map { s/[\*\?\+]// } sort (@STATUS_FILE)) { @current_status=@STATUS_FILE;
# take each line of previous status
foreach $stline (sort (@PREVIOUS_STATUS)) {
# remember line and remove meta characters
$orline = $stline;
$stline =~ tr/*.?+//d;
## print "$stline\n"; ## print "$stline\n";
@matching=grep { /$stline/ } map { s/[\*\?\+]// } (@PREVIOUS_STATUS); # search for this pattern in current status
# the extra '$_' is necessary as map evaluates in list context
# without map would return the number of tr-substitutions
@matching=grep { m/^$stline$/ } map { tr/*.?+//d; $_; } (@current_status);
## print "$#matching\n"; ## print "$#matching\n";
if ($#matching < 0) { if ($#matching < 0) {
push @STATUS_DIFF, $stline; push @STATUS_DIFF, $orline;
} }
} }
if ($#STATUS_DIFF < 0) { @STATUS_DIFF="none"; } # so, are there any differences now?
if ($#STATUS_DIFF < 0) {
$DIFFERENCES=0;
@STATUS_DIFF="none"; i
} else {
$DIFFERENCES=1;
}
} else { } else {
@STATUS_DIFF=("could not open $LOG_PREVSTATUS: $!"); @STATUS_DIFF=("could not open $LOG_PREVSTATUS: $!");
ERRLOG(@STATUS_DIFF); ERRLOG(@STATUS_DIFF);
...@@ -480,13 +496,26 @@ if ($mail_level_indices =~ m/$master_level_index/) { ...@@ -480,13 +496,26 @@ if ($mail_level_indices =~ m/$master_level_index/) {
"Client status messages:", "Client status messages:",
"=======================", "=======================",
sprintf("%.10s: Exit status (%s: OK; %s: NOTICE; %s: ALERT)", sprintf("%.10s: Exit status (%s: OK; %s: NOTICE; %s: ALERT)",
"S", $STATUS_OK, $STATUS_NOTICE, $STATUS_ALERT), " ", "S", $STATUS_OK, $STATUS_NOTICE, $STATUS_ALERT), " ");
@STATUS_HEAD, @STLINES_ALERT, @STLINES_NOTICE, @STLINES_OK,
"Differences to previous run:", if ($DIFFERENCES) {
"(i.e. lines that appeared in previous one but not in this one)", push @OBSERVER_REPORT,
@STATUS_HEAD, @STATUS_DIFF, " ", ("DIFFERENCES TO PREVIOUS RUN:",
"Reports from client services:", "(i.e. lines that appeared in previous one but not in this one)",
"=============================", @OUTPUT_REPORT); @STATUS_HEAD, @STATUS_DIFF, " ", "This run:");
}
push @OBSERVER_REPORT,
(@STATUS_HEAD, @STLINES_ALERT, @STLINES_NOTICE, @STLINES_OK);
if (! $DIFFERENCES) {
push @OBSERVER_REPORT,
(" ","No differences to previous run...");
}
push @OBSERVER_REPORT, (" ",
"Reports from client services:",
"=============================", @OUTPUT_REPORT);
# write full report # write full report
# ----------------- # -----------------
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment