forked from inuits/monitoring-plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
/
check_mount.pl
executable file
·64 lines (55 loc) · 1.15 KB
/
check_mount.pl
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
#!/usr/bin/perl -w
###################################
#
# written by Martin Scharm
# see https://binfalse.de
#
###################################
use warnings;
use strict;
use Getopt::Long qw(:config no_ignore_case);
use lib '/usr/lib/nagios/plugins';
use lib '/usr/lib64/nagios/plugins';
use utils qw(%ERRORS);
my $MOUNT = undef;
my $TYPE = undef;
sub how_to
{
print "USAGE: $0\n\t-m MOUNTPOINT\twich mountpoint to check\n\t[-t TYPE]\toptionally check whether it's this kind of fs-type\n\n";
}
GetOptions (
'm=s' => \ $MOUNT,
'mountpoint=s' => \ $MOUNT,
't=s' => \ $TYPE,
'type=s' => \ $TYPE
);
unless (defined ($MOUNT))
{
print "Please define mountpoint\n\n";
how_to;
exit $ERRORS{'CRITICAL'};
}
my $erg = `/bin/mount | /bin/grep $MOUNT`;
if ($erg)
{
if (defined ($TYPE))
{
if ($erg =~ m/type $TYPE /)
{
print $MOUNT . " is mounted! Type is " . $TYPE . "\n";
exit $ERRORS{'OK'};
}
else
{
print $MOUNT . " is mounted! But type is not " . $TYPE . "\n";
exit $ERRORS{'WARNING'};
}
}
print $MOUNT . " is mounted!\n";
exit $ERRORS{'OK'};
}
else
{
print $MOUNT . " is not mounted!\n";
exit $ERRORS{'CRITICAL'};
}