ASNMTAP
view release on metacpan or search on metacpan
applications/display-test.pl view on Meta::CPAN
($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;
}
# Crontab implementation
read_tableSoundStatusCache ($checklist, $debug);
foreach ('P', 'A', 'S', 'T', 'D', 'L') { do_crontab ($_); }
applications/display-test.pl view on Meta::CPAN
<META HTTP-EQUIV="Refresh" CONTENT="60">
<link rel="stylesheet" type="text/css" href="$HTTPSURL/asnmtap.css">
</HEAD>
<BODY>
EOM
print PNG '<IMG SRC="', $RESULTSURL, '/', $resultsdir, '/', $command, '-', $catalogID_uniqueKey, '-sql.png"></BODY></HTML>', "\n";
close(PNG);
} else {
print "Cannot create $htmlFilename!\n";
}
}
}
my ($posTokenFrom, $posTokenTo, $groep, $test, $serverID);
$posTokenFrom = index $title, '[';
if ($posTokenFrom eq -1) {
$groep = '';
$test = $title;
} else {
$posTokenTo = index $title, ']', $posTokenFrom+1;
$groep = substr($title, $posTokenFrom, $posTokenTo+2);
$test = substr($title, $posTokenTo+2);
}
$posTokenFrom = index $test, ' {';
if ($posTokenFrom eq -1) {
$serverID = '';
} else {
$posTokenTo = index $test, '}', $posTokenFrom+2;
$serverID = substr($test, $posTokenFrom+2); chop ($serverID);
$test = substr($test, 0, $posTokenFrom);
}
# http://www.bosrup.com/web/overlib/?Command_Reference
my $_exclaim = '';
if (-s "$APPLICATIONPATH/custom/sde.pm") {
require "$APPLICATIONPATH/custom/sde.pm";
$_exclaim .= printRelationshipsSDE( $serverName, $checklist, $catalogID, $uniqueKey );
}
if (-s "$APPLICATIONPATH/custom/cartography.pm") {
require "$APPLICATIONPATH/custom/cartography.pm";
$_exclaim .= printLinkToCartography( $serverName, $checklist, $catalogID, $uniqueKey );
}
# debug: toggleDiv(), pop-up: overlib() & pop-down: nd()
# onClick: overlib(), onDblClick: nd() & toggleDiv()
$_exclaim = "<TABLE WIDTH=100% BORDER=0 CELLSPACING=1 CELLPADDING=2 BGCOLOR=#000000><TR><TD BGCOLOR=#000080 WIDTH=100 ALIGN=RIGHT>Plugin</TD><TD BGCOLOR=#0000FF>$test</TD></TR>$popup<TR><TD BGCOLOR=#000080 WIDTH=100 ALIGN=RIGHT>Unique Key</TD><TD B...
my $exclaim = '<TD WIDTH="56"><a href="javascript:void(0);" onDblClick="nd(); return toggleDiv(\''.$catalogID_uniqueKey.'\');" onClick="return overlib(\''.$_exclaim.'\', CAPTION, \'Exclaim\', STICKY, CLOSECLICK, CAPCOLOR, \'#000000\', FGCOLOR, \'#...
my $_comment = ( defined $comment ? 'onmouseover="return overlib(\''.$comment.'\', CAPTION, \'Comments\', STICKY, CLOSECLICK, CAPCOLOR, \'#000000\', FGCOLOR, \'#000000\', BGCOLOR, \''.$COLORS{$statusOverlib}.'\', HAUTO, VAUTO, WIDTH, 692, OFFSETX, ...
my $comments = '<a href="'. $HTTPSURL .'/cgi-bin/comments.pl?pagedir='.$pagedir.'&pageset='.$pageset.'&debug=F&CGICOOKIE=1&action=listView&catalogID='.$catalogID.'&uKey='.$uniqueKey.'" target="_self" '.$_comment.'><IMG SRC="...
my $helpfile = (defined $help and $help eq '1') ? '<A HREF="'. $HTTPSURL .'/cgi-bin/getHelpPlugin.pl?pagedir='.$pagedir.'&pageset='.$pageset.'&debug=F&CGICOOKIE=1&catalogID='.$catalogID.'&uKey='.$uniqueKey.'" target="_self"><IMG...
$checkOk = $checkSkip = $printCondensedView = $problemSolved = $verifyNumber = 0;
$inProgressNumber = -1;
$itemFullCondensedView = ' <TR>'."\n".' '.$exclaim.$comments.$helpfile."\n";
if ( $catalogID ne $CATALOGID or defined $creationTime ) {
$itemFullCondensedView .= ' <TD class="ItemHeader">'.$groep. encode_html_entities('T', $test) .'</TD>'. "\n";
} else {
$itemFullCondensedView .= ' <TD class="ItemHeader">'.$groep.'<A HREF="#" class="ItemHeaderTest" onClick="openPngImage(\''. $RESULTSURL .'/'. $resultsdir .'/'. $command .'-'. $catalogID_uniqueKey ."-sql.html',912,576,null,null,'ChartDirector',1...
}
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub printGroepCV {
my ($title, $showGroup, $showFooter) = @_;
if ($showGroup and $title ne '') {
if ($groupFullView) {
$emptyFullView = ( scalar ( @multiarrayFullCondensedView ) ? 0 : 1 );
unless ( $emptyFullView ) {
print HTML '<TR><TD class="GroupHeader" COLSPAN=', $colspanDisplayTime, '>', encode_html_entities('T', $title), '</TD></TR>', "\n";
foreach my $arrayFullCondensedView ( @multiarrayFullCondensedView ) {
print HTML @$arrayFullCondensedView[4];
}
}
print HTML '<tr style="{height: 4;}"><TD></TD></TR>', "\n", if $showFooter;
}
if ($groupCondensedView) {
$emptyCondencedView = ( scalar ( @multiarrayFullCondensedView ) ? 0 : 1 );
unless ( $emptyCondencedView ) {
@multiarrayFullCondensedView = ( sort { $a->[2] <=> $b->[2] } @multiarrayFullCondensedView );
@multiarrayFullCondensedView = ( sort { $b->[0] <=> $a->[0] } @multiarrayFullCondensedView );
@multiarrayFullCondensedView = ( sort { $a->[3] <=> $b->[3] } @multiarrayFullCondensedView );
@multiarrayFullCondensedView = ( sort { $a->[1] <=> $b->[1] } @multiarrayFullCondensedView );
print HTMLCV '<TR><TD class="GroupHeader" COLSPAN=', $colspanDisplayTime, '>', encode_html_entities('T', $title), '</TD></TR>', "\n";
foreach my $arrayFullCondensedView ( @multiarrayFullCondensedView ) {
print HTMLCV @$arrayFullCondensedView[4] if ( @$arrayFullCondensedView[5] );
}
}
print HTMLCV '<tr style="{height: 4;}"><TD></TD></TR>', "\n", if $showFooter;
}
}
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub printItemStatus {
my ($interval, $number, $status, $endTime, $acked, $timeslot, $activationTimeslot, $suspentionTimeslot, $instability, $persistent, $downtime, $suspentionTimeslotPersistentTrue, $suspentionTimeslotPersistentFalse, $catalogID_uniqueKey, $catalogID, $...
my $statusIcon = ($acked and ($activationTimeslot - $step < $timeslot) and ($suspentionTimeslot > $timeslot)) ? ( $instability ? $ICONSUNSTABLE {$status} : $ICONSACK {$status} ) : $ICONS{$status};
my ($debugInfo, $boldStart, $boldEnd);
$debugInfo = $boldStart = $boldEnd = '';
if ($number == 0) {
$printCondensedView = 1 unless ( $status eq 'IN PROGRESS' or $status eq 'OK' or $status eq 'NO TEST' or $status eq 'OFFLINE' );
if ($ERRORS{$status} <= $ERRORS{UNKNOWN} or $ERRORS{$status} == $ERRORS{'NO DATA'}) { $playSoundStatus = ($playSoundStatus > $ERRORS{$status}) ? $playSoundStatus : $ERRORS{$status}; }
} else {
my $playSoundSet = 0;
unless ( $printCondensedView or $problemSolved or $checkSkip == $inProgressNumber) {
if ( $number == 1 ) {
$verifyNumber = $VERIFYNUMBEROK;
if ( $interval and $interval < $VERIFYMINUTEOK ) {
$verifyNumber = int($VERIFYMINUTEOK / $interval);
if ( $verifyNumber > $NUMBEROFFTESTS ) {
$verifyNumber = $NUMBEROFFTESTS;
} elsif ($verifyNumber < $VERIFYNUMBEROK) {
$verifyNumber = $VERIFYNUMBEROK;
}
}
$inProgressNumber = $verifyNumber;
if ( $verifyNumber < $NUMBEROFFTESTS ) {
$debugInfo .= "a-" if ($debug);
$inProgressNumber++ if ( $status eq 'IN PROGRESS' );
}
if ( $status eq 'IN PROGRESS' ) {
$playSoundInProgress = 1;
} else {
$playSoundPreviousStatus = $ERRORS{$status};
}
}
my ($localYear, $localMonth, $currentYear, $currentMonth, $currentDay, $currentHour, $currentMin, $currentSec) = ((localtime)[5], (localtime)[4], ((localtime)[5] + 1900), ((localtime)[4] + 1), (localtime)[3,2,1,0]);
my $solvedDate = "$currentYear-$currentMonth-$currentDay";
my $solvedTime = "$currentHour:$currentMin:$currentSec";
my $solvedTimeslot = timelocal($currentSec, $currentMin, $currentHour, $currentDay, $localMonth, $localYear);
my $notDowntimeOrPersistent = 1;
if ( $downtime or $persistent ) {
$notDowntimeOrPersistent = ( $solvedTimeslot >= $activationTimeslot ? 0 : 1 );
}
if ( $number <= $inProgressNumber ) {
$debugInfo .= "b-" if ($debug);
$checkOk++ if ( $status eq 'OK' );
if ( $notDowntimeOrPersistent and ($status eq 'IN PROGRESS' or $status eq 'OK' or $status eq 'NO TEST' or $status eq 'OFFLINE' ) ) {
$checkSkip++ unless ( $acked and $status eq 'NO TEST' );
} else {
$printCondensedView = 1
}
} elsif ( $checkOk < $verifyNumber ) {
$debugInfo .= "c-" if ($debug);
$printCondensedView = ( $checkSkip == $inProgressNumber ) ? 0 : 1;
}
if ( $checkOk >= $verifyNumber ) {
$debugInfo .= "s-" if ($debug);
$problemSolved = 1;
}
$printCondensedView = 0 if ($downtime and ! $persistent);
$debugInfo .= "$inIMW-$instability-$persistent-$downtime-$inProgressNumber-$verifyNumber-$checkOk-$checkSkip-$printCondensedView-$problemSolved-" if ($debug);
my $update = 0;
my $sqlWhere = '';
if ( $persistent == 0 ) {
if ( $problemSolved ) {
if ($solvedTimeslot > $activationTimeslot and ! $downtime) {
$sqlWhere = ' and persistent="0" and "' .$solvedTimeslot. '">activationTimeslot';
$update = 1;
}
} elsif ($number == 1) {
if ($activationTimeslot != 9999999999 and $suspentionTimeslotPersistentFalse != 0) {
if ($suspentionTimeslotPersistentFalse < $solvedTimeslot) {
$sqlWhere = ' and persistent="0" and "' .$solvedTimeslot. '">suspentionTimeslot';
$update = 1;
}
}
}
} elsif ( $persistent == 1 ) {
if ($number == 1) {
if ($activationTimeslot != 9999999999 and $suspentionTimeslotPersistentTrue != 0) {
if ($suspentionTimeslotPersistentTrue < $solvedTimeslot) {
$sqlWhere = ' and persistent="1" and "' .$solvedTimeslot. '">suspentionTimeslot';
$update = 1;
}
}
}
}
if ($update and $instability == 0) {
my $sql = 'UPDATE ' .$SERVERTABLCOMMENTS. ' SET replicationStatus="U", problemSolved="1", solvedDate="' .$solvedDate. '", solvedTime="' .$solvedTime. '", solvedTimeslot="' .$solvedTimeslot. '" where catalogID="' .$catalogID. '" and uKey="' .$...
$dbh->do ( $sql ) or $rv = errorTrapDBI($checklist, "Cannot dbh->do: $sql");
}
}
if ( $number == 2 ) {
if ( $playSoundInProgress ) {
$playSoundPreviousStatus = $ERRORS{$status};
} else {
$playSoundSet = 1;
}
} elsif ( $number == 3 and $playSoundInProgress ) {
$playSoundSet = 1;
}
if ( $playSoundSet ) {
$playSoundSet = 0;
if ( ( $ERRORS{$status} == $ERRORS{OK} or ( $ERRORS{$status} >= $ERRORS{DEPENDENT} and $ERRORS{$status} != $ERRORS{'NO DATA'} and $ERRORS{$status} != $ERRORS{TRENDLINE} ) ) and ( ( $playSoundPreviousStatus >= $ERRORS{WARNING} and $playSoundPrev...
if ( defined $tableSoundStatusCache { $catalogID_uniqueKey } ) {
if ( $tableSoundStatusCache { $catalogID_uniqueKey } ne $timeslot ) {
$playSoundStatus = ($playSoundStatus > $playSoundPreviousStatus) ? $playSoundStatus : $playSoundPreviousStatus;
$tableSoundStatusCache { $catalogID_uniqueKey } = $timeslot;
$debugInfo .= "$playSoundStatus-" if ($debug);
$boldStart = "<b>["; $boldEnd = "]</b>";
} else {
$debugInfo .= "C-" if ($debug);
}
} else {
$playSoundStatus = ($playSoundStatus > $playSoundPreviousStatus) ? $playSoundStatus : $playSoundPreviousStatus;
( run in 0.677 second using v1.01-cache-2.11-cpan-39bf76dae61 )