How to install and configure Nagios in Ubuntu 9.04
Posted: July 13, 2009 at 2:31 pm | Tags: alerts, configure, Linux, nagios, UbuntuNagios is a good open source tool for monitoring network components and services. It can be configured to send alerts by e-mail
Given that the new version (3) can be found in repositories, installation is much easier now, using apt-get:
sudo apt-get install nagios3
Checking the installation:
sudo nagios3 -v nagios.cfg
This is how the testing should look like:
Nagios 3.0.6
Copyright (c) 1999-2008 Ethan Galstad (http://www.nagios.org)
Last Modified: 12-01-2008
License: GPL
Reading configuration data…
Running pre-flight check on configuration data…
Checking services…
Checked 7 services.
Checking hosts…
Checked 2 hosts.
Checking host groups…
Checked 5 host groups.
Checking service groups…
Checked 0 service groups.
Checking contacts…
Checked 2 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 150 commands.
Checking time periods…
Checked 4 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
Everything should be ok. Errors that may occur are in most cases because of permissions.
Now we have to add the user for nagios (before that, you have to get to /etc/nagios3) :
cd /etc/nagios3
sudo htpasswd -c htpasswd.users nagios
Must enter the password twice for the new user:
New password:
Re-type new password:
Adding password for user nagios
At this point, Nagios can be accessed by Web interface:.
http://localhost/nagios3/
or, http://IP/nagios3/
Now you can configure Nagios. Configuration file resides in / etc/nagios3/nagios.cfg. The rest of the files which allow various configurations are found in conf.d. In contacts_nagios2.cfg file you can set the email account where the alerts will be sent to:
gedit contacts_nagios2.cfg
define contact{
contact_name alex
alias Admin Nagios
service_notification_period 24×7
host_notification_period 24×7
service_notification_options w,u,c,r
host_notification_options d,r
service_notification_commands notify-service-by-email
host_notification_commands notify-host-by-email
email alex@domain.com
}
E-mails will be sent to alex@domain.com.
Each contact must be added to contactgroup:
define contactgroup{
contactgroup_name admins
alias Nagios Administrators
members alex
}
Adding the new user to nagios group:
useradd -m -G nagios alex
passwd alex
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
In the web interface you may receive the following message:
It appears as though you do not have permission to view information for any of the services you requested…
In this case you have to edit cgi.cfg:
sudo gedit cgi.cfg
In this file change these lines:
authorized_for_system_information=nagios
authorized_for_configuration_information=nagios
authorized_for_system_commands=nagios
authorized_for_all_services=nagios
authorized_for_all_hosts=nagios
authorized_for_all_service_commands=nagios
authorized_for_all_host_commands=nagios
,where “nagios” is the user that has installed nagios.
If you used this tutorial or have any questions, feel free to leave a comment below. You can also rate this tutorial to let me know how I’m doing. Thanks!




























The Discussion
see what everyone is saying
[...] folosirea acestui addon, evident e nevoie ca nagios sa fie instalat. No [...]
Foarte bun tutorialul. Sunt o gramada de tutoriale pentru instalarea nagios pe net, insa cu tutorialul tau am reusit sa pun si eu pe picioare nagios.
Thanks!
@Adrian: Ma bucur ca te-a ajutat. In limita timpului disponibil incerc sa postez mai multe tutoriale despre diverse.
mee too
sincer ma cam indoiam ca va merge ceva.dar… spre uimirea mea .. tutorialul este unu foarte bine explicat si ptr necunoscatori…
eu sunt unul dintre ei si tin sa iti multumesc.
daca se poate sa vii cu un pic de ajutor si in sensul mysql referitor la setari si administrare eventual cum sa “lucrezi” cu el din broswer + ceva php admin ar fi deja tot ce se poate spune despre webhosting.
inca o data mii de multumiri
@B.F.C.
Ma bucur ca te-a ajutat tutorialul – sa stii ca toate tutorialele/ metodele prezentate aici sunt testate, deci nu prea au cum sa nu mearga.
Sigur ca as vrea sa pun mult mai multe tutoriale, eventual sa mai completez cate ceva pentru cele existente, insa am destul de putin timp pentru a ma ocupa de asta.
Nu inteleg la ce te referi cand spui “ajutor in sensul mysql si php admin” – un ghid de instalare pentru acestea?
Multam de comentariu si te mai astept pe aici.
Seems to be a clean tutorial. I’ll give it a try!
@Armance: Please try it and let me know if you encounter any problems.
thank you very much.. this article really helps me a lot..
Would be nice to know where the check_command definitions for all the plugins reside. Ubuntu’s commands.cfg doesn’t include check_http, so it’s not apparent what can be used as check_http!foo
Hi,
I want to add multiple windows server in nagios for monitor, how it’s possible please help.
i am not able to understand how i will add multiple windows machine in windows.cfg file, when i am changing host_name and alias name then do not start nagios services and getting error please check configuration file.
Please Help me.
Thanks
Rajnish
awesome!!!
Hello,
I also faced the error “It appears as though you do not have permission to view information for any
of the services you requested…”
Solution for me was changing service_description.
I was using “NSClient++ – Version”…. After changing to “NSClient – Version” the error disappeared.
Maybe this could help someone else.
Regards, tcpdump
Thank you all for your comments. As I was busy latelly, I haven’t answer to your posts. I hope you understand this.
Cheers,
Alex
Boa tarde,
Amigo eu não consigo add novo user poderia me ajudar?
ele fala que o comando não é valido
e quando tento acessar via web não acessa.
obrigado.
Amigo,
Please formulate your question in english if you really need help!
Cheers!