From 6023b4c41cf1ae6c34d35149323d0a3f94567c99 Mon Sep 17 00:00:00 2001 From: Jan Willamowius Date: Tue, 13 Sep 2005 15:41:34 +0000 Subject: [PATCH] plugin to monitor SMB servers using 'smbclient' --- src/lib/Spong/Network/plugins/check_smb | 34 +++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 src/lib/Spong/Network/plugins/check_smb diff --git a/src/lib/Spong/Network/plugins/check_smb b/src/lib/Spong/Network/plugins/check_smb new file mode 100644 index 0000000..98a64fd --- /dev/null +++ b/src/lib/Spong/Network/plugins/check_smb @@ -0,0 +1,34 @@ +# Register the routine with the plugin registry +$PLUGINS{'smb'} = \&check_smb; + +# This will do a very simple SMB check by using the smbclient command +# to probe the SMB service at the remote host. It checks to make sure +# it can at least query SMB services anonymously. + +# $Id: check_smb,v 1.1 2005/09/13 15:41:34 willamowius Exp $ + +use Spong::SafeExec qw(safe_exec); + +sub check_smb { + my( $host ) = @_; + my( $color, $summary, $message, $smbok ) = ( "green", "", "", 0 ); + my( $msg1 ); + + $msg1 = safe_exec("/usr/bin/smbclient -L '\\$host' -N 2>&1",30); + if( $msg1 =~ /Anonymous login successful/ ) { $smbok = 1; } + + $message = "$msg1\n"; + if( $smbok ) { + $color = "green"; + $summary = "smb ok"; + } else { + $color = "red"; + $summary = "smb down"; + } + + &debug( "smb - $host - $color, $summary" ); + return( $color, $summary, $message ); +} + +1; + -- 2.30.2