File:Check bind mounts.pl

From RARFORGE
Jump to: navigation, search
Check_bind_mounts.pl(file size: 786 B, MIME type: application/x-perl)
Warning: This file type may contain malicious code. By executing it, your system may be compromised.
#!/usr/bin/perl -w
 
my $mount = shift;
my @mounts = `grep bind /etc/fstab | grep -v ^\#`;
 
my $info;
my $fail;
foreach my $line (@mounts) {
    my $mount;
    if ($line =~ /[\/\w\d]+[\s]+([\/\w\d]+)\s+/i) {
        my $mount = $1;
        my $cmd = "df -a | grep  $mount";
        my @result = `df -a  | grep  $mount`;
        #my @result = `df -a $mount | grep root\@`;
        if (@result) {
            $info .= "$mount=1,";
	    print $info;
            #print "OK: $result[0]\n";
            #exit(0);
        } else {
            print "\n" . $cmd . "\n";
            $fail .= "$mount=0,";
        }
    } 
}
$info =~ s/,$// if $info;
$fail =~ s/,$// if $fail;
 
if ($fail) {
    print "CRITICAL: $fail (ok: $info)\n";
    exit(2);
} else {
    print "OK: $info\n";
    exit(0);
}

File history

Click on a date/time to view the file as it appeared at that time.

Date/TimeDimensionsUserComment
current15:49, 1 March 2013 (786 B)Robertr (Talk | contribs)

The following page links to this file:

Personal tools
Namespaces

Variants
Views
Actions
Navigation
Toolbox