z

Commercial Support Clients: Clients with support contracts can get escalated support assistance by visiting Nagios Answer Hub. These forums are for community support services. Although we at Nagios try our best to help out on the forums here, we always give priority support to our support clients.

Nagios check_smb_status.sh

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.

Nagios check_smb_status.sh

Postby ClaudeSj456 » Mon Aug 29, 2022 6:03 am

I am having a little issue here with this plugin. When run locally on the samba server machine it 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 with NRPE plugin from the nagios server it's output is 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 is the source of check_smb_status.sh:

#!/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 omegle shagle voojio $SMBSTATUS_L

exit $STATE_OK
Last edited by ClaudeSj456 on Mon Oct 31, 2022 2:17 am, edited 1 time in total.
ClaudeSj456
 
Posts: 12
Joined: Sun Feb 13, 2022 6:06 am

Re: Nagios check_smb_status.sh

Postby CarlosCarrancom » Wed Aug 31, 2022 2:25 am

The program smbstatus need to be executed by root.

Add to the /etc/sudoers.d/nrpe:

user_running_nrpe ALL = (root) NOPASSWD: /plugins_path/check_smb_status.sh
And in the nrpe.cfg:

command[check_smb_status.sh]=/usr/bin/sudo /plugins_path/check_smb_status.sh
If you have selinux activated omegle.2yu.co check the context of the file /plugins_path/check_smb_status.sh.

Also there is a problem with the omeglz echat script, when "samba" is stopped, the script return it is ok so add the line below before exit $STATE_OK:

echo | /usr/bin/smbclient -L localhost >/dev/null 2>&1 || exit $STATE_CRITICAL
CarlosCarrancom
 
Posts: 7
Joined: Thu May 05, 2022 7:02 am


Return to Open Source Nagios Projects

Who is online

Users browsing this forum: No registered users and 21 guests