Script is at Server:
#!/bin/bash if [ ! $# == 1 ]; then echo "Usage check_cluster " fi; clu_srv=$1 error="stopped" error1="disabled" error2="recoverable" host1=`sudo /usr/sbin/clustat|grep $1| awk {'print $2'}` host2=`sudo /usr/sbin/clustat|grep $1| awk {'print $3'}` service1=`sudo /usr/sbin/clustat|grep $clu_srv| awk {'print $1'}` if [[ "$host2" == "$error" ]] || [[ "$host2" == "$error1" ]]; then echo "CRITICAL - Cluster $clu_srv service failover on $host1 and state is '$host2'" else echo "OK - Cluster $clu_srv service is on $host1 and state is '$host2'" fi; ##--EndScript
It receives thee argument from script correctly. When I running this script manually at Server from command line it returns correct information, for example:
# /usr/local/nagios/libexec/check_rhcs-ERS NFSService OK - Cluster NFSService service is on NODE1 and state is 'started'
But when I tried with the script (check_nrpe) remotely with following command its showing incorrect information:
# ./check_nrpe -H localhost -c check_rhcs-ERS OK - Cluster NFSService service is on and state is ''
nrpe.cfg:
# command[check_rhcs-ERS]=/usr/local/nagios/libexec/check_rhcs-ERS NFSService
What is Wrong with the script, How to fix it?