line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Monitoring::GLPlugin::Commandline; |
2
|
2
|
|
|
2
|
|
7
|
use strict; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
48
|
|
3
|
2
|
|
|
2
|
|
6
|
use IO::File; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
253
|
|
4
|
2
|
|
|
2
|
|
8
|
use constant { OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3, DEPENDENT => 4 }; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
6764
|
|
5
|
|
|
|
|
|
|
our %ERRORS = ( |
6
|
|
|
|
|
|
|
'OK' => OK, |
7
|
|
|
|
|
|
|
'WARNING' => WARNING, |
8
|
|
|
|
|
|
|
'CRITICAL' => CRITICAL, |
9
|
|
|
|
|
|
|
'UNKNOWN' => UNKNOWN, |
10
|
|
|
|
|
|
|
'DEPENDENT' => DEPENDENT, |
11
|
|
|
|
|
|
|
); |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our %STATUS_TEXT = reverse %ERRORS; |
14
|
|
|
|
|
|
|
our $AUTOLOAD; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub new { |
18
|
3
|
|
|
3
|
0
|
9
|
my ($class, %params) = @_; |
19
|
|
|
|
|
|
|
require Monitoring::GLPlugin::Commandline::Getopt |
20
|
3
|
100
|
|
|
|
760
|
if ! grep /BEGIN/, keys %Monitoring::GLPlugin::Commandline::Getopt::; |
21
|
3
|
|
|
|
|
44
|
my $self = { |
22
|
|
|
|
|
|
|
perfdata => [], |
23
|
|
|
|
|
|
|
messages => { |
24
|
|
|
|
|
|
|
ok => [], |
25
|
|
|
|
|
|
|
warning => [], |
26
|
|
|
|
|
|
|
critical => [], |
27
|
|
|
|
|
|
|
unknown => [], |
28
|
|
|
|
|
|
|
}, |
29
|
|
|
|
|
|
|
args => [], |
30
|
|
|
|
|
|
|
opts => Monitoring::GLPlugin::Commandline::Getopt->new(%params), |
31
|
|
|
|
|
|
|
modes => [], |
32
|
|
|
|
|
|
|
statefilesdir => undef, |
33
|
|
|
|
|
|
|
}; |
34
|
3
|
|
|
|
|
10
|
foreach (qw(shortname usage version url plugin blurb extra |
35
|
|
|
|
|
|
|
license timeout)) { |
36
|
27
|
|
|
|
|
35
|
$self->{$_} = $params{$_}; |
37
|
|
|
|
|
|
|
} |
38
|
3
|
|
|
|
|
7
|
bless $self, $class; |
39
|
3
|
|
33
|
|
|
23
|
$self->{plugin} ||= $Monitoring::GLPlugin::pluginname; |
40
|
3
|
|
|
|
|
9
|
$self->{name} = $self->{plugin}; |
41
|
3
|
|
|
|
|
13
|
$Monitoring::GLPlugin::plugin = $self; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub AUTOLOAD { |
45
|
6
|
|
|
6
|
|
13
|
my ($self, @params) = @_; |
46
|
6
|
50
|
|
|
|
20
|
return if ($AUTOLOAD =~ /DESTROY/); |
47
|
|
|
|
|
|
|
$self->debug("AUTOLOAD %s\n", $AUTOLOAD) |
48
|
6
|
50
|
|
|
|
20
|
if $self->{opts}->verbose >= 2; |
49
|
6
|
50
|
|
|
|
33
|
if ($AUTOLOAD =~ /^.*::(add_arg|override_opt|create_opt)$/) { |
50
|
6
|
|
|
|
|
30
|
$self->{opts}->$1(@params); |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub DESTROY { |
55
|
1
|
|
|
1
|
|
8
|
my ($self) = @_; |
56
|
|
|
|
|
|
|
# ohne dieses DESTROY rennt nagios_exit in obiges AUTOLOAD rein |
57
|
|
|
|
|
|
|
# und fliegt aufs Maul, weil {opts} bereits nicht mehr existiert. |
58
|
|
|
|
|
|
|
# Unerklaerliches Verhalten. |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub debug { |
62
|
0
|
|
|
0
|
0
|
0
|
my ($self, $format, @message) = @_; |
63
|
0
|
|
|
|
|
0
|
my $tracefile = "/tmp/".$Monitoring::GLPlugin::pluginname.".trace"; |
64
|
0
|
0
|
|
|
|
0
|
$self->{trace} = -f $tracefile ? 1 : 0; |
65
|
0
|
0
|
0
|
|
|
0
|
if ($self->opts->verbose && $self->opts->verbose > 10) { |
66
|
0
|
|
|
|
|
0
|
printf("%s: ", scalar localtime); |
67
|
0
|
|
|
|
|
0
|
printf($format, @message); |
68
|
0
|
|
|
|
|
0
|
printf "\n"; |
69
|
|
|
|
|
|
|
} |
70
|
0
|
0
|
|
|
|
0
|
if ($self->{trace}) { |
71
|
0
|
|
|
|
|
0
|
my $logfh = IO::File->new(); |
72
|
0
|
|
|
|
|
0
|
$logfh->autoflush(1); |
73
|
0
|
0
|
|
|
|
0
|
if ($logfh->open($tracefile, "a")) { |
74
|
0
|
|
|
|
|
0
|
$logfh->printf("%s: ", scalar localtime); |
75
|
0
|
|
|
|
|
0
|
$logfh->printf($format, @message); |
76
|
0
|
|
|
|
|
0
|
$logfh->printf("\n"); |
77
|
0
|
|
|
|
|
0
|
$logfh->close(); |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
sub opts { |
83
|
279
|
|
|
279
|
0
|
253
|
my ($self) = @_; |
84
|
279
|
|
|
|
|
850
|
return $self->{opts}; |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
sub getopts { |
88
|
2
|
|
|
2
|
0
|
2
|
my ($self) = @_; |
89
|
2
|
|
|
|
|
6
|
$self->opts->getopts(); |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
sub add_message { |
93
|
0
|
|
|
0
|
0
|
|
my ($self, $code, @messages) = @_; |
94
|
0
|
0
|
|
|
|
|
$code = (qw(ok warning critical unknown))[$code] if $code =~ /^\d+$/; |
95
|
0
|
|
|
|
|
|
$code = lc $code; |
96
|
0
|
|
|
|
|
|
push @{$self->{messages}->{$code}}, @messages; |
|
0
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
sub selected_perfdata { |
100
|
0
|
|
|
0
|
0
|
|
my ($self, $label) = @_; |
101
|
0
|
0
|
0
|
|
|
|
if ($self->opts->can("selectedperfdata") && $self->opts->selectedperfdata) { |
102
|
0
|
|
|
|
|
|
my $pattern = $self->opts->selectedperfdata; |
103
|
0
|
0
|
|
|
|
|
return ($label =~ /$pattern/i) ? 1 : 0; |
104
|
|
|
|
|
|
|
} else { |
105
|
0
|
|
|
|
|
|
return 1; |
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
} |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
sub add_perfdata { |
110
|
0
|
|
|
0
|
0
|
|
my ($self, %args) = @_; |
111
|
|
|
|
|
|
|
#printf "add_perfdata %s\n", Data::Dumper::Dumper(\%args); |
112
|
|
|
|
|
|
|
#printf "add_perfdata %s\n", Data::Dumper::Dumper($self->{thresholds}); |
113
|
|
|
|
|
|
|
# |
114
|
|
|
|
|
|
|
# wenn warning, critical, dann wird von oben ein expliziter wert mitgegeben |
115
|
|
|
|
|
|
|
# wenn thresholds |
116
|
|
|
|
|
|
|
# wenn label in |
117
|
|
|
|
|
|
|
# warningx $self->{thresholds}->{$label}->{warning} existiert |
118
|
|
|
|
|
|
|
# dann nimm $self->{thresholds}->{$label}->{warning} |
119
|
|
|
|
|
|
|
# ansonsten thresholds->default->warning |
120
|
|
|
|
|
|
|
# |
121
|
|
|
|
|
|
|
|
122
|
0
|
|
|
|
|
|
my $label = $args{label}; |
123
|
0
|
|
|
|
|
|
my $value = $args{value}; |
124
|
0
|
|
0
|
|
|
|
my $uom = $args{uom} || ""; |
125
|
0
|
|
|
|
|
|
my $format = '%d'; |
126
|
|
|
|
|
|
|
|
127
|
0
|
0
|
0
|
|
|
|
if ($self->opts->can("morphperfdata") && $self->opts->morphperfdata) { |
128
|
|
|
|
|
|
|
# 'Intel [R] Interface (\d+) usage'='nic$1' |
129
|
0
|
|
|
|
|
|
foreach my $key (keys %{$self->opts->morphperfdata}) { |
|
0
|
|
|
|
|
|
|
130
|
0
|
0
|
|
|
|
|
if ($label =~ /$key/) { |
131
|
0
|
|
|
|
|
|
my $replacement = '"'.$self->opts->morphperfdata->{$key}.'"'; |
132
|
0
|
|
|
|
|
|
my $oldlabel = $label; |
133
|
0
|
|
|
|
|
|
$label =~ s/$key/$replacement/ee; |
|
0
|
|
|
|
|
|
|
134
|
0
|
0
|
|
|
|
|
if (exists $self->{thresholds}->{$oldlabel}) { |
135
|
0
|
|
|
|
|
|
%{$self->{thresholds}->{$label}} = %{$self->{thresholds}->{$oldlabel}}; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
} |
137
|
|
|
|
|
|
|
} |
138
|
|
|
|
|
|
|
} |
139
|
|
|
|
|
|
|
} |
140
|
0
|
0
|
|
|
|
|
if ($value =~ /\./) { |
141
|
0
|
0
|
|
|
|
|
if (defined $args{places}) { |
142
|
0
|
|
|
|
|
|
$value = sprintf '%.'.$args{places}.'f', $value; |
143
|
|
|
|
|
|
|
} else { |
144
|
0
|
|
|
|
|
|
$value = sprintf "%.2f", $value; |
145
|
|
|
|
|
|
|
} |
146
|
|
|
|
|
|
|
} else { |
147
|
0
|
|
|
|
|
|
$value = sprintf "%d", $value; |
148
|
|
|
|
|
|
|
} |
149
|
0
|
|
|
|
|
|
my $warn = ""; |
150
|
0
|
|
|
|
|
|
my $crit = ""; |
151
|
0
|
0
|
|
|
|
|
my $min = defined $args{min} ? $args{min} : ""; |
152
|
0
|
0
|
|
|
|
|
my $max = defined $args{max} ? $args{max} : ""; |
153
|
0
|
0
|
0
|
|
|
|
if ($args{thresholds} || (! exists $args{warning} && ! exists $args{critical})) { |
|
|
|
0
|
|
|
|
|
154
|
0
|
0
|
|
|
|
|
if (exists $self->{thresholds}->{$label}->{warning}) { |
|
|
0
|
|
|
|
|
|
155
|
0
|
|
|
|
|
|
$warn = $self->{thresholds}->{$label}->{warning}; |
156
|
|
|
|
|
|
|
} elsif (exists $self->{thresholds}->{default}->{warning}) { |
157
|
0
|
|
|
|
|
|
$warn = $self->{thresholds}->{default}->{warning}; |
158
|
|
|
|
|
|
|
} |
159
|
0
|
0
|
|
|
|
|
if (exists $self->{thresholds}->{$label}->{critical}) { |
|
|
0
|
|
|
|
|
|
160
|
0
|
|
|
|
|
|
$crit = $self->{thresholds}->{$label}->{critical}; |
161
|
|
|
|
|
|
|
} elsif (exists $self->{thresholds}->{default}->{critical}) { |
162
|
0
|
|
|
|
|
|
$crit = $self->{thresholds}->{default}->{critical}; |
163
|
|
|
|
|
|
|
} |
164
|
|
|
|
|
|
|
} else { |
165
|
0
|
0
|
|
|
|
|
if ($args{warning}) { |
166
|
0
|
|
|
|
|
|
$warn = $args{warning}; |
167
|
|
|
|
|
|
|
} |
168
|
0
|
0
|
|
|
|
|
if ($args{critical}) { |
169
|
0
|
|
|
|
|
|
$crit = $args{critical}; |
170
|
|
|
|
|
|
|
} |
171
|
|
|
|
|
|
|
} |
172
|
0
|
0
|
|
|
|
|
if ($uom eq "%") { |
173
|
0
|
|
|
|
|
|
$min = 0; |
174
|
0
|
|
|
|
|
|
$max = 100; |
175
|
|
|
|
|
|
|
} |
176
|
0
|
0
|
|
|
|
|
if (defined $args{places}) { |
177
|
|
|
|
|
|
|
# cut off excessive decimals which may be the result of a division |
178
|
|
|
|
|
|
|
# length = places*2, no trailing zeroes |
179
|
0
|
0
|
|
|
|
|
if ($warn ne "") { |
180
|
|
|
|
|
|
|
$warn = join("", map { |
181
|
0
|
|
|
|
|
|
s/\.0+$//; $_ |
|
0
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
} map { |
183
|
0
|
|
|
|
|
|
s/(\.[1-9]+)0+$/$1/; $_ |
|
0
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
} map { |
185
|
0
|
0
|
|
|
|
|
/[\+\-\d\.]+/ ? sprintf '%.'.2*$args{places}.'f', $_ : $_; |
|
0
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
} split(/([\+\-\d\.]+)/, $warn)); |
187
|
|
|
|
|
|
|
} |
188
|
0
|
0
|
|
|
|
|
if ($crit ne "") { |
189
|
|
|
|
|
|
|
$crit = join("", map { |
190
|
0
|
|
|
|
|
|
s/\.0+$//; $_ |
|
0
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
} map { |
192
|
0
|
|
|
|
|
|
s/(\.[1-9]+)0+$/$1/; $_ |
|
0
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
} map { |
194
|
0
|
0
|
|
|
|
|
/[\+\-\d\.]+/ ? sprintf '%.'.2*$args{places}.'f', $_ : $_; |
|
0
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
} split(/([\+\-\d\.]+)/, $crit)); |
196
|
|
|
|
|
|
|
} |
197
|
0
|
0
|
|
|
|
|
if ($min ne "") { |
198
|
|
|
|
|
|
|
$min = join("", map { |
199
|
0
|
|
|
|
|
|
s/\.0+$//; $_ |
|
0
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
} map { |
201
|
0
|
|
|
|
|
|
s/(\.[1-9]+)0+$/$1/; $_ |
|
0
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
} map { |
203
|
0
|
0
|
|
|
|
|
/[\+\-\d\.]+/ ? sprintf '%.'.2*$args{places}.'f', $_ : $_; |
|
0
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
} split(/([\+\-\d\.]+)/, $min)); |
205
|
|
|
|
|
|
|
} |
206
|
0
|
0
|
|
|
|
|
if ($max ne "") { |
207
|
|
|
|
|
|
|
$max = join("", map { |
208
|
0
|
|
|
|
|
|
s/\.0+$//; $_ |
|
0
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
} map { |
210
|
0
|
|
|
|
|
|
s/(\.[1-9]+)0+$/$1/; $_ |
|
0
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
} map { |
212
|
0
|
0
|
|
|
|
|
/[\+\-\d\.]+/ ? sprintf '%.'.2*$args{places}.'f', $_ : $_; |
|
0
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
} split(/([\+\-\d\.]+)/, $max)); |
214
|
|
|
|
|
|
|
} |
215
|
|
|
|
|
|
|
} |
216
|
0
|
0
|
|
|
|
|
push @{$self->{perfdata}}, sprintf("'%s'=%s%s;%s;%s;%s;%s", |
|
0
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
$label, $value, $uom, $warn, $crit, $min, $max) |
218
|
|
|
|
|
|
|
if $self->selected_perfdata($label); |
219
|
|
|
|
|
|
|
} |
220
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
sub add_pandora { |
222
|
0
|
|
|
0
|
0
|
|
my ($self, %args) = @_; |
223
|
0
|
|
|
|
|
|
my $label = $args{label}; |
224
|
0
|
|
|
|
|
|
my $value = $args{value}; |
225
|
|
|
|
|
|
|
|
226
|
0
|
0
|
|
|
|
|
if ($args{help}) { |
227
|
0
|
|
|
|
|
|
push @{$self->{pandora}}, sprintf("# HELP %s %s", $label, $args{help}); |
|
0
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
} |
229
|
0
|
0
|
|
|
|
|
if ($args{type}) { |
230
|
0
|
|
|
|
|
|
push @{$self->{pandora}}, sprintf("# TYPE %s %s", $label, $args{type}); |
|
0
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
} |
232
|
0
|
0
|
|
|
|
|
if ($args{labels}) { |
233
|
0
|
|
|
|
|
|
push @{$self->{pandora}}, sprintf("%s{%s} %s", $label, |
234
|
|
|
|
|
|
|
join(",", map { |
235
|
0
|
|
|
|
|
|
sprintf '%s="%s"', $_, $args{labels}->{$_}; |
236
|
0
|
|
|
|
|
|
} keys %{$args{labels}}), |
|
0
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
$value); |
238
|
|
|
|
|
|
|
} else { |
239
|
0
|
|
|
|
|
|
push @{$self->{pandora}}, sprintf("%s %s", $label, $value); |
|
0
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
} |
241
|
|
|
|
|
|
|
} |
242
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
sub add_html { |
244
|
0
|
|
|
0
|
0
|
|
my ($self, $line) = @_; |
245
|
0
|
|
|
|
|
|
push @{$self->{html}}, $line; |
|
0
|
|
|
|
|
|
|
246
|
|
|
|
|
|
|
} |
247
|
|
|
|
|
|
|
|
248
|
|
|
|
|
|
|
sub suppress_messages { |
249
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
250
|
0
|
|
|
|
|
|
$self->{suppress_messages} = 1; |
251
|
|
|
|
|
|
|
} |
252
|
|
|
|
|
|
|
|
253
|
|
|
|
|
|
|
sub clear_messages { |
254
|
0
|
|
|
0
|
0
|
|
my ($self, $code) = @_; |
255
|
0
|
0
|
|
|
|
|
$code = (qw(ok warning critical unknown))[$code] if $code =~ /^\d+$/; |
256
|
0
|
|
|
|
|
|
$code = lc $code; |
257
|
0
|
|
|
|
|
|
$self->{messages}->{$code} = []; |
258
|
|
|
|
|
|
|
} |
259
|
|
|
|
|
|
|
|
260
|
|
|
|
|
|
|
sub reduce_messages_short { |
261
|
0
|
|
|
0
|
0
|
|
my ($self, $message) = @_; |
262
|
0
|
|
0
|
|
|
|
$message ||= "no problems"; |
263
|
0
|
0
|
0
|
|
|
|
if ($self->opts->report && $self->opts->report eq "short") { |
264
|
0
|
|
|
|
|
|
$self->clear_messages(OK); |
265
|
0
|
0
|
|
|
|
|
$self->add_message(OK, $message) if ! $self->check_messages(); |
266
|
|
|
|
|
|
|
} |
267
|
|
|
|
|
|
|
} |
268
|
|
|
|
|
|
|
|
269
|
|
|
|
|
|
|
sub reduce_messages { |
270
|
0
|
|
|
0
|
0
|
|
my ($self, $message) = @_; |
271
|
0
|
|
0
|
|
|
|
$message ||= "no problems"; |
272
|
0
|
|
|
|
|
|
$self->clear_messages(OK); |
273
|
0
|
0
|
|
|
|
|
$self->add_message(OK, $message) if ! $self->check_messages(); |
274
|
|
|
|
|
|
|
} |
275
|
|
|
|
|
|
|
|
276
|
|
|
|
|
|
|
sub check_messages { |
277
|
0
|
|
|
0
|
0
|
|
my ($self, %args) = @_; |
278
|
|
|
|
|
|
|
|
279
|
|
|
|
|
|
|
# Add object messages to any passed in as args |
280
|
0
|
|
|
|
|
|
for my $code (qw(critical warning unknown ok)) { |
281
|
0
|
|
0
|
|
|
|
my $messages = $self->{messages}->{$code} || []; |
282
|
0
|
0
|
|
|
|
|
if ($args{$code}) { |
283
|
0
|
0
|
|
|
|
|
unless (ref $args{$code} eq 'ARRAY') { |
284
|
0
|
0
|
|
|
|
|
if ($code eq 'ok') { |
285
|
0
|
|
|
|
|
|
$args{$code} = [ $args{$code} ]; |
286
|
|
|
|
|
|
|
} |
287
|
|
|
|
|
|
|
} |
288
|
0
|
|
|
|
|
|
push @{$args{$code}}, @$messages; |
|
0
|
|
|
|
|
|
|
289
|
|
|
|
|
|
|
} else { |
290
|
0
|
|
|
|
|
|
$args{$code} = $messages; |
291
|
|
|
|
|
|
|
} |
292
|
|
|
|
|
|
|
} |
293
|
0
|
|
|
|
|
|
my %arg = %args; |
294
|
0
|
0
|
|
|
|
|
$arg{join} = ' ' unless defined $arg{join}; |
295
|
|
|
|
|
|
|
|
296
|
|
|
|
|
|
|
# Decide $code |
297
|
0
|
|
|
|
|
|
my $code = OK; |
298
|
0
|
0
|
0
|
|
|
|
$code ||= CRITICAL if @{$arg{critical}}; |
|
0
|
|
|
|
|
|
|
299
|
0
|
0
|
0
|
|
|
|
$code ||= WARNING if @{$arg{warning}}; |
|
0
|
|
|
|
|
|
|
300
|
0
|
0
|
0
|
|
|
|
$code ||= UNKNOWN if @{$arg{unknown}}; |
|
0
|
|
|
|
|
|
|
301
|
0
|
0
|
|
|
|
|
return $code unless wantarray; |
302
|
|
|
|
|
|
|
|
303
|
|
|
|
|
|
|
# Compose message |
304
|
0
|
|
|
|
|
|
my $message = ''; |
305
|
0
|
0
|
|
|
|
|
if ($arg{join_all}) { |
306
|
|
|
|
|
|
|
$message = join( $arg{join_all}, |
307
|
0
|
0
|
|
|
|
|
map { @$_ ? join( $arg{'join'}, @$_) : () } |
308
|
|
|
|
|
|
|
$arg{critical}, |
309
|
|
|
|
|
|
|
$arg{warning}, |
310
|
|
|
|
|
|
|
$arg{unknown}, |
311
|
0
|
0
|
|
|
|
|
$arg{ok} ? (ref $arg{ok} ? $arg{ok} : [ $arg{ok} ]) : [] |
|
|
0
|
|
|
|
|
|
312
|
|
|
|
|
|
|
); |
313
|
|
|
|
|
|
|
} |
314
|
|
|
|
|
|
|
|
315
|
|
|
|
|
|
|
else { |
316
|
0
|
0
|
0
|
|
|
|
$message ||= join( $arg{'join'}, @{$arg{critical}} ) |
|
0
|
|
|
|
|
|
|
317
|
|
|
|
|
|
|
if $code == CRITICAL; |
318
|
0
|
0
|
0
|
|
|
|
$message ||= join( $arg{'join'}, @{$arg{warning}} ) |
|
0
|
|
|
|
|
|
|
319
|
|
|
|
|
|
|
if $code == WARNING; |
320
|
0
|
0
|
0
|
|
|
|
$message ||= join( $arg{'join'}, @{$arg{unknown}} ) |
|
0
|
|
|
|
|
|
|
321
|
|
|
|
|
|
|
if $code == UNKNOWN; |
322
|
0
|
|
|
|
|
|
$message ||= ref $arg{ok} ? join( $arg{'join'}, @{$arg{ok}} ) : $arg{ok} |
323
|
0
|
0
|
0
|
|
|
|
if $arg{ok}; |
|
|
0
|
|
|
|
|
|
324
|
|
|
|
|
|
|
} |
325
|
|
|
|
|
|
|
|
326
|
0
|
|
|
|
|
|
return ($code, $message); |
327
|
|
|
|
|
|
|
} |
328
|
|
|
|
|
|
|
|
329
|
|
|
|
|
|
|
sub status_code { |
330
|
0
|
|
|
0
|
0
|
|
my ($self, $code) = @_; |
331
|
0
|
0
|
|
|
|
|
$code = (qw(ok warning critical unknown))[$code] if $code =~ /^\d+$/; |
332
|
0
|
|
|
|
|
|
$code = uc $code; |
333
|
0
|
0
|
0
|
|
|
|
$code = $ERRORS{$code} if defined $code && exists $ERRORS{$code}; |
334
|
0
|
0
|
0
|
|
|
|
$code = UNKNOWN unless defined $code && exists $STATUS_TEXT{$code}; |
335
|
0
|
|
|
|
|
|
return "$STATUS_TEXT{$code}"; |
336
|
|
|
|
|
|
|
} |
337
|
|
|
|
|
|
|
|
338
|
|
|
|
|
|
|
sub perfdata_string { |
339
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
340
|
0
|
0
|
|
|
|
|
if (scalar (@{$self->{perfdata}})) { |
|
0
|
|
|
|
|
|
|
341
|
0
|
|
|
|
|
|
return join(" ", @{$self->{perfdata}}); |
|
0
|
|
|
|
|
|
|
342
|
|
|
|
|
|
|
} else { |
343
|
0
|
|
|
|
|
|
return ""; |
344
|
|
|
|
|
|
|
} |
345
|
|
|
|
|
|
|
} |
346
|
|
|
|
|
|
|
|
347
|
|
|
|
|
|
|
sub metrics_string { |
348
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
349
|
0
|
0
|
|
|
|
|
if (scalar (@{$self->{metrics}})) { |
|
0
|
|
|
|
|
|
|
350
|
0
|
|
|
|
|
|
return join("\n", @{$self->{metrics}}); |
|
0
|
|
|
|
|
|
|
351
|
|
|
|
|
|
|
} else { |
352
|
0
|
|
|
|
|
|
return ""; |
353
|
|
|
|
|
|
|
} |
354
|
|
|
|
|
|
|
} |
355
|
|
|
|
|
|
|
|
356
|
|
|
|
|
|
|
sub html_string { |
357
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
358
|
0
|
0
|
|
|
|
|
if (scalar (@{$self->{html}})) { |
|
0
|
|
|
|
|
|
|
359
|
0
|
|
|
|
|
|
return join(" ", @{$self->{html}}); |
|
0
|
|
|
|
|
|
|
360
|
|
|
|
|
|
|
} else { |
361
|
0
|
|
|
|
|
|
return ""; |
362
|
|
|
|
|
|
|
} |
363
|
|
|
|
|
|
|
} |
364
|
|
|
|
|
|
|
|
365
|
|
|
|
|
|
|
sub nagios_exit { |
366
|
0
|
|
|
0
|
0
|
|
my ($self, $code, $message, $arg) = @_; |
367
|
0
|
0
|
0
|
|
|
|
$code = $ERRORS{$code} if defined $code && exists $ERRORS{$code}; |
368
|
0
|
0
|
0
|
|
|
|
$code = UNKNOWN unless defined $code && exists $STATUS_TEXT{$code}; |
369
|
0
|
0
|
|
|
|
|
$message = '' unless defined $message; |
370
|
0
|
0
|
0
|
|
|
|
if (ref $message && ref $message eq 'ARRAY') { |
371
|
0
|
|
|
|
|
|
$message = join(' ', map { chomp; $_ } @$message); |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
372
|
|
|
|
|
|
|
} else { |
373
|
0
|
|
|
|
|
|
chomp $message; |
374
|
|
|
|
|
|
|
} |
375
|
0
|
0
|
|
|
|
|
if ($self->opts->negate) { |
376
|
0
|
|
|
|
|
|
my $original_code = $code; |
377
|
0
|
|
|
|
|
|
foreach my $from (keys %{$self->opts->negate}) { |
|
0
|
|
|
|
|
|
|
378
|
0
|
0
|
0
|
|
|
|
if ((uc $from) =~ /^(OK|WARNING|CRITICAL|UNKNOWN)$/ && |
379
|
|
|
|
|
|
|
(uc $self->opts->negate->{$from}) =~ /^(OK|WARNING|CRITICAL|UNKNOWN)$/) { |
380
|
0
|
0
|
|
|
|
|
if ($original_code == $ERRORS{uc $from}) { |
381
|
0
|
|
|
|
|
|
$code = $ERRORS{uc $self->opts->negate->{$from}}; |
382
|
|
|
|
|
|
|
} |
383
|
|
|
|
|
|
|
} |
384
|
|
|
|
|
|
|
} |
385
|
|
|
|
|
|
|
} |
386
|
0
|
|
|
|
|
|
my $output = "$STATUS_TEXT{$code}"; |
387
|
0
|
0
|
0
|
|
|
|
$output .= " - $message" if defined $message && $message ne ''; |
388
|
0
|
0
|
0
|
|
|
|
if ($self->opts->can("morphmessage") && $self->opts->morphmessage) { |
389
|
|
|
|
|
|
|
# 'Intel [R] Interface (\d+) usage'='nic$1' |
390
|
|
|
|
|
|
|
# '^OK.*'="alles klar" '^CRITICAL.*'="alles hi" |
391
|
0
|
|
|
|
|
|
foreach my $key (keys %{$self->opts->morphmessage}) { |
|
0
|
|
|
|
|
|
|
392
|
0
|
0
|
|
|
|
|
if ($output =~ /$key/) { |
393
|
0
|
|
|
|
|
|
my $replacement = '"'.$self->opts->morphmessage->{$key}.'"'; |
394
|
0
|
|
|
|
|
|
$output =~ s/$key/$replacement/ee; |
|
0
|
|
|
|
|
|
|
395
|
|
|
|
|
|
|
} |
396
|
|
|
|
|
|
|
} |
397
|
|
|
|
|
|
|
} |
398
|
0
|
0
|
|
|
|
|
$output =~ s/\|/!/g if $output; |
399
|
0
|
0
|
|
|
|
|
if (scalar (@{$self->{perfdata}})) { |
|
0
|
|
|
|
|
|
|
400
|
0
|
|
|
|
|
|
$output .= " | ".$self->perfdata_string(); |
401
|
|
|
|
|
|
|
} |
402
|
0
|
|
|
|
|
|
$output .= "\n"; |
403
|
0
|
0
|
0
|
|
|
|
if ($self->opts->can("isvalidtime") && ! $self->opts->isvalidtime) { |
404
|
0
|
|
|
|
|
|
$code = OK; |
405
|
0
|
|
|
|
|
|
$output = "OK - outside valid timerange. check results are not relevant now. original message was: ". |
406
|
|
|
|
|
|
|
$output; |
407
|
|
|
|
|
|
|
} |
408
|
0
|
0
|
|
|
|
|
if (! exists $self->{suppress_messages}) { |
409
|
0
|
|
|
|
|
|
print $output; |
410
|
|
|
|
|
|
|
} |
411
|
0
|
|
|
|
|
|
exit $code; |
412
|
|
|
|
|
|
|
} |
413
|
|
|
|
|
|
|
|
414
|
|
|
|
|
|
|
sub set_thresholds { |
415
|
0
|
|
|
0
|
0
|
|
my ($self, %params) = @_; |
416
|
0
|
0
|
|
|
|
|
if (exists $params{metric}) { |
417
|
0
|
|
|
|
|
|
my $metric = $params{metric}; |
418
|
|
|
|
|
|
|
# erst die hartcodierten defaultschwellwerte |
419
|
0
|
|
|
|
|
|
$self->{thresholds}->{$metric}->{warning} = $params{warning}; |
420
|
0
|
|
|
|
|
|
$self->{thresholds}->{$metric}->{critical} = $params{critical}; |
421
|
|
|
|
|
|
|
# dann die defaultschwellwerte von der kommandozeile |
422
|
0
|
0
|
|
|
|
|
if (defined $self->opts->warning) { |
423
|
0
|
|
|
|
|
|
$self->{thresholds}->{$metric}->{warning} = $self->opts->warning; |
424
|
|
|
|
|
|
|
} |
425
|
0
|
0
|
|
|
|
|
if (defined $self->opts->critical) { |
426
|
0
|
|
|
|
|
|
$self->{thresholds}->{$metric}->{critical} = $self->opts->critical; |
427
|
|
|
|
|
|
|
} |
428
|
|
|
|
|
|
|
# dann die ganz spezifischen schwellwerte von der kommandozeile |
429
|
0
|
0
|
|
|
|
|
if ($self->opts->warningx) { # muss nicht auf defined geprueft werden, weils ein hash ist |
430
|
|
|
|
|
|
|
# Erst schauen, ob einer * beinhaltet. Von denen wird vom Laengsten |
431
|
|
|
|
|
|
|
# bis zum Kuerzesten probiert, ob die matchen. Der laengste Match |
432
|
|
|
|
|
|
|
# gewinnt. |
433
|
0
|
|
|
|
|
|
my @keys = keys %{$self->opts->warningx}; |
|
0
|
|
|
|
|
|
|
434
|
0
|
|
|
|
|
|
my @stringkeys = (); |
435
|
0
|
|
|
|
|
|
my @regexkeys = (); |
436
|
0
|
|
|
|
|
|
foreach my $key (sort { length($b) > length($a) } @keys) { |
|
0
|
|
|
|
|
|
|
437
|
0
|
0
|
|
|
|
|
if ($key =~ /\*/) { |
438
|
0
|
|
|
|
|
|
push(@regexkeys, $key); |
439
|
|
|
|
|
|
|
} else { |
440
|
0
|
|
|
|
|
|
push(@stringkeys, $key); |
441
|
|
|
|
|
|
|
} |
442
|
|
|
|
|
|
|
} |
443
|
0
|
|
|
|
|
|
foreach my $key (@regexkeys) { |
444
|
0
|
0
|
|
|
|
|
next if $metric !~ /$key/; |
445
|
0
|
|
|
|
|
|
$self->{thresholds}->{$metric}->{warning} = $self->opts->warningx->{$key}; |
446
|
0
|
|
|
|
|
|
last; |
447
|
|
|
|
|
|
|
} |
448
|
|
|
|
|
|
|
# Anschliessend nochmal schauen, ob es einen nicht-Regex-Volltreffer gibt |
449
|
0
|
|
|
|
|
|
foreach my $key (@stringkeys) { |
450
|
0
|
0
|
|
|
|
|
next if $key ne $metric; |
451
|
0
|
|
|
|
|
|
$self->{thresholds}->{$metric}->{warning} = $self->opts->warningx->{$key}; |
452
|
0
|
|
|
|
|
|
last; |
453
|
|
|
|
|
|
|
} |
454
|
|
|
|
|
|
|
} |
455
|
0
|
0
|
|
|
|
|
if ($self->opts->criticalx) { |
456
|
0
|
|
|
|
|
|
my @keys = keys %{$self->opts->criticalx}; |
|
0
|
|
|
|
|
|
|
457
|
0
|
|
|
|
|
|
my @stringkeys = (); |
458
|
0
|
|
|
|
|
|
my @regexkeys = (); |
459
|
0
|
|
|
|
|
|
foreach my $key (sort { length($b) > length($a) } @keys) { |
|
0
|
|
|
|
|
|
|
460
|
0
|
0
|
|
|
|
|
if ($key =~ /\*/) { |
461
|
0
|
|
|
|
|
|
push(@regexkeys, $key); |
462
|
|
|
|
|
|
|
} else { |
463
|
0
|
|
|
|
|
|
push(@stringkeys, $key); |
464
|
|
|
|
|
|
|
} |
465
|
|
|
|
|
|
|
} |
466
|
0
|
|
|
|
|
|
foreach my $key (@regexkeys) { |
467
|
0
|
0
|
|
|
|
|
next if $metric !~ /$key/; |
468
|
0
|
|
|
|
|
|
$self->{thresholds}->{$metric}->{critical} = $self->opts->criticalx->{$key}; |
469
|
0
|
|
|
|
|
|
last; |
470
|
|
|
|
|
|
|
} |
471
|
|
|
|
|
|
|
# Anschliessend nochmal schauen, ob es einen nicht-Regex-Volltreffer gibt |
472
|
0
|
|
|
|
|
|
foreach my $key (@stringkeys) { |
473
|
0
|
0
|
|
|
|
|
next if $key ne $metric; |
474
|
0
|
|
|
|
|
|
$self->{thresholds}->{$metric}->{critical} = $self->opts->criticalx->{$key}; |
475
|
0
|
|
|
|
|
|
last; |
476
|
|
|
|
|
|
|
} |
477
|
|
|
|
|
|
|
} |
478
|
|
|
|
|
|
|
} else { |
479
|
|
|
|
|
|
|
$self->{thresholds}->{default}->{warning} = |
480
|
0
|
0
|
|
|
|
|
defined $self->opts->warning ? $self->opts->warning : defined $params{warning} ? $params{warning} : 0; |
|
|
0
|
|
|
|
|
|
481
|
|
|
|
|
|
|
$self->{thresholds}->{default}->{critical} = |
482
|
0
|
0
|
|
|
|
|
defined $self->opts->critical ? $self->opts->critical : defined $params{critical} ? $params{critical} : 0; |
|
|
0
|
|
|
|
|
|
483
|
|
|
|
|
|
|
} |
484
|
|
|
|
|
|
|
} |
485
|
|
|
|
|
|
|
|
486
|
|
|
|
|
|
|
sub force_thresholds { |
487
|
0
|
|
|
0
|
0
|
|
my ($self, %params) = @_; |
488
|
0
|
0
|
|
|
|
|
if (exists $params{metric}) { |
489
|
0
|
|
|
|
|
|
my $metric = $params{metric}; |
490
|
0
|
|
0
|
|
|
|
$self->{thresholds}->{$metric}->{warning} = $params{warning} || 0; |
491
|
0
|
|
0
|
|
|
|
$self->{thresholds}->{$metric}->{critical} = $params{critical} || 0; |
492
|
|
|
|
|
|
|
} else { |
493
|
0
|
|
0
|
|
|
|
$self->{thresholds}->{default}->{warning} = $params{warning} || 0; |
494
|
0
|
|
0
|
|
|
|
$self->{thresholds}->{default}->{critical} = $params{critical} || 0; |
495
|
|
|
|
|
|
|
} |
496
|
|
|
|
|
|
|
} |
497
|
|
|
|
|
|
|
|
498
|
|
|
|
|
|
|
sub get_thresholds { |
499
|
0
|
|
|
0
|
0
|
|
my ($self, @params) = @_; |
500
|
0
|
0
|
|
|
|
|
if (scalar(@params) > 1) { |
501
|
0
|
|
|
|
|
|
my %params = @params; |
502
|
0
|
|
|
|
|
|
my $metric = $params{metric}; |
503
|
|
|
|
|
|
|
return ($self->{thresholds}->{$metric}->{warning}, |
504
|
0
|
|
|
|
|
|
$self->{thresholds}->{$metric}->{critical}); |
505
|
|
|
|
|
|
|
} else { |
506
|
|
|
|
|
|
|
return ($self->{thresholds}->{default}->{warning}, |
507
|
0
|
|
|
|
|
|
$self->{thresholds}->{default}->{critical}); |
508
|
|
|
|
|
|
|
} |
509
|
|
|
|
|
|
|
} |
510
|
|
|
|
|
|
|
|
511
|
|
|
|
|
|
|
sub check_thresholds { |
512
|
0
|
|
|
0
|
0
|
|
my ($self, @params) = @_; |
513
|
0
|
|
|
|
|
|
my $level = $ERRORS{OK}; |
514
|
0
|
|
|
|
|
|
my $warningrange; |
515
|
|
|
|
|
|
|
my $criticalrange; |
516
|
0
|
|
|
|
|
|
my $value; |
517
|
0
|
0
|
|
|
|
|
if (scalar(@params) > 1) { |
518
|
0
|
|
|
|
|
|
my %params = @params; |
519
|
0
|
|
|
|
|
|
$value = $params{value}; |
520
|
0
|
|
|
|
|
|
my $metric = $params{metric}; |
521
|
0
|
0
|
|
|
|
|
if ($metric ne 'default') { |
522
|
|
|
|
|
|
|
$warningrange = exists $self->{thresholds}->{$metric}->{warning} ? |
523
|
|
|
|
|
|
|
$self->{thresholds}->{$metric}->{warning} : |
524
|
0
|
0
|
|
|
|
|
$self->{thresholds}->{default}->{warning}; |
525
|
|
|
|
|
|
|
$criticalrange = exists $self->{thresholds}->{$metric}->{critical} ? |
526
|
|
|
|
|
|
|
$self->{thresholds}->{$metric}->{critical} : |
527
|
0
|
0
|
|
|
|
|
$self->{thresholds}->{default}->{critical}; |
528
|
|
|
|
|
|
|
} else { |
529
|
|
|
|
|
|
|
$warningrange = (defined $params{warning}) ? |
530
|
0
|
0
|
|
|
|
|
$params{warning} : $self->{thresholds}->{default}->{warning}; |
531
|
|
|
|
|
|
|
$criticalrange = (defined $params{critical}) ? |
532
|
0
|
0
|
|
|
|
|
$params{critical} : $self->{thresholds}->{default}->{critical}; |
533
|
|
|
|
|
|
|
} |
534
|
|
|
|
|
|
|
} else { |
535
|
0
|
|
|
|
|
|
$value = $params[0]; |
536
|
0
|
|
|
|
|
|
$warningrange = $self->{thresholds}->{default}->{warning}; |
537
|
0
|
|
|
|
|
|
$criticalrange = $self->{thresholds}->{default}->{critical}; |
538
|
|
|
|
|
|
|
} |
539
|
0
|
0
|
|
|
|
|
if (! defined $warningrange) { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
540
|
|
|
|
|
|
|
# there was no set_thresholds for defaults, no --warning, no --warningx |
541
|
|
|
|
|
|
|
} elsif ($warningrange =~ /^([-+]?[0-9]*\.?[0-9]+)$/) { |
542
|
|
|
|
|
|
|
# warning = 10, warn if > 10 or < 0 |
543
|
|
|
|
|
|
|
$level = $ERRORS{WARNING} |
544
|
0
|
0
|
0
|
|
|
|
if ($value > $1 || $value < 0); |
545
|
|
|
|
|
|
|
} elsif ($warningrange =~ /^([-+]?[0-9]*\.?[0-9]+):$/) { |
546
|
|
|
|
|
|
|
# warning = 10:, warn if < 10 |
547
|
|
|
|
|
|
|
$level = $ERRORS{WARNING} |
548
|
0
|
0
|
|
|
|
|
if ($value < $1); |
549
|
|
|
|
|
|
|
} elsif ($warningrange =~ /^~:([-+]?[0-9]*\.?[0-9]+)$/) { |
550
|
|
|
|
|
|
|
# warning = ~:10, warn if > 10 |
551
|
|
|
|
|
|
|
$level = $ERRORS{WARNING} |
552
|
0
|
0
|
|
|
|
|
if ($value > $1); |
553
|
|
|
|
|
|
|
} elsif ($warningrange =~ /^([-+]?[0-9]*\.?[0-9]+):([-+]?[0-9]*\.?[0-9]+)$/) { |
554
|
|
|
|
|
|
|
# warning = 10:20, warn if < 10 or > 20 |
555
|
|
|
|
|
|
|
$level = $ERRORS{WARNING} |
556
|
0
|
0
|
0
|
|
|
|
if ($value < $1 || $value > $2); |
557
|
|
|
|
|
|
|
} elsif ($warningrange =~ /^@([-+]?[0-9]*\.?[0-9]+):([-+]?[0-9]*\.?[0-9]+)$/) { |
558
|
|
|
|
|
|
|
# warning = @10:20, warn if >= 10 and <= 20 |
559
|
|
|
|
|
|
|
$level = $ERRORS{WARNING} |
560
|
0
|
0
|
0
|
|
|
|
if ($value >= $1 && $value <= $2); |
561
|
|
|
|
|
|
|
} |
562
|
0
|
0
|
|
|
|
|
if (! defined $criticalrange) { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
563
|
|
|
|
|
|
|
# there was no set_thresholds for defaults, no --critical, no --criticalx |
564
|
|
|
|
|
|
|
} elsif ($criticalrange =~ /^([-+]?[0-9]*\.?[0-9]+)$/) { |
565
|
|
|
|
|
|
|
# critical = 10, crit if > 10 or < 0 |
566
|
|
|
|
|
|
|
$level = $ERRORS{CRITICAL} |
567
|
0
|
0
|
0
|
|
|
|
if ($value > $1 || $value < 0); |
568
|
|
|
|
|
|
|
} elsif ($criticalrange =~ /^([-+]?[0-9]*\.?[0-9]+):$/) { |
569
|
|
|
|
|
|
|
# critical = 10:, crit if < 10 |
570
|
|
|
|
|
|
|
$level = $ERRORS{CRITICAL} |
571
|
0
|
0
|
|
|
|
|
if ($value < $1); |
572
|
|
|
|
|
|
|
} elsif ($criticalrange =~ /^~:([-+]?[0-9]*\.?[0-9]+)$/) { |
573
|
|
|
|
|
|
|
# critical = ~:10, crit if > 10 |
574
|
|
|
|
|
|
|
$level = $ERRORS{CRITICAL} |
575
|
0
|
0
|
|
|
|
|
if ($value > $1); |
576
|
|
|
|
|
|
|
} elsif ($criticalrange =~ /^([-+]?[0-9]*\.?[0-9]+):([-+]?[0-9]*\.?[0-9]+)$/) { |
577
|
|
|
|
|
|
|
# critical = 10:20, crit if < 10 or > 20 |
578
|
|
|
|
|
|
|
$level = $ERRORS{CRITICAL} |
579
|
0
|
0
|
0
|
|
|
|
if ($value < $1 || $value > $2); |
580
|
|
|
|
|
|
|
} elsif ($criticalrange =~ /^@([-+]?[0-9]*\.?[0-9]+):([-+]?[0-9]*\.?[0-9]+)$/) { |
581
|
|
|
|
|
|
|
# critical = @10:20, crit if >= 10 and <= 20 |
582
|
|
|
|
|
|
|
$level = $ERRORS{CRITICAL} |
583
|
0
|
0
|
0
|
|
|
|
if ($value >= $1 && $value <= $2); |
584
|
|
|
|
|
|
|
} |
585
|
0
|
|
|
|
|
|
return $level; |
586
|
|
|
|
|
|
|
} |
587
|
|
|
|
|
|
|
|
588
|
|
|
|
|
|
|
1; |
589
|
|
|
|
|
|
|
|
590
|
|
|
|
|
|
|
__END__ |