#########################################################################
cat /etc/init.d/nrped
#!/bin/sh
nrpe_num=`ps aux | grep /bin/nrpe | grep -v grep | wc -l`
case $1 in
start)
if [ $nrpe_num -eq 1 ]
then
echo "Error:nrpe is running."
else
/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d
echo "nrpe started successfully."
fi
;;
stop)
if [ $nrpe_num -eq 1 ]
then
nrpe_pid=`ps aux | grep /bin/nrpe | grep -v grep | awk '{print $2}'`
kill -9 $nrpe_pid
echo "nrpe stoped successfully."
else
echo "Error:nrpe is stoping."
fi
;;
restart)
if [ $nrpe_num -eq 1 ]
then
nrpe_pid=`ps aux | grep /bin/nrpe | grep -v grep | awk '{print $2}'`
kill -9 $nrpe_pid
echo "nrpe stoped successfully."
/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d
echo "nrpe started successfully."
else
echo "Error:nrpe is stoping"
/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d
echo "nrpe started successfully."
fi
esac
########################################################################
阅读(2672) | 评论(0) | 转发(1) |