* http://www.nagios.org
* http://www.nconf.org
MySQL (with InnoDB support) and Apache2 webserver with php5 is needed:
apt-get -y install apache2 mysql-server libapache2-mod-php5 php5-common php5-mysql php5-gd php5-curl php5-cli php-pear php5-xdebug php5-svn php5-mcrypt php5-auth-pam php5-geoip
After installing apache2, php5 and mysql-server you will find the associated configuration files under:
*/etc/apache2
*/etc/mysql
*/etc/php5
By default the apache webroot is /var/www
apt-get -y install nagios3 nagios-plugins
* After installing, the default Nagios configuration is populated under /etc/nagios3
* The plugin directory by default is found under /etc/nagios-plugins
In order to enable the Nagios WebGUI, the apache config file /etc/nagios3/apache2.conf has to be included in the apache2-configuration. To do so, just add the following line to your apache config file located in your apache2 config directory (/etc/apache2/apache2.conf) by typing:
echo "Include /etc/nagios3/apache2.conf" >> apache2.conf
Then apply the configuration change to apache by typing:
/etc/init.d/apache2 reload
You should now be able to access your Nagios installation WebGUI under
http(s)://yourserver'/nagios3/'
By default, in Nagios3, external commands are disabled. In order to enable external commands, set check_external_commands=1 in /etc/nagios3/nagios.cfg and type to your shell:
/etc/init.d/nagios3 stop
dpkg-statoverride --update --add nagios www-data 2710 /var/lib/nagios3/rw
dpkg-statoverride --update --add nagios nagios 751 /var/lib/nagios3
/etc/init.d/nagios3 start
Stop nagios
/etc/init.d/nagios3 stop
Install the add-on with apt-get:
apt-get install ndoutils-nagios3-mysql
[you might want to have a look to /usr/share/doc/ndoutils-nagios3-mysql/README.Debian]
edit the file /etc/default/ndoutils and set
ENABLE_NDOUTILS='1'
next, edit /etc/nagios3/nagios.cfg find and and set
broker_module=/usr/lib/ndoutils/ndomod-mysql-3x.o config_file=/etc/nagios3/ndomod.cfg
Start nagio
/etc/init.d/nagios3 start
Download the latest stable release of Nconf from http://sourceforge.net/projects/nconf/files/ to your nagaios3 webroot directory (e.g. /usr/share/nagios3/htdocs)
cd /usr/share/nagios3/htdocs
wget http://sourceforge.net/projects/nconf/files/nconf/1.2.6-0/nconf-1.2.6-0.tgz/download
tar xfz nconf-'x.x.x-x'.tgz
A new directory nconf/ will be created.
Some subdirectories of /usr/share/nagios3/htdocs/nconf/ have to be writeable to our webserver user (e.g. user www-data):
cd /usr/share/nagios3/htdocs/nconf/
chown www-data config
chown www-data output
chown www-data static_cfg
chown www-data temp
Open the nagios3 apache config file /etc/ngaios3/apache2.conf using a editor and look for a container starting with
Inside this Container look for
DirectoryIndex index.html
and append index.php to the directive that it looks like "DirectoryIndex index.html index.php"
At last but not least, create a MySQL database and a mysql user with the privileges:
SELECT, INSERT, UPDATE, DELETE, CREATE, ALTER, DROP
Now, try to access the Nconf interactive installation by typing:
http(s)://yourserver/nconf/
And follow the setup wizard entering the required forms. Use /usr/sbin/nagios3 (output of shell command type nagios3) for nagios binary.
After the wizard is complete, you have to remove the installation files before Nconf will start to work:
cd /usr/share/nagios3/htdocs/nconf/
rm -rf INSTALL INSTALL.php UPDATE UPDATE.php
'Optionally but nice: Install the OS logos and icons to ./img/logos/base/
* Download icons from: http://www.monitoringexchange.org/p/47
If you need authentication, configure ./conf/authentication.php appropriately.
After generating a Nagios-Configuration using Nconf, the all generated nagios configs are stored as a compressed tar-file under /usr/share/nagios3/htdocs/nconf/output/NagiosConfig.tgz.
Copy this file to your nagios config directory (e.g. /etc/nagios3/conf.d/) and compress it:
You may use this silly script:
----
#!/bin/bash
mv /etc/nagios3/conf.d/* /etc/nagios3/conf.BACKUP/
mv /usr/share/nagios3/htdocs/nconf/output/NagiosConfig.tgz /etc/nagios3/conf.d/
cd /etc/nagios3/conf.d/
tar xvfz NagiosConfig.tgz && rm NagiosConfig.tgz
/etc/init.d/nagios3 reload
#EoF
----
Or you may prefer to use a more improved version to run as system service, polling every 10 seconds for a new generated Nconf config output file:
----
#!/bin/bash
#
# Config:
CONFDIR=/etc/nagios3/conf.d/nconf
CONFBAK=/etc/nagios3/nconf-backup
NCONFPA=/usr/share/nagios3/htdocs/nconf/output
NCONFCF=NagiosConfig.tgz
NGSCRPT=/etc/init.d/nagios3
NGSCARG=reload
WAITPOL=10
###
echo "---"
date
echo "Now lurking for freshly generated nagios config NagiosConfig.tgz from Nconf in $NCONFPA..."
while true; do
if [ -e $NCONFPA/$NCONFCF ]; then
echo "---"
date
echo "Config found!"
if [ -d $CONFBAK/nconf ]; then
echo "Archieving old Nconf backups...."
cd $CONFBAK
tar cfj nconf-`date +%Y-%m-%d_%H-%M-%S`.tar.bz2 nconf
rm -rf nconf
fi
if [ -d $CONFDIR ]; then
echo "Backing up current config files to $CONFBAK ..."
mv $CONFDIR $CONFBAK/
mkdir $CONFDIR/
fi
echo "Copying the new config tar file into $CONFDIR/ ..."
mv $NCONFPA/$NCONFCF $CONFDIR/
echo "Extracting new the config files from $NCONFCF ..."
cd $CONFDIR/
tar xfz $NCONFCF && rm $NCONFCF
echo "Applying new nagios config ($NGSCRPT $NGSCARG)..."
$NGSCRPT $NGSCARG
echo "done."
else
# wait for next loop
sleep $WAITPOL
fi
done
#EoF
This one can be started at system start, just add a line like this to the /etc/rc.local/ (make shure the file is executable):
(sleep 10 && /bin/bash /root/scripts/nconfConfigDeploy.sh > /var/log/nconfConfigDeploy.log 2>&1)
The sleep 10 in this line ensures that the system is ready before the script will be executed time (ubuntu upstart workaround). You may adjust this delay.
----
Problem: The fist time you deploy a Nconf generated config set you may have to tune with existing .cfg files under /etc/nagios3/ and /etc/nagios-plugins/. Some keys may be defined twice, which will occur an error when reloading the nagios config over init.d script:
----
root@host:/etc/init.d/nagios3 start
* Starting nagios3 monitoring daemon nagios3
Nagios 3.0.6
Copyright (c) 1999-2008 Ethan Galstad (http://www.nagios.org)
Last Modified: 12-01-2008
License: GPL
Reading configuration data...
Warning: Duplicate definition found for command 'process-host-perfdata' (config file '/etc/nagios3/conf.d/global/misccommands.cfg', starting on line 16)
Error: Could not add object property in file '/etc/nagios3/conf.d/global/misccommands.cfg' on line 17.
***> One or more problems was encountered while processing the config files...
Check your configuration file(s) to ensure that they contain valid
directives and data defintions. If you are upgrading from a previous
version of Nagios, you should be aware that some variables/definitions
may have been removed or modified in this version. Make sure to read
the HTML documentation regarding the config files, as well as the
'Whats New' section to find out what has changed.
* errors in config! [fail]
----
Solution: You should purge all existing commands by moving/deleting the distribution defaults:
/etc/nagios-plugins/*.cfg
/ets/nagios3/*.cfg
| nconfConfigDeploy.sh | nconf automatic nagios config deployment script | 12.02.2012 20:49 | 1,34 kB |
| Attribute(s): | Public | |||
| Created: | 12.02.2012 20:44 | Total Views: | 578 | |
| Last Changed: | 05.04.2013 13:03 | Total Changes: | 3 |
Δt = 0.056869983673096s