Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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

This comment has been minimized.

Copy link

@AkhilJalagam 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