Nagios check_smb_status.sh
我对这个插件有点小问题。在samba服务器计算机上本地运行时,它工作正常: /检查\u smb\u status.sh 但当使用nagios服务器上的NRPE插件运行时,其输出不正确: /检查\u nrpe-H-t 500-c检查\u smb\u状态 以下是check\u smb\u status.sh的来源:Nagios check_smb_status.sh,nagios,Nagios,我对这个插件有点小问题。在samba服务器计算机上本地运行时,它工作正常: /检查\u smb\u status.sh 但当使用nagios服务器上的NRPE插件运行时,其输出不正确: /检查\u nrpe-H-t 500-c检查\u smb\u状态 以下是check\u smb\u status.sh的来源: #!/bin/bash # # Program : check_smb_status # : # Purpose : Nagios plugin to
#!/bin/bash
#
# Program : check_smb_status
# :
# Purpose : Nagios plugin to return the number of user/processes into a smb
# : server, total machines connected and the number of files open.
# :
# Parameters : --help
# : --version
# :
# Returns : Standard Nagios status_* codes as 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 ]; then
print_usage
exit $STATE_UNKNOWN
fi
exitstatus=$STATE_WARNING
while test -n "$1"; do
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
这是因为nagios用户无法访问文件。 您可以这样做:chmod666/var/lib/samba/*.tdb,如果您认为666太邪恶,也可以使用646 当然,您必须记住,这是一种安全风险。
samba强大的功能带来了巨大的责任:请在Nagios配置中发布check\u smb\u status.sh的源代码和check\u smb\u status例程。用户权限?尝试以“nrpe”用户身份在本地运行它。
Total Users/Process:0 Total Machines:0 Total Files:68 |Total Users/Process=0 Total Machines=0 Total Files=67
#!/bin/bash
#
# Program : check_smb_status
# :
# Purpose : Nagios plugin to return the number of user/processes into a smb
# : server, total machines connected and the number of files open.
# :
# Parameters : --help
# : --version
# :
# Returns : Standard Nagios status_* codes as 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 ]; then
print_usage
exit $STATE_UNKNOWN
fi
exitstatus=$STATE_WARNING
while test -n "$1"; do
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