If you are new to Unixmen, you may want to subscribe : ![]()
![]()
![]()
![]()
|
15 April 2010
Nagios is a popular open source computer system and network monitoring software application. It watches hosts and services, alerting users
when things go wrong and again when they get better.
Nagios was originally designed to run under Linux, but also runs well on other Unix variants. It is free software, licensed under the terms of the GNU General Public License version 2 as published by the Free Software Foundation.
Before to start, if you want to install Nagios in fedora ,RHEL or centos please read our previous tutorial
Â
I- Install Apache, PHP and some needed libraries
First we will install apache , php and needed librairies
- Install some necessary compilers using the command :
sudo apt-get install build-essential
- Install GD Libraries using the command :
sudo apt-get install libgd2-xpm-dev
- Install Apache2
sudo apt-get install apache2
Â
- Install PHP for apache 2 :
sudo apt-get install php5-common php5 libapache2-mod-php5
Now configure Apache to use PHP:
Open apache2.conf file
sudo vi  /etc/apache2/apache2.conf
and add this line
DirectoryIndex index.html index.php index.cgi
Now restart your  apache
sudo /etc/init.d/apache2  restart
II- Install and Configure Nagios :
Now lets install and configure  Nagios
First download the latest core nagios from nagios website and before installing create a user to run the service and a group to run external commands:
* sudo useradd -m nagios
* sudo passwd nagios
* sudo groupadd nagcmd
* sudo usermod -a -G nagcmd nagios
* sudo usermod -a -G nagcmd www-data
Now install the Nagios tarballs that were downloaded previously:
tar -zxvf nagios-3.2.1.tar.gz
Then cd the the extracted folder and install
cd nagios-3.2.1
sudo ./configure --with-command-group=nagcmd
sudo make all
sudo make install
sudo make install-init
sudo make install-config
sudo make install-commandmode
sudo make install-webconf
Â
Add a user for the Nagios interface:
sudo mkdir /usr/local/nagios/etc
Create a new password
sudo htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
Output
New password:
Re-type new password:
pirat9@pirat9-desktop:~/Downloads/nagios-3.2.1$
Now add Nagios directory to apache, first open apache.conf :
sudo vi /etc/apache2/apache.conf
and add these lines :
ScriptAlias /nagios/cgi-bin /usr/local/nagios/sbin
Options ExecCGI
AllowOverride None
Order allow,deny
Allow from all
AuthType Basic
AuthUserFile /usr/local/nagios/etc/htpasswd.users
Require valid-user
Alias /nagios /usr/local/nagios/share
Options None
AllowOverride None
Order allow,deny
Allow from all
AuthType Basic
AuthUserFile /usr/local/nagios/etc/htpasswd.users
Require valid-user
save and exit then restart apache2
sudo /etc/init.d/apache2 restart
Install Nagios Plugins :
- Now we have to install Nagios plugins, first download the file from nagios website, then extract it using the command :
tar -zxvf nagios-plugins-1.4.14.tar.gz
Â
- Cd the extracted folder and install the plugins
cd nagios-plugins-1.4.14
sudo ./configure --with-nagios-user=nagios --with-nagios-group=nagios
sudo make
sudo make install
-
Create a link to start the service:
sudo ln -s /etc/init.d/nagios /etc/rcS.d/S99nagios
Â
ls -altr
Output
total 20
-rw-r--r--  1 root root  447 2009-09-07 20:58 README
lrwxrwxrwx  1 root root   20 2010-04-04 22:10 S70x11-common -> ../init.d/x11-common
lrwxrwxrwx  1 root root   24 2010-04-04 22:10 S70screen-cleanup -> ../init.d/screen-cleanup
lrwxrwxrwx  1 root root   17 2010-04-04 22:10 S55urandom -> ../init.d/urandom
lrwxrwxrwx  1 root root   23 2010-04-04 22:10 S49console-setup -> ../init.d/console-setup
lrwxrwxrwx  1 root root   18 2010-04-04 22:10 S37apparmor -> ../init.d/apparmor
lrwxrwxrwx  1 root root   16 2010-04-04 22:10 S25brltty -> ../init.d/brltty
lrwxrwxrwx  1 root root   21 2010-04-04 22:10 S13pcmciautils -> ../init.d/pcmciautils
lrwxrwxrwx  1 root root   24 2010-04-04 22:10 S06keyboard-setup -> ../init.d/keyboard-setup
drwxr-xr-x 132 root root 12288 2010-04-15 01:45 ..
lrwxrwxrwx  1 root root   18 2010-04-15 02:09 S99nagios -> /etc/init.d/nagios
drwxr-xr-x  2 root root 4096 2010-04-15 02:09 .
Â
Please before running the configuration check and copy all config files from your nagios directory to /usr/local/nagios/etc/objects/ and /usr/local/nagios/etc/
like
config file '/usr/local/nagios/etc/objects/commands.cfg'...
object config file '/usr/local/nagios/etc/objects/contacts.cfg'...
object config file '/usr/local/nagios/etc/objects/timeperiods.cfg'...
object config file '/usr/local/nagios/etc/objects/templates.cfg'...
object config file '/usr/local/nagios/etc/objects/localhost.cfg'...
- Verify the config:
sudo /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
Output :
Nagios Core 3.2.1
Copyright (c) 2009-2010 Nagios Core Development Team and Community Contributors
Copyright (c) 1999-2009 Ethan Galstad
Last Modified: 03-09-2010
License: GPL
Website: http://www.nagios.org
Reading configuration data...
Read main config file okay...
Processing object config file '/usr/local/nagios/etc/objects/commands.cfg'...
Processing object config file '/usr/local/nagios/etc/objects/contacts.cfg'...
Processing object config file '/usr/local/nagios/etc/objects/timeperiods.cfg'...
Processing object config file '/usr/local/nagios/etc/objects/templates.cfg'...
Processing object config file '/usr/local/nagios/etc/objects/localhost.cfg'...
Read object config files okay...
Running pre-flight check on configuration data...
Checking services...
Checked 8 services.
Checking hosts...
Checked 1 hosts.
Checking host groups...
Checked 1 host groups.
Checking service groups...
Checked 0 service groups.
Checking contacts...
Checked 1 contacts.
Checking contact groups...
Checked 1 contact groups.
Checking service escalations...
Checked 0 service escalations.
Checking service dependencies...
Checked 0 service dependencies.
Checking host escalations...
Checked 0 host escalations.
Checking host dependencies...
Checked 0 host dependencies.
Checking commands...
Checked 24 commands.
Checking time periods...
Checked 5 time periods.
Checking for circular paths between hosts...
Checking for circular host and service dependencies...
Checking global event handlers...
Checking obsessive compulsive processor commands...
Checking misc settings...
Total Warnings: 0
Total Errors:Â Â 0
Things look okay - No serious problems were detected during the pre-flight check
pirat9@pirat9-desktop:~/Downloads/nagios-3.2.1$
- Now start Nagios:
sudo /etc/init.d/nagios start
Â
- Now you are ready to use Nagios, open your browser and type :
http://hostname/nagios or http://ip/nagiosÂ



