Created
March 16, 2012 17:51
-
-
Save zyphlar/2051455 to your computer and use it in GitHub Desktop.
Script to add new monitors in Nagios
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# newpingmonitor.sh | |
# Sets up monitoring for new basic ping monitors in nagios | |
# Ths script may be called remotely | |
E_BADARGS=65 | |
if [ ! -n "$1" ] | |
then | |
echo "Usage: `basename $0` <servername> <ip address>" | |
exit $E_BADARGS | |
fi | |
echo "define host{ | |
use generic-host | |
host_name ${1} | |
alias ${1} | |
address ${2} | |
}" >> /etc/nagios3/conf.d/$1.cfg | |
echo "> Successfully created Nagios monitor." | |
echo "> Restarting Nagios daemon..." | |
service nagios3 restart |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
what if same host exists already?