Posted by: kezhong | May 1, 2011

Install and configure Nagios on Fedora 14 using YUM

Install httpd, php, and Nagios packages
[root@kezhong ~]# yum install nagios* -y
[root@kezhong ~]# yum install httpd php -y

Modify the cgi.cfg file
[root@kezhong ~]# vim /etc/nagios/cgi.cfg
authorized_for_system_information=kezhong
authorized_for_configuration_information=kezhong
authorized_for_system_commands=kezhong
authorized_for_all_services=kezhong
authorized_for_all_hosts=kezhong
authorized_for_all_service_commands=kezhong
authorized_for_all_host_commands=kezhong

You can also tune the nagios.conf file according to your request
[root@kezhong ~]# vim /etc/httpd/conf.d/nagios.conf

Create the password for users. “-c” is used at the first user.
[root@kezhong ~]# htpasswd -c /etc/nagios/passwd kezhong
New password:
Re-type new password:
Adding password for user kezhong

Start the services
[root@kezhong ~]# chkconfig httpd on
[root@kezhong ~]# chkconfig nagios on
[root@kezhong ~]# service httpd start
[root@kezhong ~]# service nagios start

Luanch your favorate browser, enter the URL “http://127.0.0.1/nagios/”

It proved the Nagios worked from the above webpage.

Configure to make it to monitor a client
Add a line as below
[root@kezhong conf.d]# vim /etc/nagios/nagios.cfg
cfg_dir=/etc/nagios/conf.d

[root@kezhong conf.d]# cd /etc/nagios/conf.d
[root@kezhong conf.d]# vim hosts.cfg
define host {
    name        regular-host
    use         linux-server
    register       0
    max_check_attempts   5
}

define host{
    use             regular-host
    host_name       client1
    address         192.168.189.172
    contact_groups  admins
    notes           test client1
}

[root@kezhong conf.d]# vim hostgroups.cfg
define hostgroup {
    hostgroup_name  test-group
    alias           Test Servers
    members         client1
}

[root@kezhong conf.d]# vim services.cfg
define service {
    use                     generic-service
    hostgroup_name          test-group
    service_description     PING
    check_command           check_ping!200.0,20%!600.0,60%
}

[root@kezhong conf.d]# chown root:nagios hosts.cfg
[root@kezhong conf.d]# chown root:nagios hostgroups.cfg
[root@kezhong conf.d]# chown root:nagios services.cfg
[root@kezhong conf.d]# rm internet.cfg

[root@kezhong ~]# cd /etc/nagios/objects
[root@kezhong objects]# vim contacts.cfg
define contact{
    contact_name                    kezhong
    use                             generic-contact
    alias                           Nagios Admin
    email                           kezhong@yahoo.ca
}

define contactgroup{
    contactgroup_name       admins
    alias                   Nagios Administrators
    members                 kezhong
}

[root@kezhong conf.d]# service nagios restart
Refresh the browser

Finally, make sure that the sendmail service can work so as to send mail when something happen.

Reference
http://www.nagios.org/documentation


Responses

  1. […] installed Nagios as my past post “Install and configure Nagios on Fedora 14 using YUM“. Now I want to store all configuration and event data into MySQL, because the development […]

  2. for those getting could not read configuration data error: you need to add the apache user to the nagios group with: usermod -a -G nagios apache

  3. thx, i follow your this tutorial, i use fedora 14, but what i have not hosts.cfg file in /etc/nagios/objects/ .
    Can you give me information about the results obtained as general status like it is mentioned on this tutorial when all is right.
    thank you

  4. chido (Y)

  5. hi, some problem here:
    i followed the instruction all the way to
    “service nagios start”
    and then i got an error messege:
    Redirecting to /bin/systemctl start nagios.service
    Job for nagios.service failed. See ‘systemctl status nagios.service’ and ‘journalctl -xn’ for details.
    it appers to be a problem with the configuration files (i replaced “kezhong” with the name another user) but i couldn’t find it.

    any suggestions?

    • Solved:
      reinstalled nagios and pressed:
      [root@kezhong ~]# chkconfig httpd on
      [root@kezhong ~]# chkconfig nagios on
      [root@kezhong ~]# service httpd start
      [root@kezhong ~]# service nagios start

      right after the installation


Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s

Categories

%d bloggers like this: