Code: Select all
[nagios@hostname libexec]$ ./check_nrpe -H [IP] -c checkcounter -a "Counter=\\Process(nscp)\Working Set"
OK: \Process(nscp)\Working Set = 22421504|'\Process(nscp)\Working Setnone'=22421504;0;0
Thanks.
Code: Select all
[nagios@hostname libexec]$ ./check_nrpe -H [IP] -c checkcounter -a "Counter=\\Process(nscp)\Working Set"
OK: \Process(nscp)\Working Set = 22421504|'\Process(nscp)\Working Setnone'=22421504;0;0
Code: Select all
No data available: host=hostname service=Check NSClien db=Code: Select all
#!/bin/bash
############################################################################
# check_win_procs.sh
#
# Description:
# This script check the memory usage by a process on the target server.
#
#############################################################################
# Set path to the location of your Nagios plugin (check_nrpe)
pluginlocation="/usr/local/nagios/libexec"
#############################################################################
# Help
help="check_win_procs.sh \n
Usage: ./check_win_procs.sh -H host -p process [-o output]
\nOptions:\n-H Hostname of Windows server to check
-p Process to monitor
-o Choose output of value in KB, MB (default Byte)"
#############################################################################
# Check for people who need help - aren't we all nice ;-)
if [ "${1}" = "--help" -o "${#}" = "0" ];
then
echo -e "${help}";
exit 1;
fi
#############################################################################
# Some people might forget to set the plugin path (pluginlocation)
if [ ! -x ${pluginlocation}/check_nrpe ]
then
echo "CRITICAL - Plugin check_nrpe not found in ${pluginlocation}"; exit 2
fi
#############################################################################
# Get user-given variables
while getopts "H:p:o:" Input;
do
case ${Input} in
H) host=${OPTARG};;
p) proc=${OPTARG};;
o) output=${OPTARG};;
*) echo "Wrong option given. Please rtfm or launch --help"
exit 1
;;
esac
done
#############################################################################
# Catch error
if [ -z "${host}" ]; then
echo "ERROR: You must specify a host"
exit 3
elif [ -z "${proc}" ]; then
echo "ERROR: You must specify a process"
exit 3
fi
# Output
command=$(${pluginlocation}/check_nrpe -H ${host} -c checkcounter -a "Counter=\Process(${proc})\Working Set")
# In case KB or MB has been set in -o option
if [ -n "${output}" ]; then
if [ "${output}" = "KB" ] || [ "${output}" = "kb" ]; then
bytes=$(echo ${command} | cut -d = -f 3 | cut -d \; -f 1)
return_bytes=$(expr ${bytes} / 1024)
out=$(echo ${command} | sed "s/${bytes}/${return_bytes} KB/" | sed "s/${bytes};/${return_bytes};/")
elif [ "${output}" = "MB" ] || [ "${output}" = "mb" ]; then
bytes=$(echo ${command} | cut -d = -f 3 | cut -d \; -f 1)
return_bytes=$(expr ${bytes} / 1024 / 1024)
out=$(echo ${command} | sed "s/${bytes}/${return_bytes} MB/" | sed "s/${bytes};/${return_bytes};/")
fi
else
bytes=$(echo ${command} | cut -d = -f 3 | cut -d \; -f 1)
out=$(echo ${command} | sed "s/${bytes}/${bytes} Bytes/" | sed "s/${bytes};/${bytes};/")
fi
# Output
echo ${out}
exit 0
Actually, truth be told, it doesn't even look related to the plugin you're munging.xerez wrote:No data available: host=hostname service=Check NSClien db=