Building a Linux Monitoring Infrastructure II
Based on Nagios 3.0
[Continued from Building a Monitoring Infrastructure I]
Install binaries, init script, sample config files and set permissions on the external command directory.
root@Nagios:~/Downloads/nagios-3.0.5#make install
root@Nagios:~/Downloads/nagios-3.0.5#make install-init
root@Nagios:~/Downloads/nagios-3.0.5#make install-config
root@Nagios:~/Downloads/nagios-3.0.5#make install-commandmode
4. Customize Configuration
Edit the /usr/local/nagios/etc/objects/contacts.cfg config file with your favorite editor and change the email address associated with the nagiosadmin contact definition to the address you’d like to use for receiving alerts.
root@Nagios:~#emacs /usr/local/nagios/etc/objects/contacts.cfg
By the way, emacs is like notepad in Windows and there are other ones that you can use instead. It depends on your expertise on using them. Other such applications include vim, nano, joe, pico etc
5. Configure the Web Interface
Install the Nagios web config file in the Apache conf.d directory.
root@Nagios:~/Downloads/nagios-3.0.5# make install-webconf
Create a nagiosadmin account for logging into the Nagios web interface.
root@Nagios:~/Downloads/nagios-3.0.5#make htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
Restart Apache to make the new settings take effect.
root@Nagios:~/Downloads/nagios-3.0.5# /etc/init.d/apache2 reload
6. Compile and Install the Nagios Plugins
Extract the Nagios plugins source code tarball.
root@Nagios:~#cd Downloads
root@Nagios:~#tar xzf nagios-plugins-1.4.11.tar.gz
root@Nagios:~#cd nagios-plugins-1.4.11
Compile and install the plugins.
root@Nagios:~/Downloads/nagios-plugins-1.4.11#./configure —with-nagios-user=nagios —with-nagios-group=nagios
root@Nagios:~/Downloads/nagios-plugins-1.4.11#make
root@Nagios:~/Downloads/nagios-plugins-1.4.11#make install
7. Start Nagios
Configure Nagios to automatically start when the system boots.
root@Nagios:~/Downloads# ln -s /etc/init.d/nagios /etc/rcS.d/S99nagios
Verify the sample Nagios configuration files.
root@Nagios:~# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
If there are no errors, start Nagios.
root@Nagios:~#/etc/init.d/nagios start
8. Login to the Web Interface
You should now be able to access the Nagios web interface at the URL below.
http://localhost/nagios/
NOTIFICATIONS
If you want to receive email notifications for Nagios alerts, you need to install the mailx (Postfix) package.
Any other Mail Transfer Agent (MTA) can be used to send email notifications. Postfix was used here because it’s much easier to configure for use.
aayoola@Nagios:~$ sudo apt-get install mailx
You’ll have to edit the Nagios email notification commands found in /usr/local/nagios/etc/objects/commands.cfg and change any ‘/bin/mail’ references to ‘/usr/bin/mailx’. Once you do that you’ll need to restart Nagios to make the configuration changes live.
aayoola@Nagios:~$ sudo /etc/init.d/nagios restart
INSTALL & CONFIGURE POSTFIX
To install postfix, run the following command:
aayoola@Nagios:~$ sudo apt-get install postfix
To configure postfix, run the following command:
aayoola@Nagios:~$ sudo dpkg-reconfigure postfix
The file /etc/postfix/main.cf should look like this
myhostname = Nagios.Linuxlab.comalias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = /etc/mailname
mydestination = Nagios.Linuxlab.com, localhost.Linuxlab.com, localhostrelayhost = miranda.dc.turkuamk.fi
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all
inet_protocols = ipv4
The relay host was what I changed as the host miranda.dc.turkuamk.fi is a relay server within a known network and so you might want to set up one for yourself in order for that notification gets into your inbox.
Now the postfix initial configuration is complete. Run the following command to start postfix daemon:
aayoola@Nagios:~$ sudo /etc/init.d/postfix start
Object Configuration Overview
Objects are all the elements that are involved in the monitoring and notification logic and can be found in /usr/local/nagios/etc/objects.
Types of objects include:
Services
Service Groups
Hosts
Host Groups
Contacts
Contact Groups
Commands
Time Periods
Notification Escalations
Notification and Execution Dependencies
Main Configuration File
At installation a sample main configuration file /usr/local/nagios/etc/nagios.cfg is installed. The main configuration file is usually named nagios.cfg and located in the /usr/local/nagios/etc/ directory.
Subscribe to my newsletter
Read articles from Abayomi AYOOLA directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by