Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Installation and configuration of Nagios under Linux

2025-02-22 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly explains "the installation and configuration of Nagios under Linux". The content of the explanation is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "the installation and configuration of Nagios under Linux".

A brief introduction to Nagios

Nagios is an open source computer system and network monitoring tool, which can effectively monitor the host status of Windows, Linux and Unix, network settings such as switches and routers, printers and so on. When the system or service status is abnormal, send an email or SMS alarm to notify the website operation and maintenance personnel as soon as possible, and send out a normal email or SMS notification after the status is restored.

Nagios, formerly known as NetSaint, was developed and maintained by Ethan Galstad until now. NAGIOS is an acronym: "Nagios Ain't Gonna Insist On Sainthood" Sainthood is translated as a saint, and "Agios" is the Greek meaning of "saint". Nagios was developed for use under Linux, but also works very well under Unix.

Main function

Network service monitoring (SMTP, POP3, HTTP, NNTP, ICMP, SNMP, FTP, SSH)

Host resource monitoring (CPU load, disk usage, system logs), including Windows hosts (using NSClient++ plugin)

You can specify your own Plugin to collect data over the network to monitor any situation (temperature, warning... )

Scripts can be executed remotely by configuring the Nagios remote execution plug-in

Remote monitoring supports SSH or SSL plus channel monitoring.

