Nagios Learning Practice Series

Source: Internet
Author: User

In fact, the Nagios Learning Practice Series-the basic installation is simply the installation of the Nagios basic components, although the ability to open the homepage, but if not configure the relevant profile file, the left menu many pages will not open, equivalent to just a shell. Next, let's study the Nagios configuration, learn about the basic configuration, and learn about the various configuration files.

Nagios Configuration Directory

The Nagios configuration file is located in the ETC directory (/USR/LOCAL/NAGIOS/ETC) as shown in:

Introduction to the configuration file

profile name

function Description

< Strong>cgi.cfg

control the CGI access profile

nagios.cfg

Master profile: The Master profile includes a series of settings that affect the Nagios daemon

resource.cfg

Resource Profile: Resource files can save user-defined macros. One of the main uses of resource files is to save sensitive configuration information that cannot be obtained by the CGIs program module

Objects

objects is a directory in which there are many configuration files that define Nagios objects: Commands.cfg, Contacts.cfg, Localhost.cfg

Configuration file description in the objects directory

Profile Name

Function description

Commands.cfg

Command definition configuration file, where defined commands can be referenced by other configuration files

Contacts.cfg

Define profiles for contacts and contact groups

Localhost.cfg

Define a configuration file that monitors the local host

Printer.cfg

Define a profile template for the monitoring printer, which is not enabled by default

Switch.cfg

Define a profile template for the monitoring router, which is not enabled by default

Templates.cfg

Defines a template configuration file for hosts and services that can be referenced in other configuration files

Timeperiods.cfg

Define the configuration file for the Nagios monitoring time period

Windows.cfg

Monitor a profile template for a Windows host that is not enabled by default

Practice configuration Steps

Modify the configuration information below, first let Nagios monitor the various resource consumption of this machine. Before modifying the configuration file below, first back up a copy of the various configuration files, so as to avoid major problems in the modification process, you can also roll back to the pre-modified version (copy the configuration file before the modification, named Xxxx.bak as shown below)

[Email protected] etc]# cd/usr/local/nagios/etc/

[[email protected] etc]# ls

Cgi.cfg htpasswd nagios.cfg Objects Resource.cfg

[Email protected] etc]# CD objects/

[[email protected] objects]# ls

Commands.cfg contacts.cfg localhost.cfg printer.cfg switch.cfg templates.cfg timeperiods.cfg windows.cfg

[Email protected] objects]#

1) Modify Cgi.cfg first

In the Cgi.cfg file, find some of the following configuration parameters:

Default_user_name=guest

Authorized_for_system_information=nagiosadmin

Authorized_for_configuration_information=nagiosadmin

Authorized_for_system_commands=nagiosadmin

Authorized_for_all_services=nagiosadmin

Authorized_for_all_hosts=nagiosadmin

Authorized_for_all_service_commands=nagiosadmin

Authorized_for_all_host_commands=nagiosadmin

Modify these parameter configurations to the following: (If not clear why Kerry, see the previous blog Nagios Learning Practice Series-Basic installation commentary)

Default_user_name=kerry

Authorized_for_system_information=nagiosadmin,kerry

Authorized_for_configuration_information=nagiosadmin,kerry

Authorized_for_system_commands=nagiosadmin,kerry

Authorized_for_all_services=nagiosadmin,kerry

Authorized_for_all_hosts=nagiosadmin,kerry

Authorized_for_all_service_commands=nagiosadmin,kerry

Authorized_for_all_host_commands=nagiosadmin,kerry

2) Modify the Resource.cfg configuration file.

, find $user1$=/usr/local/nagios//libexec to change it to $user1$=/usr/local/nagios/libexec

3) Modify the Nagios.cfg configuration file

Modify a series of parameter configurations to remove unwanted/removed

Log_file=/usr/local/nagios/var/nagios.log

Cfg_file=/usr/local/nagios/etc/objects/commands.cfg

Cfg_file=/usr/local/nagios/etc/objects/contacts.cfg

Cfg_file=/usr/local/nagios/etc/objects/timeperiods.cfg

Cfg_file=/usr/local/nagios/etc/objects/templates.cfg

Cfg_file=/usr/local/nagios/etc/objects/localhost.cfg

Cfg_file=/usr/local/nagios/etc/objects/services.cfg

Object_cache_file=/usr/local/nagios/var/objects.cache

Precached_object_file=/usr/local/nagios/var/objects.precache

Resource_file=/usr/local/nagios/etc/resource.cfg

Status_file=/usr/local/nagios/var/status.dat

Command_check_interval=1

Command_file=/usr/local/nagios/var/rw/nagios.cmd

Lock_file=/usr/local/nagios/var/nagios.lock

Temp_file=/usr/local/nagios/var/nagios.tmp

Log_archive_path=/usr/local/nagios/var/archives

Check_result_path=/usr/local/nagios/var/spool/checkresults

State_retention_file=/usr/local/nagios/var/retention.dat

4) Modify the Localhost.cfg configuration file

First, through the command hostname view the machine name of your monitoring host, for example, the host name of this test environment is Bogon, enter the localhost.cfg configuration file, the corresponding

HOST_NAME or member configuration changes.

The contents of the Localhost.cfg file are as follows:

View Code

After the basic configuration is complete, we start the Nagios, Apache service

Launch Apache Service

[[email protected] conf]#/usr/local/apache/bin/apachectl start

Start the Nagios service

[[Email protected] conf]# service Nagios start

, you can monitor the current server load, the current number of users, HTTP service, SSH service ....

Configuration problem Rollup:

In the process of configuring Nagios, always encounter strange, all kinds of problems, the following I slowly collected some problems encountered, of course, this is I met, did not encounter problems, do not include.

Issue 1: When Nagios is configured, the Apache, Nagios service is started, and when it enters the hosts, services and other interfaces, it appears garbled, as shown in:

This problem is because Apache does not open CGI script, enter the Apache Master profile directory, modify the configuration file httpd.conf, the following two lines of comments canceled, restart the service can solve the problem.

#LoadModule Cgid_module modules/mod_cgid.so

#LoadModule Alias_module modules/mod_alias.so

Issue 2: Click on the Map page with the following error message (Red section):

Not Found

The requested url/nagios/cgi-bin/statusmap.cgi is not found on this server.

This error occurs because the Gd-devel package is not installed, and the Gd-devel package needs to be installed.

Nagios Learning Practice Series

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.