1833792 Members
2416 Online
110063 Solutions
New Discussion

Re: samba monitor script

 
SOLVED
Go to solution
p7
Frequent Advisor

samba monitor script

hi all

someone braught down the main samba daemon by accident the other day, so we couldnt do processing. i tried to put a script in cron
to monitor samba n bring it up (which was supplied by itrc, thx. its a good script but i noticed that if i kill the main samba daemon and a client samba daemon is up, the script says samba is up. i then tried it straight from startsmb and it also thinks samba is up! it there a bug here?

thx in advance




6 REPLIES 6
Geoff Wild
Honored Contributor

Re: samba monitor script

What version of Samba?

How did somone bring it down by accident?

Can you post the script?

Rgds...Geoff
Proverbs 3:5,6 Trust in the Lord with all your heart and lean not on your own understanding; in all your ways acknowledge him, and he will make all your paths straight.
p7
Frequent Advisor

Re: samba monitor script

1. # swlist -l fileset|grep -i samba
# CIFS-Server A.01.11.04 HP CIFS Server (Samba) Fi
le and Print Services
CIFS-Server.CIFS-DOC A.01.11.04 Samba Documentation (orig
inal)

2. someone braught it down by accident and didnt notice

3. #!/usr/bin/ksh
set -o xtrace
if [ -z "`ps -ef |grep -v grep |grep smbd`" ] ;then
/sbin/init.d/samba stop
/sbin/init.d/samba start
elif [ -z "`ps -ef |grep -v grep |grep nmbd`" ] ;then
/sbin/init.d/samba stop
/sbin/init.d/samba start
fi


Rainer von Bongartz
Honored Contributor

Re: samba monitor script



There is a file which contains the PID of the main smbd daemon

/var/opt/samba/locks/smbd.pid

build a monitor script by the PID from this file and check if the daemon with this PID is running.

As a template take a look at

/opt/samba/HA/samba.mon


Regards
Rainer
He's a real UNIX Man, sitting in his UNIX LAN making all his UNIX plans for nobody ...
Geoff Wild
Honored Contributor
Solution

Re: samba monitor script

Your script is flawed in that if it sees any process with smbd, then it is okay.

As Rainer says, look for the actual pid:


#!/usr/bin/ksh

SMBD=`cat /var/opt/samba/locks/smbd.pid`
NMBD=`cat /var/opt/samba/locks/nmbd.pid`
set -o xtrace

if [ -z "`ps -ef |grep -v grep |grep $SMBD`" ] ;then
/sbin/init.d/samba stop
/sbin/init.d/samba start
elif [ -z "`ps -ef |grep -v grep |grep $NMBD`" ] ;then
/sbin/init.d/samba stop
/sbin/init.d/samba start
fi


Rgds...Geoff
Proverbs 3:5,6 Trust in the Lord with all your heart and lean not on your own understanding; in all your ways acknowledge him, and he will make all your paths straight.
p7
Frequent Advisor

Re: samba monitor script

thx for all ur responses.
will test it
Dave Poeschel
Occasional Advisor

Re: samba monitor script

If you are still interested -

HP CIFS Version A.02.02.01, released 3/27/2006, contains a new utility, smbmonitor. This is a perl script with many options to choose which daemons to monitor, restart them in necessary, collect data, send alert email, etc.

The Release Note at http://docs.hp.com/en/B8725-90102/index.html has a mention of the tool and the CIFS release can be download from the software depot at http://h20293.www2.hp.com/portal/swdepot/displayProductInfo.do?productNumber=B8725AA