Skip to content

Instantly share code, notes, and snippets.

@zyphlar
Created March 16, 2012 17:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zyphlar/2051455 to your computer and use it in GitHub Desktop.
Save zyphlar/2051455 to your computer and use it in GitHub Desktop.
Script to add new monitors in Nagios
#!/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
@akhiljalagam
Copy link

akhiljalagam commented Aug 14, 2018

what if same host exists already?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment