# Register the routine with the plugin registry
$PLUGINS{'nfs'} = \&check_nfs;

# This will do a very simple NFS check by using the rpcinfo command to probe
# the portmapper at the remote host.  It checks to make sure the nfs, and
# mountd services are responding.

# $Id: check_nfs,v 1.2 2001/08/07 18:41:05 sljohnson Exp $

use Spong::SafeExec qw(safe_exec);

sub check_nfs {
   my( $host ) = @_;
   my( $color, $summary, $message, $rpcok ) = ( "green", "", "", 1 );
   my( $msg1, $msg2 );

   $msg1 = safe_exec("$RPCINFO $host nfs 2>&1",30);
   if( $msg1 !~ /ready and waiting/ ) { $rpcok = 0; }
   $msg2 = safe_exec("$RPCINFO $host mountd 2>&1",30);
   if( $msg2 !~ /ready and waiting/ ) { $rpcok = 0; }

   $message = "$msg1\n$msg2";
   if( $rpcok ) {
      $color   = "green";
      $summary = "nfs ok";
   } else {
      $color   = "red";
      $summary = "nfs down";
   }

   &debug( "nfs - $host - $color, $summary" );
   return( $color, $summary, $message );
}



1;

