| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Monitoring::GLPlugin::Commandline; |
|
2
|
2
|
|
|
2
|
|
9
|
use strict; |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
64
|
|
|
3
|
2
|
|
|
2
|
|
8
|
use IO::File; |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
351
|
|
|
4
|
2
|
|
|
2
|
|
9
|
use constant { OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3, DEPENDENT => 4 }; |
|
|
2
|
|
|
|
|
2
|
|
|
|
2
|
|
|
|
|
7430
|
|
|
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
|
|
|
|
944
|
if ! grep /BEGIN/, keys %Monitoring::GLPlugin::Commandline::Getopt::; |
|
21
|
3
|
|
|
|
|
37
|
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
|
|
|
|
|
7
|
foreach (qw(shortname usage version url plugin blurb extra |
|
35
|
|
|
|
|
|
|
license timeout)) { |
|
36
|
27
|
|
|
|
|
34
|
$self->{$_} = $params{$_}; |
|
37
|
|
|
|
|
|
|
} |
|
38
|
3
|
|
|
|
|
6
|
bless $self, $class; |
|
39
|
3
|
|
33
|
|
|
25
|
$self->{plugin} ||= $Monitoring::GLPlugin::pluginname; |
|
40
|
3
|
|
|
|
|
8
|
$self->{name} = $self->{plugin}; |
|
41
|
3
|
|
|
|
|
13
|
$Monitoring::GLPlugin::plugin = $self; |
|
42
|
|
|
|
|
|
|
} |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub AUTOLOAD { |
|
45
|
6
|
|
|
6
|
|
10
|
my ($self, @params) = @_; |
|
46
|
6
|
50
|
|
|
|
16
|
return if ($AUTOLOAD =~ /DESTROY/); |
|
47
|
|
|
|
|
|
|
$self->debug("AUTOLOAD %s\n", $AUTOLOAD) |
|
48
|
6
|
50
|
|
|
|
16
|
if $self->{opts}->verbose >= 2; |
|
49
|
6
|
50
|
|
|
|
26
|
if ($AUTOLOAD =~ /^.*::(add_arg|override_opt|create_opt)$/) { |
|
50
|
6
|
|
|
|
|
24
|
$self->{opts}->$1(@params); |
|
51
|
|
|
|
|
|
|
} |
|
52
|
|
|
|
|
|
|
} |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub DESTROY { |
|
55
|
1
|
|
|
1
|
|
9
|
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
|
350
|
|
|
350
|
0
|
279
|
my ($self) = @_; |
|
84
|
350
|
|
|
|
|
1106
|
return $self->{opts}; |
|
85
|
|
|
|
|
|
|
} |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
sub getopts { |
|
88
|
2
|
|
|
2
|
0
|
5
|
my ($self) = @_; |
|
89
|
2
|
|
|
|
|
6
|
$self->opts->getopts(); |
|
90
|
|
|
|
|
|
|
} |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
sub add_message { |
|
93
|
31
|
|
|
31
|
0
|
62
|
my ($self, $code, @messages) = @_; |
|
94
|
31
|
50
|
|
|
|
201
|
$code = (qw(ok warning critical unknown))[$code] if $code =~ /^\d+$/; |
|
95
|
31
|
|
|
|
|
57
|
$code = lc $code; |
|
96
|
31
|
|
|
|
|
32
|
push @{$self->{messages}->{$code}}, @messages; |
|
|
31
|
|
|
|
|
130
|
|
|
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_html { |
|
222
|
0
|
|
|
0
|
0
|
|
my ($self, $line) = @_; |
|
223
|
0
|
|
|
|
|
|
push @{$self->{html}}, $line; |
|
|
0
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
} |
|
225
|
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
sub suppress_messages { |
|
227
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
|
228
|
0
|
|
|
|
|
|
$self->{suppress_messages} = 1; |
|
229
|
|
|
|
|
|
|
} |
|
230
|
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
sub clear_messages { |
|
232
|
0
|
|
|
0
|
0
|
|
my ($self, $code) = @_; |
|
233
|
0
|
0
|
|
|
|
|
$code = (qw(ok warning critical unknown))[$code] if $code =~ /^\d+$/; |
|
234
|
0
|
|
|
|
|
|
$code = lc $code; |
|
235
|
0
|
|
|
|
|
|
$self->{messages}->{$code} = []; |
|
236
|
|
|
|
|
|
|
} |
|
237
|
|
|
|
|
|
|
|
|
238
|
|
|
|
|
|
|
sub reduce_messages_short { |
|
239
|
0
|
|
|
0
|
0
|
|
my ($self, $message) = @_; |
|
240
|
0
|
|
0
|
|
|
|
$message ||= "no problems"; |
|
241
|
0
|
0
|
0
|
|
|
|
if ($self->opts->report && $self->opts->report eq "short") { |
|
242
|
0
|
|
|
|
|
|
$self->clear_messages(OK); |
|
243
|
0
|
0
|
|
|
|
|
$self->add_message(OK, $message) if ! $self->check_messages(); |
|
244
|
|
|
|
|
|
|
} |
|
245
|
|
|
|
|
|
|
} |
|
246
|
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
sub reduce_messages { |
|
248
|
0
|
|
|
0
|
0
|
|
my ($self, $message) = @_; |
|
249
|
0
|
|
0
|
|
|
|
$message ||= "no problems"; |
|
250
|
0
|
|
|
|
|
|
$self->clear_messages(OK); |
|
251
|
0
|
0
|
|
|
|
|
$self->add_message(OK, $message) if ! $self->check_messages(); |
|
252
|
|
|
|
|
|
|
} |
|
253
|
|
|
|
|
|
|
|
|
254
|
|
|
|
|
|
|
sub check_messages { |
|
255
|
0
|
|
|
0
|
0
|
|
my ($self, %args) = @_; |
|
256
|
|
|
|
|
|
|
|
|
257
|
|
|
|
|
|
|
# Add object messages to any passed in as args |
|
258
|
0
|
|
|
|
|
|
for my $code (qw(critical warning unknown ok)) { |
|
259
|
0
|
|
0
|
|
|
|
my $messages = $self->{messages}->{$code} || []; |
|
260
|
0
|
0
|
|
|
|
|
if ($args{$code}) { |
|
261
|
0
|
0
|
|
|
|
|
unless (ref $args{$code} eq 'ARRAY') { |
|
262
|
0
|
0
|
|
|
|
|
if ($code eq 'ok') { |
|
263
|
0
|
|
|
|
|
|
$args{$code} = [ $args{$code} ]; |
|
264
|
|
|
|
|
|
|
} |
|
265
|
|
|
|
|
|
|
} |
|
266
|
0
|
|
|
|
|
|
push @{$args{$code}}, @$messages; |
|
|
0
|
|
|
|
|
|
|
|
267
|
|
|
|
|
|
|
} else { |
|
268
|
0
|
|
|
|
|
|
$args{$code} = $messages; |
|
269
|
|
|
|
|
|
|
} |
|
270
|
|
|
|
|
|
|
} |
|
271
|
0
|
|
|
|
|
|
my %arg = %args; |
|
272
|
0
|
0
|
|
|
|
|
$arg{join} = ' ' unless defined $arg{join}; |
|
273
|
|
|
|
|
|
|
|
|
274
|
|
|
|
|
|
|
# Decide $code |
|
275
|
0
|
|
|
|
|
|
my $code = OK; |
|
276
|
0
|
0
|
0
|
|
|
|
$code ||= CRITICAL if @{$arg{critical}}; |
|
|
0
|
|
|
|
|
|
|
|
277
|
0
|
0
|
0
|
|
|
|
$code ||= WARNING if @{$arg{warning}}; |
|
|
0
|
|
|
|
|
|
|
|
278
|
0
|
0
|
0
|
|
|
|
$code ||= UNKNOWN if @{$arg{unknown}}; |
|
|
0
|
|
|
|
|
|
|
|
279
|
0
|
0
|
|
|
|
|
return $code unless wantarray; |
|
280
|
|
|
|
|
|
|
|
|
281
|
|
|
|
|
|
|
# Compose message |
|
282
|
0
|
|
|
|
|
|
my $message = ''; |
|
283
|
0
|
0
|
|
|
|
|
if ($arg{join_all}) { |
|
284
|
|
|
|
|
|
|
$message = join( $arg{join_all}, |
|
285
|
0
|
0
|
|
|
|
|
map { @$_ ? join( $arg{'join'}, @$_) : () } |
|
286
|
|
|
|
|
|
|
$arg{critical}, |
|
287
|
|
|
|
|
|
|
$arg{warning}, |
|
288
|
|
|
|
|
|
|
$arg{unknown}, |
|
289
|
0
|
0
|
|
|
|
|
$arg{ok} ? (ref $arg{ok} ? $arg{ok} : [ $arg{ok} ]) : [] |
|
|
|
0
|
|
|
|
|
|
|
290
|
|
|
|
|
|
|
); |
|
291
|
|
|
|
|
|
|
} |
|
292
|
|
|
|
|
|
|
|
|
293
|
|
|
|
|
|
|
else { |
|
294
|
0
|
0
|
0
|
|
|
|
$message ||= join( $arg{'join'}, @{$arg{critical}} ) |
|
|
0
|
|
|
|
|
|
|
|
295
|
|
|
|
|
|
|
if $code == CRITICAL; |
|
296
|
0
|
0
|
0
|
|
|
|
$message ||= join( $arg{'join'}, @{$arg{warning}} ) |
|
|
0
|
|
|
|
|
|
|
|
297
|
|
|
|
|
|
|
if $code == WARNING; |
|
298
|
0
|
0
|
0
|
|
|
|
$message ||= join( $arg{'join'}, @{$arg{unknown}} ) |
|
|
0
|
|
|
|
|
|
|
|
299
|
|
|
|
|
|
|
if $code == UNKNOWN; |
|
300
|
0
|
|
|
|
|
|
$message ||= ref $arg{ok} ? join( $arg{'join'}, @{$arg{ok}} ) : $arg{ok} |
|
301
|
0
|
0
|
0
|
|
|
|
if $arg{ok}; |
|
|
|
0
|
|
|
|
|
|
|
302
|
|
|
|
|
|
|
} |
|
303
|
|
|
|
|
|
|
|
|
304
|
0
|
|
|
|
|
|
return ($code, $message); |
|
305
|
|
|
|
|
|
|
} |
|
306
|
|
|
|
|
|
|
|
|
307
|
|
|
|
|
|
|
sub status_code { |
|
308
|
0
|
|
|
0
|
0
|
|
my ($self, $code) = @_; |
|
309
|
0
|
0
|
|
|
|
|
$code = (qw(ok warning critical unknown))[$code] if $code =~ /^\d+$/; |
|
310
|
0
|
|
|
|
|
|
$code = uc $code; |
|
311
|
0
|
0
|
0
|
|
|
|
$code = $ERRORS{$code} if defined $code && exists $ERRORS{$code}; |
|
312
|
0
|
0
|
0
|
|
|
|
$code = UNKNOWN unless defined $code && exists $STATUS_TEXT{$code}; |
|
313
|
0
|
|
|
|
|
|
return "$STATUS_TEXT{$code}"; |
|
314
|
|
|
|
|
|
|
} |
|
315
|
|
|
|
|
|
|
|
|
316
|
|
|
|
|
|
|
sub perfdata_string { |
|
317
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
|
318
|
0
|
0
|
|
|
|
|
if (scalar (@{$self->{perfdata}})) { |
|
|
0
|
|
|
|
|
|
|
|
319
|
0
|
|
|
|
|
|
return join(" ", @{$self->{perfdata}}); |
|
|
0
|
|
|
|
|
|
|
|
320
|
|
|
|
|
|
|
} else { |
|
321
|
0
|
|
|
|
|
|
return ""; |
|
322
|
|
|
|
|
|
|
} |
|
323
|
|
|
|
|
|
|
} |
|
324
|
|
|
|
|
|
|
|
|
325
|
|
|
|
|
|
|
sub html_string { |
|
326
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
|
327
|
0
|
0
|
|
|
|
|
if (scalar (@{$self->{html}})) { |
|
|
0
|
|
|
|
|
|
|
|
328
|
0
|
|
|
|
|
|
return join(" ", @{$self->{html}}); |
|
|
0
|
|
|
|
|
|
|
|
329
|
|
|
|
|
|
|
} else { |
|
330
|
0
|
|
|
|
|
|
return ""; |
|
331
|
|
|
|
|
|
|
} |
|
332
|
|
|
|
|
|
|
} |
|
333
|
|
|
|
|
|
|
|
|
334
|
|
|
|
|
|
|
sub nagios_exit { |
|
335
|
0
|
|
|
0
|
0
|
|
my ($self, $code, $message, $arg) = @_; |
|
336
|
0
|
0
|
0
|
|
|
|
$code = $ERRORS{$code} if defined $code && exists $ERRORS{$code}; |
|
337
|
0
|
0
|
0
|
|
|
|
$code = UNKNOWN unless defined $code && exists $STATUS_TEXT{$code}; |
|
338
|
0
|
0
|
|
|
|
|
$message = '' unless defined $message; |
|
339
|
0
|
0
|
0
|
|
|
|
if (ref $message && ref $message eq 'ARRAY') { |
|
340
|
0
|
|
|
|
|
|
$message = join(' ', map { chomp; $_ } @$message); |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
341
|
|
|
|
|
|
|
} else { |
|
342
|
0
|
|
|
|
|
|
chomp $message; |
|
343
|
|
|
|
|
|
|
} |
|
344
|
0
|
0
|
|
|
|
|
if ($self->opts->negate) { |
|
345
|
0
|
|
|
|
|
|
my $original_code = $code; |
|
346
|
0
|
|
|
|
|
|
foreach my $from (keys %{$self->opts->negate}) { |
|
|
0
|
|
|
|
|
|
|
|
347
|
0
|
0
|
0
|
|
|
|
if ((uc $from) =~ /^(OK|WARNING|CRITICAL|UNKNOWN)$/ && |
|
348
|
|
|
|
|
|
|
(uc $self->opts->negate->{$from}) =~ /^(OK|WARNING|CRITICAL|UNKNOWN)$/) { |
|
349
|
0
|
0
|
|
|
|
|
if ($original_code == $ERRORS{uc $from}) { |
|
350
|
0
|
|
|
|
|
|
$code = $ERRORS{uc $self->opts->negate->{$from}}; |
|
351
|
|
|
|
|
|
|
} |
|
352
|
|
|
|
|
|
|
} |
|
353
|
|
|
|
|
|
|
} |
|
354
|
|
|
|
|
|
|
} |
|
355
|
0
|
|
|
|
|
|
my $output = "$STATUS_TEXT{$code}"; |
|
356
|
0
|
0
|
0
|
|
|
|
$output .= " - $message" if defined $message && $message ne ''; |
|
357
|
0
|
0
|
0
|
|
|
|
if ($self->opts->can("morphmessage") && $self->opts->morphmessage) { |
|
358
|
|
|
|
|
|
|
# 'Intel [R] Interface (\d+) usage'='nic$1' |
|
359
|
|
|
|
|
|
|
# '^OK.*'="alles klar" '^CRITICAL.*'="alles hi" |
|
360
|
0
|
|
|
|
|
|
foreach my $key (keys %{$self->opts->morphmessage}) { |
|
|
0
|
|
|
|
|
|
|
|
361
|
0
|
0
|
|
|
|
|
if ($output =~ /$key/) { |
|
362
|
0
|
|
|
|
|
|
my $replacement = '"'.$self->opts->morphmessage->{$key}.'"'; |
|
363
|
0
|
|
|
|
|
|
$output =~ s/$key/$replacement/ee; |
|
|
0
|
|
|
|
|
|
|
|
364
|
|
|
|
|
|
|
} |
|
365
|
|
|
|
|
|
|
} |
|
366
|
|
|
|
|
|
|
} |
|
367
|
0
|
0
|
|
|
|
|
$output =~ s/\|/!/g if $output; |
|
368
|
0
|
0
|
|
|
|
|
if (scalar (@{$self->{perfdata}})) { |
|
|
0
|
|
|
|
|
|
|
|
369
|
0
|
|
|
|
|
|
$output .= " | ".$self->perfdata_string(); |
|
370
|
|
|
|
|
|
|
} |
|
371
|
0
|
|
|
|
|
|
$output .= "\n"; |
|
372
|
0
|
0
|
0
|
|
|
|
if ($self->opts->can("isvalidtime") && ! $self->opts->isvalidtime) { |
|
373
|
0
|
|
|
|
|
|
$code = OK; |
|
374
|
0
|
|
|
|
|
|
$output = "OK - outside valid timerange. check results are not relevant now. original message was: ". |
|
375
|
|
|
|
|
|
|
$output; |
|
376
|
|
|
|
|
|
|
} |
|
377
|
0
|
0
|
|
|
|
|
if (! exists $self->{suppress_messages}) { |
|
378
|
0
|
|
|
|
|
|
print $output; |
|
379
|
|
|
|
|
|
|
} |
|
380
|
0
|
|
|
|
|
|
exit $code; |
|
381
|
|
|
|
|
|
|
} |
|
382
|
|
|
|
|
|
|
|
|
383
|
|
|
|
|
|
|
sub set_thresholds { |
|
384
|
0
|
|
|
0
|
0
|
|
my ($self, %params) = @_; |
|
385
|
0
|
0
|
|
|
|
|
if (exists $params{metric}) { |
|
386
|
0
|
|
|
|
|
|
my $metric = $params{metric}; |
|
387
|
|
|
|
|
|
|
# erst die hartcodierten defaultschwellwerte |
|
388
|
0
|
|
|
|
|
|
$self->{thresholds}->{$metric}->{warning} = $params{warning}; |
|
389
|
0
|
|
|
|
|
|
$self->{thresholds}->{$metric}->{critical} = $params{critical}; |
|
390
|
|
|
|
|
|
|
# dann die defaultschwellwerte von der kommandozeile |
|
391
|
0
|
0
|
|
|
|
|
if (defined $self->opts->warning) { |
|
392
|
0
|
|
|
|
|
|
$self->{thresholds}->{$metric}->{warning} = $self->opts->warning; |
|
393
|
|
|
|
|
|
|
} |
|
394
|
0
|
0
|
|
|
|
|
if (defined $self->opts->critical) { |
|
395
|
0
|
|
|
|
|
|
$self->{thresholds}->{$metric}->{critical} = $self->opts->critical; |
|
396
|
|
|
|
|
|
|
} |
|
397
|
|
|
|
|
|
|
# dann die ganz spezifischen schwellwerte von der kommandozeile |
|
398
|
0
|
0
|
|
|
|
|
if ($self->opts->warningx) { # muss nicht auf defined geprueft werden, weils ein hash ist |
|
399
|
|
|
|
|
|
|
# Erst schauen, ob einer * beinhaltet. Von denen wird vom Laengsten |
|
400
|
|
|
|
|
|
|
# bis zum Kuerzesten probiert, ob die matchen. Der laengste Match |
|
401
|
|
|
|
|
|
|
# gewinnt. |
|
402
|
0
|
|
|
|
|
|
my @keys = keys %{$self->opts->warningx}; |
|
|
0
|
|
|
|
|
|
|
|
403
|
0
|
|
|
|
|
|
my @stringkeys = (); |
|
404
|
0
|
|
|
|
|
|
my @regexkeys = (); |
|
405
|
0
|
|
|
|
|
|
foreach my $key (sort { length($b) > length($a) } @keys) { |
|
|
0
|
|
|
|
|
|
|
|
406
|
0
|
0
|
|
|
|
|
if ($key =~ /\*/) { |
|
407
|
0
|
|
|
|
|
|
push(@regexkeys, $key); |
|
408
|
|
|
|
|
|
|
} else { |
|
409
|
0
|
|
|
|
|
|
push(@stringkeys, $key); |
|
410
|
|
|
|
|
|
|
} |
|
411
|
|
|
|
|
|
|
} |
|
412
|
0
|
|
|
|
|
|
foreach my $key (@regexkeys) { |
|
413
|
0
|
0
|
|
|
|
|
next if $metric !~ /$key/; |
|
414
|
0
|
|
|
|
|
|
$self->{thresholds}->{$metric}->{warning} = $self->opts->warningx->{$key}; |
|
415
|
0
|
|
|
|
|
|
last; |
|
416
|
|
|
|
|
|
|
} |
|
417
|
|
|
|
|
|
|
# Anschliessend nochmal schauen, ob es einen nicht-Regex-Volltreffer gibt |
|
418
|
0
|
|
|
|
|
|
foreach my $key (@stringkeys) { |
|
419
|
0
|
0
|
|
|
|
|
next if $key ne $metric; |
|
420
|
0
|
|
|
|
|
|
$self->{thresholds}->{$metric}->{warning} = $self->opts->warningx->{$key}; |
|
421
|
0
|
|
|
|
|
|
last; |
|
422
|
|
|
|
|
|
|
} |
|
423
|
|
|
|
|
|
|
} |
|
424
|
0
|
0
|
|
|
|
|
if ($self->opts->criticalx) { |
|
425
|
0
|
|
|
|
|
|
my @keys = keys %{$self->opts->criticalx}; |
|
|
0
|
|
|
|
|
|
|
|
426
|
0
|
|
|
|
|
|
my @stringkeys = (); |
|
427
|
0
|
|
|
|
|
|
my @regexkeys = (); |
|
428
|
0
|
|
|
|
|
|
foreach my $key (sort { length($b) > length($a) } @keys) { |
|
|
0
|
|
|
|
|
|
|
|
429
|
0
|
0
|
|
|
|
|
if ($key =~ /\*/) { |
|
430
|
0
|
|
|
|
|
|
push(@regexkeys, $key); |
|
431
|
|
|
|
|
|
|
} else { |
|
432
|
0
|
|
|
|
|
|
push(@stringkeys, $key); |
|
433
|
|
|
|
|
|
|
} |
|
434
|
|
|
|
|
|
|
} |
|
435
|
0
|
|
|
|
|
|
foreach my $key (@regexkeys) { |
|
436
|
0
|
0
|
|
|
|
|
next if $metric !~ /$key/; |
|
437
|
0
|
|
|
|
|
|
$self->{thresholds}->{$metric}->{critical} = $self->opts->criticalx->{$key}; |
|
438
|
0
|
|
|
|
|
|
last; |
|
439
|
|
|
|
|
|
|
} |
|
440
|
|
|
|
|
|
|
# Anschliessend nochmal schauen, ob es einen nicht-Regex-Volltreffer gibt |
|
441
|
0
|
|
|
|
|
|
foreach my $key (@stringkeys) { |
|
442
|
0
|
0
|
|
|
|
|
next if $key ne $metric; |
|
443
|
0
|
|
|
|
|
|
$self->{thresholds}->{$metric}->{critical} = $self->opts->criticalx->{$key}; |
|
444
|
0
|
|
|
|
|
|
last; |
|
445
|
|
|
|
|
|
|
} |
|
446
|
|
|
|
|
|
|
} |
|
447
|
|
|
|
|
|
|
} else { |
|
448
|
|
|
|
|
|
|
$self->{thresholds}->{default}->{warning} = |
|
449
|
0
|
0
|
|
|
|
|
defined $self->opts->warning ? $self->opts->warning : defined $params{warning} ? $params{warning} : 0; |
|
|
|
0
|
|
|
|
|
|
|
450
|
|
|
|
|
|
|
$self->{thresholds}->{default}->{critical} = |
|
451
|
0
|
0
|
|
|
|
|
defined $self->opts->critical ? $self->opts->critical : defined $params{critical} ? $params{critical} : 0; |
|
|
|
0
|
|
|
|
|
|
|
452
|
|
|
|
|
|
|
} |
|
453
|
|
|
|
|
|
|
} |
|
454
|
|
|
|
|
|
|
|
|
455
|
|
|
|
|
|
|
sub force_thresholds { |
|
456
|
0
|
|
|
0
|
0
|
|
my ($self, %params) = @_; |
|
457
|
0
|
0
|
|
|
|
|
if (exists $params{metric}) { |
|
458
|
0
|
|
|
|
|
|
my $metric = $params{metric}; |
|
459
|
0
|
|
0
|
|
|
|
$self->{thresholds}->{$metric}->{warning} = $params{warning} || 0; |
|
460
|
0
|
|
0
|
|
|
|
$self->{thresholds}->{$metric}->{critical} = $params{critical} || 0; |
|
461
|
|
|
|
|
|
|
} else { |
|
462
|
0
|
|
0
|
|
|
|
$self->{thresholds}->{default}->{warning} = $params{warning} || 0; |
|
463
|
0
|
|
0
|
|
|
|
$self->{thresholds}->{default}->{critical} = $params{critical} || 0; |
|
464
|
|
|
|
|
|
|
} |
|
465
|
|
|
|
|
|
|
} |
|
466
|
|
|
|
|
|
|
|
|
467
|
|
|
|
|
|
|
sub get_thresholds { |
|
468
|
0
|
|
|
0
|
0
|
|
my ($self, @params) = @_; |
|
469
|
0
|
0
|
|
|
|
|
if (scalar(@params) > 1) { |
|
470
|
0
|
|
|
|
|
|
my %params = @params; |
|
471
|
0
|
|
|
|
|
|
my $metric = $params{metric}; |
|
472
|
|
|
|
|
|
|
return ($self->{thresholds}->{$metric}->{warning}, |
|
473
|
0
|
|
|
|
|
|
$self->{thresholds}->{$metric}->{critical}); |
|
474
|
|
|
|
|
|
|
} else { |
|
475
|
|
|
|
|
|
|
return ($self->{thresholds}->{default}->{warning}, |
|
476
|
0
|
|
|
|
|
|
$self->{thresholds}->{default}->{critical}); |
|
477
|
|
|
|
|
|
|
} |
|
478
|
|
|
|
|
|
|
} |
|
479
|
|
|
|
|
|
|
|
|
480
|
|
|
|
|
|
|
sub check_thresholds { |
|
481
|
0
|
|
|
0
|
0
|
|
my ($self, @params) = @_; |
|
482
|
0
|
|
|
|
|
|
my $level = $ERRORS{OK}; |
|
483
|
0
|
|
|
|
|
|
my $warningrange; |
|
484
|
|
|
|
|
|
|
my $criticalrange; |
|
485
|
0
|
|
|
|
|
|
my $value; |
|
486
|
0
|
0
|
|
|
|
|
if (scalar(@params) > 1) { |
|
487
|
0
|
|
|
|
|
|
my %params = @params; |
|
488
|
0
|
|
|
|
|
|
$value = $params{value}; |
|
489
|
0
|
|
|
|
|
|
my $metric = $params{metric}; |
|
490
|
0
|
0
|
|
|
|
|
if ($metric ne 'default') { |
|
491
|
|
|
|
|
|
|
$warningrange = exists $self->{thresholds}->{$metric}->{warning} ? |
|
492
|
|
|
|
|
|
|
$self->{thresholds}->{$metric}->{warning} : |
|
493
|
0
|
0
|
|
|
|
|
$self->{thresholds}->{default}->{warning}; |
|
494
|
|
|
|
|
|
|
$criticalrange = exists $self->{thresholds}->{$metric}->{critical} ? |
|
495
|
|
|
|
|
|
|
$self->{thresholds}->{$metric}->{critical} : |
|
496
|
0
|
0
|
|
|
|
|
$self->{thresholds}->{default}->{critical}; |
|
497
|
|
|
|
|
|
|
} else { |
|
498
|
|
|
|
|
|
|
$warningrange = (defined $params{warning}) ? |
|
499
|
0
|
0
|
|
|
|
|
$params{warning} : $self->{thresholds}->{default}->{warning}; |
|
500
|
|
|
|
|
|
|
$criticalrange = (defined $params{critical}) ? |
|
501
|
0
|
0
|
|
|
|
|
$params{critical} : $self->{thresholds}->{default}->{critical}; |
|
502
|
|
|
|
|
|
|
} |
|
503
|
|
|
|
|
|
|
} else { |
|
504
|
0
|
|
|
|
|
|
$value = $params[0]; |
|
505
|
0
|
|
|
|
|
|
$warningrange = $self->{thresholds}->{default}->{warning}; |
|
506
|
0
|
|
|
|
|
|
$criticalrange = $self->{thresholds}->{default}->{critical}; |
|
507
|
|
|
|
|
|
|
} |
|
508
|
0
|
0
|
|
|
|
|
if (! defined $warningrange) { |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
509
|
|
|
|
|
|
|
# there was no set_thresholds for defaults, no --warning, no --warningx |
|
510
|
|
|
|
|
|
|
} elsif ($warningrange =~ /^([-+]?[0-9]*\.?[0-9]+)$/) { |
|
511
|
|
|
|
|
|
|
# warning = 10, warn if > 10 or < 0 |
|
512
|
|
|
|
|
|
|
$level = $ERRORS{WARNING} |
|
513
|
0
|
0
|
0
|
|
|
|
if ($value > $1 || $value < 0); |
|
514
|
|
|
|
|
|
|
} elsif ($warningrange =~ /^([-+]?[0-9]*\.?[0-9]+):$/) { |
|
515
|
|
|
|
|
|
|
# warning = 10:, warn if < 10 |
|
516
|
|
|
|
|
|
|
$level = $ERRORS{WARNING} |
|
517
|
0
|
0
|
|
|
|
|
if ($value < $1); |
|
518
|
|
|
|
|
|
|
} elsif ($warningrange =~ /^~:([-+]?[0-9]*\.?[0-9]+)$/) { |
|
519
|
|
|
|
|
|
|
# warning = ~:10, warn if > 10 |
|
520
|
|
|
|
|
|
|
$level = $ERRORS{WARNING} |
|
521
|
0
|
0
|
|
|
|
|
if ($value > $1); |
|
522
|
|
|
|
|
|
|
} elsif ($warningrange =~ /^([-+]?[0-9]*\.?[0-9]+):([-+]?[0-9]*\.?[0-9]+)$/) { |
|
523
|
|
|
|
|
|
|
# warning = 10:20, warn if < 10 or > 20 |
|
524
|
|
|
|
|
|
|
$level = $ERRORS{WARNING} |
|
525
|
0
|
0
|
0
|
|
|
|
if ($value < $1 || $value > $2); |
|
526
|
|
|
|
|
|
|
} elsif ($warningrange =~ /^@([-+]?[0-9]*\.?[0-9]+):([-+]?[0-9]*\.?[0-9]+)$/) { |
|
527
|
|
|
|
|
|
|
# warning = @10:20, warn if >= 10 and <= 20 |
|
528
|
|
|
|
|
|
|
$level = $ERRORS{WARNING} |
|
529
|
0
|
0
|
0
|
|
|
|
if ($value >= $1 && $value <= $2); |
|
530
|
|
|
|
|
|
|
} |
|
531
|
0
|
0
|
|
|
|
|
if (! defined $criticalrange) { |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
532
|
|
|
|
|
|
|
# there was no set_thresholds for defaults, no --critical, no --criticalx |
|
533
|
|
|
|
|
|
|
} elsif ($criticalrange =~ /^([-+]?[0-9]*\.?[0-9]+)$/) { |
|
534
|
|
|
|
|
|
|
# critical = 10, crit if > 10 or < 0 |
|
535
|
|
|
|
|
|
|
$level = $ERRORS{CRITICAL} |
|
536
|
0
|
0
|
0
|
|
|
|
if ($value > $1 || $value < 0); |
|
537
|
|
|
|
|
|
|
} elsif ($criticalrange =~ /^([-+]?[0-9]*\.?[0-9]+):$/) { |
|
538
|
|
|
|
|
|
|
# critical = 10:, crit if < 10 |
|
539
|
|
|
|
|
|
|
$level = $ERRORS{CRITICAL} |
|
540
|
0
|
0
|
|
|
|
|
if ($value < $1); |
|
541
|
|
|
|
|
|
|
} elsif ($criticalrange =~ /^~:([-+]?[0-9]*\.?[0-9]+)$/) { |
|
542
|
|
|
|
|
|
|
# critical = ~:10, crit if > 10 |
|
543
|
|
|
|
|
|
|
$level = $ERRORS{CRITICAL} |
|
544
|
0
|
0
|
|
|
|
|
if ($value > $1); |
|
545
|
|
|
|
|
|
|
} elsif ($criticalrange =~ /^([-+]?[0-9]*\.?[0-9]+):([-+]?[0-9]*\.?[0-9]+)$/) { |
|
546
|
|
|
|
|
|
|
# critical = 10:20, crit if < 10 or > 20 |
|
547
|
|
|
|
|
|
|
$level = $ERRORS{CRITICAL} |
|
548
|
0
|
0
|
0
|
|
|
|
if ($value < $1 || $value > $2); |
|
549
|
|
|
|
|
|
|
} elsif ($criticalrange =~ /^@([-+]?[0-9]*\.?[0-9]+):([-+]?[0-9]*\.?[0-9]+)$/) { |
|
550
|
|
|
|
|
|
|
# critical = @10:20, crit if >= 10 and <= 20 |
|
551
|
|
|
|
|
|
|
$level = $ERRORS{CRITICAL} |
|
552
|
0
|
0
|
0
|
|
|
|
if ($value >= $1 && $value <= $2); |
|
553
|
|
|
|
|
|
|
} |
|
554
|
0
|
|
|
|
|
|
return $level; |
|
555
|
|
|
|
|
|
|
} |
|
556
|
|
|
|
|
|
|
|
|
557
|
|
|
|
|
|
|
1; |
|
558
|
|
|
|
|
|
|
|
|
559
|
|
|
|
|
|
|
__END__ |