If you have a Tip, tutorial, Idea or anything you want to share with unixmen readers, you can send it to : tips[a]unixmen.com or use our contact form Thanks.
Related Articles By Tags:
Related Articles By Tags:
-
2010-05-01 21:01:34 | Lynn - cant get nagios to start

Hi, I followed this how-to exactly, and I cant get nagios to start. I can get to the web interface, but when I click on anything it gives me an error stating:
Error: Could not read host and service status information!When I checked the nagios logs I see:
[1272750947] Nagios 3.2.1 starting... (PID=28967)
[1272750947] Local time is Sat May 01 17:55:47 EDT 2010
[1272750947] LOG VERSION: 2.0
[1272750947] Finished daemonizing... (New PID=28970)
[1272750947] Caught SIGSEGV, shutting down...
What can I try now to get nagios starting?
-
2010-05-01 21:19:46 | coldsystem

Lynn
what is the output of your
sudo /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
-
2010-05-04 02:31:48 | Corzo - did it work?

Lynn, did you make it work? im having the same problem...
-
2010-05-04 01:26:49 | Pirat9

Please post your problem on the forum with screen shots . and we will solve this together.
Thanks
-
2010-05-05 20:54:12 | Joe - remove

so how would I go about unistalling? Is there a straightforward way to remove nagios?
-
2010-05-07 02:30:16 | taivna - problem.

