« plugins/templates/check_template-mail-fingerprint.pl
↑ Summary
plugins/templates/check_template-XML.pl »
| 1 | #!/usr/bin/env perl | ||||||||||||||||||||||||||||
| 2 | # ---------------------------------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 3 | # © Copyright 2003-2011 by Alex Peeters [alex.peeters@citap.be] | ||||||||||||||||||||||||||||
| 4 | # ---------------------------------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 5 | # 2011/mm/dd, v3.002.003, check_template-mail.pl | ||||||||||||||||||||||||||||
| 6 | # ---------------------------------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 3 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 3 | ▶ | use warnings; # Must be used in test mode only. This reduces a little process speed | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | #use diagnostics; # Must be used in test mode only. This reduces a lot of process speed | ||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | ||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | 0 | ▶ | BEGIN { if ( $ENV{ASNMTAP_PERL5LIB} ) { eval 'use lib ( "$ENV{ASNMTAP_PERL5LIB}" )'; } } | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=2 SCAR=9.2
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | ||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | 3 | ▶ | use ASNMTAP::Asnmtap::Plugins v3.002.003; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 19 | 3 | ▶ | use ASNMTAP::Asnmtap::Plugins qw(:PLUGINS %STATE); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | ||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | 3 | my $objectPlugins = ASNMTAP::Asnmtap::Plugins->new ( | |||||||||||||||||||||||||||
| 24 | _programName => 'check_template-mail.pl', | ||||||||||||||||||||||||||||
| 25 | _programDescription => "Mail plugin template for testing the '$APPLICATION'", | ||||||||||||||||||||||||||||
| 26 | _programVersion => '3.002.003', | ||||||||||||||||||||||||||||
| 27 | _programGetOptions => ['username|u|loginname=s', 'password|p|passwd=s', 'environment|e=s', 'timeout|t:i', 'trendline|T:i'], | ||||||||||||||||||||||||||||
| 28 | _timeout => 30, | ||||||||||||||||||||||||||||
| 29 | _debug => 0); | ||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | ||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | 0 | my $username = $objectPlugins->getOptionsArgv ('username'); | |||||||||||||||||||||||||||
| 34 | 0 | my $password = $objectPlugins->getOptionsArgv ('password'); | |||||||||||||||||||||||||||
| 35 | 0 | my $environment = $objectPlugins->getOptionsArgv ('environment'); | |||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | ||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | 3 | ▶ | use ASNMTAP::Asnmtap::Plugins::Mail v3.002.003; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | 0 | my $body = " | |||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | This is the body of the email !!! | ||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | "; | ||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | 0 | my $objectMAIL = ASNMTAP::Asnmtap::Plugins::Mail->new ( | |||||||||||||||||||||||||||
| 48 | _asnmtapInherited => \$objectPlugins, | ||||||||||||||||||||||||||||
| 49 | _SMTP => { smtp => [ qw(smtp.citap.be) ], mime => 0 }, | ||||||||||||||||||||||||||||
| 50 | _POP3 => { pop3 => 'pop3.citap.be', username => $username, password => $password }, | ||||||||||||||||||||||||||||
| 51 | _mailType => 0, | ||||||||||||||||||||||||||||
| 52 | _text => { SUBJECT => 'uKey=MAIL_'. $environment .'_0001' }, | ||||||||||||||||||||||||||||
| 53 | _mail => { | ||||||||||||||||||||||||||||
| 54 | from => 'alex.peeters@citap.com', | ||||||||||||||||||||||||||||
| 55 | to => 'asnmtap@citap.com', | ||||||||||||||||||||||||||||
| 56 | status => $APPLICATION .' Status UP', | ||||||||||||||||||||||||||||
| 57 | body => $body | ||||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||
| 59 | ); | ||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | ||||||||||||||||||||||||||||
| 62 | # Start plugin - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | ||||||||||||||||||||||||||||
| 63 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | ||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | 0 | my ($returnCode, $numberOfMatches); | |||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | # Receiving Fingerprint Mails - - - - - - - - - - - - - - - - - - - - - - | ||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | 0 | ($returnCode, $numberOfMatches) = $objectMAIL->receiving_fingerprint_mails( custom => \&actionOnMailBody, receivedState => 0, perfdataLabel => 'email(s) received' ); | |||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||
| 71 | # Sending Fingerprint Mail - - - - - - - - - - - - - - - - - - - - - - - | ||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | 0 | $returnCode = $objectMAIL->sending_fingerprint_mail( perfdataLabel => 'email send' ); | |||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||
| 75 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | ||||||||||||||||||||||||||||
| 76 | # End plugin - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | ||||||||||||||||||||||||||||
| 77 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | ||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | 0 | $objectPlugins->exit (7); | |||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||
| 81 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | ||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||
| 83 | # Function needed by receiving_fingerprint_mail ! - - - - - - - - - - - - | ||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||
| 85 | 0 | ▶ | sub actionOnMailBody { | ||||||||||||||||||||||||||
|
Subroutine
actionOnMailBody: not called CC=3 SCAR=20.0
| |||||||||||||||||||||||||||||
| 86 | 0 | my ($self, $asnmtapInherited, $pop3, $msgnum) = @_; | |||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | 3 | ▶ | no warnings 'deprecated'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 89 | 0 | my $returnCode = $ERRORS{OK}; | |||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||
| 91 | # put here your code regarding the MailBody - - - - - - - - - - - - - - | ||||||||||||||||||||||||||||
| 92 | # print "\n\n". $self->{defaultArguments}->{result}. "\n\n"; | ||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||
| 94 | 0 | $$asnmtapInherited->pluginValues ( { stateValue => $returnCode, alert => 'OKIDO' }, $TYPE{REPLACE} ); | |||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||
| 96 | # put here your code for deleting the email from the Mailbox - - - - - | ||||||||||||||||||||||||||||
| 97 | 0 | ▶ | $pop3->Delete( $msgnum ) unless ( $$asnmtapInherited->getOptionsValue ('debug') or $$asnmtapInherited->getOptionsValue ('onDemand') ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$$asnmtapInherited->getOptionsValue("debug") or $$asnmtapInherited->getOptionsValue("onDemand")
MC/DC0%0/2
$$asnmtapInherited->getOptionsValue("debug") or $$asnmtapInherited->getOptionsValue("onDemand")
$$asnmtapInherited->getOptionsValue("debug")
$$asnmtapInherited->getOptionsValue("onDemand")
Truth table0%0/3
A or B
A= $$asnmtapInherited->getOptionsValue("debug")B= $$asnmtapInherited->getOptionsValue("onDemand")
| |||||||||||||||||||||||||||||
| 98 | 0 | $self->{defaultArguments}->{numberOfMatches}++; | |||||||||||||||||||||||||||
| 99 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | ||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||
| 101 | 0 | return ( $returnCode ); | |||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||
| 104 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | ||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||
| 106 | __END__ | ||||||||||||||||||||||||||||