ASNMTAP

 view release on metacpan or  search on metacpan

lib/ASNMTAP/Asnmtap/Plugins/IO.pod  view on Meta::CPAN

=head1 NAME

ASNMTAP::Asnmtap::Plugins::IO is a Perl module that provides IO functions used by ASNMTAP-based plugins.

=head1 DESCRIPTION

 use ASNMTAP::Asnmtap::Plugins v3.002.003;
 use ASNMTAP::Asnmtap::Plugins qw(:PLUGINS);

 my $objectPlugins = ASNMTAP::Asnmtap::Plugins->new (
   _programName        => 'check_template-IO.pl',
   _programDescription => "IO plugin template for the '$APPLICATION'",
   _programVersion     => '3.002.003',
   _programUsagePrefix => '--service <service> --protocol <protocol> --request <request>',
   _programHelpPrefix  => '--service=<service>
 --protocol=<protocol>
 --request=<request>',
   _programGetOptions  => ['host|H=s', 'port|P=i', 'service:s', 'protocol:s', 'request:s', 'username|u|loginname:s', 'password|p|passwd:s', 'timeout|t:i', 'trendline|T:i'],
   _timeout            => 30,
   _debug              => 0);

 my $host     = $objectPlugins->getOptionsArgv ('host');
 my $port     = $objectPlugins->getOptionsArgv ('port');
 my $service  = $objectPlugins->getOptionsArgv ('service');
 my $protocol = $objectPlugins->getOptionsArgv ('protocol');
 my $request  = $objectPlugins->getOptionsArgv ('request');
 my $username = $objectPlugins->getOptionsArgv ('username');
 my $password = $objectPlugins->getOptionsArgv ('password');

 use ASNMTAP::Asnmtap::Plugins::IO v3.002.003;
 use ASNMTAP::Asnmtap::Plugins::IO qw(:SOCKET);

 my $returnCode = scan_socket_info (
   asnmtapInherited => \$objectPlugins,
   protocol         => $protocol,
   host             => $host,
   port             => $port,
   service          => $service,
   request          => $request,
   socketTimeout    => 5,
   POP3             => {
     username          => $username, 
     password          => $password, 
     serviceReady      =>  "[XMail [0-9.]+ POP3 Server] service ready",
     passwordRequired  => 'Password required for',
     mailMessages      => "Maildrop has [0-9.]+ messages",
     closingSession    =>  "[XMail [0-9.]+ POP3 Server] closing session"
                       }
 );

=head1 FUNCTIONS

=head2 Socket based functions

=over 4

=item *

scan_socket_info()

=over 4

=item asnmtapInherited

A required reference to an ASNMTAP::Asnmtap::Plugins or ASNMTAP::Asnmtap::Plugins::Nagios subclass

Through this way of working we inherited the command line option I<--debug>.

=item custom

optional, is an reference to your own custom defined function

=over 4

=item $asnmtapInherited

A required reference to an ASNMTAP::Asnmtap::Plugins or ASNMTAP::Asnmtap::Plugins::Nagios subclass

Through this way of working we inherited the command line option I<--debug>.

=item $parms

a reference to the scan_socket_info () parameters

=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;

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)'; }
       if ( $_ =~ /^214 / ) { print $$INET "QUIT\n"; $$action = 'OK (214)'; }
       if ( $_ =~ /^250 / ) { print $$INET "QUIT\n"; $$action = 'OK (250)'; }
       if ( $_ =~ /^421 / ) { print $$INET "QUIT\n"; $$action = 'OK (421)'; }
       if ( $_ =~ /^500 / ) { print $$INET "QUIT\n"; $$action = 'OK (500)'; }
       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; }
     }
   }
 }

=item customArguments

optional, when you need to pass parameters to your own custom defined function, this can be done with customArguments.

 customArguments: SCALAR, ARRAY, HASH,
                  REF SCALAR, REF ARRAY, REF HASH

=item protocol

required, can be 'udp' of 'tcp'

=item host

required, scalar, remote host address <hostname>[:<port>]

=item port

required, scalar, remote port

=item service

required, scalar, remote service

=item request

optional, scalar, default 

=item socketTimeout

timeout	value for various operations

optional, scalar

=item timeout

timeout	value for all operations to die

optional, scalar, default 10

=item POP3

=over 4

=item username

required, scalar

=item password

required, scalar

=item serviceReady

 "[XMail [0-9.]+ POP3 Server] service ready"

required, scalar

=item passwordRequired

 'Password required for'

required, scalar

=item mailMessages

 "Maildrop has [0-9.]+ messages"

required, scalar

=item closingSession

 "[XMail [0-9.]+ POP3 Server] closing session"

required, scalar

=back

=back

=back

=head2 TAGS

=over 4

=item ALL

 &scan_socket_info



( run in 0.925 second using v1.01-cache-2.11-cpan-39bf76dae61 )