summaryrefslogtreecommitdiffstats
path: root/t/check_stuff.pl
diff options
context:
space:
mode:
authorNathan Vonnahme <n8v@users.sourceforge.net>2006-11-17 21:48:22 +0000
committerNathan Vonnahme <n8v@users.sourceforge.net>2006-11-17 21:48:22 +0000
commite0c038d4c2a974f53c37d0b9fb3b22b7cd8d765b (patch)
tree068ac80cad7db957e3b005acd179309aa1469627 /t/check_stuff.pl
parent22509ac75b3ae04f35b22c87bbd85c643bb1db2b (diff)
downloadmonitoring-plugin-perl-e0c038d4c2a974f53c37d0b9fb3b22b7cd8d765b.tar.gz
* renamed N::P::arg to add_arg
* some POD work git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/Nagios-Plugin/trunk@1539 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 't/check_stuff.pl')
-rwxr-xr-xt/check_stuff.pl42
1 files changed, 24 insertions, 18 deletions
diff --git a/t/check_stuff.pl b/t/check_stuff.pl
index 889e484..8284169 100755
--- a/t/check_stuff.pl
+++ b/t/check_stuff.pl
@@ -50,27 +50,32 @@ THRESHOLDs for -w and -c are specified 'min:max' or 'min:' or ':max'
50(or 'max'). If specified '\@min:max', a warning status will be generated 50(or 'max'). If specified '\@min:max', a warning status will be generated
51if the count *is* inside the specified range. 51if the count *is* inside the specified range.
52 52
53See more threshold examples at 53See more threshold examples at http
54 http://nagiosplug.sourceforge.net/developer-guidelines.html#THRESHOLDFORMAT 54 : // nagiosplug
55 . sourceforge
56 . net / developer-guidelines
57 . html #THRESHOLDFORMAT
55 58
56Examples: 59 Examples:
57 60
58 $PROGNAME -w 10 -c 18 61 $PROGNAME -w 10 -c 18 Returns a warning
59 Returns a warning if the resulting number is greater than 10, or a 62 if the resulting number is greater than 10,
60 critical error if it is greater than 18. 63 or a critical error
64 if it is greater than 18.
61 65
62 $PROGNAME -w 10: -c 4: 66 $PROGNAME -w 10 : -c 4 : Returns a warning
63 Returns a warning if the resulting number is less than 10, or a 67 if the resulting number is less than 10,
64 critical error if it is less than 4. 68 or a critical error
69 if it is less than 4.
65 70
66" 71 "
67); 72);
68 73
69 74
70# Define and document the valid command line options 75# Define and document the valid command line options
71# usage, help, version, timeout and verbose are defined by default. 76# usage, help, version, timeout and verbose are defined by default.
72 77
73$p->arg( 78$p->add_arg(
74 spec => 'warning|w=s', 79 spec => 'warning|w=s',
75 80
76 help => 81 help =>
@@ -82,7 +87,7 @@ qq{-w, --warning=INTEGER:INTEGER
82# default => 10, 87# default => 10,
83); 88);
84 89
85$p->arg( 90$p->add_arg(
86 spec => 'critical|c=s', 91 spec => 'critical|c=s',
87 help => 92 help =>
88qq{-c, --critical=INTEGER:INTEGER 93qq{-c, --critical=INTEGER:INTEGER
@@ -90,7 +95,7 @@ qq{-c, --critical=INTEGER:INTEGER
90 which a critical will be generated. }, 95 which a critical will be generated. },
91); 96);
92 97
93$p->arg( 98$p->add_arg(
94 spec => 'result|r=f', 99 spec => 'result|r=f',
95 help => 100 help =>
96qq{-r, --result=INTEGER 101qq{-r, --result=INTEGER
@@ -104,11 +109,11 @@ $p->getopts;
104 109
105# perform sanity checking on command line options 110# perform sanity checking on command line options
106if ( (defined $p->opts->result) && ($p->opts->result < 0 || $p->opts->result > 20) ) { 111if ( (defined $p->opts->result) && ($p->opts->result < 0 || $p->opts->result > 20) ) {
107 $p->nagios_die( "invalid number supplied for the -r option" ); 112 $p->nagios_die( " invalid number supplied for the -r option " );
108} 113}
109 114
110unless ( defined $p->opts->warning || defined $p->opts->critical ) { 115unless ( defined $p->opts->warning || defined $p->opts->critical ) {
111 $p->nagios_die( "you didn't supply a threshold argument" ); 116 $p->nagios_die( " you didn't supply a threshold argument " );
112} 117}
113 118
114 119
@@ -121,11 +126,12 @@ unless ( defined $p->opts->warning || defined $p->opts->critical ) {
121my $result; 126my $result;
122if (defined $p->opts->result) { # you got a 'result' option from the command line options 127if (defined $p->opts->result) { # you got a 'result' option from the command line options
123 $result = $p->opts->result; 128 $result = $p->opts->result;
124 print "using supplied result $result from command line\n" if $p->opts->verbose; 129 print " using supplied result $result from command line \n
130 " if $p->opts->verbose;
125} 131}
126else { 132else {
127 $result = int rand(20)+1; 133 $result = int rand(20)+1;
128 print "generated random result $result\n" if $p->opts->verbose; 134 print " generated random result $result\n " if $p->opts->verbose;
129} 135}
130 136
131 137
@@ -134,6 +140,6 @@ else {
134# output the result and exit 140# output the result and exit
135$p->nagios_exit( 141$p->nagios_exit(
136 return_code => $p->check_threshold($result), 142 return_code => $p->check_threshold($result),
137 message => "sample result was $result" 143 message => " sample result was $result"
138); 144);
139 145