ASNMTAP

 view release on metacpan or  search on metacpan

applications/display.pl  view on Meta::CPAN

          $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 );

applications/display.pl  view on Meta::CPAN

        $$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(@_);



( run in 1.075 second using v1.01-cache-2.11-cpan-437f7b0c052 )