Nagios: installation and configuration

Source: Internet
Author: User

Nagios: installation and configuration

Unix/linux monitoring software


Nagios

Nagios is an open-source free network monitoring tool that can effectively monitor the status of Windows, Linux, and Unix hosts, vswitches, routers, and other network settings,

Printers, etc.


Cacti

Cacti is a set of graphic analysis tools for network traffic monitoring developed based on PHP, MySQL, SNMP, and RRDTool.


Zabix

Zabbix?Bix) is an enterprise-level open source solution that provides distributed system monitoring and network monitoring functions based on the WEB interface.


######################################## #####################

Install and configure nagios

Zlib, libpng, ligjpeg, gd, php, apache (httpd)/nginx must be installed.


Installation:

Nagios-core

Nagios-plugins

Nagios-frontends (Monitoring clients with different themes)

Nagios-addons (including nrpe and nsclient ++)

Nrpe: Remote Control on linux/unix

Nsclient ++: Remote Control client on windows


----------------------------------------------

Install nagios-core


Create a nagios user and group and modify permissions at the same time

Groupadd nagios

Useradd-s/bin/false-g nagios

Useradd-s/bin/false-g nagios nagioscmd

./Configure -- with-command-user = nagioscmd

Install to/usr/local/Nagios/

Make devclean

./Configure -- with-gd-lib =/usr/lib -- with-gd-inc =/usr/include/-- with-command-user = nagioscmd

Make all

Make install

Make install-init

Make install-commandmode

Make install-config

--------------------------------------------

Install the nagios-plugin plug-in:


Nagios itself cannot monitor the system information of the local machine. You need to install this plug-in:

Compile and install the nagios plugin nagios-plugins.

Plug-ins in/usr/local/Nagios/libexec/

./Configure

Make

Make install


######################################## #####################

After nagios configuration is complete, you need to configure apache:


Generate password:

Sudohtpasswd-c/usr/local/nagios/etc/htpasswd. users nagiosadmin


This can be used in the httpd. conf file:

CdNagios-XXX

Makeinstall-webconf


Modify the following configuration file:

/Etc/apache2/apache2.conf or/usr/local/conf/httpd. conf


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

<Directory "/usr/local/nagios/sbin">

Options ExecCGI

Order allow, deny

Allow from all

AuthName "Nagios Access"

AuthType Basic

AuthUserFile/usr/local/nagios/etc/htpasswd. users

Require valid-user

</Directory>


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

<Directory "/usr/local/nagios/share">

Options None

AllowOverride None

Order allow, deny

Allow from all

AuthName "Nagios Access"

AuthType Basic

AuthUserFile/usr/local/nagios/etc/htpasswd. users

Require valid-user

</Directory>


After configuration, You need to reload apache2:

Sudo service apache2 reload


Check nagios Configuration:

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


Start nagios:

Sudoservice Nagios start


Test on the web page:

Http: // localhost/nagios/

Enter nagiosadmin and password


######################################## #####################

Nagios can only monitor the system information of the Local Machine (cpu, disk, memory, etc.), and uses nrpe for remote monitoring.


Nrpe is divided into two parts:

Check_nrpe, running on the monitoring host

NRPE daemon runs on the monitored host.


++

To be monitored (remote machines), you need to install the following content ):


Add a nagios User:

Useradd-s/sbin/nologin nagios

Passwd nagios


Install the nagios Plugin:

./Configure

Make

Make install


Modify directory permissions:

Chown-R nagios: nagios/usr/local/nagios


Install nrpe deamon:

./Configure

Make all

Make install-daemon

Make install-daemon-config


-----------------------------------

Install and Configure xinetd (the default system has been installed ):

Make install-xinetd


Configure the/etc/xinetd. d/nrpe file to add the monitoring host ip Address:

Only_from = ip address # Add the address of the monitoring host here.


Add the nrpe service to the/etc/services file:

Nrpe 5666/tcp # nrpe


Restart xinetd:

Service xinetd restart


The returned nrpe version number is correct:

/Usr/local/nagios/libexec/check_nrpe-H localhost


-----------------------------------