Simple plugin design allows users to easily develop the inspection services they need, supporting many development languages (shell scripts, C++, Perl, ruby, Python, PHP, C#, etc.)

Contains a lot of graphical data Plugins (Nagiosgraph, Nagiosgrapher, PNP4Nagios, etc.)

Can be checked by parallel services

The ability to define the hierarchy of network hosts, allowing step-by-step checking, that is, downward checking starting from the parent host

When there is a problem with the service or host, you can notify it through email, pager, sms or any user-defined plugin

Can customize the event handling mechanism to reactivate the service or host with the problem

Automatic log loop

Support for redundant monitoring

Including Web interface, you can view current network status, notifications, problem history, log files, etc.

Second, the working principle of Nagios

The function of Nagios is to monitor the service and host, but it does not include this part of the function. All the monitoring and detection functions are completed through various plug-ins.

After starting Nagios, it will periodically automatically call plug-ins to detect the status of the server. At the same time, Nagios will maintain a queue, and the status information returned by all plug-ins will enter the queue. Nagios will read the information from the head of the queue every time, and after processing, the status result will be displayed through web.

Nagios provides many plug-ins, which can be used to easily monitor the status of many services. After the installation is completed, all the plug-ins that can be used by nagios are placed in the / libexec under the nagios home directory, for example, check_disk is a plug-in to check disk space, check_load is to check CPU load, and so on. Each plug-in can view its usage and functionality by running. / check_xxx-h.

Nagios can recognize four status return messages: 0 (OK) indicates normal / green, 1 (WARNING) indicates warning / yellow, 2 (CRITICAL) indicates very serious error / red, and 3 (UNKNOWN) indicates unknown error / dark yellow. Nagios judges the status of the monitoring object according to the value returned by the plug-in, and displays it through web, so that the administrator can find the fault in time.

Four monitoring statu

In addition, the alarm function is meaningless if the monitoring system finds that the problem can not be reported to the police, so the alarm is also one of the very important functions of nagios. But, similarly, Nagios itself does not have the alarm part of the code, or even plug-ins, but to the user or other relevant open source project team to complete.

Nagios installation refers to the basic platform, that is, the installation of Nagios software packages. It is not only the framework of the monitoring system, but also the basis of all monitoring.

When you open the official documentation of Nagios, you will find that Nagios basically does not have any dependency packages, but only requires that the system is a system supported by Linux or other Nagios. However, if you do not install apache (http service), then you do not have such an intuitive interface to view monitoring information, so apache is a prerequisite for now. About the installation of apache, there are many on the Internet, just install it. Check to see if it works properly after installation.

Now that you know how Nagios manages server objects through plug-ins, let's look at how it manages remote server objects. The Nagios system provides a plug-in NRPE. Nagios runs it periodically to get all kinds of status information of the remote server. The relationship between them is shown in the following figure:

Nagios manages services remotely through NRPE

1. Nagios executes the check_nrpe plug-in installed in it and tells check_nrpe which services to detect.

two。 Connect the NRPE daemon on the remote computer through SSL,check_nrpe

3. NRPE runs various local plug-ins to detect local services and status (check_disk,..etc)

4. Finally, NRPE sends the test results to the check_nrpe,check_nrpe on the host side and sends the results to the Nagios status queue.

5. Nagios reads the information in the queue in turn, and then displays the results.

Third, the experimental environment

Host NameOSIPSoftwareNagios-ServerCentOS release 6.3 (Final) 192.168.1.108Apache, Php, Nagios, nagios-pluginsNagios-LinuxCentOS release 5.8 (Final) 192.168.1.111nagios-plugins, nrpeNagios-WindowsWindows XP192.168.1.113NSClient++

Server installs nagios software, processes the monitored data, and provides web interface for viewing and management. Of course, you can also monitor the information of the machine itself.

Client installs clients such as NRPE, performs monitoring according to the request of the monitoring machine, and then sends the results back to the monitoring computer.

The firewall is turned off / iptables: Firewall is not running.

SELINUX=disabled

IV. Experimental objectives

Fifth, Nagios server installation

5.1 basic support Kit: gcc glibc glibc-common gd gd-devel xinetd openssl-devel

# rpm-q gcc glibc glibc-common gd gd-devel xinetd openssl-devel

If these suites are not available on the system, install them using yum

# yum install-y gcc glibc glibc-common gd gd-devel xinetd openssl-devel

5.2 create nagios users and user groups

# useradd-s / sbin/nologin nagios# mkdir / usr/local/nagios# chown-R nagios.nagios / usr/local/nagios

Permissions to view the nagios directory

# ll-d / usr/local/nagios/

5.3 compile and install Nagios

# wget http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-3.4.3.tar.gz

# tar zxvf nagios-3.4.3.tar.gz

# cd nagios

#. / configure-prefix=/usr/local/nagios

# make all

# make install

# make install-init

# make install-commandmode

# make install-config

# chkconfig-add nagios

# chkconfig-- level 35 nagios on

# chkconfig-list nagios

5.4 verify that the program is installed correctly

Change the directory to the installation path (here is / usr/local/nagios) to see if there are five directories: etc, bin, sbin, share, and var. If so, it indicates that the program is installed correctly on the system. The purpose of each directory of Nagios is described as follows:

The directory where the binNagios executable is located, the directory where the etcNagios configuration file is located, the directory where the sbinNagios CGI file is located, that is, the directory where the files needed to execute the external command are located, the directory where the shareNagios web page file is located, the directory where the external plug-in is located, the directory where the varNagios log file, lock and other files are located, the directory where the var/archivesNagios log is automatically archived, the directory used to store external command files.

5.5 install the Nagios plug-in

# wget http://prdownloads.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.16.tar.gz

# tar zxvf nagios-plugins-1.4.16.tar.gz

# cd nagios-plugins-1.4.16

#. / configure-prefix=/usr/local/nagios

# make & & make install

5.6 install and configure Apache and Php

Apache and Php are not necessary to install nagios, but nagios provides a web monitoring interface, through which the running status of monitored hosts and resources can be clearly seen. Therefore, it is necessary to install a web service.

It should be noted that after the nagios3.1.x version of nagios, php support is required when configuring the web monitoring interface. The version of nagios we downloaded here is nagios-3.4.3, so after compiling and installing apache, we also need to compile the php module, and the php version selected here is php5.4.10.

a. Install Apache

# wget http://archive.apache.org/dist/httpd/httpd-2.2.23.tar.gz

# tar zxvf httpd-2.2.23.tar.gz

# cd httpd-2.2.23

#. / configure-prefix=/usr/local/apache2

# make & & make install

If an error occurs:

It can be solved by adding-- with-included-apr at compile time.

b. Install Php

# wget http://cn2.php.net/distributions/php-5.4.10.tar.gz

# tar zxvf php-5.4.10.tar.gz

# cd php-5.4.10

#. / configure-prefix=/usr/local/php-with-apxs2=/usr/local/apache2/bin/apxs

# make & & make install

c. Configure apache

Locate the configuration file / usr/local/apache2/conf/httpd.conf for apache

Find:

The code is as follows:

User daemon

Group daemon

Modify to

The code is as follows:

User nagios

Group nagios

And find it.

The code is as follows:

DirectoryIndex index.html

Modify to

The code is as follows:

DirectoryIndex index.html index.php

Then add the following:

AddType application/x-httpd-php .php for security reasons, generally speaking, the web monitoring page of nagios must be authorized to access, which requires additional verification configuration, that is, the following information is added at the end of the httpd.conf file:

XML/HTML Code copies content to the clipboard

# setting for nagios

ScriptAlias / nagios/cgi-bin "/ usr/local/nagios/sbin"

AuthType Basic

Options ExecCGI

AllowOverride None

Order allow,deny

Allow from all

AuthName "Nagios Access"

AuthUserFile / usr/local/nagios/etc/htpasswd / / Files used for access authentication in this directory

Require valid-user

Alias / nagios "/ usr/local/nagios/share"

AuthType Basic

Options None

AllowOverride None

Order allow,deny

Allow from all

AuthName "nagios Access"

AuthUserFile / usr/local/nagios/etc/htpasswd

Require valid-user

d. Create an apache directory verification file

In the above configuration, the directory verification file htpasswd is specified, which is to be created below:

# / usr/local/apache2/bin/htpasswd-c / usr/local/nagios/etc/htpasswd david

This creates an htpasswd authentication file in the / usr/local/nagios/etc directory, which requires a user name and password to be entered when accessed through http://192.168.1.108/nagios/.

e. View the contents of the certification file

# cat / usr/local/nagios/etc/htpasswd

f. Start the apache service

# / usr/local/apache2/bin/apachectl start

At this point, the installation of nagios is almost complete, and you can access it through web.

6. Configure Nagios

Nagios is mainly used to monitor one or more local hosts and all kinds of remote information, including local resources and external services. The default Nagios configuration has nothing to monitor, just template files. For Nagios to provide services, you must modify the configuration file to add hosts and services to monitor, which are described in more detail below.

6.1 introduction to the default profile

After Nagios is installed, the default configuration file is in the / usr/local/nagios/etc directory.

The meaning of each file or directory is shown in the following table:

File name or directory name use cgi.cfg to control CGI access configuration files nagios.cfgNagios main configuration files resource.cfg variable definition files, also known as resource files, define variables in these files so that they can be referenced by other configuration files, such as $USER1 $objectsobjects is a directory in which there are many profile templates to define Nagios objects objects/commands.cfg commands define configuration files The commands defined in it can be referenced by other profiles, objects/contacts.cfg defines a profile for contacts and contact groups, objects/localhost.cfg defines a profile for monitoring local hosts, objects/printer.cfg defines a profile template for monitoring printers, this file is not enabled by default, objects/switch.cfg defines a profile template for monitoring routers This file objects/templates.cfg defines a template profile for hosts and services is not enabled by default. A profile template of objects/timeperiods.cfg defining Nagios monitoring time period can be referenced in other configuration files. A profile template of objects/windows.cfg monitoring Windows host is not enabled by default.

6.2 relationships between profiles

Several definitions involved in the configuration of nagios are: host, host group, service, service group, contact person, contact group, monitoring time, monitoring command and so on. From these definitions, we can see that the configuration files of nagios are related to each other and refer to each other.

To successfully configure a nagios monitoring system, it is necessary to understand the relationship between dependencies and dependencies between each profile, and the most important points are:

First: define which hosts, host groups, services and service groups to monitor

Second: define what commands to use to implement this monitoring

Third: define the time period for monitoring

Fourth: define the contacts and groups of contacts to be notified when there is a problem with the host or service.

6.3 configure Nagios

In order to explain the problem more clearly, and to facilitate maintenance, it is recommended to create separate configuration files for each defined object of nagios:

Create a hosts.cfg file to define hosts and host groups

Create a services.cfg file to define the service

Use the default contacts.cfg file to define contacts and contact groups

Define commands with the default commands.cfg file

Use the default timeperiods.cfg to define the monitoring period

Use the default templates.cfg file as the resource reference file

A. Templates.cfg file

Nagios is mainly used to monitor host resources and services, which is called objects in nagios configuration. In order not to define some monitoring objects repeatedly, Nagios introduces a template configuration file to define some common attributes as templates for multiple references. That's what templates.cfg does.

The meaning of each parameter in the templates.cfg file is described in detail below:

XML/HTML Code copies content to the clipboard

Define contact {

Name generic-contact; contact name

Service_notification_period 24x7; when an exception occurs in the service, the time period during which the notification is sent. "24x7" is defined in the timeperiods.cfg file.

Host_notification_period 24x7; the time period during which notifications are sent when an exception occurs on the host. "24x7" is defined in the timeperiods.cfg file.

The definition of service_notification_options is "the circumstances in which notifications can be given". W is warn, indicating warning status, and u is unknown, indicating unknown status

; c is criticle, indicating the state of emergency, r is recover, indicating the state of recovery

That is, a notification is sent to the consumer when the service has a warning state, an unknown state, a state of emergency, and a restored state.

Host_notification_options d down; defines the state in which the host needs to send notification to the user, indicating the state of downtime

; u is unreachable, indicating the unreachable state, and r is recovery, indicating the restored state.

Service_notification_commands notify-service-by-email; when the service fails, the notification can be sent by email or SMS. Here, the notification is sent by email.

Where "notify-service-by-email" is defined in the commands.cfg file.

Host_notification_commands notify-host-by-email; when the host fails, the notification can be sent by email or SMS. Here, the notification is sent by email.

Where "notify-host-by-email" is defined in the commands.cfg file.

Register 0; DONT REGISTER THIS DEFINITION-ITS NOT A REAL CONTACT, JUST A TEMPLATE!

}

Define host {

Name generic-host; host name, the host name here, does not directly correspond to the host name of the real machine

Corresponds to the hostname set in the host configuration file

Notifications_enabled 1; Host notifications are enabled

Event_handler_enabled 1; Host event handler is enabled

Flap_detection_enabled 1; Flap detection is enabled

Failure_prediction_enabled 1; Failure prediction is enabled

Process_perf_data 1; its value can be 0 or 1, and its function is whether to enable the data output function of Nagios

If you assign this to 1, Nagios writes the collected data to a file for extraction.

Retain_status_information 1; Retain status information across program restarts

Retain_nonstatus_information 1; Retain non-status information across program restarts

Notification_period 24x7; specifies the time period for "sending notifications", that is, when notifications can be sent to consumers.

Register 0; DONT REGISTER THIS DEFINITION-ITS NOT A REAL HOST, JUST A TEMPLATE!

}

Define host {

Name linux-server; host name

Use generic-host; use means reference, that is, all the attributes of the host generic-host are referenced into the linux-server

In nagios configurations, references are used in many cases.

Check_period 24x7; the check_period here tells nagios to check the time period of the host

The interval between check_interval 5; nagios checks on the host, here is 5 minutes.

Retry_interval 1; retry check interval in minutes.

The maximum number of times that max_check_attempts 10; nagios checks the host, that is, when nagios finds an exception in a host, it does not immediately judge it as an exception.

Try a few more times, because the host may have been affected a little bit because of temporary network congestion or other reasons

10 here means to try at most 10 times.

Check_command check-host-alive; specifies the command to check the status of the host, where "check-host-alive" is defined in the commands.cfg file.

Notification_period 24x7; the time range within which notification is sent in case of host failure, where "workhours" is defined in timeperiods.cfg

I will talk about it one after another.

Notification_interval 10; the time when the failure has not been resolved after an exception occurred on the host, and the nagios notifies the user again. In minutes

If you think that only one notification is enough for all events, you can set the option here to 0

Notification_options d down; defines the state in which the host can send notification to the user, indicating the state of downtime

; u is unreachable, indicating the unreachable state

; r is recovery, which indicates that the state is restored.

Contact_groups ts; specify the contact group, which "admins" is defined in the contacts.cfg file.

Register 0; DONT REGISTER THIS DEFINITION-ITS NOT A REAL HOST, JUST A TEMPLATE!

}

Define host {

Name windows-server; The name of this host template

Use generic-host; Inherit default values from the generic-host template

Check_period 24x7; By default, Windows servers are monitored round the clock

Check_interval 5; Actively check the server every 5 minutes

Retry_interval 1; Schedule host check retries at 1 minute intervals

Max_check_attempts 10; Check each server 10 times (max)

Check_command check-host-alive; Default command to check if servers are "alive"

Notification_period 24x7; Send notification out at any time-day or night

Notification_interval 10; Resend notifications every 30 minutes

Notification_options DBI r; Only send notifications for specific host states

Contact_groups ts; Notifications get sent to the admins by default

Hostgroups windows-servers; Host groups that Windows servers should be a member of

Register 0; DONT REGISTER THIS-ITS JUST A TEMPLATE

}

Define service {

Name generic-service; define a service name

Active_checks_enabled 1; Active service checks are enabled

Passive_checks_enabled 1; Passive service checks are enabled/accepted

Parallelize_check 1; Active service checks should be parallelized

; (disabling this can lead to major performance problems)

Obsess_over_service 1; We should obsess over this service (if necessary)

Check_freshness 0; Default is to NOT check service 'freshness'

Notifications_enabled 1; Service notifications are enabled

Event_handler_enabled 1; Service event handler is enabled

Flap_detection_enabled 1; Flap detection is enabled

Failure_prediction_enabled 1; Failure prediction is enabled

Process_perf_data 1; Process performance data

Retain_status_information 1; Retain status information across program restarts

Retain_nonstatus_information 1; Retain non-status information across program restarts

Is_volatile 0; The service is not volatile

Check_period 24x7; the check_period here tells nagios to check the time period of the service.

The maximum number of checks on the service by max_check_attempts 3; nagios.

Normal_check_interval 5; this option is used to set the service check interval, that is, the time between this check and the next check by nagios

Here is five minutes.

Retry_check_interval 2; retry check interval in minutes.

Contact_groups ts; specify contact group

The definition of notification_options is "the circumstances in which notifications can be given". W is warn, indicating the warning status

; u is unknown, indicating an unknown state

; c is criticle, indicating the state of emergency, r is recover, indicating the state of recovery

That is, a notification is sent to the consumer after the warning state, unknown state, state of emergency, and resumption of the service occur.

Notification_interval 10; Re-notify about service problems every hour

Notification_period 24x7; specifies the time period for "sending notifications", that is, when notifications can be sent to consumers.

Register 0; DONT REGISTER THIS DEFINITION-ITS NOT A REAL SERVICE, JUST A TEMPLATE!

}

Define service {

Name local-service; The name of this service template

Use generic-service; Inherit default values from the generic-service definition

Max_check_attempts 4; Re-check the service up to 4 times in order to determine its final (hard) state

Normal_check_interval 5; Check the service every 5 minutes under normal conditions

Retry_check_interval 1; Re-check the service every minute until a hard state can be determined

Register 0; DONT REGISTER THIS DEFINITION-ITS NOT A REAL SERVICE, JUST A TEMPLATE!

}

B. resource.cfg file

Resource.cfg is the variable definition file for nagios, which contains only one line:

$USER1 $= / usr/local/nagios/libexec

The variable $USER1 $specifies the path to install the nagios plug-in. If you install the plug-in in another path, you just need to modify it here. It is important to note that variables must be defined before they can be referenced in other configuration files.

C. Commands.cfg file

This file exists by default and can be used without modification, of course, if there are new commands to add, you can add it in this file.

XML/HTML Code copies content to the clipboard

# definition of notify-host-by-email command

Define command {

The name of the command_name notify-host-by-email # command, which defines a command that sends mail when a host is abnormal.

Command_line / usr/bin/printf "% b" * Nagios *\ n\ nNotification Type: $NOTIFICATIONTYPE$\ nHost: $HOSTNAME$\ nState: $HOSTSTATE$\ nAddress: $HOSTADDRESS$\ nInfo: $HOSTOUTPUT$\ n\ nDate/Time: $LONGDATETIME$\ n "| / bin/mail-s" * * $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ * * "$CONTACTEMAIL$ # command is executed.

}

# definition of notify-service-by-email command

Define command {

The name of the command_name notify-service-by-email # command, which defines a command to send mail when a service exception occurs

Command_line / usr/bin/printf "% b"* Nagios *\ n\ nNotification Type: $NOTIFICATIONTYPE$\ n\ nService: $SERVICEDESC$\ nHost: $HOSTALIAS$\ nAddress: $HOSTADDRESS$\ nState: $SERVICESTATE$\ n\ nDate/Time: $LONGDATETIME$\ n\ nAdditional Info:\ n\ nServiceOut $\ n" | / bin/mail-s "* * $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ * *" $CONTACTEMAIL$

}

# definition of check-host-alive command

Define command {

Command_name check-host-alive # command name, which is used to detect the status of the host.

Command_line $USER1 $/ check_ping-H $HOSTADDRESS$-w 3000.080%-c 5000.0100%-p 5

# the variable $USER1 $here is defined in the resource.cfg file, that is, $USER1 $= / usr/local/nagios/libexec

# then the full path of check_ping is / usr/local/nagios/libexec/check_ping

The "- w" in "- w" indicates that the following pair of values corresponds to the "WARNING" state, and "80%" is its critical value.

The "- c" in # "- c 5000.0100%" indicates that the following pair of values corresponds to "CRITICAL", and "100%" is its critical value.

# "- p 1" indicates that each probe sends a packet.

}

Define command {

Command_name check_local_disk

Command_line $USER1 $/ check_disk-w $ARG1 $- c $ARG2 $- p $ARG3 $# $ARG1 $refers to the first argument after the command when the command is called.

}

Define command {

Command_name check_local_load

Command_line $USER1 $/ check_load-w $ARG1 $- c $ARG2 $

}

Define command {

Command_name check_local_procs

Command_line $USER1 $/ check_procs-w $ARG1 $- c $ARG2 $- s $ARG3 $

}

Define command {

Command_name check_local_users

Command_line $USER1 $/ check_users-w $ARG1 $- c $ARG2 $

}

Define command {

Command_name check_local_swap

Command_line $USER1 $/ check_swap-w $ARG1 $- c $ARG2 $

}

Define command {

Command_name check_ftp

Command_line $USER1 $/ check_ftp-H $HOSTADDRESS$ $ARG1 $

}

Define command {

Command_name check_http

Command_line $USER1 $/ check_http-I $HOSTADDRESS$ $ARG1 $

}

Define command {

Command_name check_ssh

Command_line $USER1 $/ check_ssh $ARG1 $$HOSTADDRESS$

}

Define command {

Command_name check_ping

Command_line $USER1 $/ check_ping-H $HOSTADDRESS$-w $ARG1 $- c $ARG2 $- p 5

}

Define command {

Command_name check_nt

Command_line $USER1 $/ check_nt-H $HOSTADDRESS$-p 12489-v $ARG1 $$ARG2 $

}

D. Hosts.cfg file

This file does not exist by default and needs to be created manually. Hosts.cfg is mainly used to specify the monitored CVM address and related attribute information. The configuration based on the experimental target is as follows:

XML/HTML Code copies content to the clipboard

Define host {

Use linux-server # refers to the attribute information of the host linux-server, and the linux-server host is defined in the templates.cfg file.

Host_name Nagios-Linux # Hostname

Alias Nagios-Linux # Host alias

Address 192.168.1.111 # the monitored host address, which can be an ip or a domain name.

} # define a host group

Define hostgroup {

Hostgroup_name bsmart-servers # host group name, which can be specified at will.

Alias bsmart servers # Host group alias

Members Nagios-Linux # host group member, where "Nagios-Linux" is the host defined above.

}

Note: there are two configuration files, localhost.cfg and windows.cfg, by default under / usr/local/nagios/etc/objects, the localhost.cfg file defines the monitoring host itself, and the windows.cfg file defines the windows host, including the definition of host and related services. So in this lab, you will define the monitoring host (Nagios-Server) directly in localhost.cfg and the windows host (Nagios-Windows) in windows.cfg. Modify the relevant configurations according to your own needs, as shown below:

Localhost.cfg

XML/HTML Code copies content to the clipboard

Define host {

Use linux-server; Name of host template to use

; This host definition will inherit all variables that are defined

; in (or inherited by) the linux-server host template definition.

Host_name Nagios-Server

Alias Nagios-Server

Address 127.0.0.1

}

Define hostgroup {

Hostgroup_name linux-servers; The name of the hostgroup

Alias Linux Servers; Long name of the group

Members Nagios-Server; Comma separated list of hosts that belong to this group

}

Define service {

Use local-service; Name of service template to use

Host_name Nagios-Server

Service_description PING

Check_command checkpoints pingling 100.010% 500.060%

}

Define service {

Use local-service; Name of service template to use

Host_name Nagios-Server

Service_description Root Partition

Check_command checkpoints localizations disk20% "10%" /

}

Define service {

Use local-service; Name of service template to use

Host_name Nagios-Server

Service_description Current Users

Check_command check_local_users!20!50

}

Define service {

Use local-service; Name of service template to use

Host_name Nagios-Server

Service_description Total Processes

Check_command check_local_procs!250!400!RSZDT

}

Define service {

Use local-service; Name of service template to use

Host_name Nagios-Server

Service_description Current Load

Check_command check_local_load!5.0,4.0,3.0!10.0,6.0,4.0

}

Define service {

Use local-service; Name of service template to use

Host_name Nagios-Server

Service_description Swap Usage

Check_command check_local_swap!20!10

}

Define service {

Use local-service; Name of service template to use

Host_name Nagios-Server

Service_description SSH

Check_command check_ssh

Notifications_enabled 0

}

Define service {

Use local-service; Name of service template to use

Host_name Nagios-Server

Service_description HTTP

Check_command check_http

Notifications_enabled 0

}

Windows.cfg

XML/HTML Code copies content to the clipboard

Define host {

Use windows-server; Inherit default values from a template

Host_name Nagios-Windows; The name we're giving to this host

Alias My Windows Server; A longer name associated with the host

Address 192.168.1.113; IP address of the host

}

Define hostgroup {

Hostgroup_name windows-servers; The name of the hostgroup

Alias Windows Servers; Long name of the group

}

Define service {

Use generic-service

Host_name Nagios-Windows

Service_description NSClient++ Version

Check_command check_nt!CLIENTVERSION

}

Define service {

Use generic-service

Host_name Nagios-Windows

Service_description Uptime

Check_command check_nt!UPTIME

}

Define service {

Use generic-service

Host_name Nagios-Windows

Service_description CPU Load

Check_command check check ntact CPULOADM color l 5pm 80pm 90

}

Define service {

Use generic-service

Host_name Nagios-Windows

Service_description Memory Usage

Check_command checkmate MEMUSEN color w 80-c 90

}

Define service {

Use generic-service

Host_name Nagios-Windows

Service_description C:\ Drive Space

Check_command checkpoint ntasking USEDDISKSPACEMul c-w 80-c 90

}

Define service {

Use generic-service

Host_name Nagios-Windows

Service_description W3SVC

Check_command checkpoint ntasking service SHOWALL-l W3SVC

}

Define service {

Use generic-service

Host_name Nagios-Windows

Service_description Explorer

Check_command checkpoint PROCSTATEMETHUD SHOWALL-l Explorer.exe

}

E. services.cfg file

This file does not exist by default and needs to be created manually. Services.cfg files are mainly used to define monitoring services and host resources, such as monitoring http services, ftp services, host disk space, host system load, and so on. Nagios-Server and Nagios-Windows-related services have been defined in the corresponding configuration files, so you only need to define Nagios-Linux-related services. Here, only one service is defined to verify the correctness of the configuration file. The definitions of other services will be discussed later.

The code is as follows:

Define service {

Use local-service # refers to the property values of the local-service service, and local-service is defined in the templates.cfg file.

Host_name Nagios-Linux # specifies the service on which host to monitor, and "Nagios-Server" is defined in the hosts.cfg file.

Service_description check-host-alive # describes the content of the monitoring service for reference by maintenance personnel.

Check_command check-host-alive # specifies the command to check. }

F. Contacts.cfg file

Contacts.cfg is a configuration file that defines contacts and contact groups. When the monitored host or service fails, nagios will send the information to the specified contact or user through the specified notification (email or SMS).

The code is as follows:

Define contact {

The name of the contact_name David # contact, no spaces in this place

Use generic-contact # refers to the attribute information of generic-contact, where "generic-contact" is defined in the templates.cfg file

Alias Nagios Admin

Email david.tang@bsmart.cn

}

Define contactgroup {

The name of the contactgroup_name ts # contact group, which also cannot be blank

Alias Technical Support # contact group description

Members of the members David # contact group, where "david" is the contact defined above, separated by commas if there are multiple contacts

}

G. timeperiods.cfg file

This file is only used to define the time period for monitoring. Here is a configured example:

XML/HTML Code copies content to the clipboard

# the following is to define a time period called 24x7, that is, to monitor all time periods

Define timeperiod {

The name of the timeperiod_name 24x7 # time period, with no spaces in this place

Alias 24 Hours A Day, 7 Days A Week

Sunday 00:00-24:00

Monday 00:00-24:00

Tuesday 00:00-24:00

Wednesday 00:00-24:00

Thursday 00:00-24:00

Friday 00:00-24:00

Saturday 00:00-24:00

}

# the following is the definition of a time period called workhours, that is, the working period.

Define timeperiod {

Timeperiod_name workhours

Alias Normal Work Hours

Monday 09:00-17:00

Tuesday 09:00-17:00

Wednesday 09:00-17:00

Thursday 09:00-17:00

Friday 09:00-17:00

}

H. Cgi.cfg file

This file is used to control related cgi scripts. If you want to execute cgi scripts in nagios's web monitoring interface, such as restarting the nagios process, turning off nagios notification, stopping nagios host detection, etc., you need to configure the cgi.cfg file.

Since the web monitoring interface of nagios verifies that the user is david, you only need to add the user's execution permission in the cgi.cfg file. The configuration information that needs to be modified is as follows:

The code is as follows:

Default_user_name=david

Authorized_for_system_information=nagiosadmin,david

Authorized_for_configuration_information=nagiosadmin,david

Authorized_for_system_commands=david

Authorized_for_all_services=nagiosadmin,david

Authorized_for_all_hosts=nagiosadmin,david

Authorized_for_all_service_commands=nagiosadmin,david

Authorized_for_all_host_commands=nagiosadmin,david

I. nagios.cfg file

The default path of nagios.cfg is / usr/local/nagios/etc/nagios.cfg, which is the core configuration file of nagios. All object configuration files must be defined in this file to play their role. Here, you only need to reference the object configuration file in the Nagios.cfg file.

XML/HTML Code copies content to the clipboard

Log_file=/usr/local/nagios/var/nagios.log # defines the path to the nagios log file

The cfg_file=/usr/local/nagios/etc/objects/commands.cfg # "cfg_file" variable is used to refer to the object configuration file. If there are more object configuration files, you can add them here in turn.

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

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

Cfg_file=/usr/local/nagios/etc/objects/services.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 # Native profile

Cfg_file=/usr/local/nagios/etc/objects/windows.cfg # windows host profile

Object_cache_file=/usr/local/nagios/var/objects.cache # this variable is used to specify a copy of all object profiles, or object buffer files

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

Resource_file=/usr/local/nagios/etc/resource.cfg # this variable is used to specify the path to the nagios resource file, and multiple resource files can be defined in nagios.cfg.

Status_file=/usr/local/nagios/var/status.dat # this variable is used to define a state file that holds the current status, comments, downtime information of nagios, and so on.

Status_update_interval=10 # this variable is used to define the update interval for status files (that is, status.dat) in seconds, with a minimum update interval of 1 second.

Nagiosnagios_user=nagios # this variable specifies which user the Nagios process uses to run.

Nagiosnagios_group=nagios # this variable is used to specify which user group Nagios uses to run.

Check_external_commands=1 # this variable is used to set whether nagios is allowed to run cgi commands in the web monitoring interface

# that is, whether to allow nagios to restart nagios and stop host / service checks under the web interface

# "1" is running, "0" is not allowed.

Command_check_interval=10s # this variable is used to set the interval at which nagios detects external commands, if a number is specified plus a "s" (such as 10s)

# then the interval between external detection commands is the time interval of this value in seconds

# if "s" is not used, the interval of the external detection command is the time interval of the "time unit" of this value.

Interval_length=60 # this variable specifies the time unit of nagios. The default value is 60 seconds, that is, 1 minute.

# that is, in the nagios configuration, all time units are minutes.

6.4 verify the correctness of the Nagios configuration file

Nagios is so good at validating configuration files that it can be done with a single command:

# / usr/local/nagios/bin/nagios-v / usr/local/nagios/etc/nagios.cfg

This verification function provided by Nagios is very useful, the wrong configuration file and which line in the file are usually printed in the error message, which makes it very easy to configure nagios, and alarm messages are usually ignored because they are usually only recommended.

If you see the above information, you will be fine, and then start the Nagios service.

VII. Start and stop of Nagios

7.1Startup Nagios

a. Start nagios through the initialization script

The code is as follows:

# / etc/init.d/nagios start

Or

# service nagios start

b. Start nagios manually

Start the nagios daemon with the "- d" parameter of the nagios command:

# / usr/local/nagios/bin/nagios-d / usr/local/nagios/etc/nagios.cfg

7.2 restart Nagios

When you modify the configuration file for it to take effect, you need to restart / reload the Nagios service.

a. Restart nagios by initializing the script

The code is as follows:

# / etc/init.d/nagios reload

Or

# / etc/init.d/nagios restart

Or

# service nagios restart

b. Restart nagios through the web monitoring page

You can restart nagios through "Process Info"-> "Restart the Nagios process" on the web monitoring page

c. Manual smooth restart

# kill-HUP

7.3 stop Nagios

a. Shut down the nagios service through the initialization script

The code is as follows:

# / etc/init.d/nagios stop

Or

# service nagios stop

b. Stop nagios through the web monitoring page

You can stop nagios by "Process Info"-> "Shutdown the Nagios process" on the web monitoring page

c. Stop Nagios manually

# kill

8. Check the preliminary configuration

After the startup is complete, log in to the Nagios Web monitoring page http://192.168.1.108/nagios/ to view the relevant information.

8.2 Click Current Status-> Hosts on the left to see that all three defined hosts have UP.

8.3 Click Current Status-> Services to view the service monitoring.

You can see that the service status of Nagios-Linux and Nagios-Server is already OK, but the service status of Nagios-Windows is CRITICAL,Status Information prompt Connection refused. This occurs because plug-ins are not installed on Nagios-Windows and internal services cannot be viewed. It will be explained in detail below.

9. Use NRPE to monitor "local information" on remote Linux

The above has monitored the survival of the remote Linux host, and to determine whether the remote machine is alive, we can use the ping tool to monitor it. There are also some remote host services, such as ftp, ssh and http, which are open to the outside world. Even if we don't need Nagios, we can try to find out and find a random machine to see if we can access these services. But for "local information" such as disk capacity and cpu load, Nagios can only monitor its own host, but there is little it can do about other machines. After all, it is impossible to get this information without proper permissions of the accused host. To solve this problem, nagios has an add-on, "NRPE", which can be used to monitor the "local information" of Linux type hosts.

9.1 how NRPE works

NRPE consists of two parts:

The check_nrpe plug-in, located on the monitoring host NRPE daemon, runs on a remote Linux host (usually the monitored machine)

According to the figure above, the whole monitoring process is as follows:

When Nagios needs to monitor the services or resources of a remote Linux host:

Nagios runs the check_nrpe plug-in and tells it what to check; the check_nrpe plug-in connects to the remote NRPE daemon by running the corresponding Nagios plug-in to perform the check; NRPE daemon returns the result of the check to the check_nrpe plug-in, and the plug-in submits it to nagios for processing.

Note: NRPE daemon requires the Nagios plug-in to be installed on a remote Linux host, otherwise daemon cannot do any monitoring.

9.2 on the monitored computer (Nagios-Linux)

a. Add users & set password

# useradd nagios

# passwd nagios

b. Install the Nagios plug-in

The code is as follows:

# tar zxvf nagios-plugins-1.4.16.tar.gz

# cd nagios-plugins-1.4.16

#. / configure-prefix=/usr/local/nagios

# make & & make install

When this is done, three directories, include, libexec, and share, are generated under / usr/local/nagios/.

Modify directory permissions

The code is as follows:

# chown nagios.nagios / usr/local/nagios

# chown-R nagios.nagios / usr/local/nagios/libexec

c. Install NRPE

The code is as follows:

# wget http://prdownloads.sourceforge.net/sourceforge/nagios/nrpe-2.13.tar.gz

# tar zxvf nrpe-2.13.tar.gz

# cd nrpe-2.13

#. / configure

# make all

Next, install the NPRE plug-in, daemon, and sample configuration files.

C.1 install the plug-in check_nrpe

# make install-plugin

The monitoring machine needs to install the plug-in check_nrpe, the monitored machine does not need it, we only install it here for testing purposes.

C.2 install deamon

# make install-daemon

C. 3 installation configuration file

# make install-daemon-config

Now if you look at the nagios directory, you will find that there are five directories.

As described in the installation documentation, NRPE deamon is run as a service under xinetd. In this case, xinetd must be installed first, but the general system is already installed by default.

d. Install xinted script

# make install-xinetd

You can see that the file / etc/xinetd.d/nrpe is created.

Edit the script:

Add the IP address of the monitoring host after the only_from.

Edit / etc/services file to add NRPE service

Restart the xinted service

# service xinetd restart

Check to see if NRPE has been started

You can see that port 5666 is already listening.

e. Test if NRPE is working properly

Use the check_nrpe plug-in installed on the monitored machine above to test whether NRPE is working properly.

# / usr/local/nagios/libexec/check_nrpe-H localhost

The current version of NRPE is returned

That is, it is normal to use check_nrpe to connect to nrpe daemon locally.

Note: for the smooth progress of the following work, note that the local firewall should be turned on 5666 so that it can be accessed by external monitoring computers.

F. Check_nrpe command usage

View check_nrpe command usage

# / usr/local/nagios/libexec/check_nrpe-h

As you can see, the usage is:

Check_nrpe-H monitored host-c monitoring commands to be executed

Note:-c the monitoring commands that follow must be defined in the nrpe.cfg file. That is, NRPE daemon runs only the commands defined in nrpe.cfg.

g. View the monitoring commands of NRPE

# cd / usr/local/nagios/etc

# cat nrpe.cfg | grep-v "^ #" | grep-v "^ $"

Bash/shell Code copies content to the clipboard

[root@Nagiso-Linux etc] # cat nrpe.cfg | grep-v "^ #" | grep-v "^ $"

Log_facility=daemon

Pid_file=/var/run/nrpe.pid

Server_port=5666

Nrpe_user=nagios

Nrpe_group=nagios

Allowed_hosts=127.0.0.1

Dont_blame_nrpe=0

Debug=0

Command_timeout=60

Connection_timeout=300

Commanded [check _ users] = / usr/local/nagios/libexec/check_users-w 5-c 10

Commanded [check _ load] = / usr/local/nagios/libexec/check_load-w 15leg10 penny 5-c 30pyrmr25 penny 20

Commanded [check _ sda1] = / usr/local/nagios/libexec/check_disk-w 20%-c 10%-p / dev/sda1

Commanded [check _ zombie_procs] = / usr/local/nagios/libexec/check_procs-w 5-c 10-s Z

Commanded [check _ total_procs] = / usr/local/nagios/libexec/check_procs-w 150-c 200

[root@Nagiso-Linux etc] #

The red part is the command name, which is what can be followed by the-c argument of check_nrpe, and the equal sign "=" is followed by the actual executed plug-in (this is very similar to the form of the command defined in commands.cfg, but written on one line). In other words, check_users is the abbreviation of / usr/local/nagios/libexec/check_users-w 5-c 10 after the equal sign.

We can easily know that the commands defined in the above five lines are to detect the number of logged-in users, cpu load, sda1 capacity, zombie processes, and total processes. For the specific meaning of each command, see plug-in usage (execute "plug-in name-h").

Since-c can only be followed by the commands defined in nrpe.cfg, that is, we can only use the five commands defined above. We can try it on this machine.

9.3 on the monitoring host (Nagios-Server)

Now that Nagios is up and running, what you need to do now is:

Install the check_nrpe plug-in; create a command definition for check_nrpe in commands.cfg, because only commands defined in commands.cfg can be used in services.cfg; create monitoring projects for monitored hosts

9.3.1 install the check_nrpe plug-in

# tar zxvf nrpe-2.13.tar.gz # cd nrpe-2.13#. / configure# make all# make install-plugin

Just run this step, because only the check_nrpe plug-in is needed.

Now that we have nrpe installed on Nagios-Linux, let's test the communication between the monitor using check_nrpe and the nrpe daemon running by the monitor.

Seeing that the version information of NRPE has been returned correctly, it means that everything is fine.

9.3.2 add the definition of check_nrpe in commands.cfg

# vi / usr/local/nagios/etc/objects/commands.cfg

Add the following at the end:

The meaning is as follows:

The code is as follows:

# 'check_nrpe' command definition

Define command {

Command_name check_nrpe # defines the command name as check_nrpe, which is to be used in services.cfg.

Command_line $USER1 $/ check_nrpe-H $HOSTADDRESS$-c $ARG1 $# this defines the actual running plug-in. The command line should be written exactly according to the usage of check_nrpe. If you don't know how to use it, check it with check_nrpe-h.

}

The $ARG1 $parameter followed by-c is a test command passed to nrpe daemon for execution, which I said earlier must be one of the five commands defined in nrpe.cfg. Use "!" when using check_nrpe in services.cfg Take this parameter.

9.3.3 define monitoring of Nagios-Linux hosts

Now you can define the monitoring of the Nagios-Linux host in services.cfg.

XML/HTML Code copies content to the clipboard

Define service {

Use local-service

Host_name Nagios-Linux

Service_description Current Load

Check_command check_nrpe!check_load

}

Define service {

Use local-service

Host_name Nagios-Linux

Service_description Check Disk sda1

Check_command check_nrpe!check_sda1

}

Define service {

Use local-service

Host_name Nagios-Linux

Service_description Total Processes

Check_command check_nrpe!check_total_procs

}

Define service {

Use local-service

Host_name Nagios-Linux

Service_description Current Users

Check_command check_nrpe!check_users

}

Define service {

Use local-service

Host_name Nagios-Linux

Service_description Check Zombie Procs

Check_command check_nrpe!check_zombie_procs

}

Another task is to monitor the swap usage of Nagios-Linux. However, there is no command to define this monitoring function by default in nrpe.cfg. What shall I do? Manually add it to nrpe.cfg, that is, customize the NRPE command.

Now we need to monitor the swap partition. If the free space is less than 20%, it is a warning status-> warning; is critical if it is less than 10%-> critical. We can find out that we need to use the check_swap plug-in, and the complete command line should look like this.

# / usr/local/nagios/libexec/check_swap-w 20%-c 10%

Add the definition of check_swap command to the monitored computer (Nagios-Linux)

# vi / usr/local/nagios/etc/nrpe.cfg

Add the following line

Commanded [check _ swap] = / usr/local/nagios/libexec/check_swap-w 20%-c 10%

We know that check_swap can now be used as a parameter of check_nrpe 's-c

Change the configuration file and restart it, of course.

If you are running nrpe as a stand-alone daemon, you need to restart it manually; if you are running under xinetd, you don't need it.

Since nrpe runs under xinetd in this lab, there is no need to restart the service.

Add this check_swap monitoring project to the monitoring machine (Nagios-Server)

XML/HTML Code copies content to the clipboard

Define service {

Use local-service

Host_name Nagios-Linux

Service_description Check Swap

Check_command check_nrpe!check_swap

}

Similarly, I have enabled the http service on Nagios-Linux, which needs to be monitored. In accordance with the above practice, add the definition of the check_http command to the monitored machine (Nagios-Linux).

# vi / usr/local/nagios/etc/nrpe.cfg

Add the following line

Commanded [check _ http] = / usr/local/nagios/libexec/check_http-I 127.0.0.1

Add check_http monitoring project to the monitoring machine (Nagios-Server)

XML/HTML Code copies content to the clipboard

Define service {

Use local-service

Host_name Nagios-Linux

Service_description HTTP

Check_command check_nrpe!check_http

}

All the configuration files have been modified, now restart Nagios.

# service nagios restart

9.3.4 View configuration

Log in to the Nagios Web monitoring page http://192.168.1.108/nagios/ to view relevant information.

As you can see, the monitoring of related services on Nagios-Server and Nagios-Linux has been successful, and the services on Nagios-Windows have not yet been defined, as described below.

Using NSClient++ to monitor the "local information" on the remote Windows

There is a plug-in called check_nt under Nagios's libexec, which is used to check the services of windows machines. Its function is similar to check_nrpe. But it needs to be paired with another software, NSClient++, which is similar to NRPE.

The principle of NSClient++ is as follows

You can see that the biggest difference between NSClient and nrpe is:

Nrpe is installed on the monitored machine, and there are plug-ins, and the final monitoring is carried out by these plug-ins. When the monitoring host sends the monitoring request to nrpe, nrpe calls the plug-in to complete the monitoring. NSClient++ is different, only NSClient is installed on the monitored machine, and there are no plug-ins. When the monitoring host sends the monitoring request to NSClient++, NSClient directly completes the monitoring, and all monitoring is completed by NSClient.

This also illustrates a big problem with NSClient++: inflexibility and lack of extensibility. It can only perform its own monitoring operations and cannot be extended by some plug-ins. Fortunately, NSClient++ has done a good job, basically can fully meet our monitoring needs.

10.1 install NSClient++

Download NSClient++-0.2.7.zip from http://www.nsclient.org/nscp/downloads

Extract to the root directory of disk C.

Open cmd and switch to c:\ NSClient++-0.2.7

Execute nsclient++ / install to install

Perform nsclient++ SysTray (pay attention to case), this step is to install the system tray, which takes a little longer.

Type services.msc in the run to open the "service"

The following figure shows that the NSClient service has been installed

Double-click to open, click the "login" tab, and tick before "allow services to interact with the desktop".

Edit the NSC.ini file under c:\ NSClient++-0.2.7.

Remove the comments in front of all modules in the [modules] section, except for CheckWMI.dll and RemoteConfiguration.dll.

Set the password' option in the [Settings] section to set the password, which requires a password when the nagios connects. This step is optional and I set it to '123456' here.

Uncomment the 'allowed_hosts' option in the [Settings] section and add the IP of the monitoring host running nagios. The IP are separated by commas. This place supports subnets, and if written as 192.168.1.0 take 24, it means that all the machines in the subnet can be accessed. If this place is blank, it means that all hosts can be connected.

Note that it is in the [Settings] section, because the [NSClient] section also has this option.

You must make sure that the 'port' option of [NSClient] is not commented and that its value is' 12489listen, which is the default listening port for NSClient.

Execute the nsclient++ / start startup service in cmd, and notice that the directory is c:\ NSClient++-0.2.7

Then a yellow M icon appears in the system tray in the lower right corner of the desktop.

View Servic

It has been activated normally.

Note that the default setting of the service is "automatic", that is, it starts automatically.

Execute netstat-an in cmd to see port 12489 that has started listening on tcp.

So it can be accessed from the outside?

Wrong!

The firewall should also open port 12489 of tcp, otherwise nagios will report an error when checking this service.

In this way, the configuration of the monitored machine is done, it waits for nagios to send a monitoring request, and then it executes the request to send the monitoring results back to the nagios monitoring host.

Previously, the monitoring of Windows hosts has been configured on the monitoring host (Nagios-Server), but the password entry is not set by default in commands.cfg, so modify it and add "- s 123456" as follows:

XML/HTML Code copies content to the clipboard

# 'check_nt' command definition

Define command {

Command_name check_nt

Command_line $USER1 $/ check_nt-H $HOSTADDRESS$-p 12489-s 123456-v $ARG1 $$ARG2 $

}

Now open the Nagios Web monitoring page to view the relevant information.

You can see that there is an error: NSClient-ERROR: PDH Collection thread not running.

Google, is due to the operating system language problems, it seems that NSClient default support of the language is not many, the specific Baidu.

Check the log C:\ NSClient++-0.2.7\ nsclient.log of NSClient with the following information:

2013-02-02 22:05:30: error:.\ PDHCollector.cpp:98: You need to manually configure performance counters!

Performance counters needs to be configured manually.

Open the C:\ NSClient++-0.2.7\ counters.defs file, copy the "English US" part of the file, paste it to the end of the counters.defs file, and modify Description = "Chinese".

After the modification, restart the NSClient service in mmc.

Then check the log, which is as follows:

It's under normal execution.

Open the Nagios Web monitoring page to view.

Execution succeeded, but the W3SVC service is in Unknown status. To check the information, you need to open the IIS service of Windows.

Open the Control Panel to install.

After the installation, go to the Nagios Web monitoring page to check, all monitoring is normal.

11. Configuration of Nagios mail alarm

11.1 install sendmail components

First of all, to ensure the complete installation of sendmail-related components, we can complete the installation of sendmail using the following command:

# yum install-y sendmail*

Then restart the sendmail service:

# service sendmail restart

Then send a test email to verify the availability of sendmail:

# echo "Hello World" | mail david.tang@bsmart.cn

11.2 configuration of email alarm

We have simply configured the / usr/local/nagios/etc/objects/contacts.cfg file above, and Nagios will send an alarm email to the E-mail address in the configuration file.

11.3 Nagios Notification

PROBLEM

RECOVERY

The installation and configuration of Nagios under Linux is complete.

Here are some additions to the error:

Configure nagios, look up this material for the first time.

There are some mistakes in the document. I hope the stud will be changed, otherwise it will make the novice take a lot of detours. I am,.

Initial configuration, copy the code in the document, there is an error, looking for a long time.

It is found that there is an error in the comment at the end of the statement and the use of # comment, and the comment is changed to';'to be correct.

You want to change the comment character # to';'. Thank you.

The code is as follows:

Define host {

Use linux-server # refers to the attribute information of the host linux-server, and the linux-server host is defined in the templates.cfg file.

Host_name Nagios-Linux # Hostname

Alias Nagios-Linux # Host alias

Address 192.168.1.111 # the monitored host address, which can be an ip or a domain name.

}

# define a host group

Define hostgroup {

Hostgroup_name bsmart-servers # host group name, which can be specified at will.

Alias bsmart servers # Host group alias

Members Nagios-Linux # host group member, where "Nagios-Linux" is the host defined above.

}

Thank you for reading, the above is the content of "installation and configuration of Nagios under Linux". After the study of this article, I believe you have a deeper understanding of the installation and configuration of Nagios under Linux, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report