ASNMTAP
view release on metacpan or search on metacpan
applications/display.pl view on Meta::CPAN
if ($opt_h) { print_help(); exit; }
($opt_H) || usage("MySQL hostname/address not specified\n");
my $serverName = $1 if ($opt_H =~ /([-.A-Za-z0-9]+)/);
($serverName) || usage("Invalid MySQL hostname/address: $opt_H\n");
if ($opt_C) { $checklist = $1 if ($opt_C =~ /([-.A-Za-z0-9]+)/); }
if ($opt_P) { $pagedir = $opt_P; }
if ($opt_D) {
if ($opt_D eq 'F' || $opt_D eq 'T') {
$debug = ($opt_D eq 'F') ? 0 : 1;
} else {
usage("Invalid debug: $opt_D\n");
}
}
if ($opt_L) {
if ($opt_L eq 'F' || $opt_L eq 'T') {
$loop = ($opt_L eq 'F') ? 0 : 1;
if ($opt_c) {
if ($opt_c =~ /^20\d\d-(?:0\d|1[0-2])-(?:[0-2]\d|3[0-1]) (?:[0-1]\d|2[0-3]):[0-5]\d:[0-5]\d$/) {
$creationTime = $opt_c;
} else {
usage("Invalid creation time <YYYY-MM-DD HH:MM:SS>: $opt_c\n");
}
}
} else {
usage("Invalid loop: $opt_L\n");
}
}
if ($opt_t) {
if ($opt_t eq 'F' || $opt_t eq 'T') {
$trigger = ($opt_t eq 'F') ? 0 : 1;
} else {
usage("Invalid trigger: $opt_t\n");
}
}
if ($opt_T) {
if ($opt_T eq 'F' || $opt_T eq 'T') {
$displayTime = ($opt_T eq 'F') ? 0 : 1;
} else {
usage("Invalid displayTime: $opt_T\n");
}
}
if ($opt_l) {
if ($opt_l eq 'F' || $opt_l eq 'T') {
$lockMySQL = ($opt_l eq 'F') ? 0 : 1;
} else {
usage("Invalid lockMySQL: $opt_l\n");
}
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
my ($dchecklist, $dtest, $dfetch, $tinterval, $tgroep, $resultsdir, $ttest, $firstTimeslot, $lastTimeslot, $rvOpen);
my (@fetch, $dstart, $tstart, $start, $step, $names, $data, $rows, $columns, $line, $val, @vals);
my ($command, $tstatus, $tduration, $timeValue, $prevGroep, @multiarrayFullCondensedView, @multiarrayMinimalCondensedView);
my ($rv, $dbh, $sth, $lockString, $findString, $unlockString, $doChecklist, $timeCorrectie, $timeslot);
my ($groupFullView, $groupCondensedView, $emptyFullView, $emptyCondencedView, $emptyMinimalCondencedView, $itemFullCondensedView);
my ($checkOk, $checkSkip, $configNumber, $printCondensedView, $problemSolved, $verifyNumber, $inProgressNumber);
my ($playSoundInProgress, $playSoundPreviousStatus, $playSoundStatus, %tableSoundStatusCache);
my ($prevHour, $currHour, %timeperiodID_days, %catalogID_uKey_timeperiodID) = (-1, -1);
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
my $boolean_daemonQuit = 0;
my $boolean_signal_hup = 0;
my $boolean_daemonControl = $loop;
my $colspanDisplayTime = $NUMBEROFFTESTS+2;
$colspanDisplayTime += $NUMBEROFFTESTS if $displayTime;
my $pidfile = $PIDPATH .'/'. $checklist .'.pid';
my @checklisttable = read_table($prgtext, $checklist, $loop, $debug);
resultsdirCreate();
my $pagedirBuildHash = ($pagedir =~ /^_loop_(?:[a-zA-Z0-9-]+)_(.*)$/) ? $1 : $pagedir;
build_hash_timeperiodID_days ($checklist, $pagedirBuildHash, \%timeperiodID_days, $debug);
build_hash_catalogID_uKey_timeperiodID ($checklist, $pagedirBuildHash, \%catalogID_uKey_timeperiodID, $debug);
my $directory = $HTTPSPATH .'/nav/'. $pagedir;
create_dir ($directory) unless ( -e "$directory" );
my $pagedirOrig = $pagedir;
unless (fork) { # unless ($pid = fork) {
unless (fork) {
# if ($boolean_daemonControl) { sleep until getppid == 1; }
print "Main Daemon control loop for: <$PROGNAME v$version -C $checklist> pid: <$pidfile><", get_datetimeSignal(), ">\n";
write_pid() if ($boolean_daemonControl);
if ($boolean_daemonControl) {
print "Set daemon catch signals for: <$PROGNAME v$version -C $checklist> pid: <$pidfile><", get_datetimeSignal(), ">\n";
write_tableSoundStatusCache ($checklist, $debug);
$SIG{HUP} = \&signalHUP;
$SIG{QUIT} = \&signalQUIT;
$SIG{__DIE__} = \&signal_DIE;
$SIG{__WARN__} = \&signal_WARN;
} else {
$boolean_daemonQuit = 1;
}
do {
# Catch signals implementation
if ($boolean_signal_hup) {
@checklisttable = read_table($prgtext, $checklist, ( $loop ? 2 : 0 ), $debug);
resultsdirCreate();
build_hash_timeperiodID_days ($checklist, $pagedirBuildHash, \%timeperiodID_days, $debug);
build_hash_catalogID_uKey_timeperiodID ($checklist, $pagedirBuildHash, \%catalogID_uKey_timeperiodID, $debug);
$boolean_signal_hup = 0;
}
applications/display.pl view on Meta::CPAN
while ( my ($key, $value) = each(%tableSoundStatusCache) ) {
print WRITE "$key=>$value\n";
print "'$key' => '$value'\n" if ($debug);
}
close(WRITE);
print "<--\n" if ($debug);
}
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub do_crontab {
my ($Cenvironment) = @_;
$pagedir = $pagedirOrig;
$pagedir .= "/$Cenvironment" unless ($Cenvironment eq 'P');
my $directory = $HTTPSPATH .'/nav/'. $pagedir;
create_dir ($directory) unless ( -e "$directory" );
$htmlOutput = $directory .'/'. $pageset;
$rvOpen = open(HTML, ">$htmlOutput.tmp");
unless ( $rvOpen ) {
print "Cannot open $htmlOutput.tmp to create the html information\n";
exit 0;
}
$rvOpen = open(HTMLCV, ">$htmlOutput-cv.tmp");
unless ( $rvOpen ) {
print "Cannot open $htmlOutput-cv.tmp to create the html information\n";
exit 0;
}
$rvOpen = open(HTMLMCV, ">$htmlOutput-mcv.tmp");
unless ( $rvOpen ) {
print "Cannot open $htmlOutput-mcv.tmp to create the html information\n";
exit 0;
}
$prevGroep = '';
my $dstatusMessage;
my $creationDate;
if ( defined $creationTime ) {
my ($date, $time) = split (/ /, $creationTime);
my ($year, $month, $day) = split (/-/, $date);
my ($hour, $minute, $seconds) = split (/:/, $time);
$creationDate = timelocal ( $seconds, $minute, $hour, $day, $month-1, $year-1900 );
printHtmlHeader( $APPLICATION .' - '. $ENVIRONMENT{$Cenvironment} .' from '. $CATALOGID .' ('. scalar(localtime($creationDate)) .')' );
} else {
$creationDate = time();
printHtmlHeader( $APPLICATION .' - '. $ENVIRONMENT{$Cenvironment} .' from '. $CATALOGID );
}
$rv = 1;
$dbh = DBI->connect("DBI:mysql:$DATABASE:$serverName:$SERVERPORTREADWRITE", "$SERVERUSERREADWRITE", "$SERVERPASSREADWRITE") or $rv = errorTrapDBI($checklist, "Cannot connect to the database");
if ($lockMySQL) {
if ($dbh and $rv) {
$lockString = 'LOCK TABLES ' .$SERVERTABLEVENTS. ' READ';
$dbh->do ( $lockString ) or $rv = errorTrapDBI($checklist, "Cannot dbh->do: $lockString");
}
}
$configNumber = $playSoundStatus = 0;
$doChecklist = ($dbh and $rv) ? 1 : 0;
$emptyFullView = $emptyCondencedView = $emptyMinimalCondencedView = 1;
if ($doChecklist) {
my %inMCV = ();
$inMCV{WARNING}{CRITICAL} = 1;
$inMCV{WARNING}{UNKNOWN} = 1;
$inMCV{WARNING}{DEPENDENT} = 1;
$inMCV{CRITICAL}{WARNING} = 1;
$inMCV{CRITICAL}{UNKNOWN} = 1;
$inMCV{CRITICAL}{DEPENDENT} = 1;
$inMCV{UNKNOWN}{WARNING} = 1;
$inMCV{UNKNOWN}{CRITICAL} = 1;
$inMCV{UNKNOWN}{DEPENDENT} = 1;
$inMCV{DEPENDENT}{WARNING} = 1;
$inMCV{DEPENDENT}{CRITICAL} = 1;
$inMCV{DEPENDENT}{UNKNOWN} = 1;
$groupFullView = $groupCondensedView = 0;
foreach $dchecklist (@checklisttable) {
($tinterval, $tgroep, $resultsdir, $ttest) = split(/\#/, $dchecklist, 4);
my @stest = split(/\|/, $ttest);
my $showGroepHeader = ($prevGroep ne $tgroep) ? 1 : 0;
my $showGroepFooter = (($prevGroep ne '') && $showGroepHeader) ? 1 : 0;
printGroepCV($prevGroep, $showGroepHeader, 1);
$prevGroep = $tgroep;
printGroepFooter('', $showGroepFooter);
printGroepHeader($tgroep, $showGroepHeader);
foreach $dtest (@stest) {
my ($catalogID_uniqueKey, $title, $test, $help) = split(/\#/, $dtest);
my ($catalogID, $uniqueKey) = split(/_/, $catalogID_uniqueKey);
unless ( defined $uniqueKey ) {
$uniqueKey = $catalogID;
$catalogID = $CATALOGID;
$catalogID_uniqueKey = $catalogID .'_'. $uniqueKey unless ( $catalogID eq 'CID' );
}
my ($command, undef) = split(/\.pl/, $test);
my $environment = (($test =~ /\-\-environment=([PASTDL])/) ? $1 : 'P');
next if (defined $environment and $environment ne $Cenvironment);
$configNumber++;
applications/display.pl view on Meta::CPAN
}
$sql = "select SQL_NO_CACHE activationTimeslot, suspentionTimeslot, instability, persistent, downtime, commentData, entryDate, entryTime, activationDate, activationTime, suspentionDate, suspentionTime from $SERVERTABLCOMMENTS where catalogI...
$sth = $dbh->prepare( $sql ) or $rv = errorTrapDBI($checklist, "Cannot dbh->prepare: $sql");
$sth->execute or $rv = errorTrapDBI($checklist, "Cannot sth->execute: $sql") if $rv;
my $statusOverlib = '<NIHIL>'; # $STATE{$ERRORS{'NO DATA'}};
$instability = $downtime = 0;
if ( $rv ) {
my ($TactivationTimeslot, $TsuspentionTimeslot, $Tinstability, $Tpersistent, $Tdowntime, $TcommentData, $TentryDate, $TentryTime, $TactivationDate, $TactivationTime, $TsuspentionDate, $TsuspentionTime, $firstRecordPersistentTrue, $firstRe...
$acked = $sth->rows;
$persistent = -1;
$activationTimeslot = 9999999999;
$firstRecordPersistentTrue = $firstRecordPersistentFalse = 1;
$suspentionTimeslot = $suspentionTimeslotPersistentTrue = $suspentionTimeslotPersistentFalse = 0;
if ( $acked ) {
while( ($TactivationTimeslot, $TsuspentionTimeslot, $Tinstability, $Tpersistent, $Tdowntime, $TcommentData, $TentryDate, $TentryTime, $TactivationDate, $TactivationTime, $TsuspentionDate, $TsuspentionTime) = $sth->fetchrow_array() ) {
if ( int($TactivationTimeslot) <= get_timeslot ($creationDate) and get_timeslot ($creationDate) <= int($TsuspentionTimeslot) ) {
$instability = ( $Tinstability ) ? 1 : $instability;
if ( $Tpersistent ) {
if ( $firstRecordPersistentTrue ) {
$persistent = 1;
$firstRecordPersistentTrue = 0;
$suspentionTimeslotPersistentTrue = int($TsuspentionTimeslot);
}
$suspentionTimeslotPersistentTrue = ($suspentionTimeslotPersistentTrue > int($TsuspentionTimeslot)) ? $suspentionTimeslotPersistentTrue : int($TsuspentionTimeslot);
} else {
if ( $firstRecordPersistentFalse ) {
$persistent = $firstRecordPersistentFalse = 0;
$suspentionTimeslotPersistentFalse = int($TsuspentionTimeslot);
}
$suspentionTimeslotPersistentFalse = ($suspentionTimeslotPersistentFalse > int($TsuspentionTimeslot)) ? $suspentionTimeslotPersistentFalse : int($TsuspentionTimeslot);
}
$downtime = ( $Tdowntime ) ? 1 : $downtime;
$activationTimeslot = ($activationTimeslot < int($TactivationTimeslot)) ? $activationTimeslot : int($TactivationTimeslot);
$suspentionTimeslot = ($suspentionTimeslot > int($TsuspentionTimeslot)) ? $suspentionTimeslot : int($TsuspentionTimeslot);
}
$TcommentData =~ s/'/`/g;
$TcommentData =~ s/[\n\r]+(Updated|Edited|Closed) by: (?:.+), (?:.+) \((?:.+)\) on (\d{4}-\d\d-\d\d) (\d\d:\d\d:\d\d)/\n\r$1 on $2 $3/g;
$TcommentData =~ s/[\n\r]/<br>/g;
$TcommentData =~ s/(?:<br>)+/<br>/g;
$comment .= "<TABLE WIDTH=100% BORDER=0 CELLSPACING=1 CELLPADDING=2 BGCOLOR=#000000><TR><TD BGCOLOR=#000080 ALIGN=CENTER> Entry Date/Time </TD><TD BGCOLOR=#000080 ALIGN=CENTER> Activation Date/Time </TD><TD BGCOLOR...
}
}
$sth->finish() or $rv = errorTrapDBI($checklist, "Cannot sth->finish: $sql");
}
$step = $tinterval * 60;
$lastTimeslot = get_timeslot ($creationDate);
$firstTimeslot = $lastTimeslot - ($step * $NUMBEROFFTESTS);
$timeCorrectie = 0;
if ( $trigger ) {
$findString = 'select SQL_NO_CACHE title, duration, timeslot, startTime, endTime, endDate, status, statusMessage, perfdata, filename from '.$SERVERTABLEVENTSDISPLAYDT.' where catalogID="' .$catalogID. '" and uKey = "'.$uniqueKey.'" and s...
} else {
$findString = 'select SQL_NO_CACHE title, duration, timeslot, startTime, endTime, endDate, status, statusMessage, perfdata, filename from '.$SERVERTABLEVENTS.' force index (uKey) where catalogID="' .$catalogID. '" and uKey = "'.$uniqueKe...
}
print "<", $findString, ">\n" if ($debug);
$sth = $dbh->prepare($findString) or $rv = errorTrapDBI($checklist, "Cannot dbh->prepare: $findString");
$sth->execute or $rv = errorTrapDBI($checklist, "Cannot sth->execute: $findString") if $rv;
my (@itemTimelocal, @itemStatus, @itemStarttime, @itemTimeslot, @tempStatusMessage);
@itemTimelocal = @itemStatus = @itemStarttime = @itemTimeslot = @tempStatusMessage = ();
$timeValue = $lastTimeslot;
for (; $number <= $NUMBEROFFTESTS; $number++) {
push (@itemTimelocal, $timeValue);
push (@itemStatus, ($number == 1) ? 'IN PROGRESS' : 'NO DATA');
push (@itemStarttime, sprintf ("%02d:%02d:%02d", (localtime($timeValue+$timeCorrectie))[2,1,0]));
push (@itemTimeslot, $timeValue);
push (@tempStatusMessage, undef);
$timeValue -= $step;
}
$timeValue = $lastTimeslot;
$inIMW = 1;
if ($rv) {
while (my $ref = $sth->fetchrow_hashref()) {
$timeslot = ( $step ? int(($lastTimeslot - $ref->{timeslot}) / $step) : 0 );
print "<", $timeslot, "><", $ref->{title}, "><", $ref->{startTime}, "><", $ref->{timeslot}, ">\n" if ($debug);
if ($timeslot >= 0) {
my $dstatus = ($ref->{status} eq '<NIHIL>') ? 'UNKNOWN' : $ref->{status};
$tstatus = $dstatus;
if ($dstatus eq 'OK' and $trendline) {
my $tSeconden = int(substr($ref->{duration}, 6, 2)) + int(substr($ref->{duration}, 3, 2)*60) + int(substr($ref->{duration}, 0, 2)*3600);
$tstatus = 'TRENDLINE' if ($tSeconden > $trendline);
}
$itemStatus[$timeslot] = $tstatus;
$itemStarttime[$timeslot] = $ref->{startTime};
$itemTimeslot[$timeslot] = $ref->{timeslot};
unless ( defined $ref->{perfdata} and $ref->{perfdata} ne '' ) { # remove performance data
# ($ref->{statusMessage}, undef) = split(/\|/, $ref->{statusMessage}, 2);
my $statusMessage = reverse $ref->{statusMessage};
my ($_statusMessage, undef) = reverse split(/\|/, $statusMessage, 2);
$ref->{statusMessage} = reverse $_statusMessage;
}
if ( -e $RESULTSPATH .'/'. $ref->{filename} ) {
$ref->{filename} = $RESULTSURL .'/'. $ref->{filename};
} else {
if ( -e $ref->{filename} ) {
$ref->{filename} =~ s/^$RESULTSPATH\//$RESULTSURL\//g;
} else { # work arround for when switching from ASNMTAP_PATH in mixed environment
$ref->{filename} =~ s*^/opt/asnmtap(-3.000.xxx)+/results/*$RESULTSPATH/*g;
if ( -e $ref->{filename} ) {
$ref->{filename} =~ s/^$RESULTSPATH\//$RESULTSURL\//g;
} else {
$ref->{filename} = '<NIHIL>';
}
}
}
my $tstatusMessage = ( ( $catalogID ne $CATALOGID or $ref->{filename} eq '<NIHIL>' ) ? encode_html_entities('M', $ref->{statusMessage}) : '<A HREF="'.$ref->{filename}.'" TARGET="_blank">'.encode_html_entities('M', $ref->{statusMessage...
$statusIcon = ($acked and ($activationTimeslot - $step < $ref->{timeslot}) and ($suspentionTimeslot > $ref->{timeslot})) ? ( $instability ? $ICONSUNSTABLE {$tstatus} : $ICONSACK {$tstatus} ) : $ICONS{$tstatus};
if ( $timeslot == 0 or $timeslot == 1 ) {
my ($year, $month, $day) = split (/-/, $ref->{endDate});
my ($hour, $minute, $seconds) = split (/:/, $ref->{endTime});
$itemTimelocal[$timeslot] = timelocal ( $seconds, $minute, $hour, $day, $month-1, $year-1900 );
}
if ( $timeslot == 0 or ( $timeslot == 1 and $itemStatus[0] eq 'IN PROGRESS' ) ) {
$statusOverlib = ( $timeslot ? $itemStatus[1] : $itemStatus[0] );
if ($pagedirOrig =~ /^(?:index|test)$/ and -s "$APPLICATIONPATH/custom/cartography.pm") {
require "$APPLICATIONPATH/custom/cartography.pm";
createGifForCartography( $catalogID_uniqueKey, $statusOverlib );
}
$inIMW = inIncidentMonitoringWindow ($catalogID, $uniqueKey, $ref->{timeslot}, $ref->{startTime}, $ref->{endTime}, $ref->{endDate}, \%timeperiodID_days, \%catalogID_uKey_timeperiodID, $debug);
}
if ($dstatus ne 'OK' and $dstatus ne 'OFFLINE' and $dstatus ne 'NO DATA' and $dstatus ne 'NO TEST') {
$tempStatusMessage[$timeslot] = '<IMG SRC="'.$IMAGESURL.'/'.$statusIcon.'" WIDTH="16" HEIGHT="16" BORDER=0 title="'.$tstatus.'" alt="'.$tstatus.'"></TD><TD class="StatusMessage">'.$ref->{startTime}.'</TD><TD class="StatusMessage">'....
if ( $timeslot == 0 or ( $timeslot == 1 and $itemStatus[0] eq 'IN PROGRESS' ) ) {
$ref->{statusMessage} =~ s/'/`/g;
$ref->{statusMessage} =~ s/[\n\r]/<br>/g;
$popup .= '<TR><TD BGCOLOR=#000080 WIDTH=100 ALIGN=RIGHT VALIGN=TOP>Status</TD><TD BGCOLOR=#0000FF><IMG SRC='.$IMAGESURL.'/'.$statusIcon.' WIDTH=15 HEIGHT=15 title= alt= BORDER=0> '.$ref->{startTime}.' '.encode_html_entities('M', ...
}
}
}
}
$sth->finish() or $rv = errorTrapDBI($checklist, "Cannot sth->finish: $findString");
}
printItemHeader($environment, $resultsdir, $catalogID_uniqueKey, $catalogID, $uniqueKey, $command, $title, $help, $popup, $statusOverlib, $comment);
$playSoundPreviousStatus = $playSoundInProgress = 0;
for ($number = 0; $number < $NUMBEROFFTESTS; $number++) {
my $endTime = $itemStarttime[$number];
$endTime .= '-'. $itemTimeslot[$number] if ($displayTimeslot);
printItemStatus($tinterval, $number+1, $itemStatus[$number], $endTime, $acked, $itemTimeslot[$number], $activationTimeslot, $suspentionTimeslot, $instability, $persistent, $downtime, $suspentionTimeslotPersistentTrue, $suspentionTimeslotP...
}
for ($number = 0; $number < $NUMBEROFFTESTS; $number++) {
push (@arrayStatusMessage, $tempStatusMessage[$number] ) if (defined $tempStatusMessage[$number]);
}
$itemTitle = $title;
$itemStatus = ( $itemStatus[0] eq 'IN PROGRESS' ) ? $itemStatus[1] : $itemStatus[0];
$itemTimeslot = ( $itemStatus[0] eq 'IN PROGRESS' ) ? $itemTimelocal[1] : $itemTimelocal[0];
$itemStatusIcon = ( $acked and ( $activationTimeslot - $step < $itemTimeslot ) and ( $suspentionTimeslot > $itemTimeslot ) ) ? 1 : 0;
$itemInsertInMCV = ( $instability ) ? ( $persistent ? 0 : 1 ) : ( defined $inMCV{$tLastStatus}{$tPrevStatus} ? 1 : 0 );
}
printItemFooter($catalogID_uniqueKey, $catalogID, $uniqueKey, $itemTitle, $itemStatus, $itemTimeslot, $itemStatusIcon, $itemInsertInMCV, $inIMW, $itemFullCondensedView, $printCondensedView, \@arrayStatusMessage, \%catalogID_uKey_timeperiodID)...
}
print "\n" if ($debug);
}
printGroepCV($prevGroep, 1, 0);
if ($lockMySQL) {
if ($dbh and $rv) {
$unlockString = 'UNLOCK TABLES';
$dbh->do ( $unlockString ) or $rv = errorTrapDBI($checklist, "Cannot dbh->do: $unlockString");
}
}
$dbh->disconnect or $rv = errorTrapDBI($checklist, "Sorry, the database was unable to add your entry.") if ($dbh and $rv);
}
printGroepFooter('', 0);
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
$emptyMinimalCondencedView = ( scalar ( @multiarrayMinimalCondensedView ) ? 0 : 1 );
unless ( $emptyMinimalCondencedView ) {
@multiarrayMinimalCondensedView = ( sort { $b->[2] <=> $a->[2] } @multiarrayMinimalCondensedView );
@multiarrayMinimalCondensedView = ( sort { $b->[0] <=> $a->[0] } @multiarrayMinimalCondensedView );
@multiarrayMinimalCondensedView = ( sort { $a->[3] <=> $b->[3] } @multiarrayMinimalCondensedView );
@multiarrayMinimalCondensedView = ( sort { $a->[1] cmp $b->[1] } @multiarrayMinimalCondensedView );
my $currPriorityGroup = '-MVM-P01-';
foreach my $arrayFullCondensedView ( @multiarrayMinimalCondensedView ) {
# print @$arrayFullCondensedView[2], "-", @$arrayFullCondensedView[0], "-", @$arrayFullCondensedView[3], "-", @$arrayFullCondensedView[1], "\n" if ($debug);
if ( $currPriorityGroup ne @$arrayFullCondensedView[1] ) {
$currPriorityGroup = @$arrayFullCondensedView[1];
my (undef, undef, $priorityGroup) = split( /-/, $currPriorityGroup );
print HTMLMCV '<TR><TD class="GroupHeader" COLSPAN=', $colspanDisplayTime, '>', 'Priority: '. $priorityGroup, '</TD></TR>', "\n";
}
print HTMLMCV @$arrayFullCondensedView[4];
}
print HTMLMCV '<tr style="{height: 4;}"><TD></TD></TR>', "\n";
delete @multiarrayMinimalCondensedView[0..@multiarrayMinimalCondensedView];
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
printStatusHeader('', $configNumber, $emptyFullView, $emptyCondencedView, $emptyMinimalCondencedView, $playSoundStatus);
printStatusFooter('', $emptyFullView, $emptyCondencedView, $emptyMinimalCondencedView, $playSoundStatus);
printHtmlFooter('');
close(HTML);
rename("$htmlOutput.tmp", "$htmlOutput.html") if (-e "$htmlOutput.tmp");
close(HTMLCV);
rename("$htmlOutput-cv.tmp", "$htmlOutput-cv.html") if (-e "$htmlOutput-cv.tmp");
close(HTMLMCV);
rename("$htmlOutput-mcv.tmp", "$htmlOutput-mcv.html") if (-e "$htmlOutput-mcv.tmp");
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub signal_DIE {
#print "kill -DIE <$PROGNAME v$version -C $checklist> pid: <$pidfile><", get_datetimeSignal(), ">\n";
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub signal_WARN {
#print "kill -WARN <$PROGNAME v$version -C $checklist> pid: <$pidfile><", get_datetimeSignal(), ">\n";
applications/display.pl view on Meta::CPAN
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub write_pid {
print "write PID <$PROGNAME v$version -C $checklist> pid: <$pidfile><", get_datetimeSignal(), ">\n";
if (-e "$pidfile") {
print "ERROR: couldn't create pid file <$pidfile> for <$PROGNAME v$version -C $checklist>\n";
exit 0;
} else {
open(PID,">$pidfile") || die "Cannot open $pidfile!!\n";
print PID $$;
close(PID);
}
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub create_dir {
my ($directory) = @_;
unless ( -e "$directory" ) { # create $directory
my ($status, $stdout, $stderr) = call_system ("mkdir $directory", 0);
print " create_dir ---- : mkdir $directory: $status, $stdout, $stderr\n" if ( ! $status or $stderr ne '' );
}
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub errorTrapDBI {
my ($checklist, $error_message) = @_;
print $error_message, "\nERROR: $DBI::err ($DBI::errstr)\n";
unless ( -e "$RESULTSPATH/$checklist-MySQL-sql-error.txt" ) {
my $subject = "$prgtext / Current status for $checklist: " . get_datetimeSignal();
my $message = get_datetimeSignal() . " $error_message\n--> ERROR: $DBI::err ($DBI::errstr)\n";
my $returnCode = sending_mail ( $SERVERLISTSMTP, $SENDEMAILTO, $SENDMAILFROM, $subject, $message, $debug );
print "Problem sending email to the '$APPLICATION' server administrators\n" unless ( $returnCode );
}
$rvOpen = open(DEBUG,">>$RESULTSPATH/$checklist-MySQL-sql-error.txt");
if ($rvOpen) {
print DEBUG get_datetimeSignal, ' ', $error_message, "\n--> ERROR: $DBI::err ($DBI::errstr)\n";
close(DEBUG);
} else {
print "Cannot open $RESULTSPATH/$checklist-MySQL-sql-error.txt to print debug information\n";
}
return 0;
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub build_hash_timeperiodID_days {
my ($checklist, $pagedir, $hash_timeperiodID_days, $debug) = @_;
print "build_hash_timeperiodID_days: '$checklist', '$pagedir'\n" if ($debug);
my $rv = 1;
my $dbh = DBI->connect("DBI:mysql:$DATABASE:$serverName:$SERVERPORTREADWRITE", "$SERVERUSERREADWRITE", "$SERVERPASSREADWRITE") or $rv = errorTrapDBI($checklist, "Cannot connect to the database");
return () unless ($dbh and $rv);
# (localtime)[6]: weekday Number of days since Sunday (0 - 6)
my %WDAYS = ('sunday'=>'0','monday'=>'1','tuesday'=>'2','wednesday'=>'3','thursday'=>'4','friday'=>'5','saturday'=>'6');
my $sql = "SELECT SQL_NO_CACHE DISTINCT $SERVERTABLVIEWS.catalogID, $SERVERTABLVIEWS.timeperiodID, $SERVERTABLTIMEPERIODS.sunday, $SERVERTABLTIMEPERIODS.monday, $SERVERTABLTIMEPERIODS.tuesday, $SERVERTABLTIMEPERIODS.wednesday, $SERVERTABLTIMEPERIOD...
print "<", $sql, ">\n" if ($debug);
my $sth = $dbh->prepare( $sql ) or $rv = errorTrapDBI($checklist, "Cannot dbh->prepare: $sql");
$sth->execute or $rv = errorTrapDBI($checklist, "Cannot sth->execute: $sql") if $rv;
if ($rv) {
if ( $sth->rows ) {
while (my $ref = $sth->fetchrow_hashref()) {
$$hash_timeperiodID_days{$ref->{catalogID}}->{$ref->{timeperiodID}}->{$WDAYS{sunday}} = ( $ref->{sunday} ) ? $ref->{sunday} : '';
$$hash_timeperiodID_days{$ref->{catalogID}}->{$ref->{timeperiodID}}->{$WDAYS{monday}} = ( $ref->{monday} ) ? $ref->{monday} : '';
$$hash_timeperiodID_days{$ref->{catalogID}}->{$ref->{timeperiodID}}->{$WDAYS{tuesday}} = ( $ref->{tuesday} ) ? $ref->{tuesday} : '';
$$hash_timeperiodID_days{$ref->{catalogID}}->{$ref->{timeperiodID}}->{$WDAYS{wednesday}} = ( $ref->{wednesday} ) ? $ref->{wednesday} : '';
$$hash_timeperiodID_days{$ref->{catalogID}}->{$ref->{timeperiodID}}->{$WDAYS{thursday}} = ( $ref->{thursday} ) ? $ref->{thursday} : '';
$$hash_timeperiodID_days{$ref->{catalogID}}->{$ref->{timeperiodID}}->{$WDAYS{friday}} = ( $ref->{friday} ) ? $ref->{friday} : '';
$$hash_timeperiodID_days{$ref->{catalogID}}->{$ref->{timeperiodID}}->{$WDAYS{saturday}} = ( $ref->{saturday} ) ? $ref->{saturday} : '';
}
}
$sth->finish() or $rv = errorTrapDBI($checklist, "Cannot sth->finish: $sql");
}
$dbh->disconnect or $rv = errorTrapDBI($checklist, "Sorry, the database was unable to add your entry.") if ($dbh and $rv);
if ($debug) {
use Data::Dumper;
print Dumper ( $hash_timeperiodID_days ), "\n\n";
}
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub build_hash_catalogID_uKey_timeperiodID {
my ($checklist, $pagedir, $hash_catalogID_uKey_timeperiodID, $debug) = @_;
print "build_hash_catalogID_uKey_timeperiodID: '$checklist', '$pagedir'\n" if ($debug);
my $rv = 1;
my $dbh = DBI->connect("DBI:mysql:$DATABASE:$serverName:$SERVERPORTREADWRITE", "$SERVERUSERREADWRITE", "$SERVERPASSREADWRITE") or $rv = errorTrapDBI($checklist, "Cannot connect to the database");
return () unless ($dbh and $rv);
my $sql = "SELECT SQL_NO_CACHE $SERVERTABLPLUGINS.catalogID, $SERVERTABLPLUGINS.uKey, $SERVERTABLVIEWS.timeperiodID FROM `$SERVERTABLDISPLAYDMNS`, `$SERVERTABLVIEWS`, `$SERVERTABLPLUGINS` WHERE $SERVERTABLDISPLAYDMNS.pagedir = '$pagedir' AND $SERVE...
print "<", $sql, ">\n" if ($debug);
my $sth = $dbh->prepare( $sql ) or $rv = errorTrapDBI($checklist, "Cannot dbh->prepare: $sql");
$sth->execute or $rv = errorTrapDBI($checklist, "Cannot sth->execute: $sql") if $rv;
if ($rv) {
while (my $ref = $sth->fetchrow_hashref()) {
$$hash_catalogID_uKey_timeperiodID{$ref->{catalogID}}->{$ref->{uKey}}->{ASNMTAP} = $ref->{timeperiodID};
}
$sth->finish() or $rv = errorTrapDBI($checklist, "Cannot sth->finish: $sql");
}
$dbh->disconnect or $rv = errorTrapDBI($checklist, "Sorry, the database was unable to add your entry.") if ($dbh and $rv);
if (-s "$APPLICATIONPATH/custom/sde.pm") {
require "$APPLICATIONPATH/custom/sde.pm";
getTimeperiodRelationshipsSDE( $serverName, $checklist, $hash_catalogID_uKey_timeperiodID, $debug );
}
if ($debug) {
use Data::Dumper;
print Dumper ( $hash_catalogID_uKey_timeperiodID ), "\n\n";
}
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub inIncidentMonitoringWindow {
my ($catalogID, $uniqueKey, $timeslot, $startTime, $endTime, $endDate, $timeperiodID_days, $catalogID_uKey_timeperiodID, $debug) = @_;
my $InIMW;
my ($year, $month, $day) = split (/[-\/]/, $endDate);
if (defined $year and defined $month and defined $day) {
my $Year = $year-1900;
my $Month = $month-1;
my $wDay = (localtime( timelocal( 0, 0, 0, $day, $Month, $Year ) ))[6];
my $timeperiodes = ( exists $$catalogID_uKey_timeperiodID{$catalogID}->{$uniqueKey}->{SDE_IMW}->{$wDay} ) ? $$catalogID_uKey_timeperiodID{$catalogID}->{$uniqueKey}->{SDE_IMW}->{$wDay} : $$timeperiodID_days{$catalogID}->{$$catalogID_uKey_timeperio...
if ($debug) {
# (localtime)[6]: weekday Number of days since Sunday (0 - 6)
my %WDAYS = ('0'=>'sunday','1'=>'monday','2'=>'tuesday','3'=>'wednesday','4'=>'thursday','5'=>'friday','6'=>'saturday');
print "catalogID: $catalogID, uniqueKey: $uniqueKey, year: $year, month: $month, day: $day, wDay: $wDay, ". $WDAYS{$wDay} .", timeperiodes: $timeperiodes\n";
print "catalogID_uKey_timeperiodID: ". $$catalogID_uKey_timeperiodID{$catalogID}->{$uniqueKey}->{ASNMTAP} ."\n";
}
for my $timeperiode (split (/,/, $timeperiodes)) {
my ($from, $to) = split (/-/, $timeperiode);
if ( defined $from and defined $to ) {
$to =~ s/24:00/23:59/g;
print "$from, $to\n" if ($debug);
my ($from_hour, $from_min) = split (/:/, $from);
my ($to_hour, $to_min) = split (/:/, $to);
if ( defined $from_hour and defined $from_min and defined $to_hour and defined $to_min ) {
print "$from_hour, $from_min, $to_hour, $to_min\n" if ($debug);
my $from_time = timelocal(0, $from_min, $from_hour, $day, $Month, $Year );
my $to_time = timelocal(59, $to_min, $to_hour, $day, $Month, $Year );
if ( defined $from_time and defined $to_time ) {
$InIMW = ( ( $from_time <= $timeslot and $timeslot <= $to_time ) ? 1 : ( ( defined $InIMW ) ? $InIMW : 0 ) );
if ($debug) {
print "$from_time, $timeslot, $to_time\n";
print scalar (localtime($from_time)), "\n";
print scalar (localtime($timeslot)), "\n";
print scalar (localtime($to_time)), "\n";
print "$InIMW !\n";
}
}
}
}
}
$InIMW = 1 unless (defined $InIMW);
} else {
$InIMW = 1;
}
return ($InIMW);
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub printHtmlHeader {
my $htmlTitle = shift(@_);
print_header (*HTML, $pagedir, "$pageset-cv", $htmlTitle, "Full View", 60, "ONLOAD=\"startRefresh(); initSound();\"", 'T', "<script type=\"text/javascript\" src=\"$HTTPSURL/overlib.js\"><!-- overLIB (c) Erik Bosrup --></script>", undef);
print HTML '<TABLE WIDTH="100%">', "\n";
print_header (*HTMLCV, $pagedir, "$pageset-mcv", $htmlTitle, "Condenced View", 60, "ONLOAD=\"startRefresh(); initSound();\"", 'T', "<script type=\"text/javascript\" src=\"$HTTPSURL/overlib.js\"><!-- overLIB (c) Erik Bosrup --></script>", undef);
print HTMLCV '<TABLE WIDTH="100%">', "\n";
print_header (*HTMLMCV, $pagedir, "$pageset", $htmlTitle, "Minimal Condenced View", 60, "ONLOAD=\"startRefresh(); initSound();\"", 'T', "<script type=\"text/javascript\" src=\"$HTTPSURL/overlib.js\"><!-- overLIB (c) Erik Bosrup --></script>", undef...
print HTMLMCV '<TABLE WIDTH="100%">', "\n";
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub printGroepHeader {
my ($title, $show) = @_;
if ($show) {
$groupFullView = $groupCondensedView = 0;
delete @multiarrayFullCondensedView[0..@multiarrayFullCondensedView];
}
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub printStatusHeader {
my ($title, $configNumber, $emptyFullView, $emptyCondencedView, $emptyMinimalCondencedView, $playSoundStatus) = @_;
my ($emptyFullViewMessage, $emptyCondencedViewMessage, $emptyMinimalCondencedViewMessage);
if ( $configNumber ) { # Monitored Applications
if ( $emptyFullView ) {
$emptyMinimalCondencedViewMessage = $emptyCondencedViewMessage = $emptyFullViewMessage = 'Contact ASAP the server administrators, probably collector/config problems!';
} else {
$emptyCondencedViewMessage = 'All Monitored Applications are OK' if ( $emptyCondencedView );
$emptyMinimalCondencedViewMessage = 'All Monitored Applications are OK' if ( $emptyMinimalCondencedView );
}
} elsif ( $emptyFullView and $emptyCondencedView and $emptyMinimalCondencedView ) {
if ( $doChecklist ) {
$emptyMinimalCondencedViewMessage = $emptyCondencedViewMessage = $emptyFullViewMessage = 'No Monitored Applications';
} else {
$emptyMinimalCondencedViewMessage = $emptyCondencedViewMessage = $emptyFullViewMessage = 'Contact ASAP the server administrators, probably database problems!';
}
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
if (defined $emptyFullViewMessage) {
print HTML '<TR><TD class="StatusHeader" COLSPAN="', $colspanDisplayTime, '"><BR><H1>', $emptyFullViewMessage, '</H1></TD></TR>', "\n", '</TABLE>', "\n";
} else {
print HTML '<TR><TD class="StatusHeader" COLSPAN="', $colspanDisplayTime, '">', $STATUSHEADER01, '</TD></TR>', "\n", '</TABLE>', "\n";
}
print_legend (*HTML);
print HTML '<TABLE WIDTH="100%">', "\n";
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
if (defined $emptyCondencedViewMessage) {
print HTMLCV '<TR><TD class="StatusHeader" COLSPAN="', $colspanDisplayTime, '"><BR><H1>', $emptyCondencedViewMessage, '</H1></TD></TR>', "\n", '</TABLE>', "\n";
} else {
print HTMLCV '<TR><TD class="StatusHeader" COLSPAN="', $colspanDisplayTime, '">', $STATUSHEADER01, '</TD></TR>', "\n", '</TABLE>', "\n";
}
print_legend (*HTMLCV);
print HTMLCV '<TABLE WIDTH="100%">', "\n";
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
if (defined $emptyMinimalCondencedViewMessage) {
print HTMLMCV '<TR><TD class="StatusHeader" COLSPAN="', $colspanDisplayTime, '"><BR><H1>', $emptyMinimalCondencedViewMessage, '</H1></TD></TR>', "\n", '</TABLE>', "\n";
} else {
print HTMLMCV '</TABLE>', "\n";
}
print_legend (*HTMLMCV);
print HTMLMCV '<TABLE WIDTH="100%">', "\n";
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub printItemHeader {
my ($environment, $resultsdir, $catalogID_uniqueKey, $catalogID, $uniqueKey, $command, $title, $help, $popup, $statusOverlib, $comment) = @_;
unless ( defined $creationTime ) {
my $htmlFilename = "$RESULTSPATH/$resultsdir/$command-$catalogID_uniqueKey";
$htmlFilename .= "-sql.html";
unless ( -e "$htmlFilename" ) {
my $rvOpen = open(PNG, ">$htmlFilename");
if ($rvOpen) {
print PNG <<EOM;
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>$APPLICATION @ $BUSINESS</title>
<META HTTP-EQUIV="Expires" CONTENT="Wed, 10 Dec 2003 00:00:01 GMT">
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Cache-Control" CONTENT="no-cache">
<META HTTP-EQUIV="Refresh" CONTENT="60">
<link rel="stylesheet" type="text/css" href="$HTTPSURL/asnmtap.css">
applications/display.pl view on Meta::CPAN
EOH
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
print HTMLMCV '</TABLE>', "\n";
print HTMLMCV <<EOH;
<script language="JavaScript" type="text/javascript">
function toggleDiv (div_id){
if (document.getElementById(div_id)) {
if (document.getElementById(div_id).style.display == 'none') {
document.getElementById(div_id).style.display = 'block';
} else {
document.getElementById(div_id).style.display = 'none';
}
}
}
</script>
EOH
if ($playSoundStatus) {
print HTMLMCV <<EOH;
<script language="JavaScript" type="text/javascript">
var soundState = getSoundCookie( 'soundState' );
if ( soundState != null && soundState == 'on' ) {
playSound = '<embed src="$HTTPSURL/sound/$SOUND{$playSoundStatus}" width="" height="" alt="" hidden="true" autostart="true" loop="false"><\\/embed>';
dynamicContentNS4NS6FF ('SoundStatus', playSound, 1);
}
</script>
EOH
}
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub maskPassword {
my ($parameters) = @_;
# --dnPass=
if ($parameters =~ /--dnPass=/) {
$parameters =~ s/(--dnPass=)\w+/$1********/g;
}
# --proxy=user:pasword\@proxy
if ($parameters =~ /--proxy=/) {
$parameters =~ s/(--proxy=\w*:)\w*(\@\w+)/$1********$2/g;
}
# -p user:pasword\@proxy
if ($parameters =~ /-p / and ($parameters !~ /-u / and $parameters !~ /--username=/)) {
$parameters =~ s/(-p \w*:)\w*(\@\w+)/$1********$2/g;
}
# --password=
if ($parameters =~ /--password=/) {
$parameters =~ s/(--password=)\w+/$1********/g;
}
# --username= or -u and --password= or -p (database plugins)
if ($parameters =~ /-p / and ($parameters =~ /-u / or $parameters =~ /--username=/)) {
$parameters =~ s/(-p )\w+/$1********/g;
}
# --username= or -U and --password= or -P (ftp plugins)
if ($parameters =~ /-P / and ($parameters =~ /-U / or $parameters =~ /--username=/)) {
$parameters =~ s/(-P )\w+/$1********/g;
}
# j_username= or j_password= (J2EE based Applications)
if ($parameters =~ /j_username=/ and $parameters =~ /j_password=/) {
$parameters =~ s/(j_password=)\w+/$1********/g;
}
return ($parameters);
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub print_usage () {
print "Usage: $PROGNAME -H <MySQL hostname> [-C <Checklist>] [-P <pagedir>] [-L <loop>] [-t <trigger>] [-c <YYYY-MM-DD HH:MM:SS> ] [-T <displayTime>] [-l <lockMySQL>] [-D <debug>] [-V version] [-h help]\n";
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub print_help () {
print_revision($PROGNAME, $version);
print "ASNMTAP Display for the '$APPLICATION'
-H, --hostname=<HOSTNAME>
HOSTNAME : hostname/address from the MySQL server
-C, --checklist=<FILENAME>
FILENAME : filename from the checklist for the html output loop (default 'DisplayCT')
-P, --pagedir=<PAGEDIR>
PAGEDIR : sub directory name for the html output (default 'index')
-L, --loop=F|T
F(alse) : loop off (default)
T(rue) : loop on
-t, --trigger=F|T
F(alse) : trigger off (default)
T(rue) : trigger on
-c, --creationTime=<YYYY-MM-DD HH:MM:SS>
YYYY-MM-DD HH:MM:SS: year, month, day, hours, minutes and seconds to use instead of the current time when --loop = F
-T, --displayTime=F|T
F(alse) : display timeslots into html output off
T(rue) : display timeslots into html output (default)
-l, --lockMySQL=F|T
F(alse) : lock MySQL table off (default)
T(rue) : lock MySQL table on
-D, --debug=F|T
F(alse) : screendebugging off (default)
T(true) : normal screendebugging on
-V, --version
-h, --help
Send email to $SENDEMAILTO if you have questions regarding
use of this software. To submit patches or suggest improvements, send
email to $SENDEMAILTO
";
( run in 0.790 second using v1.01-cache-2.11-cpan-39bf76dae61 )