File:Check nfs

From RARForge
Jump to navigation Jump to search size: 774 bytes, MIME type: application/x-perl)

Warning: This file type may contain malicious code. By executing it, your system may be compromised.

<source lang=perl>

  1. !/usr/bin/perl -w

use strict; my $mount = shift; my @mounts = `grep nfs /etc/fstab | grep -v ^\#`;

my $info; my $fail; foreach my $line (@mounts) {

   my $mount;
   $mount = '/Media';
   if ($line =~ /[\/\w\d]+[\s]+([\/\w\d]+)\s+/i) {
       my $mount = $1;
       #my @result = `df -a $mount | grep $mount | grep nfs`;
       my @result = `df -a $mount `;
       if (@result) {
           $info .= "$mount=1,";

print $info;

           #print "OK: $result[0]\n";
       } else {
           #print $cmd . "\n";
           $fail .= "$mount=0,";

} $info =~ s/,$// if $info; $fail =~ s/,$// if $fail;

if ($fail) {

   print "CRITICAL: $fail (ok: $info)\n";

} else {

   print "OK: $info\n";

} </source>

File history

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

current23:50, 1 March 2013 (774 bytes)Robertr (talk | contribs)

The following page uses this file: