forked from hamcos/monitoring-checks
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheck_incomingSMS
More file actions
executable file
·86 lines (66 loc) · 2.63 KB
/
Copy pathcheck_incomingSMS
File metadata and controls
executable file
·86 lines (66 loc) · 2.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#!/usr/bin/perl -w
=pod
=head1 LICENSE
Copyright (C) 2013 hamcos IT Service GmbH, Robin Schneider <robin.schneider@hamcos.de>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
=head1 DESCRIPTION
https://www.monitoringexchange.org/inventory/Check-Plugins/Hardware/Devices/Misc/check_incomingSMS
This plugin checks if there are SMS in the incoming directory. This can be
useful if you only use the GSM modem for outgoing SMS and there is the
slightest chances for incoming SMS. It can also be used to check if there are
SMS in the outgoing directory.
=cut
use strict;
use warnings;
use Nagios::Plugin;
my $VERSION = '1.0';
my $p = Nagios::Plugin->new(
usage => "Usage: %s [ -i, --incoming=directory ]",
version => $VERSION,
blurb => 'Check if there are SMS in the incoming directory',
extra =>
'This plugin checks if there are SMS in the incoming directory. This can be useful if you only use the GSM modem for outgoing SMS and there is the slightest chances for incoming SMS.',
);
## Define and document the valid command line options
## usage, help, version, timeout and verbose are defined by default.
$p->add_arg(
spec => 'warning|w=s',
help => qq{-w, --warning=INTEGER:INTEGER
warning level for incoming SMS (default 0).
The state will be WARNING if there is one SMS or more},
default => 0,
);
$p->add_arg(
spec => 'critical|c=s',
help => qq{-c, --critical=INTEGER:INTEGER
critical level for incoming SMS (default 100)},
default => 100,
);
$p->add_arg(
spec => 'incoming|i=s',
help => qq{-i, --incoming=directory
Directory to the SMS incoming directory},
default => "/var/spool/sms/incoming/",
);
$p->getopts;
my $dir = $p->opts->incoming;
$p->nagios_die("The directory $dir does not exist") unless -d $dir;
my @sms = glob "$dir/*";
my $count_sms = @sms;
my $are_or_is = 'are';
if ($count_sms == 1) {
$are_or_is = 'is';
}
$p->nagios_exit(
return_code => $p->check_threshold($count_sms),
message => " there $are_or_is $count_sms SMS in the incoming directory"
);