hi sir. Your advice is best.
but my apache failed.
II- Install and Configure Nagios : last row
Problem: AllowOverride not allowed here
PLS HELP ME!!!
-
2010-05-18 18:05:19 | Fefo - AllowOverride not allowed here

hi. i wrote the same witch is in the document. but it showed the following error:
* Restarting web server apache2 Syntax error on line 240 of /etc/apache2/apache2.conf:
AllowOverride not allowed herewhat can i do?
thx
-
2010-05-07 03:12:35 | taivna - continous

my nagios fine working but apache have problem.
AllowOverride not allowed her
-
2010-05-07 03:22:56 | taivna - Good

Oh sorry it is my fault. I add some changes apache2.conf. it was wrong.
kk sorry Sir.
-
2010-05-10 03:28:45 | tomw - Excellent...do you have a similar one for Nagvis?

Hi, I'd also like to install nagvis to Ubuntu 9.10...do you have or know of a similar step by step guide for this that follows on from installing nagios(as per above)?
-
2010-05-17 16:00:26 | Mad - Thanks, but...

Thanks for your efforts but I had to stop in the middle of getting complete.
You described:
sudo vi /etc/apache2/apache.conf
but there is'nt such a file, did you mean
sudo vi /etc/apache2/apache2.conf?If so, (I used it instead) I got errormessages that AllowOverride None ist not allowed than I restart apache service
Also I got a warning message, that the SriptAlias directive will probably never match because it overlaps an earlier SriptAlias.Any help is appreciated very much an urgendly needed.
Best regards
Mad
-
2010-06-02 06:39:38 | Anonymous - Great Job - Have question though

Hi,
Great job !!! It works very well.
However I got a question about one of your steps that isn't very clear.
Where you wrote:
"Please before running the configuration check and copy all config files from your nagios directory to /usr/local/nagios/etc/objects/ and /usr/local/nagios/etc/"FROM what directory are you talking about?
Because you haven't listed that directory and thus I have no idea which directory you are writing about.Please advise.
Thanks and Cheers!
-
2010-06-03 17:15:22 | pirat9

How to add user is :
sudo htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
orsudo htpasswd -c /usr/local/nagios/etc/htpasswd.users userX
-
2010-06-03 17:16:57 | pirat9

krushna,
check your config,
sudo /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
-
2010-07-02 21:47:17 | rm - the whole thing - cut and paste

Below are all the commands - to cut and paste
to a filenote: Nagios dir has both tar files
note: apache2 conf lines at end of this listRobert
================
sudo apt-get install apache2
sudo apt-get install libapache2-mod-php5
sudo apt-get install build-essential
sudo apt-get install libgd2-xpm-dev
sudo apt-get install php5-common php5 libapache2-mod-php5
sudo apt-get install vim
sudo vim /etc/apache2/apache2.conf
sudo useradd -m nagios
sudo passwd nagios
sudo groupadd nagcmd
sudo usermod -a -G nagcmd
sudo groupadd nagcmd
sudo usermod -a -G nagcmd nagios
sudo usermod -a -G nagcmd www-data
cd Nagios/
ls
tar -xvf nagios-3.2.1.tar.gz
cd nagios-3.2.1
sudo ./configure -with-command-group=nagcmd
sudo make all
sudo make install
sudo make install-init
sudo make install-config
sudo make install-commandmode
sudo make install-webconf
sudo mkdir /usr/local/nagios/etc
sudo htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
sudo /etc/init.d/apache2 restartcd Nagios/
tar -xvf nagios-plugins-1.4.14.tar.gz
cd nagios-plugins-1.4.14
sudo ./configure --withnagios-user=nagios --with-group=nagios
sudo ./configure --with-nagios-user=nagios --with-group=nagios
sudo make
sudo make install
sudo -ln -s /etc/init.d/nagios /etc/rcS.d/S99nagios
sudo ln -s /etc/init.d/nagios /etc/rcS.d/S99nagios
sudo /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
sudo /etc/init.d/nagios start
sudo htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
sudo /etc/init.d...
-
2010-07-02 21:53:09 | rm - the Rest of the commands

