SMBMONITOR(1)SMBMONITOR(1)NAME
smbmonitor - Monitor and control the CIFS Server status as a stand
alone program or a scheduled cron job.
SYNOPSIS
smbmonitor [daemon=targetstatus ...] [-L level] [-S schedule]
[-T timeout] [-a|-b command] [-c cleanlogflag] [-e|-d] [-l logfile]
[-i interval] [-n notify] [-t receiver-emails] [-f sender-emails]
[-s subject] [-h|-? or -help]
DESCRIPTION
This script is part of the HP CIFS Server suite.
smbmonitor.pl is a perl script of HP CIFS Server specific monitoring
and alert management. It is designed to perform daemon status checking,
detect daemon alive and trigger alerts with proper alert actions upon
detection of failures. It should be run as root user only. Normally, it
can be used for non ServiceGuard environment. For ServiceGuard
environment, refer to HA control scripts.
If the server conforms to a specified targetstatus, smbmonitor will
report the status of the server and return a zero value as result. If
the server status doesn´t match with the specified
targetstatus, an auto email as alert notification can be selected and
sent to administrators with a report of runtime system status, which
includes how much cpu utilization and disk usage to be consumed, how
many user connections and file locks maintained on the CIFS Server when
reporting system information is enabled. And also the script can take
action to bring the server status to the
targetstatus if needed. When smbmonitor is run unsuccessfully, it will
report error messages and return a non-zero value.
Use of this utility will help administrators monitor the CIFS Server
from a command line or as a scheduled cron job. When the script is
executed from a command line, the output will go to standard output
unless the option -l logfile is used. If it is executed as a schedule
cron job that has been setup in cron job table, then the option -l
logfile should be used to specify where to store smbmonitor logging
messages.
Running the script requires at least Perl 5.8.0 or above versions.
EXAMPLE
smbmonitor.pl
smbmonitor.pl smbd=check nmbd=check winbindd=ignore
Only check and report running status of smbd and nmbd daemons
without actions.
smbmonitor.pl smbd=up nmbd=up
Check running status of smbd and nmbd daemons for the CIFS Server.
If they are not running, the monitor will restart them.
smbmonitor.pl smbd=up nmbd=up winbindd=up
Check running status of all daemons such as smbd and nmbd as well
as winbindd for the CIFS Server. If they are not running, the
monitor will restart them.
smbmonitor.pl smbd=up -l /tmp/log.smbmonitor
Specify smbmonitor log file to /tmp/log.smbmonitor during checking
smbd running status.
smbmonitor.pl -n check -s "Your Alert Notice" -t administrator@company.com
Enable sending auto email for each checking. And take the specified
receiver-email and subject.
smbmonitor.pl -b your.sh
When an alert presents, smbmonitor will execute the specified script
before taking actions.
smbmonitor.pl smbd=up nmbd=up -i 1800 -n action -l /tmp/log.smbmonitor
Automatic monitoring will be executed every 30 minutes. And enable
sending alert email once taking actions, save monitoring log message
to the specified file.
smbmonitor.pl -S "0,30 * * * *" -n action -e -t administrator@company.com
Each 30 minutes, smbmonitor will be run to check server status.
Once there is an alert appeared, send auto alert email to administrator
with system information report. Need ctrl-c to terminate the execution.
smbmonitor.pl -h
smbmonotor.pl -help
Display help message.
If the following pattern is used to schedule a cron job by crontab command,
the script will be run hourly during weekday:
* 0 * * 1,2,3,4,5 /opt/samba/bin/smbmonitor.pl -l /tmp/log.smbmonitor
You can execute crontab command as root user to setup your own cron job. Refer
to crontab manpage.
OPTIONS
daemon=targetstatus
This option specifies the name of daemon and the type of daemon
checking to be the target status. The daemon can be smbd, nmbd and
winbindd with predefined targetstatus as followings:
· up - Force the daemon running up. If it´s not running, start
it. If it´s hanging, stop it and then restart it.
· down - Force the specified daemon not running. If it´s running,
stop it.
· check - Only check the specifed daemon status without any
status changes.
· keep - If the specifed daemon is not running, start it.
Otherwise do nothing.
· ignore - Don´t check the sepcified daemon.
The default setting is smbd=check nmbd=check winbindd=ignore.
Note: If a daemon that doesn´t mention in the option, the script
would ignore the daemon. For example: when using smbd=check in the
option, the script would check smbd daemon only, ignore checking of
nmbd and winbindd daemons. However, when using smbd=up or keep in
the option, the script would automatically adjust nmbd target
status to the same status of smbd because smbd daemon needs nmbd
function to conduct well.
-L level
This option specifies monitoring level for smbmonitor. The
monitoring level can be 1 or 2 with following meaning. The default
setting of the option is 1.
· 1 - Only check if the specified daemon is running, not check if
it´s hanging.
· 2 - Check if the specified daemon is both running and hanging.
Since smbmonitor uses ps to detect running status, and smbclient
and nmlookup to diagnose hanging or active of smbd and nmbd
respectively, it automatically captures a share name for guest
access from smb.conf. So it´s recommended a particular share named
as [monitor] in smb.conf with allowing guest access used for
hanging detection purpose should present in smb.conf if using
monitoring level 2. Otherwise, you are required to specify logon
user name and password in relevant variables of Global Variables
section in the script to detect server hanging status for the level
2.
For example: when monitoring level 2 is used, a particular share
[monitor] must be involved in smb.conf.
[global]
...
[monitor]
path = /tmp
read only = yes
guest ok = yes
-S schedule
This option specifies a schedule string that is used for
automatical monitoring function executed by the script itself. The
schedule string would show how frequently to invoke monitoring
process. The schedule string is a five integer pattern with
following format, field ranges and separated by spaces.
minute hour day month weekday
minute the minute of the hour, 0-59
hour the hour of the day, 0-23
day the day of the month, 1-31
month the month of the year, 1-12
weekday the day of the week, 0-6, 0=Sunday
The comma(,) specifies a list of values for a field, eg. 1,3,8. The
asterisk(*) specifies all possible values for a field. For example:
-S "* 7 1,15 * *" means the monitor will be run at 8 AM on the
first and 15th days of each month. The default of the option is
empty string.
Note:
· If you want to use the option continually to monitor server
status, you need to use ctrl-c to terminite the program during
monitor idle period.
· This option couldn´t be combined to work with cron job on HPUX.
If you are using cron job, you should ignore the option.
· If you have a large number of connections to the CIFS Server,
HP recommends using an HP-UX cron job instead of this option.
-T timeout
This option specifies a timeout used for determinating how long
hanging detection should be done when running smbclient to
establish local smb connections. It is only used in the monitoring
level 2. During detection of server hanging, if smbclient doesn´t
get any response from the CIFS server within the timeout, the
script would consider the server is hanging. At this time, there is
an hang alert appeared. An alert action can be taken or not,
depending on targetstatus. When monitoing level is assigned to
level 1, the option would be ignored. The default setting of the
option is 30 seconds.
-a|-b command
This option specifies an external command that can be executed
after or before taking alert actions. Alert actions normally happen
when server status doesn´t match with expected targetstatus. When
targetstatus is check or ignore, the script would get rid of the
options. Nothing to do. The default settings of these two options
are an empty string.
-c cleanlogflag
This option specifies if to clean up existing log file, if it´s
presence on the system. The option can be only working with the
option -l. If the option "-l logfile" is not used, the script would
ignore the option. So when using the option, you must specify your
own logfile by the option -l. The cleanlogflag can be
· yes - Clean existing log file.
· no - Don´t clean existing log file.
The default setting of the option is "no".
-e|-d
The option -e enables reporting system information to auto alert
email. The option -d disables reporting system information. System
information would contain two parts. One is basic system
information such as OS version, kernel bits and how many cpu
processors configured on the underlying system. Another part is
runtime information such as cpu utilization, file system usage,
swap information, how many users logged on to the server, how many
file locks maintained on the CIFS Server, etc. The last part of
informations would reflect system runtime situations. When
reporting system information is enabled, the script would
automatically attach these system information to auto alert email.
The default of the feature is disable.
-l logfile
This option specifies a log file location for smbmonitor You can
adopt the option with the option -c cleanlogflag together. The
default of the option is empty, meaning monitoring log messages
would be displayed to standard output.
-i interval
This option specifies an interval of time(seconds) between monitor
executions. The monitor process is suspended during the interval
periods. The option may be used in conjunction with the option -S
schedule. When specified in addition to the option -S schedule,
execution of a check for the specified schedule will occur after
each suspension interval. Only the conjunction of both the interval
execution and the schedule time will trigger the monitor activities
to begin. The default of the option is 0 seconds, meaning no
suspension intervals will occur.
-n notify
This option specifies when to send an auto alert email to
receiver(s). The notify can be:
· check - send auto alert email each checking
· action - send auto alert email if only taking alert actions
· no - not send auto alert email at any time
The default of the option is "no". When using check or action, you
must specify receiver emails by the option -t, or by directly
editing relevant variables in Global Variables section of the
script.
Note: The options -t , -f and -s require mailing system installed
on underlying HPUX system. The utility uses /usr/sbin/sendmail
command on HPUX to send alert emails. If you want to use other
mailing system, you may change relevant variable in Global
Variables section of the script.
-t receiver-emails
This option specifies one or more receiver emails that are used for
sending monitor results and auto alert email. Multiple receiver
emails should be separated by a semicolon ";". The default of the
option is empty.
-f sender-emails
This option specifies one or more sender emails that are used for
sending monitor results and auto alert email. Multiple sender
emails should be separated by a semicolon ";". The default of the
option is root user on local like root@yourhostname.com.
-s subject
This option specifies a text string used as Subject during sending
auto alert email. An valid subject should be several alphabet
digital strings quoted by quotation marks(´´ or ""), or with
underline character(_) or hyphen character(-) combined together.
The default of the option is "Auto Alert Notification from
smbmonitor".
-h|-? or -help
This option displays help message.
VERSION
This man page is for HP CIFS Server based on Samba3.0.
SEE ALSOsmbd(8), nmbd(8), winbindd(8), startsmb(1), stopsmb(1),
startwinbind(1), stopwinbind(1), smbstatus(1), smbmonitor(1)AUTHOR
This is a HP specific utility.
03/25/2009 SMBMONITOR(1)