In this article I will describe the process of setting up a basic Nagios 3 monitoring server using Ubuntu.
For more in-depth topics, please see follow-up articles that I will be posting.
This article requires you to have intermediate knowledge of Ubuntu.
It also assumes that you have a basic install of Ubuntu server 11.04 (other versions might work fine) on a suitable server. I my case this is a VMware Server guest and I have performed a default installation, only adding an openssh server to simplify management. I have also updated it with all the latest patches and installed drivers.
These instructions has been tested on Ubuntu server 11.04 x64.
In my line of work I have two choices, I can sit and wait for angry customers to call me to tell me something isn't working, or I could find out myself and be well on my way to solving it when they call.
For about two and half years now, my firm has chosen to do the former, simply because no one had any good experience with monitoring software or the free time to find out.
I can tell you now that if I had known how easy a Nagios install was two years ago, I would have taken the time to do this. Granted it might have been a lot harder back then.
One of the main problems with installing Nagios is it's near complete lack of documentation and the fact that every single guide has a different way of doing it. I will be the first to say that this one doesn't exactly improve that situation per say, but this article has one major advantage; it rocks!
So lets get started.
Like the prerequisites above explained, I will assume that your Ubuntu installation is already complete and that you have installed any additional tools you prefer, like ssh, a text editor etc. No Nagios-prerequisites are included in this so don't bother about apache, mail servers or anything like that at this point.
You should take a moment to decide how mail will work in your environment. I'm not entirely sure if there are parts of Nagios that can benefit from receiving mail but we will at least have to send out mail. For now I decided to relay all emails to my ISP's smtp server and not to complicate things by setting up a local mail server.
We will use this information in the following instructions
To install Nagios 3 just follow these simple instructions
- Make sure aptitude is up to date by issuing sudo apt-get update
- Install nagios 3 by issuing sudo apt-get install nagios3
- Gape in amazement at how page after page of installation instructions can be condensed into that.
- The setup will ask a series of questions regarding mail configuration. As discussed above I selected Satellite system as the server type.
- Depending on your choice in step 4, the setup will ask some questions about mail domains and such. For this setup I choose so specify [companyname].local for addresses that is missing domain name (I don't intend this to happen so it shouldn't matter, hopefully) and specified my ISP's smtp server as relay host.
- After the mail configuration, the setup will ask for a password for the default user nagiosadmin. We will be disabling this account later on so choose any password for now.
- That is it. Unless you have received any errors everything should be good to go.
[Creating a new user]
Personally, the first thing I want to do is create a new user and get rid of nagiosadmin for security reasons.
To create a new user you have to do a few things.
- Create the user in Nagios. My new user is called jonatan so my command looks like this: sudo htpasswd -c /etc/nagios3/htpasswd.users jonatan
- Specify a password.
- Repeat for additional users BUT WITHOUT "-c", it creates a new file and thus removes any old users.
- Edit /etc/nagios3/cgi.cfg, I use nano so my command looks like this: sudo nano /etc/nagios3/cgi.cfg
- A page or two down you will see a few variables beginning with "authorized", read what each one does and then remove nagiosadmin from each one and add users to your liking, I added my new "jonatan" user to every one except for read only users (which is disabled anyway)
At this point we're ready for a test.
Fire up your favorite web browser and enter the following address and login with your user. In my case the server ip was 192.168.0.56 so I entered http://192.168.0.56/nagios3/
Behold! Possibly the ugliest interface in the history of good software. But it does what it's supposed to do so for now just browse around and have a look at what the default config can do.
Compared to some other guides out there, this one is straighter than an Australian highway. Ubuntu makes this incredibly easy. Unfortunately, this is the easiest part, Nagios' documentation is legendary and Ubuntu's different folder structure makes a lot of it near impossible to figure out.
But that's a later problem.
In some follow-up articles I will show you how to straight out some small errors in the configs, install Nagios V-Shell and add monitored machines.
Feel free to ask any questions or add comments regarding this post in the comments. I'll try and answer best I can, promise.