Fixed typo "withnagos"
previous post cut off endRobert
=====
cd Nagios/
tar -xvf nagios-plugins-1.4.14.tar.gz
cd nagios-plugins-1.4.14
sudo ./configure --with-nagios-user=nagios --with-group=nagios
sudo make
sudo make install
sudo -ln -s /etc/init.d/nagios /etc/rcS.d/S99nagios
sudo ln -s /etc/init.d/nagios /etc/rcS.d/S99nagios
sudo /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
sudo /etc/init.d/nagios start
sudo htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
sudo /etc/init.d/apache2 restart## ADD the following to the end of /etc/apache2/apache2.conf
# added for nagios
DirectoryIndex index.html index.php index.cgiScriptAlias /nagios/cgi-bin/ "/usr/local/nagios/sbin"
Options ExecCGI
AllowOverride None
Order allow,deny
Allow from all
AuthType Basic
AuthUserFile /usr/local/nagios/etc/htpasswd.users
Require valid-user
Alias /nagios/ "/usr/local/nagios/share"Options None
AllowOverride None
Order allow,deny
Allow from all
AuthType Basic
AuthUserFile /usr/local/nagios/etc/htpasswd.users
Require valid-user
## the end of /etc/apache2/apache2.conf
-
2010-07-02 21:59:32 | rm - one more thing

not all charaters are cut and paste see correction below:
Robert
=====
the apache2.conf
ScriptAlias /nagios/cgi-bin/ "/usr/local/nagios/sbin"
greater-then Directory less-then
options go here
greater-then slash Directory less-then
Alias /nagios/ "/usr/local/nagios/share"
greater-then Directory less-then
options go here
greater-then slash Directory less-then
-
2010-07-07 15:10:21 | Saroj, Ox

Hi there,
I am getting 'Syntax error on line 243 of /etc/apache2/apache2.conf: AllowOverride not allowed here
error message, could someone please let me know what is causing this issue?Many thanks,
Saroj
Ox
-
2010-07-15 21:11:06 | SysAdmin74 - Great instructions!

Thanks for the awesome instructions! It worked perfectly!
-
2010-07-29 13:00:30 | JM - Works great from my desktop

Call me apache deficient but I can't seem to get one thing working. I can't seem to view the system from anywhere outside of the VLAN that the server resides in. I know this has to be a simple solution but I've been all over with no luck.
-
2010-08-20 13:00:21 | Mart - Script Error

The information below is already in /etc/apache2/conf.d/nagios.conf causing the error - "Syntax error on line 243 of /etc/apache2/apache2.conf: AllowOverride not allowed here" I left it in the nagios.conf file and everything appears to be working.
---------# added for nagios
DirectoryIndex index.html index.php index.cgiScriptAlias /nagios/cgi-bin/ "/usr/local/nagios/sbin"
Options ExecCGI
AllowOverride None
Order allow,deny
Allow from all
AuthType Basic
AuthUserFile /usr/local/nagios/etc/htpasswd.users
Require valid-user
Alias /nagios/ "/usr/local/nagios/share"Options None
AllowOverride None
Order allow,deny
Allow from all
AuthType Basic
AuthUserFile /usr/local/nagios/etc/htpasswd.users
Require valid-user
## the end of /etc/apache2/apache2.conf
-------


Hi
When I do "ls -altr" as per instructions I do not get dir listing you do. Can you please calrify what dir I should be in at that point in time?
Thaanks
Rudi