Installing Nagios for Monitoring on FreeBSD 8.3

Home / Installing Nagios for Monitoring on FreeBSD 8.3

Installing Nagios for Monitoring on FreeBSD 8.3

December 5, 2015 | Article | No Comments

Nagios, one of the best tool we can find for building monitoring server. Nagios is free, open source, modular, easy to use, and high scalable. Initially, Nagios was designed for Linux Operating System, but later it run on almost any UNIX-like Operating System, including FreeBSD.

In this article we will discuss about how to install and use a simple configuration for Nagios. Of course, from the theme you can imply that I use FreeBSD 8.3.

Installation

Installing Nagios is as easy as installing any FreeBSD ports.

cd /usr/ports/net-mgmt/nagios
make install clean

Make sure you choose NETSNMP on nagios group and user. This allows Nagios to manage network using SNMP (Simple Network Management Protocol).

Autostart on Boot

To run Nagios automatically at boot time, we can edit /etc/rc.conf and add nagios_enable=”YES” at end of line. Another way, we can invoke following command:

echo 'nagios_enable="YES"' >> /etc/rc.conf

Running Simple Configuration

Configuration is simple. In fact, there is no need for us to write configuration from scratch. Nagios has provide a basic configuration and ready to use for generic situation. Using it is as simple as copying the file to Nagios working directory. Here is commands:

cd /usr/local/etc/nagios
cp cgi.cfg-sample cgi.cfg
cp nagios.cfg-sample nagios.cfg
cp resource.cfg-sample resource.cfg

cd /usr/local/etc/nagios/objects
cp commands.cfg-sample commands.cfg
cp contacts.cfg-sample contacts.cfg
cp localhost.cfg-sample localhost.cfg
cp printer.cfg-sample printer.cfg
cp switch.cfg-sample switch.cfg
cp templates.cfg-sample templates.cfg
cp timeperiods.cfg-sample timeperiods.cfg

Now check and make sure there is no error occured:

nagios -v /usr/local/etc/nagios/nagios.cfg

Next we need to make administrator account for accessing Nagios home page. We use default password, which is nagiosadmin

htpasswd -c /usr/local/etc/nagios/htpasswd.users nagiosadmin

Next, we need Apache to identifying Nagios. Therefore, edit httpd.conf using ee /usr/local/etc/apache22/httpd.conf. Add following text:

ScriptAlias /nagios/cgi-bin/ /usr/local/www/nagios/cgi-bin/
Alias /nagios /usr/local/www/nagios/

<Directory /usr/local/www/nagios>
   Options None
   AllowOverride None
   Order allow,deny
   Allow from all
   AuthName "Nagios Access"
   AuthType Basic
   AuthUSerFile /usr/local/etc/nagios/htpasswd.users
   Require valid-user
</Directory>

<Directory /usr/local/www/nagios/cgi-bin>
   Options ExecCGI
   AllowOverride None
   Order allow,deny
   Allow from all
   AuthName "Nagios Access"
   AuthType Basic

   AuthUSerFile /usr/local/etc/nagios/htpasswd.users
   Require valid-user
</Directory>

Now, restart the Apache.

The configurations are stored on /usr/local/etc/nagios/. If we want to use the configuration, we can simply rename or copy the .cfg-sample file to .cfg file.

Before we play around with the files, it’s better for us to backup the directory to something else. For example:

mkdir /home/xathrya/nagios-samples/
cp * /nagios-samples/
mv bigger.cfg-sample bigger.cfg
mv cgi.cfg-sample cgi.cfg
mv checkcommands.cfg-sample checkcommands.cfg
mv localhost.cfg-sample localhost.cfg
mv misccommands.cfg-sample misccommands.cfg
mv nagios.cfg-sample nagios.cfg
mv resource.cfg-sample resource.cfg

Now we have all configuration files we need on /usr/local/etc/nagios.

Next open localhost.cfg file and adjust the setting to our network. This file will instruct Nagios to monitoring localhost or self monitoring.

In this case, we have defined commands to monitor service on localhost, defining contact information of administrator/user for Nagios notify to, etc.

Later we will check whether we have error on Nagios, using:

/usr/local/bin/nagios -v /usr/local/etc/nagios/nagios.cfg

If there is no error, you should get message like this:

.........

.........
Total Warnings: 0
Total Errors: 0
Things look okay - No serious problems were detected during the pre-flight check

Now we start Nagios with following command:

/usr/local/bin/nagios /usr/local/etc/nagios/nagios.cfg &

Now try to open browser and open the Nagios by URL. In my case, my machine has IP address 192.168.3.11 thus I can access nagios using URL http://192.168.3.11/nagios.

And that’s it. You now have Nagios monitoring your network

, ,

About Author

about author

xathrya

A man who is obsessed to low level technology.

Leave a Reply

Your email address will not be published. Required fields are marked *

Social media & sharing icons powered by UltimatelySocial