On Tue, Sep 17, 2002 at 11:49:16AM +0200, Dennis Bieling wrote:
> Hi!
> 
> Is anyone of you using the samba.monitor for mon?
> I have some problems in making it work.
> Everytime mon runs, it produces an mail.alert with just telling me the 
> name of the host and the service but nothing about the problem.
> There is no warning about the service not running or anything else.
> This happens regardless if the samba service is running or not.
> Anyone out there who can help me ?
> 

After some tests, i decided to rewrite the monitor
for more recent versions of smbclient.

I attach my version. You should try it on your system 
probably with the -d flag from the command line. 
I use the following
smbclient_auth.cf:

user=guest
password=

  Ciao
      Dietmar

-- 
 Alles Gute / best wishes  
     Dietmar Goldbeck         E-Mail: [EMAIL PROTECTED]
Reporter (to Mahatma Gandhi): Mr Gandhi, what do you think of Western
Civilization?  Gandhi: I think it would be a good idea.
#!/usr/bin/perl -w
#
# Use: try to connect anonymously to a Samba server, and
# wait for the right output.
#
# For use with "mon".
#

use  Getopt::Std;
use strict;
use vars qw( %failures $failures $host $member $details
             $error
             $opt_A $CREDFILE
             $opt_d $DEBUG);

getopts ("dA:");

$DEBUG = $opt_d || 0;
$CREDFILE = $opt_A || "/etc/mon/smbclient_auth.cf";

%failures = ();

foreach $host (@ARGV) {
    ($error, $details) = Samba_test ($host);
    if($error) {
        $failures{$host} = $details;
    }
}
 
my($member);
if ((keys(%failures))==0) {
    # we are happy
    exit 0;
} else {
    # summary:
    print join (" ", sort keys(%failures)), "\n";
    # all details:
    foreach $member (sort keys(%failures)) {
        print "$member: ", $failures{$member};
    }
    exit 1;
}


sub  Samba_test {
    my ($Server_name) = shift (@_);
    
    print STDERR "checking Server $Server_name\n" 
        unless ! $DEBUG;

    my $serviceList = `smbclient -A $CREDFILE -L $Server_name 2>&1`;
    my $exit_value  = $? >> 8;
    print STDERR "smbclient exit_value = $exit_value\nsmbclient output: 
\n$serviceList" 
        unless ! $DEBUG;
    if($exit_value) {
        return(1, $serviceList);
    }
    # check smbclient output
    if($serviceList !~ /Domain=\[.*\]\s+OS=\[.*\]\s+Server=\[.*\]/ ||
       $serviceList !~ /Sharename/ ||
       $serviceList !~ /Workgroup/ ||
       $serviceList !~ /Server/) {
        return(1, "smbclient output error:\n" . $serviceList);
    } 
    return (0, undef);
}

Reply via email to