ASNMTAP
view release on metacpan or search on metacpan
applications/collector-test.pl view on Meta::CPAN
#!/usr/bin/env perl
# ----------------------------------------------------------------------------------------------------------
# © Copyright 2003-2011 Alex Peeters [alex.peeters@citap.be]
# ----------------------------------------------------------------------------------------------------------
# 2011/mm/dd, v3.002.003, collector-test.pl for ASNMTAP::Asnmtap::Applications::Collector
# ----------------------------------------------------------------------------------------------------------
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}" )'; } }
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
use DBI;
use File::stat;
use Time::Local;
use Getopt::Long;
use Date::Calc qw(Delta_DHMS);
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
use ASNMTAP::Time v3.002.003;
use ASNMTAP::Time qw(&get_datetimeSignal &get_csvfiledate &get_csvfiletime &get_logfiledate &get_datetime &get_timeslot);
use ASNMTAP::Asnmtap::Applications::Collector v3.002.003;
use ASNMTAP::Asnmtap::Applications::Collector qw(:APPLICATIONS :COLLECTOR :DBCOLLECTOR);
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
use lib ( "$CHARTDIRECTORLIB" );
use perlchartdir;
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
use vars qw($opt_H $opt_M $opt_C $opt_W $opt_A $opt_N $opt_s $opt_S $opt_D $opt_V $opt_h $PROGNAME);
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
$PROGNAME = "collector.pl";
my $prgtext = "Collector 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 $status = 'N'; # default
my $dumphttp = 'N'; # default
my $debug = 'F'; # default
my $logging = '<NIHIL>'; # default
my $httpdump = '<NIHIL>'; # default
my $lockMySQL = 0; # default
my $alarm = 5; # default 5
my $perfParseMethode = 'PULP'; # 'AIP', default
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
my $boolean_screenDebug = 0; # default
my $boolean_debug_all = 0; # default
my $boolean_debug_NOK = 0; # default
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
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,
"s:s" => \$opt_s, "dumphttp:s" => \$opt_s,
"S:s" => \$opt_S, "status:s" => \$opt_S,
"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}; }
if ($opt_h) { print_help(); exit $ERRORS{OK}; }
($opt_H) || usage("MySQL hostname/address not specified\n");
my $serverName = $1 if ($opt_H =~ /([-.A-Za-z0-9]+)/);
($serverName) || usage("Invalid MySQL hostname/address: $opt_H\n");
($opt_M) || usage("Mode not specified\n");
my $mode = $opt_M if ($opt_M eq 'O' || $opt_M eq 'L' || $opt_M eq 'C');
($mode) || usage("Invalid mode: $opt_M\n");
if ($mode eq 'O') { $boolean_loopQuit = 1; }
($opt_C) || usage("collectorlist not specified\n");
my $collectorlist = $1 if ($opt_C =~ /([-.A-Za-z0-9]+)/);
($collectorlist) || usage("Invalid collectorlist: $opt_C\n");
if ($opt_W) {
if ($opt_W eq 'F' || $opt_W eq 'T') {
$boolean_screenDebug = ($opt_W eq 'T') ? 1 : 0;
} else {
usage("Invalid all screendebugging: $opt_W\n");
}
}
if ($opt_A) {
if ($opt_A eq 'F' || $opt_A eq 'T') {
$boolean_debug_all = ($opt_A eq 'T') ? 1 : 0;
} else {
usage("Invalid all file debugging: $opt_A\n");
}
}
applications/collector-test.pl view on Meta::CPAN
$layer->addDataSet(\@dataWarning, $COLORSRRD {WARNING}, " Warning");
$layer->addDataSet(\@dataCritical, $COLORSRRD {CRITICAL}, " Critical");
$layer->addDataSet(\@dataUnknown, $COLORSRRD {UNKNOWN}, " Unknown");
$layer->addDataSet(\@dataNoTest, $COLORSRRD {"NO TEST"}, " No test");
$layer->addDataSet(\@dataOffline, $COLORSRRD {OFFLINE}, " Offline");
# Set the sub-bar gap to 0, so there is no gap between stacked bars with a group
$layer->setBarGap(-1.7E-100, 0);
# Set the bar border to transparent
if ($withBorder) {
$layer->setBorderColor(0xF0F0F0);
} else {
$layer->setBorderColor($perlchartdir::Transparent);
}
# Add a legend box
$c->addLegend(2, $hight - 34, 0, "arial.ttf", 8)->setBackground($perlchartdir::Transparent);
# Add a custom CDML text at the bottom right of the plot area as the logo
$c->addText($width - 3, 92, $APPLICATION . " @ " . $BUSINESS, "arial.ttf", 8, 0x999999, 6, 270);
$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>
FILENAME : filename from the collectorlist for the loop of crontab
-W, --screenDebug=F|T
F(alse) : all screendebugging off (default)
T(true) : all screendebugging on
-A, --allDebug=F|T
F(alse) : all file debugging off (default)
T(true) : all file debugging on
-N, --nokDebug=F|T
F(alse) : nok file debugging off (default)
T(true) : nok file debugging on
-s, --dumphttp=N|A|W|C|U
N(one) : httpdump off (default)
A(ll) : httpdump for all events
W(arning) : httpdump only the warning, critical and unknown critical events
C(ritical) : httpdump only the critical and unknown critical events
U(nknown) : httpdump only the unknown critical events
-S, --status=N|S
N(agios): Nagios custom plugin output (default)
S(nmp) : SNMP ...
-D, --debug=F|T|L
F(alse) : screendebugging off (default)
T(true) : normal screendebugging on
L(ong) : long screendebugging on
-V, --version
-h, --help
Send email to $SENDEMAILTO if you have questions regarding
use of this software. To submit patches or suggest improvements, send
email to $SENDEMAILTO
";
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
( run in 3.053 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )