plugins/templates/check_template-mail-fingerprint-xml.pl

filter: Statementstmt 54.0% 20 / 37 Branchbran 25.0% 1 / 4 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 87.5% 7 / 8 Podpod n/a totaltotal 51.8% 28 / 54 CC 4 SCAR 11.0
CC
4
Cov
48%
actionOnMailBody
7.4
BEGIN
2.5
BEGIN
1.0
CRAP 3.0
« blib/lib/ASNMTAP/PseudoHash.pm ↑ Summary plugins/templates/check_template-mail-fingerprint.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-fingerprint-xml.pl
6 # ----------------------------------------------------------------------------------------------------------
7  
8 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 2 ▶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
BranchTrueFalseTotal
if ($ENV{"ASNMTAP_PERL5LIB"}) 0 2 2
15  
16 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
17  
18 2 ▶use ASNMTAP::Asnmtap::Plugins v3.002.003;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 2 ▶use ASNMTAP::Asnmtap::Plugins qw(:PLUGINS %STATE);
Subroutine BEGIN: called CC=1 SCAR=0.0
20  
21 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
22  
23 2 my $objectPlugins = ASNMTAP::Asnmtap::Plugins->new (
24 _programName => 'check_template-mail-fingerprint-xml.pl',
25 _programDescription => "XML fingerprint Mail plugin template for testing the '$APPLICATION'",
26 _programVersion => '3.002.003',
27 _programGetOptions => ['username|u|loginname=s', 'password|p|passwd=s', 'interval|i=i', '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 $interval = $objectPlugins->getOptionsArgv ('interval');
36 0 my $environment = $objectPlugins->getOptionsArgv ('environment');
37  
38 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
39  
40 2 ▶use ASNMTAP::Asnmtap::Plugins::Mail v3.002.003;
Subroutine BEGIN: called CC=1 SCAR=0.0
41  
42 0 my $body = "
43  
44 This is the body of the email !!!
45  
46 ";
47  
48 0 my $objectMAIL = ASNMTAP::Asnmtap::Plugins::Mail->new (
49 _asnmtapInherited => \$objectPlugins,
50 _SMTP => { smtp => [ qw(smtp.citap.be) ], mime => 0 },
51 _POP3 => { pop3 => 'pop3.citap.be', username => $username, password => $password },
52 _mailType => 1,
53 _text => { SUBJECT => 'uKey=MAIL_'. $environment .'_0002' },
54 _mail => {
55 from => 'alex.peeters@citap.com',
56 to => 'asnmtap@citap.com',
57 status => $APPLICATION .' Status UP',
58 body => $body
59 }
60 );
61  
62 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
63 # Start plugin - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
64 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
65  
66 0 my ($returnCode, $numberOfMatches);
67  
68 # Receiving Fingerprint Mails - - - - - - - - - - - - - - - - - - - - - -
69  
70 0 ($returnCode, $numberOfMatches) = $objectMAIL->receiving_fingerprint_mails( custom => \&actionOnMailBody, receivedState => 0, outOfDate => $interval, perfdataLabel => 'email(s) received' );
71  
72 # Sending Fingerprint Mail - - - - - - - - - - - - - - - - - - - - - - -
73  
74 0 $returnCode = $objectMAIL->sending_fingerprint_mail( perfdataLabel => 'email send' );
75  
76 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
77 # End plugin - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
78 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
79  
80 0 $objectPlugins->exit (7);
81  
82 # Function needed by receiving_fingerprint_mail ! - - - - - - - - - - - -
83  
84 0 ▶sub actionOnMailBody {
Subroutine actionOnMailBody: not called CC=3 SCAR=20.0
85 0 my ($self, $asnmtapInherited, $pop3, $msgnum) = @_;
86  
87 2 ▶ no warnings 'deprecated';
Subroutine BEGIN: called CC=1 SCAR=0.0
88 0 my $returnCode = $ERRORS{OK};
89  
90 # put here your code regarding the MailBody - - - - - - - - - - - - - -
91 # print "\n\n". $self->{defaultArguments}->{result}. "\n\n";
92  
93 0 $$asnmtapInherited->pluginValues ( { stateValue => $returnCode, alert => 'OKIDO' }, $TYPE{REPLACE} );
94  
95 # put here your code for deleting the email from the Mailbox - - - - -
96 0 ▶ $pop3->Delete( $msgnum ) unless ( $$asnmtapInherited->getOptionsValue ('debug') or $$asnmtapInherited->getOptionsValue ('onDemand') );
Branch: 1 branch
BranchTrueFalseTotal
unless $$asnmtapInherited->getOptionsValue("debug") or $$asnmtapInherited->getOptionsValue("onDemand") 0 0 0
Condition0%0/3
$$asnmtapInherited->getOptionsValue("debug") or $$asnmtapInherited->getOptionsValue("onDemand")
l!l&&r!l&&!r
000
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")
ABresult
1X1
011
000
97 0 $self->{defaultArguments}->{numberOfMatches}++;
98 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
99  
100 0 return ( $returnCode );
101 }
102  
103 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
104  
105 __END__
« blib/lib/ASNMTAP/PseudoHash.pm ↑ Summary plugins/templates/check_template-mail-fingerprint.pl »