Home » Nagios administration with nagiosadmin

Nagios administration with nagiosadmin

1.Preparations

First of all we have to install some packages:

apt-get install apache2-mpm-prefork build-essential wget libgd2-xpm-dev openssl libssl-dev unzip make perl gcc php5-cli php5-gd libapache2-mod-php5 mysql-server-5.0 libmysqlclient15off libdbd-mysql-perl php5-mysql php5-common php5-cli php5-gd traceroute libglib2.0-dev sudo

Then add new user and group called nagios:

userdel -f nagios useradd -c "Nagios Admin" nagios groupadd nagios usermod -G nagios nagios usermod -G nagios www-data usermod -a -G nagios www-data

2.Nagios installation

Use the script below to download, configure and compile nagios source code:

#!/bin/bash download="/tmp/download" if [ -d $download ]; then echo "dir exists.........." else echo "creating dir........" mkdir -p $download fi cd $download if [ -e $download/nagios-3.1.2.tar.gz ]; then echo "file exists........." else echo "downloading file..." wget http://dfn.dl.sourceforge.net/sourceforge/nagios/nagios-3.1.2.tar.gz fi tar xvzf nagios-3.1.2.tar.gz cd nagios-3.1.2 ./configure --with-httpd-conf=/etc/apache2/sites-available --with-nagios-user=nagios --with-command-group=nagios make all make install make install-init make install-commandmode make install-config make install-webconf rm -rf $download

For nagios and nagiosadmin web interface create access password:

htpasswd -cm /usr/local/nagios/etc/htpasswd.users nagiosadmin
Change file owner to www-data and set up rights to 600:
chown www-data /usr/local/nagios/etc/htpasswd.users chmod 600 /usr/local/nagios/etc/htpasswd.users

3.Nagios plugins installation

Next step is to download, configure and install nagios plugins. I recommend below script:

#!/bin/bash download="/tmp/download" if [ -d $download ]; then echo "dir exists.........." else echo "creating dir........" mkdir -p $download fi cd $download if [ -e $download/nagios-plugins-1.4.13.tar.gz ]; then echo "file exists........." else echo "downloading file..." wget http://dfn.dl.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.13.tar.gz fi tar xzf $download/nagios-plugins-1.4.13.tar.gz -C $download cd $download/nagios-plugins-1.4.13 ./configure --enable-perl-modules make make install chown nagios.nagios /usr/local/nagios chown -R nagios.nagios /usr/local/nagios/libexec rm -rf $download

4.Styles: Default, Nuvola and Vautuor

In my opinion default nagios style is awful.
Two styles are worth mentioning: Nuvola Style and Vautour Style. Sample screenshots of this styles are shown below:

Default style
Nuvola style
Vautour style

5.NagiosAdmin

If you haven't enabled php5 or rewrite modules for apache2, let's do it now:

a2enmod php5 && a2enmod rewrite && /etc/init.d/apache2 force-reload
Download latest stable version of NagiosAdmin application. I also recommend to use below script:
#!/bin/bash download="/tmp/download" if [ -d $download ]; then echo "dir exists.........." else echo "creating dir........" mkdir -p $download fi cd $download if [ -e $download/nagiosadmin-0.9.2.tar.bz2 ]; then echo "file exists........." else echo "downloading file..." wget --no-check-certificate https://projects.secure-net-concepts.de/attachments/download/1/nagiosadmin-0.9.2.tar.bz2 fi if [ -d /var/www/nagiosadmin ] || [ -d /var/www/nagiosadmin-0.9.2 ]; then echo "removing /var/wwww/nagiosadmin" rm -rf /var/www/nagiosadmin /var/www/nagiosadmin-0.9.2 fi tar xjpvf nagiosadmin-0.9.2.tar.bz2 -C /var/www/ mv /var/www/nagiosadmin-0.9.2 /var/www/nagiosadmin
Create user with proper rights and database:
mysql -u root mysql> CREATE DATABASE nagiosadmin; mysql> GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,ALTER,INDEX,DROP ON nagiosadmin.* TO 'nagiosadmin'@'localhost' IDENTIFIED BY 'somepassword'; mysql>FLUSH PRIVILEGES;

