I'm Zen from the other topics

I made a small script to automaticly deploy the generated confs from NConf and thought until this will be done from the interface you guys could use it. So here it is:
Code: Select all
#!/bin/bash
CFOLDER=/var/www/html/nconf/output/ # Generated config folder
CFILE=NagiosConfig.tgz # Generated config name
NACONFDIR=/etc/nagios # Actual Nagios config dir
NACONFMAINFILE=/etc/nagios/nagios.cfg # Nagios Main Config File
if [ -e ${CFOLDER}${CFILE} ] ; then
tar --overwrite -xzvf ${CFOLDER}${CFILE} -C $NACONFDIR
NABIN=`which nagios`
ERRORS=`$NABIN -v $NACONFMAINFILE | grep "Total Errors:" | cut -d: -f2 | sed -e"s/ //g"`
if [ "$ERRORS" == "0" ] ; then
/etc/init.d/nagios restart
mv ${CFOLDER}${CFILE} ${CFOLDER}${CFILE}.`date +'%Y%m%d'`
else echo Errors
fi
fi
do a chmod +x filename on the file
then run crontab -e
and add a silimar line:
*/5 * * * * /path/to/filename
Now every 5 minutes the script will look for new generated configs and put the into nagios. Then checks if there are errors and if there aren't it restarts nagios.
Hope this will help some of you and hope it's ok that I post it here
