view release on metacpan or search on metacpan
Makefile.PL view on Meta::CPAN
if ( $prompt ) {
ExtUtils::MakeMaker::prompt( $intro . "Press <enter> to see the detailed list." );
} else {
print "These are the modules that will get installed:\n\n";
}
# This hash will contain a list of all perl modules we would like to explicitly depend upon in our Makefile
my %PREREQ_PM;
# Maintains a cache of what 3rd party modules you have installed
sub has_module {
my ($module, $version) = @_;
$version ||= '';
return ( ( $version =~ /^\*\d{2,2}(?:\d{2,2}(?:\d{2,2})?)?$/ ) ? 2 : ( $has_module_cache { "$module$version" } ||= eval ( "require $module; Exporter::require_version ( '$module', $version ) if ( $version ); 1" ) ) );
}
# Print a single prerequisite to the screen
sub generate_PREREQ_PM {
my ($feature, $dependency, $modules, $install) = @_;
my $buffer;
my $i = 0;
foreach (keys %$modules) {
my $detected = has_module ( $_, $modules->{$_} );
$buffer .= sprintf ( "%-24s [%s] %-32s %-8s\n", ( $i++ ? '' : $feature), ($detected >= 2 ? '+' : ( $detected ? '*' : ' ') ), $_ . ( $modules->{ $_ } and $modules->{ $_ } !~ /^\*\d{2,2}(?:\d{2,2}(?:\d{2,2})?)?$/ ? " (v$modules->{$_})" : '' ), ( $i...
}
return $buffer;
}
# Print the entire prerequisites table
sub generate_PREREQ_PM_table {
my $buffer = sprintf ( "%-24s %-36s %-8s\n", 'Feature', 'Prerequisites', 'Install?' );
$buffer .= sprintf ( "%s %s %s\n","-" x 24,"-" x 36,"-" x 8 );
foreach my $prerequisites ( @prerequisites ) { $buffer .= generate_PREREQ_PM ( @$prerequisites[1..4] ); }
$buffer .= "\n<- An asterix [*] indicates if the module is currently installed.\n";
return $buffer;
}
# Update the entire prerequisites table
sub update_prerequisites_table {
my ($u_level, $u_default) = @_;
return if ( $u_default > 2 );
my ($action, $u1, $u2, $u3);
($u1, $u2, $u3) = $u_level =~ /^\*(\d{2,2})(?:(\d{2,2})(\d{2,2})?)?$/;
if ( defined $u3 ) {
return unless ( $u_default ); $action = 3;
} elsif ( defined $u2 ) {
Makefile.PL view on Meta::CPAN
# 'dist' => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', PREOP => q{$(PERLRUN) -MExtUtils::Autoconf -e'ExtUtils::Autoconf->run_autogen'} },
);
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
package MY;
# What happens when we say 'make ...' - - - - - - - - - - - - - - - - - -
# sub postamble {
# return <<"EOM";
# autogen :
# \t\$(PERLRUN) -MExtUtils::Autoconf -e 'ExtUtils::Autoconf->run_autogen'
# configure :
# \t\$(PERLRUN) -MExtUtils::Autoconf -e'ExtUtils::Autoconf->run_configure'
# autoclean :
# \t\$(PERLRUN) -MExtUtils::Autoconf -e'ExtUtils::Autoconf->run_realclean'
# realclean purge ::
# \t\$(PERLRUN) -MExtUtils::Autoconf -e 'ExtUtils::Autoconf->run_realclean'
# clean ::
# \t\$(PERLRUN) -MExtUtils::Autoconf -e 'ExtUtils::Autoconf->run_clean'
# EOM
# }
# What happens when we say 'make test' - - - - - - - - - - - - - - - - -
sub test {
q(
TEST_VERBOSE=0
test: all
$(FULLPERL) t/TEST $(TEST_VERBOSE)
);
}
# Determine things that should *not* be installed - - - - - - - - - - - -
sub libscan {
my ($self, $path) = @_;
return '' if $path =~ m:\betc\/:;
return '' if $path =~ m:\busr\/:;
return '' if $path =~ m:\bCVS\/:;
$path;
}
# Pass ASNMTAP version number to pod2man - - - - - - - - - - - - - - - -
sub manifypods {
my $self = shift;
my $version = $self->{VERSION} || $VERSION;
local ($_) = $self->SUPER::manifypods(@_);
s/pod2man\s*$/pod2man --release ASNMTAP-$version/m;
$_;
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
applications/archive.pl view on Meta::CPAN
my ( $week, $year ) = get_week('yesterday');
( $year, my $month, my $day ) = Monday_of_Week($week, $year);
my $firstDayOfWeekEpoch = Date_to_Time ($year, $month, $day, 0, 0, 0); # First day current week epoch date
my $yesterdayEpoch = get_epoch ('yesterday'); # Yesterday epoch date
my $currentEpoch = get_epoch ('today'); # time() or Current epoch date
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub print_help ();
sub print_usage ();
Getopt::Long::Configure('bundling');
GetOptions (
"A:s" => \$opt_A, "archivelist:s" => \$opt_A,
"c:s" => \$opt_c, "cgisess:s" => \$opt_c,
"r:s" => \$opt_r, "reports:s" => \$opt_r,
"d:s" => \$opt_d, "database:s" => \$opt_d,
"y:s" => \$opt_y, "yearsago:s" => \$opt_y,
"f:s" => \$opt_f, "force:s" => \$opt_f,
applications/archive.pl view on Meta::CPAN
}
} else {
print "Cannot open $emailReport to print email report information\n";
}
my ($rc) = send_email_report (*EMAILREPORT, $emailReport, $rvOpen, $prgtext, $debug);
exit;
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub archiveCommentsAndEventsTables {
my ($eventsAgo, $commentsAgo) = @_;
print EMAILREPORT "\nArchive '$SERVERTABLCOMMENTS' and '$SERVERTABLEVENTS' tables:\n--------------------------------------------------\n" unless ( $debug );
# Init parameters
my ($rv, $dbh, $sth, $sql, $year, $month, $day, $timeslot, $yearMOVE, $monthMOVE, $sqlMOVE, $sqlUPDATE);
$rv = 1;
$dbh = DBI->connect("dbi:mysql:$DATABASE:$SERVERNAMEREADWRITE:$SERVERPORTREADWRITE", "$SERVERUSERREADWRITE", "$SERVERPASSREADWRITE" ) or $rv = errorTrapDBI("Cannot connect to the database", $debug);
applications/archive.pl view on Meta::CPAN
print "$sqlUPDATE\n" if ($debug);
$dbh->do ( $sqlUPDATE ) or $rv = errorTrapDBI("Cannot dbh->do: $sqlUPDATE", $debug) unless ( $debug );
$dbh->disconnect or $rv = errorTrapDBI("Sorry, the database was unable to add your entry.", $debug);
}
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub checkTableDBI {
my ($dbh, $database, $table, $op, $msg_type, $msg_text) = @_;
print "-> <$database.$table>, <$op>, <$msg_type>, <$msg_text>\n" if ($debug);
my ($Table, $Op, $Msg_type, $Msg_text) = '';
my $rv = 1;
my $sql = "check table $table";
my $sth = $dbh->prepare($sql) or $rv = errorTrapDBI("dbh->prepare: $sql", $debug);
$rv = $sth->execute() or $rv = errorTrapDBI("sth->execute: $sql", $debug) if $rv;
applications/archive.pl view on Meta::CPAN
$sth->finish() or $rv = errorTrapDBI("sth->finish", $debug);
$rv = ($rv and "$database.$table" eq $Table and $op eq $Op and $msg_type eq $Msg_type and $msg_text eq $Msg_text) ? 1 : 0;
}
return ($rv);
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub createCommentsAndEventsArchiveTables {
my ($daysBefore) = @_;
print EMAILREPORT "\nCreate '$SERVERTABLCOMMENTS' and '$SERVERTABLEVENTS' tables when needed:\n--------------------------------------------------\n" unless ( $debug );
# Init parameters
my ($rv, $dbh, $sql, $year, $month);
$year = get_year ($daysBefore);
$rv = 1;
$dbh = DBI->connect("dbi:mysql:$DATABASE:$SERVERNAMEREADWRITE:$SERVERPORTREADWRITE", "$SERVERUSERREADWRITE", "$SERVERPASSREADWRITE" ) or $rv = errorTrapDBI("Cannot connect to the database", $debug);
applications/archive.pl view on Meta::CPAN
} else {
print "Table: '$SERVERTABLCOMMENTS', Year: '$year', Status: ALREADY CREATED\n\n" if ($debug);
}
$dbh->disconnect or $rv = errorTrapDBI("Sorry, the database was unable to add your entry.", $debug);
}
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub doBackupCsvSqlErrorWeekDebugReport {
my ($RESULTSPATH, $DEBUGDIR, $REPORTDIR, $gzipEpoch, $removeAllNokEpoch, $removeGzipEpoch, $removeDebugEpoch, $removeReportsEpoch, $removeWeeksEpoch, $firstDayOfWeekEpoch, $yesterdayEpoch, $currentEpoch) = @_;
print EMAILREPORT "\nDo backup, csv, sql, error, week, and debug files:\n--------------------------------------------------\n" unless ( $debug );
my ($darchivelist, $dtest, $pagedir, $ttest, $command, $rvOpendir, $path, $filename, $debugPath, $debugFilename, $reportPath, $reportFilename, $weekFilename);
my @files = ();
foreach $darchivelist (@archivelisttable) {
($pagedir, $ttest) = split(/\#/, $darchivelist, 2);
my @stest = split(/\|/, $ttest);
applications/archive.pl view on Meta::CPAN
print "Filename : <$filename>\n" if ($debug >= 2);
catAllCsvFilesYesterdayWeek ($firstDayOfWeekEpoch, $yesterdayEpoch, $catalogID_uKey, $command, $path, $weekFilename, $filename);
removeAllNokgzipCsvSqlErrorWeekFilesOlderThenAndMoveToBackupShare ($gzipEpoch, $removeAllNokEpoch, $removeGzipEpoch, $removeDebugEpoch, $removeWeeksEpoch, $catalogID_uKey, $command, $path, $filename);
}
}
}
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub removeAllNokgzipCsvSqlErrorWeekFilesOlderThenAndMoveToBackupShare {
my ($gzipEpoch, $removeAllNokEpoch, $removeGzipEpoch, $removeDebugEpoch, $removeWeeksEpoch, $catalogID_uKey, $command, $path, $filename) = @_;
my ($datum, $staart) = split(/\-/, $filename, 2);
if ( $staart ) {
if ( $staart eq "all.txt" ) {
if ($datum le get_yearMonthDay($removeAllNokEpoch)) {
if ($debug) {
print "A- <$datum><", get_yearMonthDay($removeAllNokEpoch), "><$path><$filename>\n";
} else {
applications/archive.pl view on Meta::CPAN
print EMAILREPORT "N- <$datum><", get_yearMonthDay($removeAllNokEpoch), "> unlink <$path><$filename>\n";
unlink ($path.'/'.$filename);
}
}
}
}
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub catAllCsvFilesYesterdayWeek {
my ($firstDayOfWeekEpoch, $yesterdayEpoch, $catalogID_uKey, $command, $path, $weekFilename, $filename) = @_;
for (my $loop = $firstDayOfWeekEpoch; $loop <= $yesterdayEpoch; $loop += 86400) {
if ($filename eq get_yearMonthDay($loop)."-$command-$catalogID_uKey-csv.txt") {
my $rvOpen = open(CAT, ">>$path/$weekFilename");
if ($rvOpen) {
$rvOpen = open(CSV, "$path/$filename");
if ($rvOpen) {
applications/archive.pl view on Meta::CPAN
close(CAT);
} else {
print "Cannot open $filename!\n";
}
}
}
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub gzipOrRemoveHttpDumpDebug {
my ($gzipDebugEpoch, $removeDebugEpoch, $debugPath, $debugFilename) = @_;
my ($suffix, $extentie, $datum, $restant);
print "<$debugFilename>\n" if ($debug);
my $_debugFilename = reverse $debugFilename;
my ($_suffix, $_extentie) = reverse split(/\./, $_debugFilename, 2);
$suffix = reverse $_suffix;
$extentie = reverse $_extentie;
applications/archive.pl view on Meta::CPAN
unlink ($debugPath.'/'.$debugFilename);
}
}
}
}
}
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub removeCgisessFiles {
my ($removeCgisessEpoch) = @_;
my $emailreport = "\nRemove cgisess files:\n---------------------\n";
if ( $debug ) { print "$emailreport"; } else { print EMAILREPORT "$emailreport"; }
my @cgisessPathFilenames = glob("$CGISESSPATH/cgisess_*");
foreach my $cgisessPathFilename (@cgisessPathFilenames) {
my (undef, $cgisessFilename) = split (/^$CGISESSPATH\//, $cgisessPathFilename);
my (undef, $sessionID) = split (/^cgisess_/, $cgisessFilename);
applications/archive.pl view on Meta::CPAN
} else {
print "CS-<$cgisessPathFilename> ASNMTAP not LEXY>\n" if ($debug >= 2);
}
}
}
}
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub removeOldReportFiles {
my ($removeReportsEpoch, $removeGzipEpoch, $reportPath, $reportFilename) = @_;
my ($suffix, $prefix, $datum, $plugin, $restant, $extentie);
($suffix, $prefix) = split(/\.pl/, $reportFilename, 2);
($datum, $plugin) = split(/\-/, $suffix, 2) if (defined $suffix);
($restant, $extentie) = split(/\./, $prefix, 2) if (defined $prefix);
if ($debug) {
print "<$reportFilename>";
applications/archive.pl view on Meta::CPAN
unlink ($reportPath.'/'.$reportFilename);
}
}
}
}
}
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub errorTrapDBI {
my ($error_message, $debug) = @_;
print EMAILREPORT " DBI Error:\n", $error_message, "\nERROR: $DBI::err ($DBI::errstr)\n";
return 0;
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub print_usage () {
print "Usage: $PROGNAME [-A <archivelist>] [-c F|T] [-r F|T] [-d F|T] [-y <years ago>] [-f F|T] [-D <debug>] [-V version] [-h help]\n";
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub print_help () {
print_revision($PROGNAME, $version);
print "ASNMTAP Archiver for the '$APPLICATION'
-A, --archivelist=<filename>
FILENAME : filename from the archivelist for the html output loop (default undef)
-c, --cgisess=F|T
F(alse) : don't remove the cgisess files
T(true) : remove the cgisess files (default)
-r, --reports=F|T
F(alse) : don't backup Csv, Sql, Error, Week, Debug reports
applications/bin/generateCollectorDaemonSchedulingReports.pl view on Meta::CPAN
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
my $debug = 0; # default
my $currentYear = sprintf ("%04d", (localtime)[5]+1900 ); # default
my $currentMonth= sprintf ("%02d", ((localtime)[4])+1 ); # default
my $currentDay = sprintf ("%02d", ((localtime)[3]) ); # default
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub print_help ();
sub print_usage ();
Getopt::Long::Configure('bundling');
GetOptions (
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
"D:s" => \$opt_D, "debug:s" => \$opt_D,
"V" => \$opt_V, "version" => \$opt_V,
"h" => \$opt_h, "help" => \$opt_h
);
applications/bin/generateCollectorDaemonSchedulingReports.pl view on Meta::CPAN
if ( $debug ) { print $emailMessage; } else { print EMAILREPORT $emailMessage; }
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
my ($rc) = send_email_report (*EMAILREPORT, $emailReport, $rvOpen, $prgtext, $debug);
exit;
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub create_dir {
my ($directory) = @_;
unless ( -e "$directory" ) { # create $directory
my ($status, $stdout, $stderr) = call_system ("mkdir $directory", $debug);
if (!$status and ($stdout ne '' or $stderr ne '')) {
my $error = " > create_dir: mkdir $directory: status: $status, stdout: $stdout, stderr: $stderr\n";
if ( $debug ) { print $error; } else { print EMAILREPORT $error; }
}
}
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub print_usage () {
print "Usage: $PROGNAME [-D <debug>] [-V version] [-h help]\n";
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub print_help () {
print_revision($PROGNAME, $version);
print "ASNMTAP Generate Collector Daemon Scheduling Reports for the '$APPLICATION'
-D, --debug=F|T|L
F(alse) : screendebugging off (default)
T(true) : normal screendebugging on
L(ong) : long screendebugging on
-V, --version
-h, --help
applications/bin/generateReports.pl view on Meta::CPAN
my $debug = 0; # default
my $daysAfter = 3; # default
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
my ($currentYear, $currentMonth, $currentDay) = ( ((localtime)[5] + 1900), ((localtime)[4] + 1), (localtime)[3] );
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub print_help ();
sub print_usage ();
Getopt::Long::Configure('bundling');
GetOptions (
"y:s" => \$opt_y, "year:s" => \$opt_y,
"m:s" => \$opt_m, "month:s" => \$opt_m,
"d:s" => \$opt_d, "day:s" => \$opt_d,
"a:s" => \$opt_a, "daysAfter:s" => \$opt_a,
"u:s" => \$opt_u, "ukey:s" => \$opt_u,
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
applications/bin/generateReports.pl view on Meta::CPAN
}
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
my ($rc) = send_email_report (*EMAILREPORT, $emailReport, $rvOpen, $prgtext, $debug);
exit;
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub create_dir {
my ($directory) = @_;
unless ( -e "$directory" ) { # create $directory
my ($status, $stdout, $stderr) = call_system ("mkdir $directory", $debug);
if (!$status and ($stdout ne '' or $stderr ne '')) {
my $error = " > create_dir: mkdir $directory: status: $status, stdout: $stdout, stderr: $stderr\n";
if ( $debug ) { print $error; } else { print EMAILREPORT $error; }
}
}
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub print_usage () {
print "Usage: $PROGNAME [-y <year>] [-m <month>] [-d <day>] [-a <days after>] [-u <uKey>] [-D <debug>] [-V version] [-h help]\n";
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub print_help () {
print_revision($PROGNAME, $version);
print "ASNMTAP Generate Reports for the '$APPLICATION'
-y, --year=<year> (default: current year)
-m, --month=<month> (default: current month)
-d, --day=<day> (default: current day)
-a, --daysAfter=<days after|F(alse)> (default: 3)
-u, --uKey=<uKey plugin> (default: all plugins)
-D, --debug=F|T|L
F(alse) : screendebugging off (default)
applications/bin/holidayBundleSetDowntimes.pl view on Meta::CPAN
my $prgtext = "Set Holiday Bundle Downtimes for the '$APPLICATION'";
my $version = do { my @r = (q$Revision: 3.002.003$ =~ /\d+/g); sprintf "%d."."%03d" x $#r, @r }; # must be all on one line or MakeMaker will get confused.
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
my $debug = 0; # default
my $daysBefore = 3;
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub print_help ();
sub print_usage ();
Getopt::Long::Configure('bundling');
GetOptions (
"D:s" => \$opt_D, "debug:s" => \$opt_D,
"V" => \$opt_V, "version" => \$opt_V,
"h" => \$opt_h, "help" => \$opt_h
);
if ($opt_V) { print_revision($PROGNAME, $version); exit $ERRORS{OK}; }
applications/bin/holidayBundleSetDowntimes.pl view on Meta::CPAN
$dbh->disconnect or $rv = DBI_error_trap(*EMAILREPORT, "Sorry, the database was unable to add your entry.", \$logger, $debug);
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
my ($rc) = send_email_report (*EMAILREPORT, $emailReport, $rvOpen, $prgtext, $debug);
exit;
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub print_usage () {
print "Usage: $PROGNAME [-D <debug>] [-V version] [-h help]\n";
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub print_help () {
print_revision($PROGNAME, $version);
print "ASNMTAP Set Holiday Bundle Downtimes for the '$APPLICATION'
-D, --debug=F|T|L
F(alse) : screendebugging off (default)
T(true) : normal screendebugging on
L(ong) : long screendebugging on
-V, --version
-h, --help
applications/bin/importDataThroughCatalog.pl view on Meta::CPAN
my $boolean_screenDebug = 0; # default 0
my $boolean_debug_all = 0; # default 0
my $boolean_debug_NOK = 0; # default 0
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
my $booleanQuit = 0;
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub print_help ();
sub print_usage ();
Getopt::Long::Configure('bundling');
GetOptions (
"T:s" => \$opt_T, "type:s" => \$opt_T,
"M=s" => \$opt_M, "mode=s" => \$opt_M,
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
"D:s" => \$opt_D, "debug:s" => \$opt_D,
"V" => \$opt_V, "version" => \$opt_V,
"h" => \$opt_h, "help" => \$opt_h
applications/bin/importDataThroughCatalog.pl view on Meta::CPAN
printDebugAll ("Start collector - : <$mode> <$PROGNAME v$version");
do_importDataThroughCatalog ();
printDebugAll ("Einde collector - : <$mode> <$PROGNAME v$version") if ($debug eq 'T');
my ($rc) = send_email_report (*EMAILREPORT, $emailReport, $rvOpen, $prgtext, $debug);
}
exit;
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub signal_DIE {
# printDebugAll ("kill -DIE <$PROGNAME v$version pid: <$pidfile>");
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub signal_WARN {
# printDebugAll ("kill -WARN <$PROGNAME v$version pid: <$pidfile>");
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub signalQUIT {
printDebugAll ("kill -QUIT <$PROGNAME v$version pid: <$pidfile>");
printDebugAll (" Wait until next timeslot");
my ($prevSecs, $currSecs);
$currSecs = int((localtime)[0]);
do {
sleep 1;
$prevSecs = $currSecs;
$currSecs = int((localtime)[0]);
applications/bin/importDataThroughCatalog.pl view on Meta::CPAN
use Sys::Hostname;
my $subject = "$prgtext\@". hostname() .": import data through catalog successfully stopped at ". get_datetimeSignal();
my $returnCode = sending_mail ( $SERVERLISTSMTP, $SENDEMAILTO, $SENDMAILFROM, $subject, $subject ."\n", 0 );
print "Problem sending email to the '$APPLICATION' server administrators\n" unless ( $returnCode );
exit 1;
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub signalHUP {
printDebugAll ("kill -HUP <$PROGNAME v$version pid: <$pidfile>");
$boolean_signal_hup = 1;
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub write_pid {
printDebugAll ("write PID <$PROGNAME v$version pid: <$pidfile>");
if (-e "$pidfile") {
printDebugAll ("ERROR: couldn't create pid file <$pidfile> for <$PROGNAME v$version>");
print "ERROR: couldn't create pid file <$pidfile> for <$PROGNAME v$version>\n";
exit 0;
} else {
open(PID,">$pidfile") || die "Cannot open $pidfile!!\n";
print PID $$;
close(PID);
}
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub printDebugAll {
my ($l_text) = @_;
if ($boolean_screenDebug or $boolean_debug_all) {
chomp ($l_text);
my $date = scalar(localtime());
my $tlogging = $logging .'importDataThroughCatalog'. get_logfiledate();
print "$l_text $date\n" if ( $boolean_screenDebug );
if ($boolean_debug_all and $logging ne '<NIHIL>') {
applications/bin/importDataThroughCatalog.pl view on Meta::CPAN
close(ALLDEBUG);
} else {
print "Cannot open $tlogging-all.txt to print debug information\n";
}
}
}
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub printDebugNOK {
my ($l_text) = @_;
if ($boolean_debug_NOK and $logging ne '<NIHIL>') {
chomp ($l_text);
my $date = scalar(localtime());
my $tlogging = $logging .'importDataThroughCatalog'. get_logfiledate();
my $rvOpen = open(NOKDEBUG,">>$tlogging-nok.txt");
if ($rvOpen) {
print NOKDEBUG "$l_text $date\n";
close(NOKDEBUG);
} else {
print "Cannot open $tlogging-nok.txt to print debug information\n";
}
}
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub do_importDataThroughCatalog {
printDebugAll (" IN: do_importDataThroughCatalog <$PROGNAME v$version pid: <$pidfile>");
($dbh, $rv, $alarmMessage) = DBI_connect ( $DATABASE, $SERVERNAMEREADWRITE, $SERVERPORTREADWRITE, $SERVERUSERREADWRITE, $SERVERPASSREADWRITE, $alarm, \&DBI_error_trap, [*EMAILREPORT, "Cannot connect to the database"], \$logger, $debug, $boolean_deb...
if ($dbh and $rv) {
my ($catalogID, $catalogType, $databaseFQDN, $databasePort);
$sql = "select catalogID, catalogType, databaseFQDN, databasePort from $SERVERTABLCATALOG where catalogID <> '$CATALOGID' and catalogType <> 'central' and activated = '1'";
$sth = $dbh->prepare( $sql ) or $rv = DBI_error_trap(*EMAILREPORT, "Cannot dbh->prepare: $sql", \$logger, $debug);
($rv, undef) = DBI_execute ($rv, \$sth, $alarm, \&DBI_error_trap, [*EMAILREPORT, "Cannot sth->execute: $sql"], \$logger, $debug);
$sth->bind_columns( \$catalogID, \$catalogType, \$databaseFQDN, \$databasePort ) or $rv = DBI_error_trap(*EMAILREPORT, "Cannot sth->bind_columns: $sql", \$logger, $debug) if $rv;
applications/bin/importDataThroughCatalog.pl view on Meta::CPAN
}
$dbh->disconnect or $rv = DBI_error_trap(*EMAILREPORT, "Sorry, the database was unable to add your entry.", \$logger, $debug);
}
printDebugAll ("OUT: do_importDataThroughCatalog <$PROGNAME v$version pid: <$pidfile>");
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub importData {
my ($EMAILREPORT, $dbhSOURCE, $dbh, $replicationStatus, $table, $whereCLAUSE, @primaryKeys) = @_;
printDebugAll (" IN: importData <$PROGNAME v$version pid: <$pidfile>: $replicationStatus, $table, $whereCLAUSE, @primaryKeys");
print $EMAILREPORT " - importData: $replicationStatus, $table, $whereCLAUSE, @primaryKeys\n" unless ($debug);
my $sqlSOURCE = "select * from `$table` where $whereCLAUSE limit $limit";
print "+ $sqlSOURCE\n" if ($debug);
my $sthSOURCE = $dbhSOURCE->prepare( $sqlSOURCE ) or $rv = DBI_error_trap(*EMAILREPORT, "Cannot dbhSOURCE->prepare: $sqlSOURCE", \$logger, $debug);
($rv, undef) = DBI_execute ($rv, \$sthSOURCE, $alarm, \&DBI_error_trap, [*EMAILREPORT, "Cannot sthSOURCE->execute: $sqlSOURCE"], \$logger, $debug);
applications/bin/importDataThroughCatalog.pl view on Meta::CPAN
$sthSOURCE->finish() or $rv = DBI_error_trap(*EMAILREPORT, "Cannot sthSOURCE->finish: $sqlSOURCE", \$logger, $debug);
}
print $EMAILREPORT " ERROR: DBH/STH\n" unless ($debug or $rv);
printDebugAll (" OUT: importData <$PROGNAME v$version pid: <$pidfile>");
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub print_usage () {
print "Usage: $PROGNAME [-T <CONFIG|DATA|ALL>] [-D <debug>] [-V version] [-h help]\n";
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub print_help () {
print_revision($PROGNAME, $version);
print "ASNMTAP Import Data Through Catalog for the '$APPLICATION'
-T, --type=<CONFIG|DATA|ALL> (default: current ALL)
-M, --mode=O|D
O(nce) : run the program once
D(aemon) : run the program as a loop
-D, --debug=F|T|L
F(alse) : screendebugging off (default)
T(true) : normal screendebugging on
applications/collector-test.pl view on Meta::CPAN
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
my $boolean_loopQuit = 0;
my ($directory, $action, $dproc, $dcron);
my ($tmin, $thour, $tmday, $tmon, $twday, $tinterval, $tcommand);
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub print_help ();
sub print_usage ();
Getopt::Long::Configure('bundling');
GetOptions (
"H=s" => \$opt_H, "hostname=s" => \$opt_H,
"M=s" => \$opt_M, "mode=s" => \$opt_M,
"C=s" => \$opt_C, "collectorlist=s" => \$opt_C,
"W:s" => \$opt_W, "screenDebug:s" => \$opt_W,
"A:s" => \$opt_A, "allDebug:s" => \$opt_A,
"N:s" => \$opt_N, "nokDebug:s" => \$opt_N,
applications/collector-test.pl view on Meta::CPAN
}
printDebugAll ("Einde collector - : <$mode> <$PROGNAME v$version -C $collectorlist>") if ($debug eq 'T');
} until ($boolean_loopQuit);
}
exit;
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub resultsdirCreate {
foreach $dcron (@crontabtable) {
(undef, undef, undef, undef, undef, undef, $tcommand) = split(/ +/, $dcron, 7);
my @scommand = split(/\|/, $tcommand);
foreach my $dcommand (@scommand) {
my (undef, $resultsdir, undef, undef, undef) = split(/\#/, $dcommand);
$logging = $RESULTSPATH .'/'. $resultsdir;
create_dir ($logging);
applications/collector-test.pl view on Meta::CPAN
$httpdump .= "/";
create_header ($httpdump."HEADER.html");
create_footer ($httpdump."FOOTER.html");
}
}
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub do_crontab {
my $currentDate = time();
my ($min, $hour, $mday, $mon, $wday) = ((localtime($currentDate))[1,2,3], (localtime($currentDate))[4]+1, (localtime($currentDate))[6]);
foreach $dcron (@crontabtable) {
($tmin, $thour, $tmday, $tmon, $twday, $tinterval, $tcommand) = split(/ +/, $dcron, 7);
my ($doIt, $doOffline) = set_doIt_and_doOffline ($min, $hour, $mday, $mon, $wday, $tmin, $thour, $tmday, $tmon, $twday);
if ( $doIt || $doOffline ) {
printDebugAll ("Start CollectorCT - : <$PROGNAME v$version -C $collectorlist> pid: <$pidfile>");
my @scommand = split(/\|/, $tcommand);
applications/collector-test.pl view on Meta::CPAN
do {
sleep 5;
$prevSecs = $currSecs;
$currSecs = int((localtime)[0]);
} until ($currSecs < $prevSecs);
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub signal_DIE {
# printDebugAll ("kill -DIE <$PROGNAME v$version -C $collectorlist> pid: <$pidfile>");
# if ( $DBI_CONNECT_ALARM_OFF or $! =~ /\QDBI_CONNECT_ALARM_OFF = \E(\d*)\Q\n\E/ or $@ =~ /\QDBI_CONNECT_ALARM_OFF = \E(\d*)\Q\n\E/ ) {
# print "DBI_CONNECT_ALARM_OFF\n";
# } elsif ( $DBI_EXECUTE_ALARM_OFF or $! =~ /\QDBI_EXECUTE_ALARM_OFF = \E(\d*)\Q\n\E/ or $@ =~ /\QDBI_EXECUTE_ALARM_OFF = \E(\d*)\Q\n\E/ ) {
# print "DBI_EXECUTE_ALARM_OFF\n";
# } else {
# print "DBI_xxx_ALARM_OFF\n";
# }
applications/collector-test.pl view on Meta::CPAN
# }
#
# $Log::Log4perl::caller_depth++;
# my $logger = get_logger("");
# $logger->fatal(@_);
# die @_; # Now terminate really
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub signal_WARN {
# printDebugAll ("kill -WARN <$PROGNAME v$version -C $collectorlist> pid: <$pidfile>");
if ( $CHILD_OFF or $! =~ /\QASNMTAP::Asnmtap::Applications::Collector::CHILD_OFF = \E(\d*)\Q\n\E/ or $@ =~ /\QASNMTAP::Asnmtap::Applications::Collector::CHILD_OFF = \E(\d*)\Q\n\E/ ) {
my $alarm = ( ( defined $CHILD_OFF and $CHILD_OFF ) ? $CHILD_OFF : $1 );
if ( defined $alarm ) {
use Proc::ProcessTable;
my $t = new Proc::ProcessTable;
foreach my $process ( @{$t->table} ) {
applications/collector-test.pl view on Meta::CPAN
$boolean_signal_kill = 1;
printDebugAll ("kill -9 <$PROGNAME v$version -C $collectorlist> pid: <". $process->pid ."> ppid: <$$>");
}
}
}
}
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub signalQUIT {
printDebugAll ("kill -QUIT <$PROGNAME v$version -C $collectorlist> pid: <$pidfile>");
printDebugAll (" Wait until next timeslot");
my ($prevSecs, $currSecs);
$currSecs = int((localtime)[0]);
do {
sleep 1;
$prevSecs = $currSecs;
$currSecs = int((localtime)[0]);
applications/collector-test.pl view on Meta::CPAN
use Sys::Hostname;
my $subject = "$prgtext\@". hostname() .": Config $APPLICATIONPATH/etc/$collectorlist successfully stopped at ". get_datetimeSignal();
my $returnCode = sending_mail ( $SERVERLISTSMTP, $SENDEMAILTO, $SENDMAILFROM, $subject, $subject ."\n", 0 );
print "Problem sending email to the '$APPLICATION' server administrators\n" unless ( $returnCode );
exit 1;
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub signalHUP {
printDebugAll ("kill -HUP <$PROGNAME v$version -C $collectorlist> pid: <$pidfile>");
$boolean_signal_hup = 1;
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub write_pid {
printDebugAll ("write PID <$PROGNAME v$version -C $collectorlist> pid: <$pidfile>");
if (-e "$pidfile") {
printDebugAll ("ERROR: couldn't create pid file <$pidfile> for <$PROGNAME v$version -C $collectorlist>");
print "ERROR: couldn't create pid file <$pidfile> for <$PROGNAME v$version -C $collectorlist>\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 ($systemAction, $stdout, $stderr, $exit_value, $signal_num, $dumped_core);
$systemAction = "mkdir $directory";
if ($CAPTUREOUTPUT) {
use IO::CaptureOutput qw(capture_exec);
($stdout, $stderr) = capture_exec("$systemAction");
} else {
applications/collector-test.pl view on Meta::CPAN
unless ( $exit_value == 0 && $signal_num == 0 && $dumped_core == 0 && $stderr eq '' ) {
printDebugAll (" create_dir ---- : mkdir $directory: <$exit_value><$signal_num><$dumped_core><$stderr>");
printDebugNOK (" create_dir ---- : mkdir $directory: <$exit_value><$signal_num><$dumped_core><$stderr>");
}
}
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub call_system {
my ($asnmtapEnv, $currentDate, $catalogID_uniqueKey, $catalogID, $uniqueKey, $resultsdir, $title, $system_action, $status, $interval, $instability, $persistent, $downtime, $debug, $dbiFilename, $logging, $httpdump, $dumphttp, $queryMySQL) = @_;
my $rvOpen;
my $action = '';
my $httpdumpFilename = '';
my $httpdumpFilenameTmp = '';
my $debugFilename = '<NIHIL>';
my $dumphttpRename = '<NIHIL>';
my ($stdout, $stderr, $exit_value, $signal_num, $dumped_core);
applications/collector-test.pl view on Meta::CPAN
}
$boolean_signal_kill = 0;
if (-e "$PLUGINPATH/$msgCommand.pl") {
my $systemAction = "cd $PLUGINPATH; ./$system_action --status=$status --debug=$debug --logging=$logging --asnmtapEnv='$asnmtapEnv'";
$systemAction .= " --dumphttp=$httpdumpFilenameTmp" if ($dumphttp ne 'N');
my $_handler = $SIG{ALRM};
my $alarm = $interval * 60;
$SIG{ALRM} = sub { $CHILD_OFF = $alarm; warn "ASNMTAP::Asnmtap::Applications::Collector::CHILD_OFF = $alarm\n" };
alarm ( $alarm );
if ($CAPTUREOUTPUT) {
use IO::CaptureOutput qw(capture_exec);
($stdout, $stderr) = capture_exec("$systemAction");
my (@returnStatus) = split (/\n/, $stdout);
$returnStatus = $returnStatus[-1];
} else {
system ("$systemAction"); $stdout = $stderr = '';
}
applications/collector-test.pl view on Meta::CPAN
printDebugNOK (" perfParse ----- : $perfParseCommand: <$exit_value><$signal_num><$dumped_core><$stderr>") unless ( $exit_value == 0 && $signal_num == 0 && $dumped_core == 0 && $stderr eq '' );
}
}
insertEntryDBI ($currentDate, $catalogID_uniqueKey, $catalogID, $uniqueKey, $title, $dbiFilename.$msgCommand.'-'.$catalogID_uniqueKey.'-sql', $system_action, $interval, $dumphttpRename, $logging, $debug, $startDate, $startTime, $endDate, $endTime, ...
return $action;
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub printDebugAll {
my ($l_text) = @_;
if ($boolean_screenDebug or $boolean_debug_all) {
chomp ($l_text);
my $date = scalar(localtime());
my $tlogging = $logging . get_logfiledate();
print "$l_text $date\n" if ( $boolean_screenDebug );
if ($boolean_debug_all and $logging ne '<NIHIL>') {
applications/collector-test.pl view on Meta::CPAN
close(ALLDEBUG);
} else {
print "Cannot open $tlogging-all.txt to print debug information\n";
}
}
}
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub printDebugNOK {
my ($l_text) = @_;
if ($boolean_debug_NOK and $logging ne '<NIHIL>') {
chomp ($l_text);
my $date = scalar(localtime());
my $tlogging = $logging . get_logfiledate();
my $rvOpen = open(NOKDEBUG,">>$tlogging-nok.txt");
if ($rvOpen) {
print NOKDEBUG "$l_text $date\n";
close(NOKDEBUG);
} else {
print "Cannot open $tlogging-nok.txt to print debug information\n";
}
}
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub insertEntryDBI {
my ($currentDate, $catalogID_uniqueKey, $catalogID, $uniqueKey, $title, $dbiFilename, $test, $interval, $status, $logging, $debug, $startDate, $startTime, $endDate, $endTime, $duration, $statusMessage, $perfdata, $filename, $insertMySQL, $queryMySQ...
return ( 1 ) unless ( $insertMySQL );
my ($sth, $lockString, $findString, $updateString, $insertString, $flushString, $unlockString, $insertEntryDBI, $updateEntryDBI);
$insertEntryDBI = 0;
$updateEntryDBI = 0;
my ($dbh, $rv, $alarmMessage) = DBI_connect ( $DATABASE, $serverName, $SERVERPORTREADWRITE, $SERVERUSERREADWRITE, $SERVERPASSREADWRITE, $alarm, \&errorTrapDBI, [$currentDate, $catalogID_uniqueKey, $catalogID, $uniqueKey, $test, $title, $status, $st...
if ($dbh and $rv) {
applications/collector-test.pl view on Meta::CPAN
$dbh->disconnect or $rv = errorTrapDBI($currentDate, $catalogID_uniqueKey, $catalogID, $uniqueKey, $test, $title, $status, $startDate, $startTime, $endDate, $endTime, $duration, $statusMessage, $perfdata, $interval, $instability, $persistent, $do...
my $environment = (($test =~ /\-\-environment=([PASTDL])/) ? $1 : 'P');
$rv = graphEntryDBI ($catalogID, $uniqueKey, $title, $environment, $dbiFilename, $interval, 121, 6, 1, 0, get_trendline_from_test ($test), 0, $debug) if ($interval > 0);
}
return $rv;
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub errorTrapDBI {
my ($currentDate, $catalogID_uniqueKey, $catalogID, $uniqueKey, $test, $title, $status, $startDate, $startTime, $endDate, $endTime, $duration, $statusMessage, $perfdata, $interval, $instability, $persistent, $downtime, $filename, $error_message, $l...
print $error_message, "\nERROR: $DBI::err ($DBI::errstr)\n";
my $tlogging = $logging . get_logfiledate();
my ($msgCommand, undef) = split(/\.pl/, $test);
# APE # TODO - REMOVE
# my $rvOpen = open(DEBUG,">>$tlogging-$msgCommand-$catalogID_uniqueKey.sql");
applications/collector-test.pl view on Meta::CPAN
close(DEBUG);
} else {
print "Cannot open $RESULTSPATH/$collectorlist-MySQL-sql-error.txt to print debug information\n";
}
return 0;
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub errorTrapDBIdowntime {
my ($collectorlist, $error_message, $logger, $debug) = @_;
print $collectorlist, "\n", $error_message, "\nERROR: $DBI::err ($DBI::errstr)\n";
$$logger->error("$collectorlist:\n" .$error_message. "\nERROR: $DBI::err ($DBI::errstr)") if ( defined $$logger and $$logger->is_error() );
return 0;
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub graphEntryDBI {
my ($catalogID, $uniqueKey, $title, $environment, $dbiFilename, $interval, $limitTest, $xLabelStep, $withBorder, $markOrZone, $yMarkValue, $xRealtime, $debug) = @_;
$title .= ' ('. $ENVIRONMENT{$environment} .')' if (defined $environment);
$title .= ' from '. $catalogID;
# $limitTest -> 241: (120*2.0)+1, x = 2.0 -> $xLabelStep = 6 * x -> 12
# 181: (120*1.5)+1, x = 1.5 -> $xLabelStep = 6 * x -> 9
# 121: (120*1.0)+1, x = 1.0 -> $xLabelStep = 6 * x -> 6
my $width = 893;
applications/collector-test.pl view on Meta::CPAN
$c->addText($width - 18, $hight - 21, "Interval: " . $interval . " min, " . $DEPARTMENT . " @ " . $BUSINESS . ", created on: " . scalar(localtime()) . ".", "arial.ttf", 8, 0x000000, 6, 0);
#output the chart
$c->makeChart("$dbiFilename.png");
return $rv;
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub errorTrapDBIgraphEntry {
my ($error_message, $logger, $debug) = @_;
print 'errorTrapDBIgraphEntry', "\n", $error_message, "\nERROR: $DBI::err ($DBI::errstr)\n";
$$logger->error("errorTrapDBIgraphEntry:\n" .$error_message. "\nERROR: $DBI::err ($DBI::errstr)") if ( defined $$logger and $$logger->is_error() );
return 0;
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub print_usage () {
print "Usage: $PROGNAME -H <MySQL hostname> [-M <mode>] [-C <collectorlist>] [-W <screenDebug>] [-A <allDebug>] [-N <nokDebug>] [-s <dumphttp>] [-S <status>] [-D <debug>] [-V version] [-h help]\n";
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub print_help () {
print_revision($PROGNAME, $version);
print "ASNMTAP Collector for the '$APPLICATION'
-H, --hostname=<HOSTNAME>
HOSTNAME : hostname/address from the MySQL server
-M, --mode=O|L|C
O(nce) : run the program once
L(oop) : run the program as a loop
C(rontab) : run the program crontab based
-C, --collectorlist=<FILENAME>
applications/collector.pl view on Meta::CPAN
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
my $boolean_loopQuit = 0;
my ($directory, $action, $dproc, $dcron);
my ($tmin, $thour, $tmday, $tmon, $twday, $tinterval, $tcommand);
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub print_help ();
sub print_usage ();
Getopt::Long::Configure('bundling');
GetOptions (
"H=s" => \$opt_H, "hostname=s" => \$opt_H,
"M=s" => \$opt_M, "mode=s" => \$opt_M,
"C=s" => \$opt_C, "collectorlist=s" => \$opt_C,
"W:s" => \$opt_W, "screenDebug:s" => \$opt_W,
"A:s" => \$opt_A, "allDebug:s" => \$opt_A,
"N:s" => \$opt_N, "nokDebug:s" => \$opt_N,
applications/collector.pl view on Meta::CPAN
}
printDebugAll ("Einde collector - : <$mode> <$PROGNAME v$version -C $collectorlist>") if ($debug eq 'T');
} until ($boolean_loopQuit);
}
exit;
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub resultsdirCreate {
foreach $dcron (@crontabtable) {
(undef, undef, undef, undef, undef, undef, $tcommand) = split(/ +/, $dcron, 7);
my @scommand = split(/\|/, $tcommand);
foreach my $dcommand (@scommand) {
my (undef, $resultsdir, undef, undef, undef) = split(/\#/, $dcommand);
$logging = $RESULTSPATH .'/'. $resultsdir;
create_dir ($logging);
applications/collector.pl view on Meta::CPAN
$httpdump .= "/";
create_header ($httpdump."HEADER.html");
create_footer ($httpdump."FOOTER.html");
}
}
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub do_crontab {
my $currentDate = time();
my ($min, $hour, $mday, $mon, $wday) = ((localtime($currentDate))[1,2,3], (localtime($currentDate))[4]+1, (localtime($currentDate))[6]);
foreach $dcron (@crontabtable) {
($tmin, $thour, $tmday, $tmon, $twday, $tinterval, $tcommand) = split(/ +/, $dcron, 7);
my ($doIt, $doOffline) = set_doIt_and_doOffline ($min, $hour, $mday, $mon, $wday, $tmin, $thour, $tmday, $tmon, $twday);
if ( $doIt || $doOffline ) {
printDebugAll ("Start CollectorCT - : <$PROGNAME v$version -C $collectorlist> pid: <$pidfile>");
my @scommand = split(/\|/, $tcommand);
applications/collector.pl view on Meta::CPAN
do {
sleep 5;
$prevSecs = $currSecs;
$currSecs = int((localtime)[0]);
} until ($currSecs < $prevSecs);
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub signal_DIE {
# printDebugAll ("kill -DIE <$PROGNAME v$version -C $collectorlist> pid: <$pidfile>");
# if ( $DBI_CONNECT_ALARM_OFF or $! =~ /\QDBI_CONNECT_ALARM_OFF = \E(\d*)\Q\n\E/ or $@ =~ /\QDBI_CONNECT_ALARM_OFF = \E(\d*)\Q\n\E/ ) {
# print "DBI_CONNECT_ALARM_OFF\n";
# } elsif ( $DBI_EXECUTE_ALARM_OFF or $! =~ /\QDBI_EXECUTE_ALARM_OFF = \E(\d*)\Q\n\E/ or $@ =~ /\QDBI_EXECUTE_ALARM_OFF = \E(\d*)\Q\n\E/ ) {
# print "DBI_EXECUTE_ALARM_OFF\n";
# } else {
# print "DBI_xxx_ALARM_OFF\n";
# }
applications/collector.pl view on Meta::CPAN
# }
#
# $Log::Log4perl::caller_depth++;
# my $logger = get_logger("");
# $logger->fatal(@_);
# die @_; # Now terminate really
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub signal_WARN {
# printDebugAll ("kill -WARN <$PROGNAME v$version -C $collectorlist> pid: <$pidfile>");
if ( $CHILD_OFF or $! =~ /\QASNMTAP::Asnmtap::Applications::Collector::CHILD_OFF = \E(\d*)\Q\n\E/ or $@ =~ /\QASNMTAP::Asnmtap::Applications::Collector::CHILD_OFF = \E(\d*)\Q\n\E/ ) {
my $alarm = ( ( defined $CHILD_OFF and $CHILD_OFF ) ? $CHILD_OFF : $1 );
if ( defined $alarm ) {
use Proc::ProcessTable;
my $t = new Proc::ProcessTable;
foreach my $process ( @{$t->table} ) {
applications/collector.pl view on Meta::CPAN
$boolean_signal_kill = 1;
printDebugAll ("kill -9 <$PROGNAME v$version -C $collectorlist> pid: <". $process->pid ."> ppid: <$$>");
}
}
}
}
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub signalQUIT {
printDebugAll ("kill -QUIT <$PROGNAME v$version -C $collectorlist> pid: <$pidfile>");
printDebugAll (" Wait until next timeslot");
my ($prevSecs, $currSecs);
$currSecs = int((localtime)[0]);
do {
sleep 1;
$prevSecs = $currSecs;
$currSecs = int((localtime)[0]);
applications/collector.pl view on Meta::CPAN
use Sys::Hostname;
my $subject = "$prgtext\@". hostname() .": Config $APPLICATIONPATH/etc/$collectorlist successfully stopped at ". get_datetimeSignal();
my $returnCode = sending_mail ( $SERVERLISTSMTP, $SENDEMAILTO, $SENDMAILFROM, $subject, $subject ."\n", 0 );
print "Problem sending email to the '$APPLICATION' server administrators\n" unless ( $returnCode );
exit 1;
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub signalHUP {
printDebugAll ("kill -HUP <$PROGNAME v$version -C $collectorlist> pid: <$pidfile>");
$boolean_signal_hup = 1;
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub write_pid {
printDebugAll ("write PID <$PROGNAME v$version -C $collectorlist> pid: <$pidfile>");
if (-e "$pidfile") {
printDebugAll ("ERROR: couldn't create pid file <$pidfile> for <$PROGNAME v$version -C $collectorlist>");
print "ERROR: couldn't create pid file <$pidfile> for <$PROGNAME v$version -C $collectorlist>\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 ($systemAction, $stdout, $stderr, $exit_value, $signal_num, $dumped_core);
$systemAction = "mkdir $directory";
if ($CAPTUREOUTPUT) {
use IO::CaptureOutput qw(capture_exec);
($stdout, $stderr) = capture_exec("$systemAction");
} else {
applications/collector.pl view on Meta::CPAN
unless ( $exit_value == 0 && $signal_num == 0 && $dumped_core == 0 && $stderr eq '' ) {
printDebugAll (" create_dir ---- : mkdir $directory: <$exit_value><$signal_num><$dumped_core><$stderr>");
printDebugNOK (" create_dir ---- : mkdir $directory: <$exit_value><$signal_num><$dumped_core><$stderr>");
}
}
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub call_system {
my ($asnmtapEnv, $currentDate, $catalogID_uniqueKey, $catalogID, $uniqueKey, $resultsdir, $title, $system_action, $status, $interval, $instability, $persistent, $downtime, $debug, $dbiFilename, $logging, $httpdump, $dumphttp, $queryMySQL) = @_;
my $rvOpen;
my $action = '';
my $httpdumpFilename = '';
my $httpdumpFilenameTmp = '';
my $debugFilename = '<NIHIL>';
my $dumphttpRename = '<NIHIL>';
my ($stdout, $stderr, $exit_value, $signal_num, $dumped_core);
applications/collector.pl view on Meta::CPAN
}
$boolean_signal_kill = 0;
if (-e "$PLUGINPATH/$msgCommand.pl") {
my $systemAction = "cd $PLUGINPATH; ./$system_action --status=$status --debug=$debug --logging=$logging --asnmtapEnv='$asnmtapEnv'";
$systemAction .= " --dumphttp=$httpdumpFilenameTmp" if ($dumphttp ne 'N');
my $_handler = $SIG{ALRM};
my $alarm = $interval * 60;
$SIG{ALRM} = sub { $CHILD_OFF = $alarm; warn "ASNMTAP::Asnmtap::Applications::Collector::CHILD_OFF = $alarm\n" };
alarm ( $alarm );
if ($CAPTUREOUTPUT) {
use IO::CaptureOutput qw(capture_exec);
($stdout, $stderr) = capture_exec("$systemAction");
my (@returnStatus) = split (/\n/, $stdout);
$returnStatus = $returnStatus[-1];
} else {
system ("$systemAction"); $stdout = $stderr = '';
}
applications/collector.pl view on Meta::CPAN
printDebugNOK (" perfParse ----- : $perfParseCommand: <$exit_value><$signal_num><$dumped_core><$stderr>") unless ( $exit_value == 0 && $signal_num == 0 && $dumped_core == 0 && $stderr eq '' );
}
}
insertEntryDBI ($currentDate, $catalogID_uniqueKey, $catalogID, $uniqueKey, $title, $dbiFilename.$msgCommand.'-'.$catalogID_uniqueKey.'-sql', $system_action, $interval, $dumphttpRename, $logging, $debug, $startDate, $startTime, $endDate, $endTime, ...
return $action;
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub printDebugAll {
my ($l_text) = @_;
if ($boolean_screenDebug or $boolean_debug_all) {
chomp ($l_text);
my $date = scalar(localtime());
my $tlogging = $logging . get_logfiledate();
print "$l_text $date\n" if ( $boolean_screenDebug );
if ($boolean_debug_all and $logging ne '<NIHIL>') {
applications/collector.pl view on Meta::CPAN
close(ALLDEBUG);
} else {
print "Cannot open $tlogging-all.txt to print debug information\n";
}
}
}
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub printDebugNOK {
my ($l_text) = @_;
if ($boolean_debug_NOK and $logging ne '<NIHIL>') {
chomp ($l_text);
my $date = scalar(localtime());
my $tlogging = $logging . get_logfiledate();
my $rvOpen = open(NOKDEBUG,">>$tlogging-nok.txt");
if ($rvOpen) {
print NOKDEBUG "$l_text $date\n";
close(NOKDEBUG);
} else {
print "Cannot open $tlogging-nok.txt to print debug information\n";
}
}
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub insertEntryDBI {
my ($currentDate, $catalogID_uniqueKey, $catalogID, $uniqueKey, $title, $dbiFilename, $test, $interval, $status, $logging, $debug, $startDate, $startTime, $endDate, $endTime, $duration, $statusMessage, $perfdata, $filename, $insertMySQL, $queryMySQ...
return ( 1 ) unless ( $insertMySQL );
my ($sth, $lockString, $findString, $updateString, $insertString, $flushString, $unlockString, $insertEntryDBI, $updateEntryDBI);
$insertEntryDBI = 0;
$updateEntryDBI = 0;
my ($dbh, $rv, $alarmMessage) = DBI_connect ( $DATABASE, $serverName, $SERVERPORTREADWRITE, $SERVERUSERREADWRITE, $SERVERPASSREADWRITE, $alarm, \&errorTrapDBI, [$currentDate, $catalogID_uniqueKey, $catalogID, $uniqueKey, $test, $title, $status, $st...
if ($dbh and $rv) {
applications/collector.pl view on Meta::CPAN
$dbh->disconnect or $rv = errorTrapDBI($currentDate, $catalogID_uniqueKey, $catalogID, $uniqueKey, $test, $title, $status, $startDate, $startTime, $endDate, $endTime, $duration, $statusMessage, $perfdata, $interval, $instability, $persistent, $do...
my $environment = (($test =~ /\-\-environment=([PASTDL])/) ? $1 : 'P');
$rv = graphEntryDBI ($catalogID, $uniqueKey, $title, $environment, $dbiFilename, $interval, 121, 6, 1, 0, get_trendline_from_test ($test), 0, $debug) if ($interval > 0);
}
return $rv;
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub errorTrapDBI {
my ($currentDate, $catalogID_uniqueKey, $catalogID, $uniqueKey, $test, $title, $status, $startDate, $startTime, $endDate, $endTime, $duration, $statusMessage, $perfdata, $interval, $instability, $persistent, $downtime, $filename, $error_message, $l...
print $error_message, "\nERROR: $DBI::err ($DBI::errstr)\n";
my $tlogging = $logging . get_logfiledate();
my ($msgCommand, undef) = split(/\.pl/, $test);
# APE # TODO - REMOVE
# my $rvOpen = open(DEBUG,">>$tlogging-$msgCommand-$catalogID_uniqueKey.sql");
applications/collector.pl view on Meta::CPAN
close(DEBUG);
} else {
print "Cannot open $RESULTSPATH/$collectorlist-MySQL-sql-error.txt to print debug information\n";
}
return 0;
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub errorTrapDBIdowntime {
my ($collectorlist, $error_message, $logger, $debug) = @_;
print $collectorlist, "\n", $error_message, "\nERROR: $DBI::err ($DBI::errstr)\n";
$$logger->error("$collectorlist:\n" .$error_message. "\nERROR: $DBI::err ($DBI::errstr)") if ( defined $$logger and $$logger->is_error() );
return 0;
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub graphEntryDBI {
my ($catalogID, $uniqueKey, $title, $environment, $dbiFilename, $interval, $limitTest, $xLabelStep, $withBorder, $markOrZone, $yMarkValue, $xRealtime, $debug) = @_;
$title .= ' ('. $ENVIRONMENT{$environment} .')' if (defined $environment);
$title .= ' from '. $catalogID;
# $limitTest -> 241: (120*2.0)+1, x = 2.0 -> $xLabelStep = 6 * x -> 12
# 181: (120*1.5)+1, x = 1.5 -> $xLabelStep = 6 * x -> 9
# 121: (120*1.0)+1, x = 1.0 -> $xLabelStep = 6 * x -> 6
my $width = 893;
applications/collector.pl view on Meta::CPAN
$c->addText($width - 18, $hight - 21, "Interval: " . $interval . " min, " . $DEPARTMENT . " @ " . $BUSINESS . ", created on: " . scalar(localtime()) . ".", "arial.ttf", 8, 0x000000, 6, 0);
#output the chart
$c->makeChart("$dbiFilename.png");
return $rv;
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub errorTrapDBIgraphEntry {
my ($error_message, $logger, $debug) = @_;
print 'errorTrapDBIgraphEntry', "\n", $error_message, "\nERROR: $DBI::err ($DBI::errstr)\n";
$$logger->error("errorTrapDBIgraphEntry:\n" .$error_message. "\nERROR: $DBI::err ($DBI::errstr)") if ( defined $$logger and $$logger->is_error() );
return 0;
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub print_usage () {
print "Usage: $PROGNAME -H <MySQL hostname> [-M <mode>] [-C <collectorlist>] [-W <screenDebug>] [-A <allDebug>] [-N <nokDebug>] [-s <dumphttp>] [-S <status>] [-D <debug>] [-V version] [-h help]\n";
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub print_help () {
print_revision($PROGNAME, $version);
print "ASNMTAP Collector for the '$APPLICATION'
-H, --hostname=<HOSTNAME>
HOSTNAME : hostname/address from the MySQL server
-M, --mode=O|L|C
O(nce) : run the program once
L(oop) : run the program as a loop
C(rontab) : run the program crontab based
-C, --collectorlist=<FILENAME>
applications/custom/cartography.pm-orig view on Meta::CPAN
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
use ASNMTAP::Asnmtap::Applications v3.002.003;
use ASNMTAP::Asnmtap::Applications qw($IMAGESPATH %ICONS);
use ASNMTAP::Asnmtap::Applications::Display v3.002.003;
use ASNMTAP::Asnmtap::Applications::Display qw(:APPLICATIONS :DBDISPLAY);
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub createGifForCartography {
my ($catalogID_uniqueKey, $status) = @_;
my $value = $catalogID_uniqueKey;
$value =~ s/-/_/g;
my $command = "cp ${IMAGESPATH}/$ICONS{$status} ${RESULTSPATH}/_ASNMTAP/${value}.gif";
system ("$command");
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub printLinkToCartography {
my ($serverName, $checklist, $catalogID, $uniqueKey) = @_;
# modify the value of $url with the link to your cartography tool - - -
my $url = 'http://cartography.citap.be/index.htm?entry';
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
my $value = "${catalogID}_${uniqueKey}";
$value =~ s/-/_/g;
my $dataLinkToCartography = "<TR><TD BGCOLOR=#000080 ALIGN=RIGHT COLSPAN=2>Cartography</TD></TR>";
applications/custom/display.pm-orig view on Meta::CPAN
use strict;
use warnings; # Must be used in test mode only. This reduces a little process speed
#use diagnostics; # Must be used in test mode only. This reduces a lot of process speed
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
BEGIN { if ( $ENV{ASNMTAP_PERL5LIB} ) { eval 'use lib ( "$ENV{ASNMTAP_PERL5LIB}" )'; } }
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub printStatusMessageCustom {
my $statusMessage = shift(@_);
my $break = '';
my $errorMessage = '';
if ($statusMessage =~ /<NIHIL>/ ) {
$errorMessage = 'possible a problem with this execution for this plugin';
# ***************************************************************************
# Error codes indicate an error with DUMMY-Tn *
# ***************************************************************************
applications/custom/sde-supportRequest.pm-orig view on Meta::CPAN
use ASNMTAP::Asnmtap::Applications::CGI v3.002.003;
use ASNMTAP::Asnmtap::Applications::CGI qw(:APPLICATIONS :CGI :DBREADONLY :DBTABLES);
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
use SOAP::Lite;
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub webserviceSupportRequest {
my ($catalogID, $uKey, $method, $whereClause, $fieldlist, $pagedir, $pageset, $htmlTitle, $subTitle, $refresh, $onload, $sessionID, $debug) = @_;
# DATABASE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
my $CARTO_SERVER = 'crinaeadtbs01';
my $CARTO_DATABASE = 'carto';
my $CARTO_TABLE = 'TestRelationships';
# SOAP - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
my $tool = 'ASNMTAP';
my $cluster = 'http://itiltest1.smals-mvm.be/ivwse';
applications/custom/sde-supportRequest.pm-orig view on Meta::CPAN
'http://www.w3.org/2001/XMLSchema' => 's',
'http://schemas.xmlsoap.org/wsdl/' => 'wsdl',
'http://schemas.xmlsoap.org/wsdl/http/' => 'http',
'http://microsoft.com/wsdl/mime/textMatching/' => 'tm',
'http://infravision.com/ivwse' => 's1'
);
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub _getEventsData {
my ($catalogID, $uKey, $hash_valueEventsData, $pagedir, $pageset, $htmlTitle, $subTitle, $refresh, $onload, $sessionID, $debug) = @_;
my $rv = 1;
my $dbh = DBI->connect("DBI:mysql:$DATABASE:$SERVERNAMEREADONLY:$SERVERPORTREADONLY", "$SERVERUSERREADONLY", "$SERVERPASSREADONLY") or $rv = error_trap_DBI(*STDOUT, "Cannot connect to the database", $debug, $pagedir, $pageset, $htmlTitle, $subTit...
if ($dbh and $rv) {
my $sql = "select SQL_NO_CACHE title, duration, timeslot, endDate, endTime, status, statusMessage, filename from $SERVERTABLEVENTSDISPLAYDT where catalogID = '$catalogID' and uKey = '$uKey' and step <> '0' order by timeslot desc limit 1";
my $sth = $dbh->prepare( $sql ) or $rv = error_trap_DBI(*STDOUT, "Cannot dbh->prepare: $sql", $debug, $pagedir, $pageset, $htmlTitle, $subTitle, $refresh, $onload, $sessionID);
$sth->execute or $rv = error_trap_DBI(*STDOUT, "Cannot sth->execute: $sql", $debug, $pagedir, $pageset, $htmlTitle, $subTitle, $refresh, $onload, $sessionID) if $rv;
applications/custom/sde-supportRequest.pm-orig view on Meta::CPAN
}
$dbh->disconnect or $rv = error_trap_DBI(*STDOUT, "Sorry, the database was unable to add your entry.", $debug, $pagedir, $pageset, $htmlTitle, $subTitle, $refresh, $onload, $sessionID) if ($dbh and $rv);
}
return $rv;
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub _getSupportRequestData {
my ($serverName, $database, $table, $catalogID, $uKey, $hash_valueSupportRequestData, $pagedir, $pageset, $htmlTitle, $subTitle, $refresh, $onload, $sessionID, $debug) = @_;
$$hash_valueSupportRequestData{code} = '?';
$$hash_valueSupportRequestData{slaID} = '?';
$$hash_valueSupportRequestData{impact} = 'High';
$$hash_valueSupportRequestData{invoicedOrg} = '?';
$$hash_valueSupportRequestData{service} = '?';
$$hash_valueSupportRequestData{priority} = 'P01';
my $rv = 1;
applications/custom/sde-supportRequest.pm-orig view on Meta::CPAN
}
$dbh->disconnect or $rv = error_trap_DBI(*STDOUT, "Sorry, the database was unable to add your entry.", $debug, $pagedir, $pageset, $htmlTitle, $subTitle, $refresh, $onload, $sessionID) if ($dbh and $rv);
}
return $rv;
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub _actionOnSoapResponse {
my ($asnmtapInherited, $som, $arguments) = @_;
my $root = $som->dataof ('/Envelope/Body');
my $WebServiceResults = $root->value;
if ( $asnmtapInherited->getOptionsValue('debug') ) {
use Data::Dumper;
print Dumper ($WebServiceResults), "\n";
}
my $response = $arguments->{method} .'Response';
my $returnCode = ( ( exists $WebServiceResults->{ $response } ) ? ( ( defined $WebServiceResults->{ $response } and $WebServiceResults->{ $response } ne '' ) ? $ERRORS{OK} : $ERRORS{WARNING} ) : $ERRORS{CRITICAL} );
unless ( $returnCode ) {
if ( $arguments->{method} eq 'InsertSupportRequest' ) {
# ...
} else { # $arguments->{method} =~ /^GetSupportRequest(?:List)*$/
if ( exists $WebServiceResults->{$response}->{SupportRequest} ) {
sub processGetSupportRequestResponse {
my ($supportRequest, $arguments, $counter) = @_;
if ( defined $supportRequest->{Number} ) {
my ($header, $data) = ('', '');
if ( defined $arguments->{fieldlist}->{'*'} ) {
while (my ($key, $value) = each %{ $supportRequest } ) {
$header .= '"'. $key .'",' unless ($counter);
$data .= '"'. $value .'",';
}
applications/custom/sde-supportRequest.pm-orig view on Meta::CPAN
$succeeded = 'SR <#>' unless ( $objectPlugins->pluginValue ( 'stateValue' ) );
my $alert = $objectPlugins->pluginValue ('alert');
my $error = $objectPlugins->pluginValue ('error');
undef $objectPlugins;
$succeeded = error_SupportRequest(*STDOUT, $error, $debug, $pagedir, $pageset, $htmlTitle, $subTitle, -2, $onload, $sessionID) unless ( $succeeded );
return ( $succeeded, $alert, $error );
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub insertSupportRequest {
my ($catalogID, $uKey, $title, $remoteUser, $outageStartDate, $outageStartTime, $description, $pagedir, $pageset, $htmlTitle, $subTitle, $refresh, $onload, $sessionID, $debug) = @_;
return ( webserviceSupportRequest( $catalogID, $uKey, 'InsertSupportRequest', undef, undef, $pagedir, $pageset, $htmlTitle, $subTitle, $refresh, $onload, $sessionID, $debug ) );
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub getSupportRequest {
my ($catalogID, $uKey, $title, $remoteUser, $problemSolved, $list, $updated, $supportRequest, $pagedir, $pageset, $htmlTitle, $subTitle, $refresh, $onload, $sessionID, $debug) = @_;
return ( webserviceSupportRequest($catalogID, $uKey, ( ( defined $list && $list ) ? 'GetSupportRequestList' : 'GetSupportRequest' ), "Customer='ASNMTAP MONITORING' and source='Alarm' CompletionCode<>'SOLVED'", 'Number,Status,CompletionCode,CI,Categ...
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub updateSupportRequest {
my ($catalogID, $uKey, $title, $remoteUser, $outageEndDate, $outageEndTime, $description, $supportRequest, $pagedir, $pageset, $htmlTitle, $subTitle, $refresh, $onload, $sessionID, $debug) = @_;
return ( webserviceSupportRequest( $catalogID, $uKey, 'UpdateSupportRequest', undef, undef, $pagedir, $pageset, $htmlTitle, $subTitle, $refresh, $onload, $sessionID, $debug ) );
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub error_SupportRequest {
my ($HTML, $error_message, $debug, $pagedir, $pageset, $htmlTitle, $subTitle, $refresh, $onload, $sessionID) = @_;
my $subject = "$htmlTitle / error_SupportRequest: " . get_datetimeSignal();
my $message = get_datetimeSignal() . "\npagedir : $pagedir\npageset : $pageset\nhtml title: $htmlTitle\n\nerror message:\n$error_message\n";
my $returnCode = sending_mail ( $SERVERLISTSMTP, $SENDEMAILTO, $SENDMAILFROM, $subject, $message, $debug );
print "Problem sending email to the '$APPLICATION' server administrators\n" unless ( $returnCode );
if ( $refresh == 0 ) {
return (0, $error_message, "Error: ...", "String: ...");
} elsif ( $refresh == -1 ) {
applications/custom/sde.pm-orig view on Meta::CPAN
BEGIN { if ( $ENV{ASNMTAP_PERL5LIB} ) { eval 'use lib ( "$ENV{ASNMTAP_PERL5LIB}" )'; } }
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
use ASNMTAP::Asnmtap::Applications::Display v3.002.003;
use ASNMTAP::Asnmtap::Applications::Display qw(:APPLICATIONS :DBDISPLAY);
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub getTimeperiodRelationshipsSDE {
my ($serverName, $checklist, $hash_catalogID_uKey_timeperiodID, $debug) = @_;
my $CARTO_DATABASE = 'carto';
my $CARTO_TABLE = 'TestRelationships';
my $rv = 1;
my $dbh = DBI->connect("DBI:mysql:$CARTO_DATABASE:$serverName:$SERVERPORTREADWRITE", "$SERVERUSERREADWRITE", "$SERVERPASSREADWRITE") or $rv = errorTrapDBI($checklist, "Cannot connect to the database");
if ($dbh and $rv) {
my $sql = "select SQL_NO_CACHE catalogID, uKey, priority, imw_sunday, imw_monday, imw_tuesday, imw_wednesday, imw_thursday, imw_friday, imw_saturday from $CARTO_TABLE";
applications/custom/sde.pm-orig view on Meta::CPAN
$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);
}
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub printRelationshipsSDE {
my ($serverName, $checklist, $catalogID, $uniqueKey) = @_;
my $CARTO_DATABASE = 'carto';
my $CARTO_TABLE = 'TestRelationships';
my $dataRelationshipsSDE = '';
my $rv = 1;
my $dbh = DBI->connect("DBI:mysql:$CARTO_DATABASE:$serverName:$SERVERPORTREADWRITE", "$SERVERUSERREADWRITE", "$SERVERPASSREADWRITE") or $rv = errorTrapDBI($checklist, "Cannot connect to the database");
applications/custom/supportRequest.pm-orig view on Meta::CPAN
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
use ASNMTAP::Time qw(&get_datetimeSignal);
use ASNMTAP::Asnmtap::Applications::CGI v3.002.003;
use ASNMTAP::Asnmtap::Applications::CGI qw(:APPLICATIONS :CGI :DBREADONLY :DBTABLES);
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub insertSupportRequest {
my ($catalogID, $uKey, $title, $remoteUser, $outageStartDate, $outageStartTime, $description, $pagedir, $pageset, $htmlTitle, $subTitle, $refresh, $onload, $sessionID, $debug) = @_;
my ($succeeded, $alert, $error) = ( 1 );
# ...
return ($succeeded, $alert, $error);
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub getSupportRequest {
my ($catalogID, $uKey, $title, $remoteUser, $problemSolved, $list, $updated, $supportRequest, $pagedir, $pageset, $htmlTitle, $subTitle, $refresh, $onload, $sessionID, $debug) = @_;
my ($succeeded, $alert, $error) = ( 1 );
# ...
return ($succeeded, $alert, $error);
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub updateSupportRequest {
my ($catalogID, $uKey, $title, $remoteUser, $outageEndDate, $outageEndTime, $description, $supportRequest, $pagedir, $pageset, $htmlTitle, $subTitle, $refresh, $onload, $sessionID, $debug) = @_;
my ($succeeded, $alert, $error) = ( 1 );
# ...
return ($succeeded, $alert, $error);
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub error_SupportRequest {
my ($HTML, $error_message, $debug, $pagedir, $pageset, $htmlTitle, $subTitle, $refresh, $onload, $sessionID) = @_;
my $subject = "$htmlTitle / error_SupportRequest: " . get_datetimeSignal();
my $message = get_datetimeSignal() . "\npagedir : $pagedir\npageset : $pageset\nhtml title: $htmlTitle\n\nerror message:\n$error_message\n";
my $returnCode = sending_mail ( $SERVERLISTSMTP, $SENDEMAILTO, $SENDMAILFROM, $subject, $message, $debug );
print "Problem sending email to the '$APPLICATION' server administrators\n" unless ( $returnCode );
if ( $refresh == 0 ) {
return (0, $error_message, "Error: ...", "String: ...");
} elsif ( $refresh == -1 ) {
applications/display-test.pl view on Meta::CPAN
my $creationTime; # default
my $displayTime = 1; # default
my $lockMySQL = 0; # default
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
my $displayTimeslot = 0; # only for extra debugging information
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub print_help ();
sub print_usage ();
Getopt::Long::Configure('bundling');
GetOptions (
"V" => \$opt_V, "version" => \$opt_V,
"h" => \$opt_h, "help" => \$opt_h,
"H=s" => \$opt_H, "hostname=s" => \$opt_H,
"C:s" => \$opt_C, "checklist:s" => \$opt_C,
"P:s" => \$opt_P, "pagedir:s" => \$opt_P,
"D:s" => \$opt_D, "debug:s" => \$opt_D,
applications/display-test.pl view on Meta::CPAN
exit 0;
}
exit 0;
}
# if ($boolean_daemonControl) { waitpid($pid,0); }
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub resultsdirCreate {
foreach $dchecklist (@checklisttable) {
my (undef, undef, $resultsdir, undef) = split(/\#/, $dchecklist, 4);
my $logging = $RESULTSPATH .'/'. $resultsdir;
create_dir ($logging);
$logging .= "/";
create_header ($logging ."HEADER.html");
create_footer ($logging ."FOOTER.html");
}
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub read_tableSoundStatusCache {
my ($checklist, $debug) = @_;
%tableSoundStatusCache = ();
if (-e "$APPLICATIONPATH/tmp/$checklist-sound-status.cache") {
my $rvOpen = open(READ, "$APPLICATIONPATH/tmp/$checklist-sound-status.cache");
if ($rvOpen) {
while (<READ>) {
chomp;
applications/display-test.pl view on Meta::CPAN
print "-->\n";
while ( my ($key, $value) = each(%tableSoundStatusCache) ) { print "'$key' => '$value'\n"; }
print "<--\n";
}
}
}
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub write_tableSoundStatusCache {
my ($checklist, $debug) = @_;
my $rvOpen = open(WRITE, ">$APPLICATIONPATH/tmp/$checklist-sound-status.cache");
if ($rvOpen) {
print "\n$APPLICATIONPATH/tmp/$checklist-sound-status.cache: WRITE\n-->\n" if ($debug);
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");
applications/display-test.pl view on Meta::CPAN
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";
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub signalQUIT {
print "kill -QUIT <$PROGNAME v$version -C $checklist> pid: <$pidfile><", get_datetimeSignal(), ">\n";
unlink $pidfile;
$boolean_daemonQuit = 1;
use Sys::Hostname;
my $subject = "$prgtext\@". hostname() .": Config $APPLICATIONPATH/etc/$checklist successfully stopped at ". get_datetimeSignal();
my $returnCode = sending_mail ( $SERVERLISTSMTP, $SENDEMAILTO, $SENDMAILFROM, $subject, $subject ."\n", 0 );
print "Problem sending email to the '$APPLICATION' server administrators\n" unless ( $returnCode );
exit 1;
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub signalHUP {
print "kill -HUP <$PROGNAME v$version -C $checklist> pid: <$pidfile><", get_datetimeSignal(), ">\n";
$boolean_signal_hup = 1;
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
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 );
}
applications/display-test.pl view on Meta::CPAN
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');
applications/display-test.pl view on Meta::CPAN
$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);
applications/display-test.pl view on Meta::CPAN
}
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];
applications/display-test.pl view on Meta::CPAN
$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 );
applications/display-test.pl view on Meta::CPAN
} 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) {
applications/display-test.pl view on Meta::CPAN
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 ) {
applications/display-test.pl view on Meta::CPAN
}
}
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}; }
applications/display-test.pl view on Meta::CPAN
if ($displayTime) {
$itemFullCondensedView .= ' <TD><IMG SRC="'. $IMAGESURL .'/'. $statusIcon .'" WIDTH="16" HEIGHT="16" BORDER=0 title="'. $status .'" alt="'. $status .'"></TD>'. "\n";
$itemFullCondensedView .= ' <TD class="ItemStatus"><FONT COLOR="'. $COLORS{$status} .'">'. $debugInfo . $boldStart . $endTime . $boldEnd .'</FONT></TD>'. "\n";
} else {
$itemFullCondensedView .= ' <TD><IMG SRC="'. $IMAGESURL .'/'. $statusIcon .'" WIDTH="16" HEIGHT="16" BORDER=0 title="'. $endTime .'" alt="'. $endTime .'"></TD>'. "\n";
}
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub printStatusMessage {
my ($statusMessage) = @_;
my $break = '';
my $errorMessage;
# ***************************************************************************
# The 400 series of Web error codes indicate an error with your Web browser *
# ***************************************************************************
if ($statusMessage =~ /400 Bad Request/ ) {
$errorMessage = 'The request could not be understood by the server due to incorrect syntax';
applications/display-test.pl view on Meta::CPAN
$errorMessage = printStatusMessageCustom( decode_html_entities('E', $statusMessage) );
}
my $returnMessage = ' <TR><TD WIDTH="56"> </TD><TD VALIGN="TOP">' . $statusMessage . '</TD></TR>' . "\n";
$returnMessage .= ' <TR><TD WIDTH="56"> </TD><TD> </TD><TD> </TD><TD class="StatusMessageError">' . encode_html_entities('E', $errorMessage) . '</TD></TR>' . "\n" if ($errorMessage);
return ( $returnMessage );
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub printHtmlFooter {
my $title = @_;
print HTML "</BODY>\n</HTML>";
print HTMLCV "</BODY>\n</HTML>";
print HTMLMCV "</BODY>\n</HTML>";
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub printGroepFooter {
my ($title, $show) = @_;
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub printItemFooter {
my ($catalogID_uniqueKey, $catalogID, $uniqueKey, $title, $status, $timeslot, $statusIcon, $insertInMCV, $inIMW, $itemFullCondensedView, $printCondensedView, $arrayStatusMessage, $catalogID_uKey_timeperiodID) = @_;
$itemFullCondensedView .= "</TR>\n";
if (@$arrayStatusMessage) {
$itemFullCondensedView .= '<TR style="{height: 0;}"><TD COLSPAN="'. $colspanDisplayTime .'"><DIV id="'.$catalogID_uniqueKey.'" style="display:none"><TABLE WIDTH=100% BORDER=0 CELLSPACING=1 CELLPADDING=2>'. "\n";
foreach my $arrayStatusMessage ( @$arrayStatusMessage ) { $itemFullCondensedView .= printStatusMessage ( $arrayStatusMessage ); }
$itemFullCondensedView .= "</TABLE></DIV></TD></TR>\n";
}
applications/display-test.pl view on Meta::CPAN
$groupCondensedView += $printCondensedView;
my $groep = ( $title =~ /^\[(\d+)\]/ ? $1 : 0);
push ( @multiarrayFullCondensedView, [ $ERRORS{"$status"}, $groep, $timeslot, $statusIcon, $itemFullCondensedView, $printCondensedView ] );
my $priorityGroup = '-MCV-' . ( ( exists $$catalogID_uKey_timeperiodID{$catalogID}->{$uniqueKey}->{SDE_IMW}->{priority} ) ? $$catalogID_uKey_timeperiodID{$catalogID}->{$uniqueKey}->{SDE_IMW}->{priority} : 'P01' ) . '-';
push ( @multiarrayMinimalCondensedView, [ $ERRORS{"$status"}, $priorityGroup, $timeslot, $statusIcon, $itemFullCondensedView ] ) if ( ( ! $statusIcon or ( $statusIcon and $insertInMCV ) ) and $status !~ /(?:OK|DEPENDENT|OFFLINE|NO TEST|TRENDLINE)/ ...
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub printStatusFooter {
my ($title, $emptyFullView, $emptyCondencedView, $emptyMinimalCondencedView, $playSoundStatus) = @_;
print HTML '</TABLE>', "\n";
print HTML <<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';
applications/display-test.pl view on Meta::CPAN
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;
applications/display-test.pl view on Meta::CPAN
# 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
applications/display.pl view on Meta::CPAN
my $creationTime; # default
my $displayTime = 1; # default
my $lockMySQL = 0; # default
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
my $displayTimeslot = 0; # only for extra debugging information
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub print_help ();
sub print_usage ();
Getopt::Long::Configure('bundling');
GetOptions (
"V" => \$opt_V, "version" => \$opt_V,
"h" => \$opt_h, "help" => \$opt_h,
"H=s" => \$opt_H, "hostname=s" => \$opt_H,
"C:s" => \$opt_C, "checklist:s" => \$opt_C,
"P:s" => \$opt_P, "pagedir:s" => \$opt_P,
"D:s" => \$opt_D, "debug:s" => \$opt_D,
applications/display.pl view on Meta::CPAN
exit 0;
}
exit 0;
}
# if ($boolean_daemonControl) { waitpid($pid,0); }
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub resultsdirCreate {
foreach $dchecklist (@checklisttable) {
my (undef, undef, $resultsdir, undef) = split(/\#/, $dchecklist, 4);
my $logging = $RESULTSPATH .'/'. $resultsdir;
create_dir ($logging);
$logging .= "/";
create_header ($logging ."HEADER.html");
create_footer ($logging ."FOOTER.html");
}
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub read_tableSoundStatusCache {
my ($checklist, $debug) = @_;
%tableSoundStatusCache = ();
if (-e "$APPLICATIONPATH/tmp/$checklist-sound-status.cache") {
my $rvOpen = open(READ, "$APPLICATIONPATH/tmp/$checklist-sound-status.cache");
if ($rvOpen) {
while (<READ>) {
chomp;
applications/display.pl view on Meta::CPAN
print "-->\n";
while ( my ($key, $value) = each(%tableSoundStatusCache) ) { print "'$key' => '$value'\n"; }
print "<--\n";
}
}
}
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub write_tableSoundStatusCache {
my ($checklist, $debug) = @_;
my $rvOpen = open(WRITE, ">$APPLICATIONPATH/tmp/$checklist-sound-status.cache");
if ($rvOpen) {
print "\n$APPLICATIONPATH/tmp/$checklist-sound-status.cache: WRITE\n-->\n" if ($debug);
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");
applications/display.pl view on Meta::CPAN
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";
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub signalQUIT {
print "kill -QUIT <$PROGNAME v$version -C $checklist> pid: <$pidfile><", get_datetimeSignal(), ">\n";
unlink $pidfile;
$boolean_daemonQuit = 1;
use Sys::Hostname;
my $subject = "$prgtext\@". hostname() .": Config $APPLICATIONPATH/etc/$checklist successfully stopped at ". get_datetimeSignal();
my $returnCode = sending_mail ( $SERVERLISTSMTP, $SENDEMAILTO, $SENDMAILFROM, $subject, $subject ."\n", 0 );
print "Problem sending email to the '$APPLICATION' server administrators\n" unless ( $returnCode );
exit 1;
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub signalHUP {
print "kill -HUP <$PROGNAME v$version -C $checklist> pid: <$pidfile><", get_datetimeSignal(), ">\n";
$boolean_signal_hup = 1;
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
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 );
}
applications/display.pl view on Meta::CPAN
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');
applications/display.pl view on Meta::CPAN
$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);
applications/display.pl view on Meta::CPAN
}
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];
applications/display.pl view on Meta::CPAN
$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 );
applications/display.pl view on Meta::CPAN
} 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) {
applications/display.pl view on Meta::CPAN
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 ) {
applications/display.pl view on Meta::CPAN
}
}
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}; }
applications/display.pl view on Meta::CPAN
if ($displayTime) {
$itemFullCondensedView .= ' <TD><IMG SRC="'. $IMAGESURL .'/'. $statusIcon .'" WIDTH="16" HEIGHT="16" BORDER=0 title="'. $status .'" alt="'. $status .'"></TD>'. "\n";
$itemFullCondensedView .= ' <TD class="ItemStatus"><FONT COLOR="'. $COLORS{$status} .'">'. $debugInfo . $boldStart . $endTime . $boldEnd .'</FONT></TD>'. "\n";
} else {
$itemFullCondensedView .= ' <TD><IMG SRC="'. $IMAGESURL .'/'. $statusIcon .'" WIDTH="16" HEIGHT="16" BORDER=0 title="'. $endTime .'" alt="'. $endTime .'"></TD>'. "\n";
}
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub printStatusMessage {
my ($statusMessage) = @_;
my $break = '';
my $errorMessage;
# ***************************************************************************
# The 400 series of Web error codes indicate an error with your Web browser *
# ***************************************************************************
if ($statusMessage =~ /400 Bad Request/ ) {
$errorMessage = 'The request could not be understood by the server due to incorrect syntax';
applications/display.pl view on Meta::CPAN
$errorMessage = printStatusMessageCustom( decode_html_entities('E', $statusMessage) );
}
my $returnMessage = ' <TR><TD WIDTH="56"> </TD><TD VALIGN="TOP">' . $statusMessage . '</TD></TR>' . "\n";
$returnMessage .= ' <TR><TD WIDTH="56"> </TD><TD> </TD><TD> </TD><TD class="StatusMessageError">' . encode_html_entities('E', $errorMessage) . '</TD></TR>' . "\n" if ($errorMessage);
return ( $returnMessage );
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub printHtmlFooter {
my $title = @_;
print HTML "</BODY>\n</HTML>";
print HTMLCV "</BODY>\n</HTML>";
print HTMLMCV "</BODY>\n</HTML>";
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub printGroepFooter {
my ($title, $show) = @_;
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub printItemFooter {
my ($catalogID_uniqueKey, $catalogID, $uniqueKey, $title, $status, $timeslot, $statusIcon, $insertInMCV, $inIMW, $itemFullCondensedView, $printCondensedView, $arrayStatusMessage, $catalogID_uKey_timeperiodID) = @_;
$itemFullCondensedView .= "</TR>\n";
if (@$arrayStatusMessage) {
$itemFullCondensedView .= '<TR style="{height: 0;}"><TD COLSPAN="'. $colspanDisplayTime .'"><DIV id="'.$catalogID_uniqueKey.'" style="display:none"><TABLE WIDTH=100% BORDER=0 CELLSPACING=1 CELLPADDING=2>'. "\n";
foreach my $arrayStatusMessage ( @$arrayStatusMessage ) { $itemFullCondensedView .= printStatusMessage ( $arrayStatusMessage ); }
$itemFullCondensedView .= "</TABLE></DIV></TD></TR>\n";
}
applications/display.pl view on Meta::CPAN
$groupCondensedView += $printCondensedView;
my $groep = ( $title =~ /^\[(\d+)\]/ ? $1 : 0);
push ( @multiarrayFullCondensedView, [ $ERRORS{"$status"}, $groep, $timeslot, $statusIcon, $itemFullCondensedView, $printCondensedView ] );
my $priorityGroup = '-MCV-' . ( ( exists $$catalogID_uKey_timeperiodID{$catalogID}->{$uniqueKey}->{SDE_IMW}->{priority} ) ? $$catalogID_uKey_timeperiodID{$catalogID}->{$uniqueKey}->{SDE_IMW}->{priority} : 'P01' ) . '-';
push ( @multiarrayMinimalCondensedView, [ $ERRORS{"$status"}, $priorityGroup, $timeslot, $statusIcon, $itemFullCondensedView ] ) if ( ( ! $statusIcon or ( $statusIcon and $insertInMCV ) ) and $status !~ /(?:OK|DEPENDENT|OFFLINE|NO TEST|TRENDLINE)/ ...
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub printStatusFooter {
my ($title, $emptyFullView, $emptyCondencedView, $emptyMinimalCondencedView, $playSoundStatus) = @_;
print HTML '</TABLE>', "\n";
print HTML <<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';
applications/display.pl view on Meta::CPAN
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;
applications/display.pl view on Meta::CPAN
# 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
applications/htmlroot/cgi-bin/admin/generateConfig.pl view on Meta::CPAN
}
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
print_legend (*STDOUT);
print '</BODY>', "\n", '</HTML>', "\n";
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub createCollectorCTscript {
my ($typeMonitoringCharDorC, $typeServersCharMorS, $typeActiveServer, $serverFQDN, $serverAdminCollectorFQDN, $serverASNMTAP_PATH , $serverRSYNC_PATH , $serverSSH_PATH, $databaseFQDN, $subdir, $collectorDaemon, $mode, $dumphttp, $status, $debugDaem...
my ($hostnameAdminCollector, undef) = split (/\./, $serverAdminCollectorFQDN, 2);
return ('') if ( "CollectorCT-$collectorDaemon.sh" eq "CollectorCT-${hostnameAdminCollector}.sh" );
my $filename = "$APPLICATIONPATH/tmp/$CONFIGDIR/generated/$typeMonitoringCharDorC$typeServersCharMorS-$typeActiveServer-$serverFQDN/$subdir/CollectorCT-$collectorDaemon.sh";
my $command = "cat $APPLICATIONPATH/tools/templates/CollectorCT-template.sh >> $filename";
my $rvOpen = open(CollectorCT, ">$filename");
applications/htmlroot/cgi-bin/admin/generateConfig.pl view on Meta::CPAN
close (CollectorCT);
}
my $statusMessage = do_system_call ($command, $debug);
$statusMessage .= "<tr bgcolor=\"$COLORSTABLE{ENDBLOCK}\"><td><a href=\"/$CONFIGDIR/generated/$typeMonitoringCharDorC$typeServersCharMorS-$typeActiveServer-$serverFQDN/$subdir/CollectorCT-$collectorDaemon.sh\" target=\"_blank\">CollectorCT-$collect...
return ($statusMessage);
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub createAsnmtapCollectorCTscript {
my ($typeMonitoring, $typeServersCharMorS, $typeActiveServer, $serverFQDN, $serverAdminCollectorFQDN, $serverASNMTAP_PATH , $serverRSYNC_PATH , $serverSSH_PATH, $subdir, $debug) = @_;
my $typeMonitoringCharDorC = ($typeMonitoring) ? 'D' : 'C';
my $filename = "$APPLICATIONPATH/tmp/$CONFIGDIR/generated/$typeMonitoringCharDorC$typeServersCharMorS-$typeActiveServer-$serverFQDN/$subdir/root-collector.sh";
my $rvOpen = open(AsnmtapCollectorCTscript, ">$filename");
if ($rvOpen) {
print AsnmtapCollectorCTscript <<STARTUPFILE;
#!/bin/sh
applications/htmlroot/cgi-bin/admin/generateConfig.pl view on Meta::CPAN
close (AsnmtapCollectorCTscript);
}
$statusMessage .= "<tr bgcolor=\"$COLORSTABLE{ENDBLOCK}\"><td><a href=\"/$CONFIGDIR/generated/$typeMonitoringCharDorC$typeServersCharMorS-$typeActiveServer-$serverFQDN/$subdir/asnmtap-collector.sh\" target=\"_blank\">asnmtap-collector.sh ($subdir)<...
return ($statusMessage);
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub createDisplayCTscript {
my ($typeMonitoringCharDorC, $typeServersCharMorS, $typeActiveServer, $serverFQDN, $serverASNMTAP_PATH , $serverRSYNC_PATH , $serverSSH_PATH, $databaseFQDN, $subdir, $displayDaemon, $pagedirs, $loop, $trigger, $displayTime, $lockMySQL, $debugDaemon...
my $filename = "$APPLICATIONPATH/tmp/$CONFIGDIR/generated/$typeMonitoringCharDorC$typeServersCharMorS-$typeActiveServer-$serverFQDN/$subdir/DisplayCT-$displayDaemon.sh";
my $command = "cat $APPLICATIONPATH/tools/templates/DisplayCT-template.sh >> $filename";
my $rvOpen = open(DisplayCT, ">$filename");
if ($rvOpen) {
print DisplayCT <<STARTUPFILE;
#!/bin/bash
applications/htmlroot/cgi-bin/admin/generateConfig.pl view on Meta::CPAN
close (DisplayCT);
}
my $statusMessage = do_system_call ($command, $debug);
$statusMessage .= "<tr bgcolor=\"$COLORSTABLE{ENDBLOCK}\"><td><a href=\"/$CONFIGDIR/generated/$typeMonitoringCharDorC$typeServersCharMorS-$typeActiveServer-$serverFQDN/$subdir/DisplayCT-$displayDaemon.sh\" target=\"_blank\">DisplayCT-$displayDaemon...
return ($statusMessage);
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub createAsnmtapDisplayCTscript {
my ($typeMonitoring, $typeServersCharMorS, $typeActiveServer, $serverFQDN, $serverASNMTAP_PATH , $serverRSYNC_PATH , $serverSSH_PATH, $subdir, $debug) = @_;
my $typeMonitoringCharDorC = ($typeMonitoring) ? 'D' : 'C';
my $filename = "$APPLICATIONPATH/tmp/$CONFIGDIR/generated/$typeMonitoringCharDorC$typeServersCharMorS-$typeActiveServer-$serverFQDN/$subdir/root-display.sh";
my $rvOpen = open(AsnmtapDisplayCTscript, ">$filename");
if ($rvOpen) {
print AsnmtapDisplayCTscript <<STARTUPFILE;
#!/bin/sh
applications/htmlroot/cgi-bin/admin/generateConfig.pl view on Meta::CPAN
close (AsnmtapDisplayCTscript);
}
$statusMessage .= "<tr bgcolor=\"$COLORSTABLE{ENDBLOCK}\"><td><a href=\"/$CONFIGDIR/generated/$typeMonitoringCharDorC$typeServersCharMorS-$typeActiveServer-$serverFQDN/$subdir/asnmtap-display.sh\" target=\"_blank\">asnmtap-display.sh ($subdir)</a><...
return ($statusMessage);
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub createRsyncMirrorScriptsFailover {
my ($serverID, $typeMonitoring, $typeServers, $typeActiveServer, $masterFQDN, $masterASNMTAP_PATH, $masterRSYNC_PATH, $masterSSH_PATH, $slaveFQDN, $slaveASNMTAP_PATH, $slaveRSYNC_PATH, $slaveSSH_PATH, $collectorDaemon, $matchingRsyncMirrorConfigFai...
my $typeMonitoringCharDorC = ($typeMonitoring) ? 'D' : 'C';
my ($filename, $command, $rvOpen);
my $statusMessage = '';
if ( $typeServers ) { # Failover
# --------------------------------------------------------------------------
# Failover between $masterFQDN and $slaveFQDN
# --------------------------------------------------------------------------
applications/htmlroot/cgi-bin/admin/generateConfig.pl view on Meta::CPAN
}
$statusMessage .= "<tr bgcolor=\"$COLORSTABLE{ENDBLOCK}\"><td><a href=\"/$CONFIGDIR/generated/" .$typeMonitoringCharDorC. "S-$typeActiveServer-$slaveFQDN/slave/rsync-mirror-failover-$slaveFQDN-$collectorDaemon.conf\" target=\"_blank\">rsync-mirro...
}
return ($statusMessage);
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub createRsyncMirrorScriptsDistributed {
my ($serverID, $typeMonitoring, $typeServers, $typeActiveServer, $masterFQDN, $masterASNMTAP_PATH, $masterRSYNC_PATH, $masterSSH_PATH, $slaveFQDN, $slaveASNMTAP_PATH, $slaveRSYNC_PATH, $slaveSSH_PATH, $centralTypeMonitoring, $centralTypeServers, $c...
my $typeMonitoringCharDorC = ($typeMonitoring) ? 'D' : 'C';
my ($filename, $command, $rvOpen);
my $statusMessage = '';
if ( $typeMonitoring ) { # Distributed
$filename = "$APPLICATIONPATH/tmp/$CONFIGDIR/generated/CM-$centralTypeActiveServer-$centralMasterFQDN/master/rsync-wrapper-distributed-$centralMasterFQDN.sh";
applications/htmlroot/cgi-bin/admin/generateConfig.pl view on Meta::CPAN
$statusMessage .= "<tr bgcolor=\"$COLORSTABLE{ENDBLOCK}\"><td><a href=\"/$CONFIGDIR/generated/" .$typeMonitoringCharDorC. "S-$typeActiveServer-$slaveFQDN/slave/rsync-mirror-distributed-$slaveFQDN-$collectorDaemon.conf\" target=\"_blank\">rsync-...
}
}
return ($statusMessage);
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub read_directory {
my ($directory, $subDirectory, $htmlBefore, $htmlAfter, $debug) = @_;
my $directoryAndFileList = ( $debug eq 'T' ) ? "$htmlBefore$directory$subDirectory$htmlAfter" : '';
my $rvOpendir = opendir (DIR, "$directory$subDirectory");
if ($rvOpendir) {
while ($_ = readdir (DIR)) {
next if ($_ eq "." or $_ eq ".." or $_ eq "HEADER.html" or $_ eq "FOOTER.html");
applications/htmlroot/cgi-bin/admin/generateConfig.pl view on Meta::CPAN
}
closedir DIR;
}
return ($directoryAndFileList);
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub do_compare_view {
my ($command, $details, $debug) = @_;
sub do_compare_diff {
my ($compareView, $type, $details, $debug) = @_;
my ($path, $generated, $installed, $compareDiff);
$path = $generated = $installed = '';
if ($type == 1) {
my (undef, $dummy) = split (/Only in generated\//, $compareView);
($path, $generated) = split (/: /, $dummy);
$compareDiff = "$path/$generated added" if ( $debug eq 'T' );
} elsif ($type == 2) {
applications/htmlroot/cgi-bin/admin/generateConfig.pl view on Meta::CPAN
# APE #
# unless ($details)
# $action = 'errorView' unless ( $commandsToExecute eq $commandsExecuted );
# }
return ($statusMessage);
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub do_system_call {
my ($command, $debug) = @_;
my ($stdout, $stderr, $exit_value, $signal_num, $dumped_core, $status, $statusMessage);
if ($CAPTUREOUTPUT) {
use IO::CaptureOutput qw(capture_exec);
($stdout, $stderr) = capture_exec("$command");
} else {
system ("$command"); $stdout = $stderr = '';
}
applications/htmlroot/cgi-bin/admin/generateConfig.pl view on Meta::CPAN
$statusMessage .= "</td></tr>";
} else {
$statusMessage = '';
}
return ($statusMessage);
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub system_call {
my ($command, $parameters, $debug) = @_;
my $doSystemCall = 0;
my $statusMessage = '';
if ( $command eq "mkdir" ) {
$doSystemCall = 1 unless ( -e "$parameters" );
} elsif ( $command eq "rm -rf" ) {
if ($parameters =~ /$APPLICATIONPATH\/tmp\/$CONFIGDIR\// and -e "$parameters") { $doSystemCall = 1; }
} elsif ( $command eq "cp" ) {
applications/htmlroot/cgi-bin/detailedStatisticsReportGenerationAndCompareResponsetimeTrends.pl view on Meta::CPAN
($test, undef) = split(/\.pl/, $test);
$sqlQuery = create_sql_query_events_from_range_year_month ($inputType, $sqlStartDate, $sqlEndDate, $sqlSelect, $forceIndex, $sqlWhere, $sqlPeriode, "AND status <> 'OK' AND status <> 'OFFLINE' AND status <> 'NO TEST'", '', "", "order by ...
$sth = $dbh->prepare( $sqlQuery ) or $rv = error_trap_DBI("", "Cannot dbh->prepare: $sqlQuery", $debug, '', "", '', "", -1, '', $sessionID);
$sth->execute() or $rv = error_trap_DBI("", "Cannot sth->execute: $sqlQuery", $debug, '', "", '', "", -1, '', $sessionID) if $rv;
$sth->bind_columns( \$startDateQ, \$startTime, \$endDateQ, \$endTime, \$duration, \$status, \$statusMessage ) or $rv = error_trap_DBI("", "Cannot sth->bind_columns: $sqlQuery", $debug, '', "", '', "", -1, '', $sessionID) if $rv;
}
}
if ( $rv ) {
sub createLinkToDebugFile {
my ($startDate, $startTime, $status, $statusMessage) = @_;
my ($year, $month, $day) = split (/-/, $startDate);
my ($hour, $min, $sec) = split (/:/, $startTime);
if ( $formatOutput ne 'html' or $htmlToPdf ) {
return ($statusMessage);
} else {
my $catalogID_uKey1 = ( ( $CcatalogID eq 'CID' ) ? '' : $CcatalogID .'_' ) . $uKey1;
applications/htmlroot/cgi-bin/detailedStatisticsReportGenerationAndCompareResponsetimeTrends.pl view on Meta::CPAN
print '<BR>', "\n";
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
print_legend (*STDOUT);
print '</BODY>', "\n", '</HTML>', "\n";
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub setBlockBGcolor {
my ($oneblock, $status, $step, $startDateQ, $startTime, $nyear, $nmonth, $nday, $nhours, $nminuts, $nseconds, $nstatus, $nrest) = @_;
my $block;
if ($step == 0) {
$block = ($oneblock) ? " bgcolor=\"$COLORSTABLE{ENDBLOCK}\" " : " bgcolor=\"$COLORSTABLE{NOBLOCK}\" ";
$oneblock = 0;
} else {
my ($year, $month, $day) = split(/-/, $startDateQ);
my ($hours, $minuts, $seconds) = split(/:/, $startTime);
applications/htmlroot/cgi-bin/detailedStatisticsReportGenerationAndCompareResponsetimeTrends.pl view on Meta::CPAN
} else {
$rrest = '';
}
$rrest =~ s/^ +//g;
return ($oneblock, $block, $rrest, '');
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub setPreviousValues {
my ($startDateQ, $startTime, $endDateQ, $endTime, $seconden, $status, $rest) = @_;
my ($nyear, $nmonth, $nday) = split(/-/, $startDateQ);
my ($nhours, $nminuts, $nseconds) = split(/:/, $startTime);
return ($nyear, $nmonth, $nday, $nhours, $nminuts, $nseconds, $startDateQ, $startTime, $endDateQ, $endTime, $seconden, $status, $rest);
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
applications/htmlroot/cgi-bin/generateChart.pl view on Meta::CPAN
}
}
# Output the chart
binmode(STDOUT);
print "Content-type: image/png\n\n";
print $c->makeChart2($perlchartdir::PNG);
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub getAverage {
my ($number, $dbh, $rv, $uKey, $sqlStartDate, $sqlEndDate, $sqlPeriode, $selChart, $debug) = @_;
my ($sql, $sth, $errorMessage, $dbiErrorCode, $dbiErrorString, $startDate, $hour, $average, @avg, @labels);
if ( $selChart eq "HourlyAverage" ) {
$sql = create_sql_query_events_from_range_year_month ($inputType, $sqlStartDate, $sqlEndDate, "select SQL_NO_CACHE startDate, hour(startTime) as hour, round(avg(time_to_sec(duration)), 2)", $forceIndex, "WHERE catalogID = '$CcatalogID' and uKey =...
} else {
$sql = create_sql_query_events_from_range_year_month ($inputType, $sqlStartDate, $sqlEndDate, "select SQL_NO_CACHE startDate, round(avg(time_to_sec(duration)), 2)", $forceIndex, "WHERE catalogID = '$CcatalogID' and uKey = '$uKey'", $sqlPeriode, "...
}
applications/htmlroot/cgi-bin/generateChart.pl view on Meta::CPAN
@avg2 = @avg; @labels2 = @labels;
} elsif ( $number == 3 ) {
@avg3 = @avg; @labels3 = @labels;
}
return ($rv, $errorMessage, $dbiErrorCode, $dbiErrorString);
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub rebuildDataArrayHourlyAverage {
my ($arr_full, $arr_part, $arr_data) = @_;
my (@arr_res, $found, $cdate1, $time1, $cdate2, $time2, $year1, $month1, $day1, $year2, $month2, $day2);
for (my $i = 0; $i < @$arr_full; $i++) {
($cdate1, $time1) = split(/:/, @$arr_full[$i]);
($year1, $month1, $day1) = split(/-/, $cdate1);
$found = 0;
for (my $j = 0; $j < @$arr_part; $j++) {
applications/htmlroot/cgi-bin/generateChart.pl view on Meta::CPAN
}
push (@arr_res, 0.00) unless ( $found );
}
return @arr_res;
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub rebuildDataArrayDailyAverage {
my ($arr_full, $arr_part, $arr_data) = @_;
my (@arr_res, $found);
for (my $i = 0; $i < @$arr_full; $i++) {
$found = 0;
for (my $j = 0; $j < @$arr_part; $j++) {
if (@$arr_full[$i] eq @$arr_part[$j]) {
push (@arr_res, @$arr_data[$j]);
applications/htmlroot/cgi-bin/moderator/runStatusOnDemand.pl view on Meta::CPAN
print '<BR>', "\n";
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
print_legend (*STDOUT);
print '</BODY>', "\n", '</HTML>', "\n";
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub listAllProblems {
my ($classType, $text, $daemonPidStatus, $prefix, $daemonProcessTableHash, $regex, $action, $debug) = @_;
print "<tr><td colspan=\"2\" class=\"RunStatusOnDemandCaptureRunning\">$text</td></tr>\n" if (keys (%$daemonProcessTableHash));
while ( my ($pid, $ppid) = each(%$daemonProcessTableHash) ) {
my $cmndline = (defined $regex and $daemonProcessTableCmndline {$pid} =~ /$regex/) ? $1 . ' ...' : $daemonProcessTableCmndline {$pid};
if ($iconDelete) {
if ($action eq 'remove') {
my $urlAction = "<A HREF=\"$urlWithAccessParameters&pid=<NIHIL>&ppid=<NIHIL>&command=$PIDPATH/${daemonPidStatus}${prefix}${pid}.pid&action=remove\"><IMG SRC=\"$IMAGESURL/$ICONSSYSTEM{pidRemove}\" ALT=\"Remove\" BORDER=0></A>";
applications/htmlroot/cgi-bin/moderator/runStatusOnDemand.pl view on Meta::CPAN
print "<tr><td colspan=\"2\" class=\"RunStatusOnDemandCapture$classType\">No running process for pidfile '$PIDPATH/${daemonPidStatus}${prefix}${pid}.pid' found</td></tr>\n";
} else {
printf($FORMATPS, "RunStatusOnDemandCapture$classType", $pid, $ppid, $daemonProcessTablePctmem {$pid}, $daemonProcessTableSize {$pid}, $daemonProcessTableTtydev {$pid}, $daemonProcessTableState {$pid}, scalar(localtime($daemonProcessTableStar...
}
}
}
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub doRequestedActions {
my ($htmlTitle, $title, $command, $statusOK, $statusNOK, $debug) = @_;
print "<P class=\"RunStatusOnDemandHtmlTitle\">$htmlTitle: <font class=\"RunStatusOnDemandCommand\">$title</font></P><IMG SRC=\"".$IMAGESURL."/gears.gif\" HSPACE=\"0\" VSPACE=\"0\" BORDER=\"0\" NAME=\"Progress\" title=\"Please Wait ...\" alt=\"Plea...
my ($rStatus, $rStdout, $rStderr) = call_system ("$SSHCOMMAND -o 'StrictHostKeyChecking=no' -o 'UserKnownHostsFile=$WWWKEYPATH/.ssh/known_hosts' -i '$WWWKEYPATH/.ssh/ssh' $SSHLOGONNAME\@localhost '$command'", ($debug eq 'T') ? 1 : 0);
$rStderr =~ s/^stdin: is not a tty//;
chomp ($rStderr);
# my $message = ($rStderr) ? $rStderr : (($rStatus) ? $statusOK : $statusNOK);
my $message = ($rStderr) ? $rStderr : $statusOK;
applications/htmlroot/cgi-bin/moderator/trendlineCorrectionReports.pl view on Meta::CPAN
my ($catalogID, $uKey, $title, $test, $resultsdir, $trendline, $percentage, $tolerance, $hour, $calculated);
$sql = "select SQL_NO_CACHE $SERVERTABLPLUGINS.catalogID, $SERVERTABLPLUGINS.uKey, concat( LTRIM(SUBSTRING_INDEX($SERVERTABLPLUGINS.title, ']', -1)), ' (', $SERVERTABLENVIRONMENT.label, ')' ) as Title, $SERVERTABLPLUGINS.test, $SERVERTABLPLUGIN...
$sth = $dbh->prepare( $sql ) or $rv = error_trap_DBI(*STDOUT, "Cannot dbh->prepare: $sql", $debug, $pagedir, $pageset, $htmlTitle, $subTitle, 3600, '', $sessionID);
$sth->execute() or $rv = error_trap_DBI(*STDOUT, "Cannot sth->execute: $sql", $debug, $pagedir, $pageset, $htmlTitle, $subTitle, 3600, '', $sessionID) if $rv;
$sth->bind_columns( \$catalogID, \$uKey, \$title, \$test, \$resultsdir, \$trendline, \$percentage, \$tolerance, \$hour, \$calculated ) or $rv = error_trap_DBI(*STDOUT, "Cannot sth->bind_columns: $sql", $debug, $pagedir, $pageset, $htmlTitle, $s...
$matchingTrendlineCorrections .= '<table width="100%" border="0" cellspacing="1" cellpadding="1" bgcolor="'. $COLORSTABLE{TABLE} .'"><tr><th align="center" colspan="'. $colspan .'"> Trendline > 0 </th></tr>'. $header;
if ( $rv ) {
sub matchingTrendlineCorrections {
my ($catalogID, $uKey, $title, $test, $resultsdir, $trendline, $percentage, $tolerance, $calculated) = @_;
use POSIX qw(ceil floor);
my ($calculatedMIN, $calculatedMAX, $calculatedNEW, $ActionItem);
$calculated = sprintf("%.2f", $calculated * ( 100 + $percentage ) / 100 );
if ( $tolerance ) {
$calculatedMIN = sprintf("%.2f", $calculated * ( 100 - $tolerance ) / 100 );
$calculatedMAX = sprintf("%.2f", $calculated * ( 100 + $tolerance ) / 100 );
applications/htmlroot/cgi-bin/runCmdOnDemand.pl view on Meta::CPAN
} else {
print "<br>Select application for immediate launch.<br>";
}
}
print '<BR>', "\n";
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
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;
applications/sbin/purge_table.pl view on Meta::CPAN
unless ( $rvOpen ) {
print "Can't create $emailReport\n";
exit;
}
purgeTables ( $ago );
my ($rc) = send_email_report (*EMAILREPORT, $emailReport, $rvOpen, 'Purge table', 'F');
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub purgeTables {
my ($tableAgo) = @_;
print EMAILREPORT "\nPurge '$table' table:\n--------------------------------------------------\n" unless ( $debug );
# Init parameters
my ($rv, $dbh, $sth, $sql, $year, $month, $day, $purgetime);
$rv = 1;
$dbh = DBI->connect("dbi:mysql:$database:$host:$port", "$username", "$password" ) or $rv = _ErrorTrapDBI("Cannot connect to the database", $debug);
applications/sbin/purge_table.pl view on Meta::CPAN
$sql = 'DELETE FROM `' .$table. '` WHERE archivetime < "' .$purgetime. '"';
print "$sql\n" if ($debug);
$dbh->do( $sql ) or $rv = _ErrorTrapDBI("Cannot dbh->do: $sql", $debug) unless ( $debug );
$dbh->disconnect or $rv = _ErrorTrapDBI("Sorry, the database was unable to add your entry.", $debug);
}
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub _ErrorTrapDBI {
my ($error_message, $debug) = @_;
print EMAILREPORT " DBI Error:\n", $error_message, "\nERROR: $DBI::err ($DBI::errstr)\n";
return 0;
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
lib/ASNMTAP/Asnmtap.pm view on Meta::CPAN
undef %_config;
# Plugin variables - - - - - - - - - - - - - - - - - - - - - - - - - - -
our %ERRORS = ('OK'=>'0','WARNING'=>'1','CRITICAL'=>'2','UNKNOWN'=>'3','DEPENDENT'=>'4','OFFLINE'=>'5','NO TEST'=>'6','NO DATA'=>'7','IN PROGRESS'=>'8','TRENDLINE'=>'9');
our %STATE = ('0'=>'OK','1'=>'WARNING','2'=>'CRITICAL','3'=>'UNKNOWN','4'=>'DEPENDENT','5'=>'OFFLINE','6'=>'NO TEST','7'=>'NO DATA','8'=>'IN PROGRESS','9'=>'TRENDLINE');
our %TYPE = ('REPLACE'=>'0','APPEND'=>'1','INSERT'=>'2','COMMA_REPLACE'=>'3','COMMA_APPEND'=>'4','COMMA_INSERT'=>'5');
# Constructor & initialisation - - - - - - - - - - - - - - - - - - - - -
sub new (@) {
my $classname = shift;
unless ( defined $classname ) { my @c = caller; die "Syntax error: Class name expected after new at $c[1] line $c[2]\n" }
if ( ref $classname) { my @c = caller; die "Syntax error: Can't construct new ".ref($classname)." from another object at $c[1] line $c[2]\n" }
my $self = {};
my @parameters = (_programName => 'NOT DEFINED',
_programDescription => 'NOT DEFINED',
_programVersion => '0.000.000',
lib/ASNMTAP/Asnmtap.pm view on Meta::CPAN
}
bless ($self, $classname);
$self->_init(\%args);
$self->_getOptions();
return ($self);
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub _init {
carp ('ASNMTAP::Asnmtap: _init') if ( $_[0]->{_debug} );
$_[0]->{_programUsageSuffix} = ' [-v|--verbose <LEVEL>] [-V|--version] [-h|--help] [--usage] [--dumpData]';
$_[0]->{_programHelpSuffix} = "
-v, --verbose=<LEVEL>
0: single line, minimal output
1: single line, additional information
2: multi line, configuration debug output
3: lots of detail for problem diagnosis
lib/ASNMTAP/Asnmtap.pm view on Meta::CPAN
Display the stringified data structures from the current object
";
push (@{ $_[0]->{_programGetOptions} }, 'verbose|v:i', 'version|V', 'help|h', 'usage', 'dumpData');
$_[0]->[ $_[0]->[0]{_getOptionsType} = @{$_[0]} ] = {};
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub _getOptions {
carp ('ASNMTAP::Asnmtap: _getOptions') if ( $_[0]->{_debug} );
Getopt::Long::Configure ('bundling', 'pass_through');
my %getOptionsArgv;
my $programGetOptions = $_[0]->{_programGetOptions};
my $resultGetOptions = GetOptions ( \%getOptionsArgv, @$programGetOptions );
carp ('ASNMTAP::Asnmtap: _getOptions '. "Unknown option(s): @ARGV") if ( ref $_[0] !~ /ASNMTAP::Asnmtap::Plugins/ );
$_[0]->[ $_[0]->[0]{_getOptionsArgv} = @{$_[0]} ] = {%getOptionsArgv};
$_[0]->printRevision () if ( exists $_[0]->{_getOptionsArgv}->{version} );
lib/ASNMTAP/Asnmtap.pm view on Meta::CPAN
$_[0]->printUsage ('.') if ( exists $_[0]->{_getOptionsArgv}->{usage} );
my $verbose = (exists $_[0]->{_getOptionsArgv}->{verbose}) ? $_[0]->{_getOptionsArgv}->{verbose} : 0;
$_[0]->printUsage ('Invalid verbose option: '. $verbose) unless ($verbose =~ /^[0123]$/);
$_[0]->[ $_[0]->[0]{_getOptionsValues} = @{$_[0]} ] = {};
}
# = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
sub _checkAccObjRef { unless ( ref $_[0] ) { cluck 'Syntax error: Access object reference expected'; exit $ERRORS{UNKNOWN} } }
sub _checkSubArgs0 { if ( @_ > 1 ) { cluck "Syntax error: To many arguments ". (caller 1)[3]; exit $ERRORS{UNKNOWN} } }
sub _checkSubArgs1 { if ( @_ > 2 ) { cluck "Syntax error: To many arguments ". (caller 1)[3]; exit $ERRORS{UNKNOWN} } }
sub _checkSubArgs2 { if ( @_ > 3 ) { cluck "Syntax error: To many arguments ". (caller 1)[3]; exit $ERRORS{UNKNOWN} } }
sub _checkReadOnly0 { if ( @_ > 1 ) { cluck "Syntax error: Can't change value of read-only attribute ". (caller 1)[3]; exit $ERRORS{UNKNOWN} } }
sub _checkReadOnly1 { if ( @_ > 2 ) { cluck "Syntax error: Can't change value of read-only attribute ". (caller 1)[3]; exit $ERRORS{UNKNOWN} } }
sub _checkReadOnly2 { if ( @_ > 3 ) { cluck "Syntax error: Can't change value of read-only attribute ". (caller 1)[3]; exit $ERRORS{UNKNOWN} } }
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub _dumpValue {
require Dumpvalue;
my $dumper = Dumpvalue->new ();
print "\n->ASNMTAP::Asnmtap: Dump debug data\n\n";
$dumper->dumpValue ( $_[0] );
print "\n\n";
cluck $_[1];
exit $ERRORS{UNKNOWN};
}
# Object accessor methods - - - - - - - - - - - - - - - - - - - - - - - -
sub programName { &_checkAccObjRef ( $_[0] ); &_checkSubArgs1; $_[0]->{_programName} = $_[1] if ( defined $_[1] ); $_[0]->{_programName}; }
sub programDescription { &_checkAccObjRef ( $_[0] ); &_checkSubArgs1; $_[0]->{_programDescription} = $_[1] if ( defined $_[1] ); $_[0]->{_programDescription}; }
sub programVersion { &_checkAccObjRef ( $_[0] ); &_checkSubArgs1; $_[0]->{_programVersion} = $_[1] if ( defined $_[1] ); $_[0]->{_programVersion}; }
sub getOptionsArgv { &_checkAccObjRef ( $_[0] ); &_checkReadOnly1; ( defined $_[1] and defined $_[0]->{_getOptionsArgv}->{$_[1]} ) ? $_[0]->{_getOptionsArgv}->{$_[1]} : undef; }
sub getOptionsValue { &_checkAccObjRef ( $_[0] ); &_checkReadOnly1; ( defined $_[1] and defined $_[0]->{_getOptionsValues}->{$_[1]} ) ? $_[0]->{_getOptionsValues}->{$_[1]} : undef; }
sub getOptionsType { &_checkAccObjRef ( $_[0] ); &_checkReadOnly1; ( defined $_[1] and defined $_[0]->{_getOptionsType}->{$_[1]} ) ? $_[0]->{_getOptionsType}->{$_[1]} : undef; }
sub debug { &_checkAccObjRef ( $_[0] ); &_checkSubArgs1; $_[0]->{_debug} = $_[1] if ( defined $_[1] and $_[1] =~ /^[01]$/ ); $_[0]->{_debug}; }
# Class accessor methods - - - - - - - - - - - - - - - - - - - - - - - -
sub dumpData {
&_checkAccObjRef ( $_[0] ); &_checkSubArgs1;
if ( defined $_[1] or $_[0]->{_debug} ) {
use Data::Dumper;
print "\n". ref ($_[0]) .": Now we'll dump data\n\n", Dumper ( $_[0] ), "\n\n";
}
}
# Utility methods - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub printRevision {
&_checkAccObjRef ( $_[0] ); &_checkSubArgs1;
print "\nThis is program: ", $_[0]->{_programName}, " (", $_[0]->{_programDescription}, ") v", $_[0]->{_programVersion}, "
Copyright (c) $COPYRIGHT ASNMTAP, Author: Alex Peeters [alex.peeters\@citap.be]
";
exit ( (ref $_[0]) =~ /^ASNMTAP::Asnmtap::Plugins/ ? $ERRORS{UNKNOWN} : 0 ) unless ( defined $_[1] );
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub printUsage {
&_checkAccObjRef ( $_[0] ); &_checkSubArgs1;
print 'Usage: ', $_[0]->{_programName};
print (' ', $_[0]->{_programUsagePrefix}) if ( defined $_[0]->{_programUsagePrefix} );
print (' ', $_[0]->{_programUsageSuffix}) if ( defined $_[0]->{_programUsageSuffix} );
print "\n\n";
if ( defined $_[1] ) {
print ($_[1], "\n") unless ($_[1] eq '.');
exit ( (ref $_[0]) =~ /^ASNMTAP::Asnmtap::Plugins/ ? $ERRORS{UNKNOWN} : 0 );
}
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub printHelp {
&_checkAccObjRef ( $_[0] ); &_checkSubArgs0;
$_[0]->printRevision(1);
$_[0]->printUsage();
print $_[0]->{_programHelpPrefix}, "\n" if ( defined $_[0]->{_programHelpPrefix} );
print $_[0]->{_programHelpSuffix}, "\n" if ( defined $_[0]->{_programHelpSuffix} );
print "Send email to $SENDEMAILTO if you have questions regarding\nuse of this software. To submit patches or suggest improvements, send\nemail to $SENDEMAILTO\n\n";
exit ( (ref $_[0]) =~ /^ASNMTAP::Asnmtap::Plugins/ ? $ERRORS{UNKNOWN} : 0 );
}
# = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
sub call_system {
&_checkAccObjRef ( $_[0] ); &_checkSubArgs1;
my ($stdout, $stderr);
if ( $CAPTUREOUTPUT ) {
use IO::CaptureOutput qw(capture_exec);
($stdout, $stderr) = capture_exec ( $_[1] );
chomp($stdout); chomp($stderr);
} else {
$stdout = $stderr = ''; system ( $_[1] );
lib/ASNMTAP/Asnmtap.pm view on Meta::CPAN
ref $_[0], ": status : $status\n",
ref $_[0], ": stdout : '$stdout'\n",
ref $_[0], ": stderr : '$stderr'\n";
}
return ( $status, $stdout, $stderr );
}
# Destructor - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub DESTROY { print (ref ($_[0]), "::DESTROY: ()\n") if ( $_[0]->{_debug} ); }
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1;
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
__END__
=head1 NAME
lib/ASNMTAP/Asnmtap/Applications.pm view on Meta::CPAN
$ASNMTAP::Asnmtap::Applications::VERSION = do { my @r = (q$Revision: 3.002.003$ =~ /\d+/g); sprintf "%d."."%03d" x $#r, @r };
}
# = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
# Public subs = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
# = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
# TMP, exist into: Asnmtap
sub print_revision ($$);
sub usage;
sub call_system;
sub print_revision ($$) {
my $commandName = shift;
my $pluginRevision = shift;
$pluginRevision =~ s/^\$Revision: //;
$pluginRevision =~ s/ \$\s*$//;
print "
$commandName $pluginRevision
© Copyright $COPYRIGHT Alex Peeters [alex.peeters\@citap.be]
";
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub usage {
my $format = shift;
printf($format, @_);
exit $ERRORS{UNKNOWN};
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub call_system {
my ($system_action, $debug) = @_;
my ($stdout, $stderr, $exit_value, $signal_num, $dumped_core, $status);
if ($CAPTUREOUTPUT) {
use IO::CaptureOutput qw(capture_exec);
($stdout, $stderr) = capture_exec("$system_action");
chomp($stdout); chomp($stderr);
} else {
system ("$system_action"); $stdout = $stderr = '';
lib/ASNMTAP/Asnmtap/Applications.pm view on Meta::CPAN
$exit_value = $? >> 8;
$signal_num = $? & 127;
$dumped_core = $? & 128;
$status = ( $exit_value == 0 && $signal_num == 0 && $dumped_core == 0 && $stderr eq '' ) ? 1 : 0;
print "< $system_action >< $exit_value >< $signal_num >< $dumped_core >< $status >< $stdout >< $stderr >\n" if ($debug);
return ($status, $stdout, $stderr);
}
# = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
sub read_table;
sub get_session_param;
sub get_trendline_from_test;
# = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
sub _in_cyclus;
sub set_doIt_and_doOffline;
# = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
sub create_header;
sub create_footer;
sub encode_html_entities;
sub decode_html_entities;
sub print_header;
sub print_legend;
# = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
sub init_email_report;
sub send_email_report;
sub sending_mail;
# = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
sub CSV_prepare_table;
sub CSV_insert_into_table;
sub CSV_import_from_table;
sub CSV_cleanup_table;
# = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
sub DBI_connect;
sub DBI_do;
sub DBI_execute;
sub DBI_error_trap;
# = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
sub LOG_init_log4perl;
# = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
# Public subs without TAGS = = = = = = = = = = = = = = = = = = = = = = =
# = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
# = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
# Common variables = = = = = = = = = = = = = = = = = = = = = = = = = = =
# = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
# Applications variables - - - - - - - - - - - - - - - - - - - - - - - -
lib/ASNMTAP/Asnmtap/Applications.pm view on Meta::CPAN
$SOUND{6} = $_config{SOUND}{6} if ( exists $_config{SOUND}{6} );
$SOUND{7} = $_config{SOUND}{7} if ( exists $_config{SOUND}{7} );
$SOUND{8} = $_config{SOUND}{8} if ( exists $_config{SOUND}{8} );
$SOUND{9} = $_config{SOUND}{9} if ( exists $_config{SOUND}{9} );
}
undef %_config;
# = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
sub read_table {
my ($prgtext, $filename, $email, $tDebug) = @_;
my @table = ();
my $rvOpen = open(CT, "$APPLICATIONPATH/etc/$filename");
if ( $rvOpen ) {
while (<CT>) {
chomp;
unless ( /^#/ ) {
lib/ASNMTAP/Asnmtap/Applications.pm view on Meta::CPAN
} else {
print "Cannot open $APPLICATIONPATH/etc/$filename!\n";
exit $ERRORS{UNKNOWN};
}
return @table;
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub get_session_param {
my ($sessionID, $cgipath, $filename, $debug) = @_;
my ($Tdebug, $cgisession);
if ($debug eq 'F') {
$Tdebug = 0;
} elsif ($debug eq 'T') {
$Tdebug = 1;
} elsif ($debug eq 'L') {
$Tdebug = 2;
lib/ASNMTAP/Asnmtap/Applications.pm view on Meta::CPAN
print "\n-> cgisess '$cgipathFilename' correct sessionID: $sessionID!\n" if ($Tdebug);
return (1, %session);
} else {
print "\n-> cgisess '$cgipathFilename' wrong sessionID: $sessionID!\n" if ($Tdebug);
return (0, ());
}
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub get_trendline_from_test {
my ($test) = @_;
my ($pos, $posFrom);
my $trendline = 0;
if (($pos = index $test, " -t ") ne -1) {
$posFrom = $pos + 4;
} elsif (($pos = index $test, " --trendline=") ne -1) {
$posFrom = $pos + 13;
}
lib/ASNMTAP/Asnmtap/Applications.pm view on Meta::CPAN
if (defined $posFrom) {
$trendline = substr($test, $posFrom);
$trendline =~ s/(\d+)[ |\n][\D|\d]*/$1/g;
}
return $trendline;
}
# = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
sub _in_cyclus {
my ($what, $cyclus, $min, $max) = @_;
my @a = split(/,/, $cyclus);
my @b = ();
my ($x, $i);
map {
if (/^\*\/(\d+)$/) { # */n
if ($1) {
for $i ($min..$max) { push (@b, $i) if ((($i-$min) % $1) == 0); };
lib/ASNMTAP/Asnmtap/Applications.pm view on Meta::CPAN
push (@b, $_);
}
} @a;
for $x (@b) { return (1) if ($what eq $x); }
return (0);
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub set_doIt_and_doOffline {
my ($min, $hour, $mday, $mon, $wday, $tmin, $thour, $tmday, $tmon, $twday) = @_;
my ($doIt, $doOffline);
# do it -- this month?
$doIt = (($tmon eq "*") || ($mon eq $tmon) || _in_cyclus($mon, $tmon, 1, 12)) ? 1 : 0;
# do it -- this day of the month?
$doIt = ($doIt && (($tmday eq "*") || ($mday eq $tmday) || _in_cyclus($mday, $tmday, 1, 31))) ? 1 : 0;
lib/ASNMTAP/Asnmtap/Applications.pm view on Meta::CPAN
$doIt = ($doIt && (($tmin eq "*") || ($min eq $tmin) || _in_cyclus($min, $tmin, 0, 59))) ? 1 : 0;
# do Offline?
$doOffline = (!$doIt && (($min eq $tmin) || _in_cyclus($min, $tmin, 0, 59))) ? 1 : 0;
return ($doIt, $doOffline);
}
# = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
sub create_header {
my $filename = shift;
unless ( -e "$filename" ) { # create HEADER.html
my $rvOpen = open(HEADER, ">$filename");
if ($rvOpen) {
print_header (*HEADER, "index", "index-cv", $APPLICATION, "Debug", 3600, '', 'F', '', undef, "asnmtap-results.css");
print HEADER '<br>', "\n", '<table WIDTH="100%" border=0><tr><td class="DataDirectory">', "\n";
close(HEADER);
} else {
print "Cannot open $filename to create reports page\n";
}
}
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub create_footer {
my $filename = shift;
unless ( -e "$filename" ) { # create FOOTER.html
my $rvOpen = open(FOOTER, ">$filename");
if ($rvOpen) {
print FOOTER '</td></tr></table>', "\n", '<BR>', "\n";
print_legend (*FOOTER);
print FOOTER '</BODY>', "\n", '</HTML>', "\n";
close(FOOTER);
} else {
print "Cannot open $filename to create reports page\n";
}
}
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub encode_html_entities {
my ($type, $string) = @_;
sub convert_octalLatin1_to_decimalHtmlEntity {
my $octalLatin1 = shift;
return ("&#" .oct($octalLatin1). ";");
}
sub convert_charLatin1_to_decimalHtmlEntity {
my $charLatin1 = shift;
return ("&#" .ord($charLatin1). ";");
}
# Entities: & | é @ " # ' ( § ^ è ! ç { à } ) ° - _ ^ ¨ $ * ù % ´ µ £ ` , ? ; . : / = + ~ < > \ ² ³
use HTML::Entities;
my $htmlEntityString;
if ($type eq 'A') { # convert All entities
lib/ASNMTAP/Asnmtap/Applications.pm view on Meta::CPAN
$htmlEntityString =~ s/([\240-\377])/convert_charLatin1_to_decimalHtmlEntity($1)/eg;
} else {
$htmlEntityString = $string;
}
return ($htmlEntityString);
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub decode_html_entities {
my ($type, $string) = @_;
# Entities: & | é @ " # ' ( § ^ è ! ç { à } ) ° - _ ^ ¨ $ * ù % ´ µ £ ` , ? ; . : / = + ~ < > \ ² ³
use HTML::Entities;
my $htmlEntityString;
if ($type eq 'A') { # convert All entities
$htmlEntityString = decode_entities($string);
} elsif ($type eq 'C') { # Comment data
lib/ASNMTAP/Asnmtap/Applications.pm view on Meta::CPAN
$htmlEntityString = decode_entities($string);
} else {
$htmlEntityString = $string;
}
return ($htmlEntityString);
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub print_header {
my ($HTML, $pagedir, $pageset, $htmlTitle, $subTitle, $refresh, $onload, $openPngImage, $headScript, $sessionID, $stylesheet) = @_;
my ($pageDir, $environment) = split (/\//, $pagedir, 2);
$environment = 'P' unless (defined $environment);
my $sessionIdOrCookie = ( defined $sessionID ) ? "&CGISESSID=$sessionID" : "&CGICOOKIE=1";
my $reloadOrToggle = ( $subTitle =~ /^(?:Full View|Condenced View|Minimal Condenced View)$/ ) ? "<A HREF=\"#\" onClick=\"togglePageDirCookie('pagedir_id_${pageDir}_${environment}', '$HTTPSURL/nav/$pagedir')\">" : "<A HREF=\"#\" onClick=\"reloadP...
my $selectEnvironment = (( $pagedir ne '<NIHIL>' and $pageset ne '<NIHIL>' ) ? '<form action="" name="environment"><select name="environment" size="1" onChange="loadEnvironmentPageDirCookie(\'' .$pageDir. '\', this.options[this.selectedIndex].value...
my $showToggle = ($pagedir ne '<NIHIL>') ? $reloadOrToggle : "<A HREF=\"$HTTPSURL/cgi-bin/$pageset/index.pl?pagedir=$pagedir&pageset=$pageset&debug=F$sessionIdOrCookie\">";
lib/ASNMTAP/Asnmtap/Applications.pm view on Meta::CPAN
close(REPORTS);
} else {
print "Cannot open $reportFilename to create reports page\n";
}
}
}
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub print_legend {
my $HTML = shift;
print $HTML <<EndOfHtml;
<HR>
<table width="100%">
<tr>
<td class="LegendCopyright">© Copyright $COPYRIGHT \@ $BUSINESS</td>
<td class="LegendIcons"><FONT COLOR="$COLORS{'IN PROGRESS'}"><IMG SRC="$IMAGESURL/$ICONS{'IN PROGRESS'}" ALT="IN PROGRESS" WIDTH="16" HEIGHT="16" BORDER=0 ALIGN="middle"> in progress</FONT></TD>
<td class="LegendIcons"><FONT COLOR="$COLORS{OK}"><IMG SRC="$IMAGESURL/$ICONS{OK}" ALT="OK" WIDTH="16" HEIGHT="16" BORDER=0 ALIGN="middle"> ok</FONT></TD>
<td class="LegendIcons"><FONT COLOR="$COLORS{TRENDLINE}"><IMG SRC="$IMAGESURL/$ICONS{TRENDLINE}" ALT="TRENDLINE" WIDTH="16" HEIGHT="16" BORDER=0 ALIGN="middle" onMouseOver="LegendSound('$SOUND{$ERRORS{TRENDLINE}}');"> trendline</FONT></TD>
lib/ASNMTAP/Asnmtap/Applications.pm view on Meta::CPAN
print $HTML <<EndOfHtml;
</td>
</tr>
</table>
<HR>
EndOfHtml
}
# = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
sub init_email_report {
my ($EMAILREPORT, $filename, $debug) = @_;
my $emailReport = $RESULTSPATH .'/'. $filename;
my $rvOpen = ( $debug ) ? '1' : open($EMAILREPORT, "> $emailReport");
select((select($EMAILREPORT), $| = 1)[0]); # autoflush
unless ( defined $rvOpen ) {
$emailReport = '~/'. $filename;
$rvOpen = open($EMAILREPORT, "> $emailReport");
select((select($EMAILREPORT), $| = 1)[0]); # autoflush
print "Cannot create '$emailReport' for buffering email report information\n" unless (-e "$emailReport");
}
return ($emailReport, $rvOpen);
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub send_email_report {
my ($EMAILREPORT, $emailReport, $rvOpen, $prgtext, $debug) = @_;
my $returnCode;
if ( $rvOpen and ! $debug ) {
close($EMAILREPORT);
if (-e "$emailReport") {
my $emailMessage;
$rvOpen = open($EMAILREPORT, "$emailReport");
lib/ASNMTAP/Asnmtap/Applications.pm view on Meta::CPAN
} else {
print "$emailReport to send email report information doesn't exist\n";
}
}
return ($returnCode);
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub sending_mail {
my ( $serverListSMTP, $mailTo, $mailFrom, $mailSubject, $mailBody, $debug ) = @_;
# look at Mail.pm !!!
use Mail::Sendmail qw(sendmail %mailcfg);
$mailcfg{port} = 25;
$mailcfg{retries} = 3;
$mailcfg{delay} = 1;
$mailcfg{mime} = 0;
$mailcfg{debug} = ($debug eq 'T') ? 1 : 0;
$mailcfg{smtp} = $serverListSMTP;
use Sys::Hostname;
my %mail = ( To => $mailTo, From => $mailFrom, Subject => $mailSubject .' from '. hostname(), Message => $mailBody );
my $returnCode = ( sendmail %mail ) ? 1 : 0;
print "\$Mail::Sendmail::log says:\n", $Mail::Sendmail::log, "\n" if ($debug eq 'T');
return ( $returnCode );
}
# = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
sub CSV_prepare_table {
my ($path, $tableFilename, $extention, $tableName, $columnSequence, $tableDefinition, $logger, $debug) = @_;
my $rv = 1;
my $dbh = DBI->connect ("DBI:CSV:", "", "", {f_schema => undef, f_dir => $path, f_ext => $extention} ) or $rv = DBI_error_trap(*EMAILREPORT, "Cannot connect to the database", $logger, $debug);
if ( $rv ) {
$dbh->{csv_tables}{$tableName} = { file => $tableFilename };
$dbh->{csv_null} = 1;
$dbh->{csv_allow_whitespace} = 0;
lib/ASNMTAP/Asnmtap/Applications.pm view on Meta::CPAN
}
return $dbh;
} else {
return undef;
}
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub CSV_insert_into_table {
my ($rv, $dbh, $tableName, $columnSequence, $tableValues, $columnNameAutoincrement, $logger, $debug) = @_;
if ( defined $dbh and $rv ) {
my ($column, $placeholders, @values);
foreach my $columnName ( @{$columnSequence} ) {
$column .= $columnName .',';
$placeholders .= '?,';
push ( @values, ( ( $columnName eq $columnNameAutoincrement ) ? '' : $tableValues->{$columnName} ) );
}
lib/ASNMTAP/Asnmtap/Applications.pm view on Meta::CPAN
print "$sql\n\n@values\n\n" if ($debug);
$dbh->do ($sql, undef, @values) or $rv = DBI_error_trap(*EMAILREPORT, "Cannot dbh->do: $sql, @values", $logger, $debug);
}
}
return $rv;
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub CSV_import_from_table {
my ($rv, $dbh, $tableName, $columnSequence, $columnNameAutoincrement, $force, $logger, $debug) = @_;
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub _do_action_SQL {
my ($rv, $dbhASNMTAP, $tableName, $columnSequence, $columnNameCount, $columnNameAutoincrement, $ref, $logger, $debug) = @_;
my ($actionSQL, $set, $where, $sql) = ('I', ' SET ', ' WHERE ');
if ( $tableName eq $SERVERTABLEVENTS ) {
$where .= 'catalogID = "' .$$ref->{lc('catalogID')}. '" and uKey = "' .$$ref->{lc('uKey')}. '" and step <> "0" and timeslot = "' .$$ref->{lc('timeslot')}. '" order by id desc limit 1';
$sql = 'SELECT SQL_NO_CACHE status FROM ' . $SERVERTABLEVENTS . $where;
}
print "$sql\n\n" if ($debug);
lib/ASNMTAP/Asnmtap/Applications.pm view on Meta::CPAN
}
$sth->finish() or $rv = DBI_error_trap(*EMAILREPORT, "Cannot sth->finish", $logger, $debug);
}
return $rv;
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub CSV_cleanup_table {
my ($dbh, $logger, $debug) = @_;
$dbh->disconnect if (defined $dbh);
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub CSV_error_message {
my ($EMAILREPORT, $error_message, $logger, $debug) = @_;
use Scalar::Util qw(openhandle);
my $error = " > CSV Error:\n $error_message\n";
if ( ! $debug and defined $EMAILREPORT and openhandle($EMAILREPORT) ) { print $EMAILREPORT $error; } else { print $error; }
$$logger->info("CSV Error: $error_message") if ( defined $$logger and $$logger->is_info() );
return 0;
}
# = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
sub DBI_connect {
my ($database, $server, $port, $user, $passwd, $alarm, $DBI_error_trap, $DBI_error_trap_Arguments, $logger, $debug, $boolean_debug_all) = @_;
$$logger->info(" IN: DBI_connect: port: $port - alarm: $alarm") if ( defined $$logger and $$logger->is_info() );
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub _DBI_handle_error {
my ($error, $dbh) = @_;
no warnings;
print " _DBI_handle_error: $error\n";
$$logger->error(" _DBI_handle_error: $error");
use warnings;
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
lib/ASNMTAP/Asnmtap/Applications.pm view on Meta::CPAN
$dbh->dbix_l4p_getattr('dbix_l4p_logger'); # $$logger = $dbh->dbix_l4p_getattr('dbix_l4p_logger');
} else {
$dbh = DBI->connect("dbi:mysql:$database:$server:$port", "$user", "$passwd", { RaiseError => 1, PrintError => 0, ShowErrorStatement => 1 } ) or $rv = $DBI_error_trap->(@{$DBI_error_trap_Arguments}, $logger, $debug);
}
} else {
$$logger->info(" DBI_connect: SIGNAL") if ( defined $$logger and $$logger->is_info() );
use POSIX ':signal_h';
my $DBI_CONNECT_ALARM_OFF = 0;
my $_mask = POSIX::SigAction->new ( SIGALRM ); # list of signals to mask in the handler
my $_actionNew = POSIX::SigAction->new ( sub { $DBI_CONNECT_ALARM_OFF = $alarm; die "DBI_CONNECT_ALARM_OFF = $alarm\n"; }, $_mask );
my $_actionOld = POSIX::SigAction->new ();
sigaction ( SIGALRM, $_actionNew, $_actionOld );
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
eval {
$DBI_CONNECT_ALARM_OFF = 1;
alarm($alarm);
if ( $boolean_debug_all ) {
lib/ASNMTAP/Asnmtap/Applications.pm view on Meta::CPAN
if ( $DBI_CONNECT_ALARM_OFF ) {
$dbh = undef;
$rv = $DBI_error_trap->(@{$DBI_error_trap_Arguments}, $logger, $debug);
$alarmMessage = "DBI_CONNECT_ALARM_OFF = $DBI_CONNECT_ALARM_OFF";
$$logger->debug(" DBI_CONNECT_ALARM_OFF: Connection to '$database' timed out") if ( defined $$logger and $$logger->is_debug() );
}
}
# set up error handling
$dbh->{HandleError} = sub { _DBI_handle_error(@_) } if ( defined $dbh and $rv );
$$logger->info('OUT: DBI_connect') if ( defined $$logger and $$logger->is_info() );
return ($dbh, $rv, $alarmMessage);
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub DBI_do {
my ($rv, $dbh, $statement, $alarm, $DBI_error_trap, $DBI_error_trap_Arguments, $logger, $debug) = @_;
$$logger->info(" IN: DBI_do: rv: $rv - alarm: $alarm") if ( defined $$logger and $$logger->is_info() );
my ($affected, $alarmMessage) = (0);
if ( $rv ) {
unless ( $alarm ) {
$$logger->info(" DBI_do: NO SIGNAL") if ( defined $$logger and $$logger->is_info() );
$affected = $$dbh->do($statement) or $rv = $DBI_error_trap->(@{$DBI_error_trap_Arguments}, $logger, $debug);
} else {
$$logger->info(" DBI_do: SIGNAL") if ( defined $$logger and $$logger->is_info() );
use POSIX ':signal_h';
my $DBI_DO_ALARM_OFF = 0;
my $_mask = POSIX::SigAction->new ( SIGALRM ); # list of signals to mask in the handler
my $_actionNew = POSIX::SigAction->new ( sub { $DBI_DO_ALARM_OFF = $alarm; die "DBI_DO_ALARM_OFF = $alarm\n"; }, $_mask );
my $_actionOld = POSIX::SigAction->new ();
sigaction ( SIGALRM, $_actionNew, $_actionOld );
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
eval {
$DBI_DO_ALARM_OFF = 1;
alarm($alarm);
$affected = $$dbh->do($statement) or $rv = $DBI_error_trap->(@{$DBI_error_trap_Arguments}, $logger, $debug);
alarm(0);
lib/ASNMTAP/Asnmtap/Applications.pm view on Meta::CPAN
}
}
}
$$logger->info("OUT: DBI_do") if ( defined $$logger and $$logger->is_info() );
return ( $rv, $alarmMessage, $affected );
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub DBI_execute {
my ($rv, $sth, $alarm, $DBI_error_trap, $DBI_error_trap_Arguments, $logger, $debug) = @_;
$$logger->info(" IN: DBI_execute: rv: $rv - alarm: $alarm") if ( defined $$logger and $$logger->is_info() );
my $alarmMessage;
if ( $rv ) {
unless ( $alarm ) {
$$logger->info(" DBI_execute: NO SIGNAL") if ( defined $$logger and $$logger->is_info() );
$$sth->execute() or $rv = $DBI_error_trap->(@{$DBI_error_trap_Arguments}, $logger, $debug);
} else {
$$logger->info(" DBI_execute: SIGNAL") if ( defined $$logger and $$logger->is_info() );
use POSIX ':signal_h';
my $DBI_EXECUTE_ALARM_OFF = 0;
my $_mask = POSIX::SigAction->new ( SIGALRM ); # list of signals to mask in the handler
my $_actionNew = POSIX::SigAction->new ( sub { $DBI_EXECUTE_ALARM_OFF = $alarm; die "DBI_EXECUTE_ALARM_OFF = $alarm\n"; }, $_mask );
my $_actionOld = POSIX::SigAction->new ();
sigaction ( SIGALRM, $_actionNew, $_actionOld );
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
eval {
$DBI_EXECUTE_ALARM_OFF = 1;
alarm($alarm);
$$sth->execute() or $rv = $DBI_error_trap->(@{$DBI_error_trap_Arguments}, $logger, $debug);
alarm(0);
lib/ASNMTAP/Asnmtap/Applications.pm view on Meta::CPAN
}
}
}
$$logger->info("OUT: DBI_execute") if ( defined $$logger and $$logger->is_info() );
return ( $rv, $alarmMessage );
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub DBI_error_trap {
my ($EMAILREPORT, $error_message, $logger, $debug) = @_;
use Scalar::Util qw(openhandle);
my $error = " > DBI Error:\n" .$error_message. "\nERROR: $DBI::err ($DBI::errstr)\n";
if ( ! $debug and defined $EMAILREPORT and openhandle($EMAILREPORT) ) { print $EMAILREPORT $error; } else { print $error; }
$$logger->info("DBI Error:" .$error_message. "ERROR: $DBI::err ($DBI::errstr)") if ( defined $$logger and $$logger->is_info() );
return 0;
}
# = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
sub LOG_init_log4perl {
my ($item, $config, $boolean_debug_all) = @_;
my $logger;
if ( $boolean_debug_all ) {
eval {
use Log::Log4perl qw(get_logger);
use DBIx::Log4perl;
if ( -e "$APPLICATIONPATH/log4perl.cnf" ) {
lib/ASNMTAP/Asnmtap/Applications/CGI.pm view on Meta::CPAN
@ASNMTAP::Asnmtap::Applications::CGI::EXPORT_OK = ( @{ $ASNMTAP::Asnmtap::Applications::CGI::EXPORT_TAGS{ALL} } );
$ASNMTAP::Asnmtap::Applications::CGI::VERSION = do { my @r = (q$Revision: 3.002.003$ =~ /\d+/g); sprintf "%d."."%03d" x $#r, @r };
}
# = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
# Public subs = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
# = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
sub user_session_and_access_control;
# = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
sub do_action_DBI;
sub error_trap_DBI;
sub check_record_exist;
sub create_sql_query_events_from_range_year_month;
sub create_sql_query_from_range_SLA_window;
# = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
sub get_title;
sub get_sql_crontab_scheduling_report_data;
sub get_sql_startDate_sqlEndDate_numberOfDays_test;
# = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
sub create_combobox_from_keys_and_values_pairs;
sub create_combobox_from_DBI;
sub create_combobox_multiple_from_DBI;
sub record_navigation_table;
sub record_navigation_bar;
sub record_navigation_bar_alpha;
# = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
# Public subs without TAGS = = = = = = = = = = = = = = = = = = = = = = =
# = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
# = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
# Common variables = = = = = = = = = = = = = = = = = = = = = = = = = = =
# = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
# = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
sub user_session_and_access_control {
my ($sessionControl, $level, $cgi, $pagedir, $pageset, $debug, $htmlTitle, $subTitle, $queryString) = @_;
my ($errorUserAccessControl, $sessionID, $userType, $cfhOld, $cfhNew, $password);
$sessionID = '';
if (! $sessionControl or ( $ENV{REMOTE_ADDR} eq $REMOTE_ADDR and $ENV{HTTP_HOST} =~ /^${REMOTE_HOST}(:\d+)?/ )) {
($cfhOld) = $|; $cfhNew = select (STDOUT); $| = 1;
print $cgi->header;
$| = $cfhOld; select ($cfhNew);
return ("", 0, 0, 0, 0, 1, 1, $errorUserAccessControl, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, $subTitle);
# --> ($sessionID, $iconAdd, $iconDelete, $iconDetails, $iconEdit, $iconQuery, $iconTable,
# $errorUserAccessControl, $CremoteUser, $CremoteAddr, $CremoteNetmask, $CgivenName, $CfamilyName,
# $Cemail, $Cpassword, $CuserType, $Cpagedir, $Cactivated, $CkeyLanguage, $subTitle)
}
sub setAccessControlParameters {
my ($level, $pagedir, $pageset, $debug, $cgi, $session, $sessionID, $subTitle, $queryString) = @_;
my $logonRequestLogoff = ($cgi->param('logonRequest') or "logon");
if ( $logonRequestLogoff ne 'logoff' ) {
if ( $session->param('~logged-in') ) {
$subTitle .= " <a href=\"" .$ENV{SCRIPT_NAME}. "?pagedir=$pagedir&pageset=$pageset&debug=$debug&CGISESSID=$sessionID&logonRequest=logoff\"><IMG SRC=\"$IMAGESURL/logoff.jpg\" title=\"Logoff " .$session->param('remote...
} else {
$session->param('remoteUser', $ENV{REMOTE_USER}) if ($ENV{REMOTE_USER});
}
lib/ASNMTAP/Asnmtap/Applications/CGI.pm view on Meta::CPAN
$session->delete();
return ("", 0, 0, 0, 0, 1, 1, $errorUserAccessControl, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, $subTitle);
}
$subTitle = setAccessControlParameters( $level, $pagedir, $pageset, $debug, $cgi, $session, $sessionID, $subTitle, $queryString );
return ($sessionID, $session->param('iconAdd'), $session->param('iconDelete'), $session->param('iconDetails'), $session->param('iconEdit'), $session->param('iconQuery'), $session->param('iconTable'), $errorUserAccessControl, $session->param('remote...
}
# = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
sub do_action_DBI {
my ($rv, $dbh, $sql, $pagedir, $pageset, $htmlTitle, $subTitle, $sessionID, $debug) = @_;
my $sth = $dbh->prepare( $sql ) or $rv = error_trap_DBI(*STDOUT, "Cannot dbh->prepare: $sql", $debug, $pagedir, $pageset, $htmlTitle, $subTitle, 3600, '', $sessionID);
$sth->execute() or $rv = error_trap_DBI(*STDOUT, "Cannot sth->execute: $sql", $debug, $pagedir, $pageset, $htmlTitle, $subTitle, 3600, '', $sessionID) if $rv;
my $numberRecordsIntoQuery = ($rv) ? $sth->fetchrow_array() : 0;
$sth->finish() or $rv = error_trap_DBI(*STDOUT, "Cannot sth->finish: $sql", $debug, $pagedir, $pageset, $htmlTitle, $subTitle, 3600, '', $sessionID) if $rv;
return ($rv, $numberRecordsIntoQuery);
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub error_trap_DBI {
my ($HTML, $error_message, $debug, $pagedir, $pageset, $htmlTitle, $subTitle, $refresh, $onload, $sessionID) = @_;
my $subject = "$htmlTitle / error_trap_DBI: " . get_datetimeSignal();
my $message = get_datetimeSignal() . "\npagedir : $pagedir\npageset : $pageset\nhtml title: $htmlTitle\n\nerror message:\n$error_message\n\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 );
if ( $refresh == 0 ) {
return (0, $error_message, "DBI Error: $DBI::err", "DBI String: $DBI::errstr");
} elsif ( $refresh == -1 ) {
lib/ASNMTAP/Asnmtap/Applications/CGI.pm view on Meta::CPAN
return 0;
} else {
print_header ($HTML, $pagedir, $pageset, $htmlTitle, $subTitle, $refresh, $onload, 'F', '', $sessionID);
print "<H1>DBI Error:</H1>\n", $error_message, "\n<br><br>ERROR: $DBI::err ($DBI::errstr)\n<BR>";
return 0;
}
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub check_record_exist {
my ($rv, $dbh, $sql, $titleTXT, $keyTXT, $nameTXT, $matchingRecords, $pagedir, $pageset, $htmlTitle, $subTitle, $sessionID, $debug) = @_;
my ($key, $title);
my $sth = $dbh->prepare( $sql ) or $rv = error_trap_DBI(*STDOUT, "Cannot dbh->prepare: $sql", $debug, $pagedir, $pageset, $htmlTitle, $subTitle, 3600, '', $sessionID);
$sth->execute() or $rv = error_trap_DBI(*STDOUT, "Cannot sth->execute: $sql", $debug, $pagedir, $pageset, $htmlTitle, $subTitle, 3600, '', $sessionID) if $rv;
$sth->bind_columns( \$key, \$title ) or $rv = error_trap_DBI(*STDOUT, "Cannot sth->bind_columns: $sql", $debug, $pagedir, $pageset, $htmlTitle, $subTitle, 3600, '', $sessionID) if $rv;
if ( $rv ) {
if ( $sth->rows ) {
$matchingRecords .= "<h1>$titleTXT:</h1><table><tr><th>$keyTXT</th><th>$nameTXT</th></tr>";
lib/ASNMTAP/Asnmtap/Applications/CGI.pm view on Meta::CPAN
}
$sth->finish() or $rv = error_trap_DBI(*STDOUT, "Cannot sth->finish: $sql", $debug, $pagedir, $pageset, $htmlTitle, $subTitle, 3600, '', $sessionID);
}
return ($rv, $matchingRecords);
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub create_sql_query_events_from_range_year_month {
my ($inputType, $startDate, $endDate, $sqlSelect, $sqlForce, $sqlWhere, $sqlPeriode, $sqlQuery, $sqlGroup, $sqlOrder, $sqlOrderUnion, $sqlUnionKeyword) = @_;
$sqlUnionKeyword = 'ALL' if ($sqlUnionKeyword ne 'ALL' or $sqlUnionKeyword ne 'DISTINCT');
my ($yearFrom, $monthFrom, $dayFrom) = split (/-/, $startDate);
my ($yearTo, $monthTo, $dayTo) = split (/-/, $endDate);
use Date::Calc qw(Add_Delta_Days Delta_Days);
my $deltaDays = Delta_Days ($yearFrom, $monthFrom, $dayFrom, $yearTo, $monthTo, $dayTo);
lib/ASNMTAP/Asnmtap/Applications/CGI.pm view on Meta::CPAN
} else {
$sql = $sqlCommon;
}
}
return $sql;
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub create_sql_query_from_range_SLA_window {
my (@days) = @_; # @_ => ($sunday, $monday, $tuesday, $wednesday, $thursday, $friday, $saturday)
my ($day, $windowSLA) = (0);
foreach my $periode (@days) {
$day++;
if ( defined $periode and $periode and $periode !~ /00:00-24:00/ ) {
my @range = split (/,/, $periode);
my $windowToday;
lib/ASNMTAP/Asnmtap/Applications/CGI.pm view on Meta::CPAN
$windowSLA .= '( DAYOFWEEK(startDate) = '. $day .' and ( '. $windowToday .' ) )'
}
}
}
return ( defined $windowSLA ? ' and ( '. $windowSLA .' )' : '' );
}
# = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
sub get_title {
my ($dbh, $rv, $catalogID, $uKey, $debug, $refresh, $sessionID) = @_;
my ($sql, $sth, $errorMessage, $dbiErrorCode, $dbiErrorString, $title, $environment, $trendline, $step, $applicationTitle, $trendValue, $stepValue);
$sql = "select concat( LTRIM(SUBSTRING_INDEX(title, ']', -1)), ' (', $SERVERTABLENVIRONMENT.label, ')' ), $SERVERTABLPLUGINS.environment, trendline, step from $SERVERTABLPLUGINS, $SERVERTABLENVIRONMENT WHERE catalogID = '$catalogID' and uKey = '$uK...
$sth = $dbh->prepare( $sql ) or ($rv, $errorMessage, $dbiErrorCode, $dbiErrorString) = error_trap_DBI("", "Cannot dbh->prepare: $sql", $debug, '', "", '', "", $refresh, '', $sessionID);
$sth->execute() or ($rv, $errorMessage, $dbiErrorCode, $dbiErrorString) = error_trap_DBI("", "Cannot sth->execute: $sql", $debug, '', "", '', "", $refresh, '', $sessionID) if $rv;
$sth->bind_columns( \$title, \$environment, \$trendline, \$step ) or ($rv, $errorMessage, $dbiErrorCode, $dbiErrorString) = error_trap_DBI("", "Cannot sth->bind_columns: $sql", $debug, '', "", '', "", $refresh, '', $sessionID) if $rv;
if ( $rv ) {
while( $sth->fetch() ) {
lib/ASNMTAP/Asnmtap/Applications/CGI.pm view on Meta::CPAN
return ($rv, $errorMessage, $dbiErrorCode, $dbiErrorString, $applicationTitle, $trendValue, $stepValue);
} elsif ( $refresh == -1 ) {
return ($rv, $applicationTitle);
} else {
return ($rv, $applicationTitle, $trendValue);
}
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub get_sql_crontab_scheduling_report_data {
my ($dbh, $sql, $rv, $errorMessage, $dbiErrorCode, $dbiErrorString, $sessionID, $hight, $hightMin, $uKeys, $labels, $stepValue, $catalogID, $uKeysSqlWhere, $debug) = @_;
my ($collectorDaemon, $uKey, $lineNumber, $minute, $hour, $dayOfTheMonth, $monthOfTheYear, $dayOfTheWeek, $noOffline, $applicationTitle, $step);
my $sth = $dbh->prepare( $sql ) or ($rv, $errorMessage, $dbiErrorCode, $dbiErrorString) = error_trap_DBI("", "Cannot dbh->prepare: $sql", $debug, '', "", '', "", 0, '', $sessionID);
$sth->execute() or ($rv, $errorMessage, $dbiErrorCode, $dbiErrorString) = error_trap_DBI("", "Cannot sth->execute: $sql", $debug, '', "", '', "", 0, '', $sessionID) if $rv;
$sth->bind_columns( \$collectorDaemon, \$uKey, \$lineNumber, \$minute, \$hour, \$dayOfTheMonth, \$monthOfTheYear, \$dayOfTheWeek, \$noOffline ) or ($rv, $errorMessage, $dbiErrorCode, $dbiErrorString) = error_trap_DBI("", "Cannot sth->bind_columns: ...
my $numberOfLabels = 0;
if ( $rv ) {
lib/ASNMTAP/Asnmtap/Applications/CGI.pm view on Meta::CPAN
}
$sth->finish() or ($rv, $errorMessage, $dbiErrorCode, $dbiErrorString) = error_trap_DBI("", "Cannot sth->finish", $debug, '', "", '', "", 0, '', $sessionID);
}
return ($rv, $errorMessage, $dbiErrorCode, $dbiErrorString, $hight, $numberOfLabels);
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub get_sql_startDate_sqlEndDate_numberOfDays_test {
my ($strictDate, $firstStartDate, $inputType, $selYear, $selQuarter, $selMonth, $selWeek, $selStartDate, $selEndDate, $currentYear, $currentMonth, $currentDay, $debug) = @_;
use Date::Calc qw(Add_Delta_Days check_date Days_in_Month Delta_Days Monday_of_Week Week_of_Year);
my ($startDate, $endDate, $goodDate);
if ($inputType eq "fromto") {
if (defined $selEndDate and $selEndDate ne '') {
$startDate = $selStartDate;
$endDate = $selEndDate;
lib/ASNMTAP/Asnmtap/Applications/CGI.pm view on Meta::CPAN
print "I) " if ( $debug eq 'T' );
$goodDate = 0;
}
print "$inputType, $selYear, $selQuarter, $selMonth, $selWeek, $selStartDate, $selEndDate, $startDate, $endDate, $sqlStartDate, $sqlEndDate, $fromDeltaDays, $toDeltaDays, $numberOfDays, $sqlDeltaDays, $goodDate\n" if ( $debug eq 'T' );
return ($goodDate, $sqlStartDate, $sqlEndDate, $numberOfDays);
}
# = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
sub create_combobox_from_keys_and_values_pairs {
my ($comboboxSelectKeysAndValuesPairs, $sortOn, $sortNumeric, $Ckey, $selectName, $selectValue, $selectLabel, $formDisabled, $onChange, $debug) = @_;
my %comboSelectKeysAndValuesPairs = map { my ($key, $value) = split (/=>/) } split (/\|/, $comboboxSelectKeysAndValuesPairs);
my $comboSelect = "<select name=\"$selectName\" $formDisabled $onChange>\n";
if ($selectLabel ne '') {
$comboSelect .= " <option value=\"$selectValue\"";
$comboSelect .= " selected" if ($Ckey eq $selectValue);
$comboSelect .= ">$selectLabel</option>\n";
lib/ASNMTAP/Asnmtap/Applications/CGI.pm view on Meta::CPAN
$comboSelect .= ">$value</option>\n";
}
}
$comboSelect .= " </select>\n";
return ($comboSelect);
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub create_combobox_from_DBI {
my ($rv, $dbh, $sql, $firstOption, $nextAction, $Ckey, $selectName, $selectValue, $selectLabel, $formDisabled, $onChange, $pagedir, $pageset, $htmlTitle, $subTitle, $sessionID, $debug) = @_;
my ($key, $value);
my $sth = $dbh->prepare( $sql ) or $rv = error_trap_DBI(*STDOUT, "Cannot dbh->prepare: $sql", $debug, $pagedir, $pageset, $htmlTitle, $subTitle, 3600, '', $sessionID);
$sth->execute() or $rv = error_trap_DBI(*STDOUT, "Cannot sth->execute: $sql", $debug, $pagedir, $pageset, $htmlTitle, $subTitle, 3600, '', $sessionID) if $rv;
$sth->bind_columns( \$key, \$value) or $rv = error_trap_DBI(*STDOUT, "Cannot sth->bind_columns: $sql", $debug, $pagedir, $pageset, $htmlTitle, $subTitle, 3600, '', $sessionID) if $rv;
my $comboSelect = "<select name=\"$selectName\" $formDisabled $onChange>\n";
lib/ASNMTAP/Asnmtap/Applications/CGI.pm view on Meta::CPAN
$sth->finish() or $rv = error_trap_DBI(*STDOUT, "Cannot sth->finish: $sql", $debug, $pagedir, $pageset, $htmlTitle, $subTitle, 3600, '', $sessionID);
}
$comboSelect .= " </select>\n";
return ($rv, $comboSelect, $htmlTitle);
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub create_combobox_multiple_from_DBI {
my ($rv, $dbh, $sql, $action, $Ckey, $selectName, $selectValue, $selectSize, $textareaCols, $formDisabled, $onChange, $pagedir, $pageset, $htmlTitle, $subTitle, $sessionID, $debug) = @_;
my ($key, $value);
my $sth = $dbh->prepare( $sql ) or $rv = error_trap_DBI(*STDOUT, "Cannot dbh->prepare: $sql", $debug, $pagedir, $pageset, $htmlTitle, $subTitle, 3600, '', $sessionID);
$sth->execute() or $rv = error_trap_DBI(*STDOUT, "Cannot sth->execute: $sql", $debug, $pagedir, $pageset, $htmlTitle, $subTitle, 3600, '', $sessionID) if $rv;
$sth->bind_columns( \$key, \$value) or $rv = error_trap_DBI(*STDOUT, "Cannot sth->bind_columns: $sql", $debug, $pagedir, $pageset, $htmlTitle, $subTitle, 3600, '', $sessionID) if $rv;
my $comboboxSelect = '';
if ($rv) {
lib/ASNMTAP/Asnmtap/Applications/CGI.pm view on Meta::CPAN
}
$sth->finish() or $rv = error_trap_DBI(*STDOUT, "Cannot sth->finish: $sql", $debug, $pagedir, $pageset, $htmlTitle, $subTitle, 3600, '', $sessionID);
}
return ($rv, $comboboxSelect);
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub record_navigation_table {
my ($rv, $dbh, $sql, $label, $keyLabels, $keyNumbers, $ignoreFieldNumbers, $translationFieldsKeysAndValues, $addAccessParameters, $orderBy, $header, $navigationBar, $iconAdd, $iconDelete, $iconDetails, $iconEdit, $nextAction, $pagedir, $pageset, $p...
my $sth = $dbh->prepare( $sql ) or $rv = error_trap_DBI(*STDOUT, "Cannot dbh->prepare: $sql", $debug, $pagedir, $pageset, $htmlTitle, $subTitle, 3600, '', $sessionID);
$sth->execute() or $rv = error_trap_DBI(*STDOUT, "Cannot sth->execute: $sql", $debug, $pagedir, $pageset, $htmlTitle, $subTitle, 3600, '', $sessionID) if $rv;
my $matchingRecords = '';
if ( $rv ) {
my @keyLabels = split (/\|/, $keyLabels);
my @keyNumbers = split (/\|/, $keyNumbers);
lib/ASNMTAP/Asnmtap/Applications/CGI.pm view on Meta::CPAN
$matchingRecords .= " </table>\n";
$sth->finish() or $rv = error_trap_DBI(*STDOUT, "Cannot sth->finish: $sql", $debug, $pagedir, $pageset, $htmlTitle, $subTitle, 3600, '', $sessionID);
$nextAction = "listView";
}
return ($rv, $matchingRecords, $nextAction);
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub record_navigation_bar {
my ($currentPageNo, $numberRecordsIntoQuery, $showRecordsOnPage, $urlWithAccessParameters) = @_;
my $navigationBar;
if ( $numberRecordsIntoQuery > $showRecordsOnPage ) {
my $numberOffPagesMax = int((($numberRecordsIntoQuery - 1) / $showRecordsOnPage) + 1);
$currentPageNo = $numberOffPagesMax if ($currentPageNo > $numberOffPagesMax);
my $wantedRecordFirst = (($currentPageNo - 1) * $showRecordsOnPage) + 1;
my $TwantedRecordLast = $wantedRecordFirst + ($showRecordsOnPage - 1);
my $wantedRecordLast = ($TwantedRecordLast < $numberRecordsIntoQuery) ? $TwantedRecordLast : $numberRecordsIntoQuery;
lib/ASNMTAP/Asnmtap/Applications/CGI.pm view on Meta::CPAN
}
$navigationBar .= "</td></tr></table>\n";
}
return ($navigationBar);
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub record_navigation_bar_alpha {
my ($rv, $dbh, $table, $field, $where, $numberRecordsIntoQuery, $showRecordsOnPage, $urlWithAccessParameters, $pagedir, $pageset, $htmlTitle, $subTitle, $sessionID, $debug) = @_;
my $navigationBarAlpha = '';
if ( $numberRecordsIntoQuery > $showRecordsOnPage ) {
$navigationBarAlpha = "<table border=\"0\" width=\"100%\" bgcolor=\"$COLORSTABLE{ENDBLOCK}\"><tr bgcolor=\"$COLORSTABLE{STARTBLOCK}\"><td align=\"center\">";
my ($rownumber, $label);
my $sql = "select DISTINCT \@rownum:=\@rownum+1 AS rownumber, LEFT($table.$field, 1) as AtoZ from (select \@rownum:=0) r, `$table` force index ($field) where $where group by AtoZ order by $field asc";
lib/ASNMTAP/Asnmtap/Applications/Display.pod view on Meta::CPAN
=over 4
=item located at /opt/asnmtap/applications/custom
=over 4
=item display.pm
Here we can add customised expressions to manipulate the output of the display regarding the content of the $statusMessage where the extra error information is added to $errorMessage
sub printStatusMessageCustom {
my $statusMessage = shift(@_);
my $break = '';
my $errorMessage = '';
if ($statusMessage =~ /<NIHIL>/ ) {
$errorMessage = 'possible a problem with this execution for this plugin';
# ***************************************************************************
# Error codes indicate an error with DUMMY-Tn *
# ***************************************************************************
lib/ASNMTAP/Asnmtap/Plugins.pm view on Meta::CPAN
@ASNMTAP::Asnmtap::Plugins::EXPORT_OK = ( @{ $ASNMTAP::Asnmtap::Plugins::EXPORT_TAGS{ALL} } );
$ASNMTAP::Asnmtap::Plugins::VERSION = do { my @r = (q$Revision: 3.002.003$ =~ /\d+/g); sprintf "%d."."%03d" x $#r, @r };
}
our $ALARM_OFF = 0;
# Constructor & initialisation - - - - - - - - - - - - - - - - - - - - -
sub _init {
$_[0]->SUPER::_init($_[1]);
carp ('ASNMTAP::Asnmtap::Plugins: _init') if ( $_[0]->{_debug} );
# --httpdump & --dumphttp tijdelijk voor backwards compatibiliteit !!!
$_[0]->{_programUsageSuffix} = ' [-S|--status N] [-A|asnmtapEnv [F|T]|[F|T]|[F|T]] [-O|onDemand F|T|N|Y] [-L|--logging <LOGGING>] [-D|--debugfile|--httpdump|--dumphttp <DEBUGFILE>] [-d|--debug F|T|L|M|A|S] '. $_[0]->{_programUsageSuffix};
$_[0]->{_programHelpSuffix} = "
-S, --status=N
N(agios) : Nagios custom plugin output (default)
lib/ASNMTAP/Asnmtap/Plugins.pm view on Meta::CPAN
$_[0]->[ $_[0]->[0]{_browseragent} = @{$_[0]} ] = (defined $_[1]->{_browseragent}) ? $_[1]->{_browseragent} : 'Mozilla/5.0 (compatible; ASNMTAP; U; ASNMTAP 3.002.003 postfix; nl-BE; rv:3.002.003) Gecko/yyyymmdd libwww-perl/5.813';
$_[0]->[ $_[0]->[0]{_SSLversion} = @{$_[0]} ] = (defined $_[1]->{_SSLversion} and $_[1]->{_SSLversion} =~ /^(?:2|3|23)$/) ? $_[1]->{_SSLversion} : 3;
$_[0]->[ $_[0]->[0]{_clientCertificate} = @{$_[0]} ] = $_[1]->{_clientCertificate} if (defined $_[1]->{_clientCertificate});
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub _getOptions {
$_[0]->SUPER::_getOptions();
carp ('ASNMTAP::Asnmtap::Plugins: _getOptions') if ( $_[0]->{_debug} );
# Default _pluginValues - - - - - - - - - - - - - - - - - - - - - - - -
$_[0]->[ $_[0]->[0]{_pluginValues} = @{$_[0]} ] = {};
$_[0]->{_pluginValues}->{stateValue} = $ERRORS{DEPENDENT};
$_[0]->{_pluginValues}->{stateError} = $STATE{$_[0]->{_pluginValues}->{stateValue}};
lib/ASNMTAP/Asnmtap/Plugins.pm view on Meta::CPAN
# Timing Out Slow Plugins - part 1/2 - - - - - - - - - - - - - - - - - -
if ( exists $_[0]->{_getOptionsArgv}->{timeout} ) {
$_[0]->{_pluginValues}->{_alarm_} = alarm (0);
if ( $_[0]->{_pluginValues}->{_alarm_} && $_[0]->{_getOptionsArgv}->{timeout} > $_[0]->{_pluginValues}->{_alarm_} ) {
$_[0]->{_getOptionsArgv}->{timeout} = $_[0]->{_pluginValues}->{_alarm_};
}
$_[0]->{_pluginValues}->{_handler_} = $SIG{ALRM};
$SIG{ALRM} = sub { $ALARM_OFF = 1; die "ASNMTAP::Asnmtap::Plugins::ALARM_OFF = 1\n" };
alarm ( $_[0]->{_getOptionsArgv}->{timeout} );
}
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub _init_proxy_and_client_certificate {
my $proxy = ( exists $ENV{ASNMTAP_PROXY} ? $ENV{ASNMTAP_PROXY} : ( exists $_[0]->{_getOptionsArgv}->{proxy} and defined $_[0]->{_getOptionsArgv}->{proxy} ? $_[0]->{_getOptionsArgv}->{proxy} : undef ) );
if ( defined $proxy and $proxy ne '' ) {
my ($proxyServer, $proxyNo, $proxyServerNo, $proxyUsername, $proxyPassword, $proxyUsernamePassword);
($proxyUsernamePassword, $proxyServerNo) = split(/\@/, $proxy );
if ( defined $proxyServerNo ) {
($proxyUsername, $proxyPassword) = split(/\:/, $proxyUsernamePassword, 2);
$_[0]->printUsage ('Username and/or Password missing: : '. $proxy) unless (defined $proxyUsername and defined $proxyPassword);
($proxyServer, $proxyNo) = split(/\&/, $proxyServerNo );
lib/ASNMTAP/Asnmtap/Plugins.pm view on Meta::CPAN
if (defined $_[0]->{_clientCertificate}->{pkcs12File} and defined $_[0]->{_clientCertificate}->{pkcs12Password}) {
# CLIENT PKCS12 CERT SUPPORT, Use of this type of certificate will take precedence over previous certificate settings described.
$ENV{HTTPS_PKCS12_FILE} = $_[0]->{_clientCertificate}->{pkcs12File};
$ENV{HTTPS_PKCS12_PASSWORD} = $_[0]->{_clientCertificate}->{pkcs12Password};
}
}
}
# Object accessor methods - - - - - - - - - - - - - - - - - - - - - - - -
sub appendPerformanceData { &_checkAccObjRef ( $_[0] ); &_checkSubArgs1; $_[0]->{_pluginValues}->{performanceData} .= ' '. $_[1] if ( defined $_[1] ); }
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub browseragent { &_checkAccObjRef ( $_[0] ); &_checkSubArgs1; $_[0]->{_browseragent} = $_[1] if ( defined $_[1] ); $_[0]->{_browseragent}; }
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub SSLversion {
&_checkAccObjRef ( $_[0] ); &_checkSubArgs1;
if ( defined $_[1] ) {
$_[0]->{_SSLversion} = ($_[1] =~ /^(?:2|3|23)$/ ? $_[1] : 3);
}
$_[0]->{_SSLversion};
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub clientCertificate {
&_checkAccObjRef ( $_[0] ); &_checkSubArgs2;
if ( defined $_[1] ) {
if ( defined $_[2] ) {
$_[0]->{_clientCertificate}->{$_[1]} = $_[2] if ( exists $_[0]->{_clientCertificate}->{$_[1]} );
}
( defined $_[0]->{_clientCertificate}->{$_[1]} ) ? $_[0]->{_clientCertificate}->{$_[1]} : undef;
}
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub pluginValue {
&_checkAccObjRef ( $_[0] ); &_checkSubArgs2;
if ( defined $_[1] and exists $_[0]->{_pluginValues}->{$_[1]}) {
if ( exists $_[2] ) {
if ( $_[1] eq 'stateValue' ) {
&_dumpValue ( $_[2], 'Wrong value!' ) unless ( defined $_[2] && $_[2] =~ /^[0-3]$/ );
my $stateValue = $_[0]->{_pluginValues}->{stateValue} == $ERRORS{DEPENDENT} ? $_[2] : ( $_[0]->{_pluginValues}->{stateValue} > $_[2] ? $_[0]->{_pluginValues}->{stateValue} : $_[2] );
$_[0]->{_pluginValues}->{stateValue} = $stateValue;
$_[0]->{_pluginValues}->{stateError} = $STATE{$stateValue};
} elsif ( $_[1] eq 'stateError' ) {
lib/ASNMTAP/Asnmtap/Plugins.pm view on Meta::CPAN
$_[0]->{_pluginValues}->{$_[1]} = $_[2] if ( defined $_[2] );
}
}
( defined $_[0]->{_pluginValues}->{$_[1]} ) ? $_[0]->{_pluginValues}->{$_[1]} : undef;
}
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub pluginValues {
&_checkAccObjRef ( $_[0] ); &_checkSubArgs2;
&_dumpValue ( $_[1], 'Request parameter is not a hash.' ) if ( ref $_[1] ne 'HASH' );
&_dumpValue ( $_[1], 'Replace/Append value missing!' ) unless (defined $_[2]);
if ( exists $_[1]->{stateValue} ) {
&_dumpValue ( $_[1]->{stateValue}, 'Wrong value!' ) unless ( defined $_[1]->{stateValue} && $_[1]->{stateValue} =~ /^[0-3]$/ );
my $stateValue = $_[0]->{_pluginValues}->{stateValue} == $ERRORS{DEPENDENT} ? $_[1]->{stateValue} : ( $_[0]->{_pluginValues}->{stateValue} > $_[1]->{stateValue} ? $_[0]->{_pluginValues}->{stateValue} : $_[1]->{stateValue} );
$_[0]->{_pluginValues}->{stateValue} = $stateValue;
$_[0]->{_pluginValues}->{stateError} = $STATE{$stateValue};
} elsif ( exists $_[1]->{stateError} ) {
lib/ASNMTAP/Asnmtap/Plugins.pm view on Meta::CPAN
} elsif ( $_[2] == $TYPE{COMMA_INSERT} ) {
$_[0]->{_pluginValues}->{alert} = ( $_[1]->{alert} . ( defined $_[0]->{_pluginValues}->{alert} ? ', '. $_[0]->{_pluginValues}->{alert} : '' ) ) if ( defined $_[1]->{alert} );
$_[0]->{_pluginValues}->{error} = ( $_[1]->{error} . ( defined $_[0]->{_pluginValues}->{alert} ? ', '. $_[0]->{_pluginValues}->{error} : '' ) ) if ( defined $_[1]->{error} );
}
$_[0]->{_pluginValues}->{result} = $_[1]->{result} if ( defined $_[1]->{result} );
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub proxy {
&_checkAccObjRef ( $_[0] ); &_checkSubArgs2;
if ( defined $_[1] ) {
if ( exists $_[0]->{_proxy} ) {
if ( defined $_[2] ) {
$_[0]->{_proxy}->{$_[1]} = $_[2] if ( exists $_[0]->{_proxy}->{$_[1]} );
}
( defined $_[0]->{_proxy}->{$_[1]} ) ? $_[0]->{_proxy}->{$_[1]} : undef;
} else {
undef;
}
}
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub timeout { &_checkAccObjRef ( $_[0] ); &_checkSubArgs1; $_[0]->{_timeout} = $_[1] if ( defined $_[1] ); $_[0]->{_timeout}; }
# Class accessor methods - - - - - - - - - - - - - - - - - - - - - - - -
sub setEndTime_and_getResponsTime {
&_checkAccObjRef ( $_[0] ); &_checkSubArgs1;
my ($endTimeSeconds, $endTimeMicroseconds) = gettimeofday();
$_[0]->{_pluginValues}->{endTime} = "$endTimeSeconds.$endTimeMicroseconds";
my ($startTimeSeconds, $startTimeMicroseconds) = split (/\./, $_[1]);
$startTimeMicroseconds = 0 unless ( defined $startTimeMicroseconds );
return ( defined $startTimeSeconds ? int ( ( ( $endTimeSeconds >= $startTimeSeconds ) ? tv_interval ( [$startTimeSeconds, $startTimeMicroseconds], [$endTimeSeconds, $endTimeMicroseconds] ) : tv_interval ( [$endTimeSeconds, $endTimeMicroseconds], [$...
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub write_debugfile {
&_checkAccObjRef ( $_[0] ); &_checkReadOnly2;
my $debugfile = $_[0]->{_getOptionsArgv}->{debugfile};
if ( defined $debugfile ) {
my $openAppend = ( defined $_[2] and $_[2] =~ /^1$/ ) ? 1 : 0;
my $rvOpen = open (DEBUGFILE, ($openAppend ? '>>' : '>') .$debugfile);
if ($rvOpen) {
print DEBUGFILE ${$_[1]}, "\n";
close(DEBUGFILE);
} else {
print ref ($_[0]) .": Cannot open $debugfile to print debug information\n";
}
}
}
# Utility methods - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub printUsage {
$_[0]->_getOptions () if ( exists $_[0]->{_getOptionsArgv}->{usage} );
$_[0]->SUPER::printUsage ($_[1]);
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub printHelp {
$_[0]->_getOptions ();
$_[0]->SUPER::printHelp ();
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub call_system {
&_checkAccObjRef ( $_[0] ); &_checkReadOnly2;
return ( $ERRORS{DEPENDENT} ) unless ( defined $_[1] );
my ($status, $stdout, $stderr) = $_[0]->SUPER::call_system ( $_[1] );
if ( $status ) {
if ( $_[0]->{_getOptionsValues}->{debug} ) {
$_[0]->pluginValues ( { stateValue => $ERRORS{OK}, alert => $_[1] .': OK', result => ( defined $stdout ? $stdout : undef ) }, $TYPE{APPEND} );
} else {
$_[0]->pluginValues ( { stateValue => $ERRORS{OK}, result => ( defined $stdout ? $stdout : undef ) }, $TYPE{APPEND} );
lib/ASNMTAP/Asnmtap/Plugins.pm view on Meta::CPAN
} else {
$_[0]->pluginValues ( { stateValue => $ERRORS{UNKNOWN}, error => $_[1] .': '. $stderr, result => ( defined $stderr ? $stderr : undef ) }, $TYPE{APPEND} );
}
return ( $ERRORS{UNKNOWN} );
}
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub exit {
&_checkAccObjRef ( $_[0] ); &_checkSubArgs1;
exit $ERRORS { $_[0]->{_pluginValues}->{stateError} } if ( exists $_[0]->{_exit_} and $_[0]->{_exit_} == 1 );
# Timing Out Slow Plugins - part 2/2 - - - - - - - - - - - - - - - - -
if ( exists $_[0]->{_getOptionsArgv}->{timeout} ) {
my $remaining = alarm (0);
if ( $ALARM_OFF or $! =~ /\QASNMTAP::Asnmtap::Plugins::ALARM_OFF = 1\n\E/ or $@ =~ /\QASNMTAP::Asnmtap::Plugins::ALARM_OFF = 1\n\E/ ) {
lib/ASNMTAP/Asnmtap/Plugins.pm view on Meta::CPAN
$_[0]->dumpData (1) if ( $_[0]->getOptionsArgv ('dumpData') );
print "$returnMessage\n" if ( $_[0]->{_plugins} );
$_[0]->{_exit_} = 1;
exit $ERRORS { $_[0]->{_pluginValues}->{stateError} };
}
# Destructor - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub DESTROY {
print (ref ($_[0]), "::DESTROY: ()\n") if ( $_[0]->{_debug} );
if ( exists $_[0]->{_pluginValues} ) {
unless ( exists $_[0]->{_exit_} and $_[0]->{_exit_} == 1 ) {
$_[0]->{_exit_} = 2;
$_[0]->exit(0);
}
}
$_[0]->{_exit_} = 1;
lib/ASNMTAP/Asnmtap/Plugins/IO.pm view on Meta::CPAN
SOCKET => [ qw(&scan_socket_info) ] );
@ASNMTAP::Asnmtap::Plugins::IO::EXPORT_OK = ( @{ $ASNMTAP::Asnmtap::Plugins::IO::EXPORT_TAGS{ALL} } );
$ASNMTAP::Asnmtap::Plugins::IO::VERSION = do { my @r = (q$Revision: 3.002.003$ =~ /\d+/g); sprintf "%d."."%03d" x $#r, @r };
}
# Utility methods - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub scan_socket_info {
my %defaults = ( asnmtapInherited => undef,
custom => undef,
customArguments => undef,
protocol => undef,
host => undef,
port => undef,
service => undef,
request => undef,
socketTimeout => undef,
timeout => 10,
lib/ASNMTAP/Asnmtap/Plugins/IO.pm view on Meta::CPAN
print 'ASNMTAP::Asnmtap::Plugins::IO::scan_socket_info::socketTimeout: ', $parms{socketTimeout}, "\n";
print 'ASNMTAP::Asnmtap::Plugins::IO::scan_socket_info::timeout: ', $parms{timeout}, "\n";
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
my ($exit, $action, $INET);
$exit = 0;
$action = '<NIHIL>';
$SIG{ALRM} = sub { alarm (0); $exit = 1 };
alarm ( $parms{timeout} ); $exit = 0;
use IO::Socket;
if ( defined $parms{socketTimeout} ) {
$INET = IO::Socket::INET->new ( Proto => $parms{protocol}, PeerAddr => $parms{host}, PeerPort => $parms{port} );
} else {
$INET = IO::Socket::INET->new ( Proto => $parms{protocol}, PeerAddr => $parms{host}, PeerPort => $parms{port}, Timeout => $parms{socketTimeout} );
}
lib/ASNMTAP/Asnmtap/Plugins/IO.pod view on Meta::CPAN
=item $INET
$INET provides an object interface to using sockets in the AF_INET domain. It is built upon the IO::Socket interface and inherits all the methods defined by IO::Socket.
=item $action
a reference to the action
=back
sub actionOnSocketResponse {
my ($asnmtapInherited, $parms, $INET, $action) = @_;
while ( <$$INET> ) {
chomp;
if ( $exit ) { $$action = "<TIMEOUT>"; last; }
SWITCH: {
if ( $_ =~ /^220 / ) { print $$INET "HELP\n"; }
if ( $_ =~ /^211 / ) { print $$INET "QUIT\n"; $$action = 'OK (211)'; }
lib/ASNMTAP/Asnmtap/Plugins/IO.pod view on Meta::CPAN
if ( $_ =~ /^501 / ) { print $$INET "QUIT\n"; $$action = 'OK (501)'; }
if ( $_ =~ /^502 / ) { print $$INET "QUIT\n"; $$action = 'OK (502)'; }
if ( $_ =~ /^504 / ) { print $$INET "QUIT\n"; $$action = 'OK (504)'; }
if ( $_ =~ /^221 / ) { $$action = 'OK (221)'; last; }
}
}
}
and now with customArguments:
sub actionOnSocketResponse {
my ($asnmtapInherited, $parms, $INET, $action, $arguments) = @_;
while ( <$$INET> ) {
chomp;
if ( $exit ) { $$action = "<TIMEOUT>"; last; }
SWITCH: {
if ( $_ =~ /^220 / ) { print $$INET "HELP\n"; }
if ( $_ =~ /^211 / ) { print $$INET "QUIT\n"; $$action = 'OK (211)'; }
lib/ASNMTAP/Asnmtap/Plugins/Mail.pm view on Meta::CPAN
%ASNMTAP::Asnmtap::Plugins::Mail::EXPORT_TAGS = ( ALL => [ qw() ] );
@ASNMTAP::Asnmtap::Plugins::Mail::EXPORT_OK = ( @{ $ASNMTAP::Asnmtap::Plugins::Mail::EXPORT_TAGS{ALL} } );
$ASNMTAP::Asnmtap::Plugins::Mail::VERSION = do { my @r = (q$Revision: 3.002.003$ =~ /\d+/g); sprintf "%d."."%03d" x $#r, @r };
}
# Constructor & initialisation - - - - - - - - - - - - - - - - - - - - -
sub new (@) {
my $classname = shift;
unless ( defined $classname ) { my @c = caller; die "Syntax error: Class name expected after new at $c[1] line $c[2]\n" }
if ( ref $classname) { my @c = caller; die "Syntax error: Can't construct new ".ref($classname)." from another object at $c[1] line $c[2]\n" }
my $self = {};
my @parameters = (_asnmtapInherited => undef,
_SMTP =>
{
lib/ASNMTAP/Asnmtap/Plugins/Mail.pm view on Meta::CPAN
$self->{_mail}->{body} = $args{_mail}->{body} if ( exists $args{_mail}->{body} );
}
bless ($self, $classname);
$self->_init();
return ($self);
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub _init {
my $asnmtapInherited = $_[0]->{_asnmtapInherited};
unless ( defined $asnmtapInherited ) { cluck ( 'ASNMTAP::Asnmtap::Plugins::Mail: asnmtapInherited missing' ); exit $ERRORS{UNKNOWN} }
carp ('ASNMTAP::Asnmtap::Pluginw::MAIL: _init') if ( $$asnmtapInherited->{_debug} );
unless ( defined $$asnmtapInherited->{_programName} and $$asnmtapInherited->{_programName} ne 'NOT DEFINED' ) {
$$asnmtapInherited->pluginValues ( { stateValue => $ERRORS{UNKNOWN}, error => 'Missing parent object attribute mName' }, $TYPE{APPEND} );
return ( $ERRORS{UNKNOWN} );
}
lib/ASNMTAP/Asnmtap/Plugins/Mail.pm view on Meta::CPAN
}
if ( $$asnmtapInherited->{_debug} ) {
use Data::Dumper;
print "\n". ref ($_[0]) .": Now we'll dump data\n\n", Dumper ( $_[0] ), "\n\n";
}
}
# Utility methods - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub sending_fingerprint_mail {
my $self = shift; &_checkAccObjRef ( $self );
my $asnmtapInherited = $self->{_asnmtapInherited};
return ( $$asnmtapInherited->pluginValue ('stateValue') ) unless ( exists $self->{_subject_} );
my %defaults = ( perfdataLabel => undef );
my %parms = (%defaults, @_);
$$asnmtapInherited->setEndTime_and_getResponsTime ( $$asnmtapInherited->pluginValue ('endTime') ) if ( defined $parms{perfdataLabel} );
lib/ASNMTAP/Asnmtap/Plugins/Mail.pm view on Meta::CPAN
my $responseTime = $$asnmtapInherited->setEndTime_and_getResponsTime ( $$asnmtapInherited->pluginValue ('endTime') );
$$asnmtapInherited->appendPerformanceData ( "'". $parms{perfdataLabel} ."'=". $responseTime .'ms;;;;' );
}
print "\$Mail::Sendmail::log says:\n", $Mail::Sendmail::log, "\n" if ( $$asnmtapInherited->getOptionsValue ('debug') );
return ( $returnCode );
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub receiving_fingerprint_mails {
my $self = shift; &_checkAccObjRef ( $self );
my $asnmtapInherited = $self->{_asnmtapInherited};
return ( $$asnmtapInherited->pluginValue ('stateValue') ) unless ( exists $self->{_subject_} );
my %defaults = ( custom => undef,
customArguments => undef,
checkFingerprint => 1,
receivedState => 0,
outOfDate => undef,
lib/ASNMTAP/Asnmtap/Plugins/Mail.pm view on Meta::CPAN
$email->Close;
}
$$asnmtapInherited->appendPerformanceData ( "'". $parms{perfdataLabel} ."'=". $self->{defaultArguments}->{numberOfMatches} .';;;;' ) if ( defined $parms{perfdataLabel} );
return ( $returnCode, $self->{defaultArguments}->{numberOfMatches} );
}
}
# Destructor - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub DESTROY { print (ref ($_[0]), "::DESTROY: ()\n") if ( exists $$_[0]->{_asnmtapInherited} and $$_[0]->{_asnmtapInherited}->{_debug} ); }
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1;
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
__END__
=head1 NAME