Two files have to be edited with database credentials:

Check /var/www/nagiosadmin/apps/backend/modules/generator/config/module.yml file to make sure that you have correct below listed lines:

config_check_command: /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg 2>&1 reload_nagios_command: /usr/bin/sudo /usr/bin/killall -HUP nagios
Add line to /etc/sudoers file:
%nagios ALL= NOPASSWD: /usr/bin/killall -HUP nagios
Run commands to prepare Nagios Administrator to work:
cd /var/www/nagiosadmin ./symfony fix-perms ./symfony propel-insert-sql ./symfony propel-load-data backend ./symfony check

Edit /usr/local/nagios/etc/nagios.cfg and comment out all lines with config files without cfg_file=/usr/local/nagios/etc/objects/timeperiods.cfg and add new line cfg_dir=/var/www/nagiosadmin/data/nagios. The file should look like this:

#cfg_file=/usr/local/nagios/etc/objects/commands.cfg #cfg_file=/usr/local/nagios/etc/objects/contacts.cfg cfg_file=/usr/local/nagios/etc/objects/timeperiods.cfg #cfg_file=/usr/local/nagios/etc/objects/templates.cfg # Definitions for monitoring the local (Linux) host #cfg_file=/usr/local/nagios/etc/objects/localhost.cfg #cfg_dir=/usr/local/nagios/etc/servers #cfg_dir=/usr/local/nagios/etc/printers #cfg_dir=/usr/local/nagios/etc/switches #cfg_dir=/usr/local/nagios/etc/routers cfg_dir=/var/www/nagiosadmin/data/nagios

Before we use Nagios Administrator, we have to configure apache virtual host. So we need to edit /etc/apache2/sites-available/nagios.conf:

<VirtualHost your_server_ip_address:80> ServerAdmin root@localhost ServerName nagiosadmin.example.com DocumentRoot "/var/www/nagiosadmin/web" php_admin_flag magic_quotes_gpc 0 php_admin_value memory_limit "32M" <Directory "/var/www/nagiosadmin/web"> AllowOverride All Order allow,deny Allow from all </Directory> <Files index.php> AuthType Basic AuthName "NagiosAdmin" AuthUserFile /usr/local/nagios/etc/htpasswd.users require user nagiosadmin </Files> ScriptAlias /nagios/cgi-bin "/usr/local/nagios/sbin" Alias /nagios/images/logos/nagiosimages /var/www/nagiosadmin/web/uploads/os_images <Directory "/usr/local/nagios/sbin"> Options ExecCGI AllowOverride None Order allow,deny Allow from all AuthName "Nagios Access" AuthType Basic AuthUserFile /usr/local/nagios/etc/htpasswd.users Require valid-user </Directory> Alias /nagios "/usr/local/nagios/share" <Directory "/usr/local/nagios/share"> Options None AllowOverride None Order allow,deny Allow from all AuthName "Nagios Access" AuthType Basic AuthUserFile /usr/local/nagios/etc/htpasswd.users Require valid-user </Directory> ErrorLog /var/log/apache2/nagiosadmin.error.log LogLevel warn CustomLog /var/log/apache2/nagiosadmin.access.log combined </VirtualHost>

This virtual host has to be enabled with apache utility: a2ensite nagios.conf.
Don't forget to check apache configuration with command apache2ctl -t.
If everything is fine we need to restart apache: /etc/init.d/apache2 restart

6.Running nagios with nagiosadmin

Default Nagios Administrator interface language is german, so if you want to change that behaviour find out /var/www/nagiosadmin/apps/backend/config/i18n.yml file and change line including default_culture: from de to en.
Now we can use web browser to access our nagiosadmin application(http://nagiosadmin.example.com configured on apache) and fill up some forms especially:

Click on Generator tab and save button to reload nagios with new configuration. You should have on your screen info: Nagios reloaded successfully.

Nagios can be accessed using http://nagiosadmin.example.com/nagios address
One last think is to add nagios to startup scripts

update-rc.d nagios defaults
That's all.





Write a comment

  • Required fields are marked with *

If you have trouble reading the code, click on the code itself to generate a new random code.