ASNMTAP
view release on metacpan or search on metacpan
plugins/templates/check_template-ras.pl view on Meta::CPAN
my $objectPlugins = ASNMTAP::Asnmtap::Plugins->new (
_programName => 'check_template-ras.pl',
_programDescription => "RAS plugin template for the '$APPLICATION'",
_programVersion => '3.002.003',
_programUsagePrefix => '--phonenumber=<phonenumber> [--port=<port>] [--baud=<baud rate>]',
_programHelpPrefix => '--phonenumber<phonenumber>
--port=<port>
windows: com1, com2, com3 or com4
linux : /dev/ttyS0, /dev/ttyS1, /dev/ttyS2 or /dev/ttyS3
--baud=<baud rate>
300, 1200, 2400, 4800, 9600, 19200, 28800, 38400, 57600 or 115200',
_programGetOptions => ['Phonenumber=s', 'Port:s' ,'Baud:s', 'loglevel|l=s', 'timeout|t:i', 'trendline|T:i'],
_timeout => 30,
_debug => 0);
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
my $loglevel = $objectPlugins->getOptionsArgv ('loglevel');
my $phonenumber = $objectPlugins->getOptionsArgv ('Phonenumber');
$objectPlugins->printUsage ('Missing command line argument Phonenumber') unless (defined $phonenumber);
my $port = $objectPlugins->getOptionsArgv ('Port');
$objectPlugins->printUsage ('Missing command line argument Port') unless (defined $port);
my $baud = $objectPlugins->getOptionsArgv ('Baud');
$objectPlugins->printUsage ('Missing command line argument Baud') unless (defined $baud);
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
use ASNMTAP::Asnmtap::Plugins::Modem v3.002.003;
use ASNMTAP::Asnmtap::Plugins::Modem qw(&get_modem_request);
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Start plugin - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
my $returnCode = get_modem_request (
asnmtapInherited => \$objectPlugins,
custom => \&actionOnModemResponse,
phonenumber => $phonenumber,
port => $port,
baudrate => $baud,
phonebook => 'ASNMTAP',
defaultGateway => '192.168.123.254',
interface => 'eth0',
logtype => 'file',
loglevel => $loglevel
);
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# End plugin - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
$objectPlugins->exit (7);
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub actionOnModemResponse {
my ($asnmtapInherited, $parms, $modem, $ok, $answer, $not_connected_guess, $arguments) = @_;
my $debug = $asnmtapInherited->getOptionsValue ('debug');
if ($debug and defined $arguments) {
for ( ref $arguments ) {
/^REF$/ &&
do {
for ( ref $$arguments ) {
/^ARRAY$/ &&
do { print "REF ARRAY: @$$arguments\n"; last; };
/^HASH$/ &&
do { print "REF HASH: "; while (my ($key, $value) = each %{ $$arguments } ) { print "$key => $value "; }; print "\n"; last; };
}
last;
};
/^ARRAY$/ &&
do { print "ARRAY: @$arguments\n"; last; };
/^HASH$/ &&
do { print "HASH: "; while (my ($key, $value) = each %{ $arguments } ) { print "$key => $value "; }; print "\n"; last; };
/^SCALAR$/ &&
do { print "REF SCALAR: ", $$arguments, "\n"; last; };
print "SCALAR: ", $arguments, "\n";
}
}
print 'ASNMTAP::Asnmtap::Plugins::Modem::get_modem_request::actionOnModemResponse: ', $asnmtapInherited->programDescription (), "\n" if ( $debug );
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub errorTrapFTP {
my ($asnmtapInherited, $error_message, $ftp_message, $debug) = @_;
print "$error_message\n" if ($debug);
chomp ($ftp_message);
$asnmtapInherited->pluginValues ( { stateValue => $ERRORS{CRITICAL}, error => $error_message .': '. $ftp_message, result => '' }, $TYPE{APPEND} );
return 0;
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# use Net::FTP;
my ($ftp, $rv, $hostname);
$rv = 1;
$hostname = 'ftp.citap.be';
# $ftp = Net::FTP->new ($hostname, Debug => $debug) or $rv = errorTrapFTP ($asnmtapInherited, 'Cannot connect to '. $hostname, "$@", $debug);
# $ftp->quit if $rv;
return ( $rv ? $ERRORS{OK} : $ERRORS{UNKNOWN} );
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
__END__
=head1 NAME
check_template-ras.pl
( run in 2.542 seconds using v1.01-cache-2.11-cpan-437f7b0c052 )