Configure the/usr/local/nagios/etc/nrpe. cfg file for nrpe:

This file checks the user, cpu load, hda1 capacity, zombie process, and total process.

Check_users, check_load, check_hda1, check_zombie_procs, and check_total_procs.

Information about swap to be added:

Command [check_swap] =/usr/local/nagios/libexec/check_swap-w 20%-c 10%


++

To monitor remote machine system information, you need to install check_nrpe on the monitoring machine:


Install check_nrpe:

./Configure

Makeall

Makeinstall-plugin


If the nrpedaemon of the monitored machine is installed, the version information returned by the test is correct:

/Usr/local/Nagios/libexec/check_nrpe-H remote_ip


Add check_nrpe in/usr/local/nagios/etc/objects/commands. cfg:

Define command {

Command_name check_nrpe

Command_line/usr/local/nagios/libexec/check_nrpe-H $ HOSTADDRESS $-c $ ARG1 $ # You can also replace the path with $ USER1 $.


Add five monitoring services in/usr/local/nagios/etc/objects/services. cfg:

Define service {

Host_name ip # Add the ip address of the remote machine, which must be defined in hosts. cfg

Service_description service-name # service name

Check_command check_nrpe \

! Check_users/check_load/check_hda1/check_zombie_procs/check_total_procs/check_swap # define these services in the same way.

}


Restart nagios to monitor remote unix/linux machines.


######################################## #####################

The following three methods are available for nagios to monitor remote windows machines:

Nrpe

Check_NT

NSCP (NSClient ++) (use this now)


Nrpe is divided into two parts:

1. Check_nrpe, running on the monitoring host

2. NRPE daemon runs on the monitored host.


Check_NT:

This plug-in is the simplest. You only need to install it on the monitoring machine and connect to the remote machine through the network protocol.

++

Install NSCP on the monitored windows machine:


In cmd:

Cd C: \ NSClient

Nsclient ++/install

Nsclient ++ SysTray


Open service. msc to check whether the nsclient has been started.

Service. msc-> NSClientpp-> login-> allow services to interact with the Desktop


Modify the configuration file C: \ NSClient \ NSC. ini:

Remove the comments before all modules in the [modules] section except CheckWMI. dlland RemoteConfiguration. dll.

In the [Settings] section, set the 'Password' option to set the password, which is required when nagios is connected. This step is optional and is convenient for me.

Skip it. Do not use a password.

Remove the comment of the 'allowed _ hosts' option in the [Settings] section, and add the IP address of the monitoring host running nagios. I will change it to the following

Example: allowed_hosts = 127.0.0.1/32,192.168 .0.111 is separated by commas (,). This field supports subnets. If it is written as 192.168.0.0/24, it indicates that

Can be accessed by all hosts. If this field is blank, all hosts can be connected. Note that [Settings] is part of [NSClient].

This option is also available in some cases.

Ensure that the 'Port' option of [NSClient] is not commented out and its value is '123456'. This is the default listening port of NSClient.


Restart:

Nsclient ++/start


Add a port to the firewall:

Windows Firewall-> enable

Windows Firewall-> exception-> Add port-> NSClient ++ 12489


++

Install and configure NSCP on the monitoring machine:

1. check_nt has been installed by default


2. Define commands

Define command {

Command_name check_nt

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

}


Test NSClient:

/Usr/local/Nagios/libexec/check_nt-H remote_ip-p 12489-v CLIENTVERSION


Test the connectivity of a windows Server:

/Usr/local/nagios/libexec/check_ping-H remote_ip-p 12489-s password-w 200.0, 20%-c 500.0, 60%


Add five monitoring services to the Monitoring Project/usr/local/Nagios/etc/objects/services. cfg:

Define service {

Host_name ip # Add the ip address of the remote machine, which must be defined in hosts. cfg

Service_description service-name # service name

Check_command check_nt \

! UPTIME \ CPULOAD \ MEMUSE \ USEDDISKSPACE \ SERVICESTATE \ PROCSTATE # define these services in the same way.

}


Restart nagios to monitor remote windows machines.


######################################## #####################


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.