Nagios check_smb_status.sh -
i having little issue here plugin. when run locally on samba server machine works fine:
./check_smb_status.sh
total users/process:21 total machines:16 total files:67 |total users/process=21 total machines=16 total files=67
but when run nrpe plugin nagios server it's output not correct:
./check_nrpe -h -t 500 -c check_smb_status
total users/process:0 total machines:0 total files:68 |total users/process=0 total machines=0 total files=67
here source of check_smb_status.sh:
#!/bin/bash # # program : check_smb_status # : # purpose : nagios plugin return number of user/processes smb # : server, total machines connected , number of files open. # : # parameters : --help # : --version # : # returns : standard nagios status_* codes defined in utils.sh # : # notes : #============:============================================================== # 1.0 : may/08/2011 # progpath=`/bin/echo $0 | /bin/sed -e 's,[\\/][^\\/][^\\/]*$,,'` revision=`/bin/echo '$revision: 1.0 $' | /bin/sed -e 's/[^0-9.]//g'` smbstatus_p="/tmp/smbstatus_p" smbstatus_l="/tmp/smbstatus_l" /usr/bin/smbstatus -p > $smbstatus_p 2> /dev/null /usr/bin/smbstatus -l > $smbstatus_l 2> /dev/null . $progpath/utils.sh print_usage() { /bin/echo "usage: $progname --help" /bin/echo "usage: $progname --version" } print_help() { print_revision $progname $revision /bin/echo "" print_usage /bin/echo "" /bin/echo "samba status check." /bin/echo "" support } if [ $# -gt 1 ]; print_usage exit $state_unknown fi exitstatus=$state_warning while test -n "$1"; case "$1" in --help) print_help exit $state_ok ;; -h) print_help exit $state_ok ;; --version) print_revision $progname $revision exit $state_ok ;; -v) print_revision $progname $revision exit $state_ok ;; *) echo "unknown argument: $1" print_usage exit $state_unknown ;; esac shift done total_usersprocess=$(/bin/egrep "^([0-9]| +[0-9])" $smbstatus_p | wc -l) total_files=$(/bin/egrep "^([0-9]| +[0-9])" $smbstatus_l | wc -l) total_machines=$(/bin/egrep "^([0-9]| +[0-9])" $smbstatus_p | awk '{print $5}' | sort -u | wc -l) /bin/echo "total users/process:$total_usersprocess total machines:$total_machines total files:$total_files |total users/process=$total_usersprocess total machines=$total_machines total files=$total_files" /bin/rm -f $smbstatus_p $smbstatus_l exit $state_ok
it's because nagios user cannot access files. can : chmod 666 /var/lib/samba/*.tdb , or 646 if think 666 devilish. of course, must keep in mind, security risk. , great samba power, comes great responsability :)
Comments
Post a Comment