Installing and Configuring Nagios on Ubuntu


How to install Nagios.

SO today I decided to install and test nagios for testing purposes as its being used to monitor various services in the company I’m working in, surprisingly it was really simple…

I started by simply using the synaptic to locate and mark up nagios and click install, it installs apache but it doesn’t connect them.

then you test to see everything is ok by using

sudo nagios3 -v nagios.cfg

where nagios.cfg can be found in /etc/nagios3

the next step is creating nagios user and user group on the http server using

#htpasswd -c htpasswd.users nagios while in /etc/nagios3

which will create the file htpaswd.users which includes a user name and an encrypted password.

use a browser to log on to http://host_ip/nagios3 and you’ll be prompted for credentials, use the user name and password you just created.

you’ll find your self in the nagios interface but have access to nothing

Part 2: modify the configuration files

these files should be modified to reflect the current nagios configuration…to follow the instructions i started with the timeperiods_nagios2.cfg which can be foudn in conf.d directory which includes the time period definitions i just went through them to learn what each of them is, there are basically work hours/nonwork hours/24X7/and never

contacts_nagios2.cfg contains the contact people to recieve the emails

create group nagcmd if it wasn’t already created
then create user nagios
add users nagios and www-data to nagcmd group

grep nagios /etc/group to make sure they were created

i tried to open the http://host_ip/nagios3 and eventhough it opened and all i wasn’t able to view anything recieving It appears as though you do not have permission to view information for any of the hosts you requested… error

so i had to do something

i’m expecting that it has something to do with the htpasswd part

this took a while to solve but i finally found out that the default user name for nagios is infact nagiosadmin rather than nagios, and my installation somehow was inconsistent while file nagios.cfg had the main user as nagios, the cgi.cfg had the main user ans nagios admin. and of course the htpasswd.users had nagios, the solution was modifying the cgi.cfg to match the rest, simply by searching for and replacing nagios admin.

Part 3
now how to configure nagios to listen to services and check, first of all nagios places all the executable files in /usr/lib/nagios/plugins/ these files are used to check the services. you can of course develop your own, but i didnt try that yet.

now you go to /etc/nagios-plugins/config this contain the config files that calls on these executables, you can configure here.

then another important file is hostname_nagios2.cfg which actually contains the monitored services, you define the thresholds here.

Part 4

another important note, to actually allow modifying nagios from the web interface you need to tweak the
nagios.cfg, firts the command_file variable should point to an empty file named anything (and you have to create it) the commands are kept there till the nagios reads them. and then log_external_commands should be set to 1.

#/etc/init.d/nagios3 restart


I restarted the nagios service and for some reason it didn’t start I checked the log to find out that the service wasn’t able to create the cmd file (the one talked about earlier) I deleted the file and tried to restart again and got the same result, obviously the nagios user didnt have write access to that folder, and after chmoding the folder it worked out perfectly.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s