How to install Nagios 4.0.1 (Monitoring Tool) in ubuntu 13.10 server (Saucy Salamander)
Sponsored Link
Some of the many features of Nagios Core include:
Monitoring of network services (SMTP, POP3, HTTP, NNTP, PING, etc.)
Monitoring of host resources (processor load, disk usage, etc.)
Simple plugin design that allows users to easily develop their own service checks
Parallelized service checks
Ability to define network host hierarchy using "parent" hosts, allowing detection of and distinction between hosts that are down and those that are unreachable
Contact notifications when service or host problems occur and get resolved (via email, pager, or user-defined method)
Ability to define event handlers to be run during service or host events for proactive problem resolution
Automatic log file rotation
Support for implementing redundant monitoring hosts
Optional web interface for viewing current network status, notification and problem history, log file, etc.
Preparing your system
We have already discussed how to install ubuntu 13.10 LAMP server and now you need to install the following extra packages
sudo apt-get install wget build-essential php5-gd wget libgd2-xpm libgd2-xpm-dev libapache2-mod-php5 apache2-utils daemon
Now you need to download nagios core and plugins from here
Adding the Nagios User and Group
Next add the appropriate user and group for the Nagios process to run
sudo useradd nagios
sudo groupadd nagcmd
sudo usermod -a -G nagcmd nagios
Now you need to install nagios core installation
You need to login as root and run the following commands
Extract the downloaded files (Nagios core and Plugins)
tar zxvf nagios-4.0.1.tar.gz
tar zxvf nagios-plugins-1.5.tar.gz
Change to the new Nagios directory and install the packages
cd nagios-4.0.1/
./configure --with-nagios-group=nagios --with-command-group=nagcmd -–with-mail=/usr/bin/sendmail
make all
make install
make install-init
make install-config
make install-commandmode
When you run the following command
make install-webconf
You might see the following error
/usr/bin/install -c -m 644 sample-config/httpd.conf /etc/httpd/conf.d/nagios.conf
/usr/bin/install: cannot create regular file â/etc/httpd/conf.d/nagios.confâ: No such file or directory
make: *** [install-webconf] Error 1
As per the error message it's clear that nagios is trying to create the nagios.conf file inside the /etc/httpd.conf file to fix the problem try the following
mkdir /etc/httpd
mkdir /etc/httpd/conf.d
mkdir /etc/httpd/conf.d/nagios.conf
and Finally run the following command
sudo make install-webconf
You should see similar to the following output
/usr/bin/install -c -m 644 sample-config/httpd.conf /etc/httpd/conf.d/nagios.conf
*** Nagios/Apache conf file installed ***
Now following the next steps for nagions installation
cp -R contrib/eventhandlers/ /usr/local/nagios/libexec/
chown -R nagios:nagios /usr/local/nagios/libexec/eventhandlers
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
/etc/init.d/nagios start
When i try to start nagios i got the following error
root@ubuntu:/# /etc/init.d/nagios start
/etc/init.d/nagios: 20: .: Can't open /etc/rc.d/init.d/functions
To fix the above error try the following commands to fix the problem try the following solution
Solution
wget https://raw.github.com/nicolargo/nagiosautoinstall/master/hack4nagiosstart.sh
chmod a+x ./hack4nagiosstart.sh
./hack4nagiosstart.sh
Now your nagios should start without any problem
Create a Default User for Web Access.
Add a default user for Web Interface Access:
htpasswd –c /usr/local/nagios/etc/htpasswd.users nagiosadmin
Nagios Plugin installation
cd nagios-plugins-1.5
./configure --with-nagios-user=nagios --with-nagios-group=nagios
make
make install
Nagios Service Setup
ln -s /etc/init.d/nagios /etc/rcS.d/S99nagios
Login Nagios Web Interface
After correctly following the procedures you should now be able to access your Nagios Core installation from a web browser.
Simply use the following:
http://
And log in with the credentials you chose when adding the nagiosadmin user to the htpasswd.users file
Hi.
I’m having trouble installing in the apache2.
when I type “http://my ip/nagios” appears the login screen, however, presents an error log.
root@NagiOS:/usr/local/etc/nagios-4.0.1# ./configure –with-nagios-group=nagios –with-command-group=nagcmd -–with-mail=/usr/bin/sendmail
configure: error: unrecognized option: `-–with-mail=/usr/bin/sendmail’
Try `./configure –help’ for more information
Followed these instructions to the T. Installed a brand new fresh copy of Ubuntu 13.10 Server and after running “sudo apt-get install wget build-essential php5-gd wget libgd2-xpm libgd2-xpm-dev libapache2-mod-php5 apache2-utils daemon” i get “unable to locate package libgd2-xpm”
Try libgd2-xpm-dev
When trying to run the hack script get the following error message.
nagios@nagios-virtual-machine:~/Downloads/nagios-4.0.2$ sudo ./hack4nagiosstart.sh
Reading package lists… Done
Building dependency tree
Reading state information… Done
daemon is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 13 not upgraded.
sed: -e expression #1, char 73: Invalid content of \{\}
* is not running
/etc/init.d/nagios: 51: /etc/init.d/nagios: /usr/usr/usr/sbin/service: not found
Fresh install of Ubuntu 13.04 and Nagios 4.0.2 Don’t know if theres a difference between 4.0.1 and 4.0.2 or not.
Thanks
Hi Frank.
Did you find a solution to your problem? I’m experiencing the same issue.
Regards
Chris
I`m used
./configure –with-command-group=nagcmd –with-httpd-conf=/etc/apache2/conf-enabled
to avoid “make install-webconf” error on apache2:
/usr/bin/install: cannot create regular file /etc/httpd/conf.d/nagios.conf: No such file or directory
Thanks a ton for the tutorial. I was struggling with the Nagios Start until I found the hack4nagiosstart.sh Worked great and saved me from rewriting the /etc/init.d/nagios. Thanks!!
Hi all,
Thanks for the amazing guide.
I can manage to install nagios successfully as per the guide.
Everything smooth but except that whenever I click on the links in the nagios page, the cgi files are being downloaded.
How can I configure/fix this?
Sorry, I’m newbie to linux
Thanks in advance
Sorry,
I managed to solve it.
Forgot to enable the cgi.
”
sudo a2enmod cgi
sudo service apache2 restart
“
Hi all,
Thanks for the amazing guide.
After following the tutorial, when trying to access the nagios page, it does not load the main page of login.
However, the apache server is running.
No I’ve done wrong.
Thanks in advance.
I have the same problem. Did you find the reason?
Hi,
Could you try the following commands:
cp /etc/httpd/conf.d/nagios.conf/httpd.conf /etc/apache2/conf-available/nagios.conf
ln -s /etc/apache2/conf-available/nagios.conf /etc/apache2/conf-enabled/nagios.conf
Then restart Apache and see if that resolves your issue?
…modified your command slightly to get it running:
cp /etc/httpd/conf.d/nagios.conf /etc/apache2/conf-available/
ln -s /etc/apache2/conf-available/nagios.conf /etc/apache2/conf-enabled/nagios.conf
service apache2 restart
best regards
Very nice! Thank you so much! Installed Nagios 4.0.2 on fresh Ubuntu 13.10 without any Problems!
only one step more after Nagios Service Setup was needed:
Service apache2 restart
I get the following error trying to start nagios
/etc/init.d/nagios: 100: /etc/init.d/nagios: Syntax error: “}” unexpected (expecting “fi”)
I have the same issue when I try to start Nagios:
~$ sudo /etc/init.d/nagios start
/etc/init.d/nagios: 102: /etc/init.d/nagios: Syntax error: “}” unexpected (expecting “fi”)
can you help me?
Thank you so much.
i have the same probleme.
PLZ HELP !!
same error for me
etc/init.d/nagios: Syntax error: “}” unexpected (expecting “fi”)
when i run ./hack4nagiosstart.sh
i have the error
which version of ubuntu you are using
I’ve got same issue after run ./hack4nagiosstart.sh:
etc/init.d/nagios: Syntax error: “}” unexpected (expecting “fi”)
using Ubuntu 13.10 amd64. Nagios 4.0.3.
I’ve got same issue:
etc/init.d/nagios: Syntax error: “}” unexpected (expecting “fi”)
I’m using Ubuntu 13.10 AMD64 Server.
I cannot open website for http://localhost/nagios
“server not found”
I have followed all the above steps..
root@swetha-virtual-machine:/home/swetha/Downloads/nagios-4.0.4# /etc/init.d/nagios start
Starting nagios:No directory, logging in with HOME=/
done.
nagios console is not visible.Got the below error:
The requested URL /nagios/ was not found on this server.
Apache/2.2.22 (Ubuntu) Server at localhost Port 80
was anybody able to figure out the solution to this problem?
Thanks!
this is a problem with both files:
firts execute;
./hack4nagiosstart.sh
when the error print:
etc/init.d/nagios: Syntax error: “}” unexpected (expecting “fi”)
you edit this file /etc/init.d/nagios en line
where apear this: “if [ ] ; then kill -9 ;
fi$daemonpid ”
replace fi$daemonpid to fi ; $daemonpid
next save file and execute
sudo service nagios start
sudo service nagios stop
and not execute again /hack4nagiosstart.sh
this file is corrupted in the end line
next continue the installation in this webpage
Had the same problem (Ubuntu 14.04)
You just need to
sudo ln -s /etc/httpd/conf.d/nagios.conf /etc/apache2/sites-enabled/000-nagios.conf
and
sudo service apache2 restart
It should be available on your http://host/nagios then.
I had the same issue on Ubuntu 14.04.
All i needed to do was:
sudo ln -s /etc/httpd/conf.d/nagios.conf /etc/apache2/sites-enabled/000-nagios.conf
sudo a2enmod cgi
sudo service apache2 restart
Thanks for the help. I was stuck at the “make install -webconf part but you bailed me out. I thank God for your timely help.