Installation and configuration of Nagios monitoring linux+windows under Linux

Source: Internet
Author: User
Tags chmod gettext locale openssl require time interval ssh centos


Introduction of Nagios



Nagios is an open source computer system and network monitoring tool, can effectively monitor Windows, Linux and UNIX host State, switch routers and other network settings, printers and so on. When the system or service status is abnormal, send an email or SMS alert the first time to notify the site operators, in the state of recovery after the normal mail or SMS notification.



Nagios formerly known as Netsaint, by Ethan Galstad development and maintenance to date. Nagios is an abbreviated form: "Nagios Ain ' t gonna insist on sainthood" sainthood translates as saints, while "Agios" is the Greek representation of "saint". Nagios was developed under Linux, but also worked 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), also includes Windows host (using nsclient++ plugin)
• You can specify the plugin you write to monitor any situation (temperature, warning ...) by  over the network. )
• Remote execution of scripts can be performed by configuring Nagios remote execution Plug-ins
• Remote monitoring to support SSH or SSL plus channel mode 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.)
• Parallel service Checking
• The ability to define the hierarchy of network hosts, allowing for a step-by-step check, starting from the parent host
• Notify by email, pager, SMS or any user-defined plugin when there is a problem with the service or host
• Ability to customize event-handling mechanisms to reactivate problematic services or hosts
• Automatic log loops
• Support for redundant monitoring
• Includes web interface to view current network status, notifications, problem histories, log files, etc.



Second, Nagios working principle



Nagios's function is to monitor the service and host, but he does not include this part of the function, all monitoring, detection functions are through a variety of plug-ins to complete.



Start Nagios, it will periodically automatically invoke the plug-in to detect the server state, while Nagios will maintain a queue, all plug-ins returned to the status of information are entered the queue, Nagios each time from the beginning of the team to read information, and processing, the status results through the Web display.



Nagios provides a number of plug-ins that make it easy to monitor many service states. After the installation is complete, in the Nagios home directory in the/libexec in the Nagios can use all the plug-ins, such as Check_disk is to check the disk space plug-ins, check_load check the CPU load, and so on. Each plug-in can view its usage and functionality by running./check_xxx–h.



Nagios can identify 4 state return information, i.e.
0 (OK) indicates that the status is normal/green,
1 (WARNING) indicates a warning/yellow,
2 (CRITICAL) indicates a very serious error/red,
3 (UNKNOWN) indicates an unknown error/dark yellow. Nagios based on the value returned by the plug-in to determine the status of the monitoring object, and through the web display, for the administrator to find fault in time.



Four kinds of monitoring states:



Status Code Color
Normal OK Green
Warning WARNING Yellow
Severe CRITICAL Red
Unknown error unkown Dark Yellow
Besides the alarm function, if the monitoring system found that the problem can not be reported to the police that there is no sense, so the alarm is also a very important function of Nagios. However, similarly, Nagios itself does not have the alarm part of the code, not 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, Nagios software package installation. It is the framework of the monitoring system and the basis of all monitoring.



Open Nagios Official documents, you will find that Nagios basically do not have any dependencies, only the system is a Linux or other Nagios supported systems. But if you don't have Apache (HTTP service), then you don't have an intuitive interface to view the monitoring information, so Apache is a prerequisite. On the installation of Apache, there are many online, just follow the installation. Check to see if you can work properly after installation.



Knowing how Nagios manages the server object through Plug-ins, it's time to start studying how it manages remote server objects. The Nagios system provides a plug-in Nrpe. Nagios runs it periodically to obtain various state information for the remote server. The relationship between them is shown in the following illustration:






Nagios through Nrpe to remote management services



1. Nagios executes the Check_nrpe plugin installed inside it and tells Check_nrpe what services to check.
2. Connect the Nrpe daemon on the remote machine via Ssl,check_nrpe
3. NRPE runs a variety of local plug-ins to detect local services and statuses (Check_disk,.. etc
4. Finally, NRPE the results to the host-side Check_nrpe,check_nrpe and sends the results to the Nagios status queue.
5. Nagios sequentially reads the information in the queue, and then displays the results.



Third, experimental environment
-------------------------------------------------------------------------------- --
Host name    |       SYSCTM os          |     ip     |      Software
----------------------------------------------------------------------------------
nagios-server  CentOS Release 6.3 (Final) 192.168.10.11 Apache or Nginx, PHP, Nagios, Nagios-plugins
nagios-linux   CentOS Release 5.8 (Final) 192.168.10.12 nagios-plugins, Nrpe
nagios-windows Windows server2003          192.168.10.13 NSCP
----------------------------------------------------------------- -----------------



The Server installs the Nagios software, handles the monitored data, and provides Web interface viewing and management. Of course, you can also monitor the information on the machine itself.
Client installed Nrpe and other clients, according to the monitoring machine request to perform monitoring, and then back to the monitoring machine results.
The firewall is closed/iptables:firewall is not running.
Selinux=disabled



Iv. objective of the experiment






V. Nagios-server SERVICE-side installation



5.1 Base Support Kit: GCC glibc glibc-common gd gd-devel xinetd openssl-devel



[Root@nagios-server/]# rpm-q gcc glibc glibc-common gd gd-devel xinetd openssl-devel
If these kits are not available on the system, use the Yum installation



[Root@nagios-server/]# yum install-y gcc glibc glibc-common gd gd-devel xinetd



5.2 Creating Nagios users and user groups
[Root@nagios-server/]# useradd-s/sbin/nologin Nagios
[Root@nagios-server/]# Mkdir/usr/local/nagios
[Root@nagios-server/]# chown-r Nagios.nagios/usr/local/nagios



5.3 Compile and install Nagios
Nagios official website
Http://www.nagios.org/download
[Root@nagios-server src]# wget http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-4.0.2.tar.gz
[Root@nagios-server src]# tar zxvf nagios-4.0.2.tar.gz
[Root@nagios-server src]# CD nagios-4.0.2
[Root@nagios-server nagios-4.0.2]#./configure--prefix=/usr/local/nagios



Creating sample config files in sample-config/...



Configuration Summary for Nagios 4.0.2 11-25-2013 * * *:



General Options:
-------------------------
Nagios Executable:nagios
Nagios User/group:nagios,nagios
Command User/group:nagios,nagios
Event Broker:yes
Install ${prefix}:/usr/local/nagios
Install ${includedir}:/usr/local/nagios/include/nagios
Lock File: ${prefix}/var/nagios.lock
Check Result directory: ${prefix}/var/spool/checkresults
Init Directory:/ETC/RC.D/INIT.D
Apache CONF.D Directory:/ETC/HTTPD/CONF.D
Mail Program:/bin/mail
Host Os:linux-gnu
Iobroker Method:epoll



Web Interface Options:
------------------------
HTML url:http://localhost/nagios/
CGI url:http://localhost/nagios/cgi-bin/
Traceroute (used by WAP):/bin/traceroute



Review the options above for accuracy. If They look okay,
Type ' make all ' to compile the main program and CGIs.



[Root@nagios-server nagios-4.0.2]# make all



Compile Finished * * *



If the main program and CGIs compiled without any errors, you
Can continue with installing Nagios as follows (type ' make '
Without any arguments for a list of all possible options):



Make install
-This installs is the main program, CGIs, and HTML files



Make Install-init
-This installs the Init script IN/ETC/RC.D/INIT.D



Make Install-commandmode
-This installs and configures permissions on the
Directory for holding the external command file



Make Install-config
-This installs *sample* config files in/usr/local/nagios/etc
You'll have to modify this sample files before you can
Use Nagios. Read the HTML documentation for more info
On doing this. Pay particular attention to the docs on
Object configuration files, as they determine what/how
Things get monitored!



Make install-webconf
-This installs the Apache config file for the Nagios
Web interface



Make Install-exfoliation
-This installs the exfoliation theme for the Nagios
Web interface



Make Install-classicui
-This installs the classic theme for the Nagios
Web interface



Support Notes *******************************************



If you have questions about configuring or running Nagios,
Please make sure so you:



-Look at the sample config files
-Read the documentation on the Nagios Library at:



Http://library.nagios.com



Before you post a question to one of the mailing lists.
Also make sure to include pertinent information that could
Help others. This might include:



-What version of Nagios you are using
-What version of the plugins you are using
-Relevant snippets from your config files
-Relevant error messages from the Nagios log file



For more information on obtaining support for Nagios, visit:



Http://support.nagios.com



*************************************************************



Enjoy.



[Root@nagios-server nagios-4.0.2]# make install



Exfoliation Theme Installed * * *
Note:use ' make install-classicui ' to revert to classic Nagios theme



MAKE[1]: Leaving directory '/usr/local/src/nagios-4.0.2 '
Make Install-basic
MAKE[1]: Entering directory '/usr/local/src/nagios-4.0.2 '
/usr/bin/install-c-M 775-o nagios-g nagios-d/usr/local/nagios/libexec
/usr/bin/install-c-M 775-o nagios-g nagios-d/usr/local/nagios/var
/usr/bin/install-c-M 775-o nagios-g nagios-d/usr/local/nagios/var/archives
/usr/bin/install-c-M 775-o nagios-g nagios-d/usr/local/nagios/var/spool/checkresults



Main program, CGIs and HTML files installed * * *



Can continue with installing Nagios as follows (type ' make '
Without any arguments for a list of all possible options):



Make Install-init
-This installs the Init script IN/ETC/RC.D/INIT.D



Make Install-commandmode
-This installs and configures permissions on the
Directory for holding the external command file



Make Install-config
-This installs sample config files in/usr/local/nagios/etc



MAKE[1]: Leaving directory '/usr/local/src/nagios-4.0.2 '



[Root@nagios-server nagios-4.0.2]# make Install-init



/usr/bin/install-c-M 755-d-o root-g root/etc/rc.d/init.d
/usr/bin/install-c-M 755-o root-g root Daemon-init/etc/rc.d/init.d/nagios



Init Script Installed * * *



[Root@nagios-server nagios-4.0.2]# make Install-commandmode



/usr/bin/install-c-M 775-o nagios-g nagios-d/USR/LOCAL/NAGIOS/VAR/RW
chmod G+S/USR/LOCAL/NAGIOS/VAR/RW



External Command Directory configured * * *



[Root@nagios-server nagios-4.0.2]# make Install-config


/usr/bin/install-c-M 775-o nagios-g nagios-d/usr/local/nagios/etc


/usr/bin/install-c-M 775-o nagios-g nagios-d/usr/local/nagios/etc/objects


/usr/bin/install-c-b-m 664-o nagios-g nagios sample-config/nagios.cfg/usr/local/nagios/etc/nagios.cfg


/usr/bin/install-c-b-m 664-o nagios-g nagios sample-config/cgi.cfg/usr/local/nagios/etc/cgi.cfg


/usr/bin/install-c-b-m 660-o nagios-g nagios sample-config/resource.cfg/usr/local/nagios/etc/resource.cfg


/usr/bin/install-c-b-m 664-o nagios-g nagios sample-config/template-object/templates.cfg/usr/local/nagios/etc/ Objects/templates.cfg


/usr/bin/install-c-b-m 664-o nagios-g nagios sample-config/template-object/commands.cfg/usr/local/nagios/etc/ Objects/commands.cfg


/usr/bin/install-c-b-m 664-o nagios-g nagios sample-config/template-object/contacts.cfg/usr/local/nagios/etc/ Objects/contacts.cfg


/usr/bin/install-c-b-m 664-o nagios-g nagios sample-config/template-object/timeperiods.cfg/usr/local/nagios/etc/ Objects/timeperiods.cfg


/usr/bin/install-c-b-m 664-o nagios-g nagios sample-config/template-object/localhost.cfg/usr/local/nagios/etc/ Objects/localhost.cfg


/usr/bin/install-c-b-m 664-o nagios-g nagios sample-config/template-object/windows.cfg/usr/local/nagios/etc/ Objects/windows.cfg


/usr/bin/install-c-b-m 664-o nagios-g nagios sample-config/template-object/printer.cfg/usr/local/nagios/etc/ Objects/printer.cfg


/usr/bin/install-c-b-m 664-o nagios-g nagios sample-config/template-object/switch.cfg/usr/local/nagios/etc/objects /switch.cfg


Config Files Installed * * *



Remember, these are *sample* config files. ' ll need to read
The documentation for more information on how to actually define
Services, hosts, etc. to fit your particular needs.



[Root@nagios-server nagios-4.0.2]# chkconfig--add Nagios
[Root@nagios-server nagios-4.0.2]# chkconfig--level Nagios on
[Root@nagios-server nagios-4.0.2]# chkconfig--list Nagios



5.4 Verify that the program is properly installed



Switch directories to the installation path (here is/usr/local/nagios), see if there are etc, bin, sbin, share, VAR, five directories, if the presence of the program is properly installed to the system. Nagios Each directory uses the following description:



Bin----> Nagios executable program directory
etc----> Nagios Config file directory
Sbin----> Nagios CGI Files directory, which is the directory where the files needed to execute the external command
Share----> Nagios the directory where the Web page files are located
Libexec----> Nagios External Plugins directory
var----> Nagios log files, lock files, and so on
var/archives----> Nagios Log Automatic archive directory
VAR/RW----> directory for storing external command files



5.5 Installing Nagios Plugin
[Root@nagios-server nagios-4.0.2]# CD/USR/LOCAL/SRC
[Root@nagios-server src]# wget http://assets.nagios.com/downloads/nagiosplugins/nagios-plugins-1.5.tar.gz
[Root@nagios-server src]# tar zxvf nagios-plugins-1.5.tar.gz
[Root@nagios-server src]# CD nagios-plugins-1.5
[Root@nagios-server nagios-plugins-1.5]#./configure--prefix=/usr/local/nagios


Configure:creating./config.status


Config.status:creating Gl/makefile


Config.status:creating Nagios-plugins.spec


Config.status:creating Makefile


Config.status:creating Tap/makefile


Config.status:creating Lib/makefile


Config.status:creating Plugins/makefile


Config.status:creating Lib/tests/makefile


Config.status:creating Plugins-root/makefile


Config.status:creating Plugins-scripts/makefile


Config.status:creating Plugins-scripts/subst


Config.status:creating plugins-scripts/utils.pm


Config.status:creating plugins-scripts/utils.sh


Config.status:creating Perlmods/makefile


Config.status:creating test.pl


Config.status:creating Pkg/solaris/pkginfo


Config.status:creating po/makefile.in


Config.status:creating config.h


config.status:executing depfiles Commands


config.status:executing Libtool Commands


config.status:executing po-directories Commands


Config.status:creating Po/potfiles


Config.status:creating Po/makefile


--with-apt-get-command:


--with-ping6-command:/bin/ping6-n-u-w%d-c%d%s


--with-ping-command:/bin/ping-n-u-w%d-c%d%s


--with-ipv6:yes


--with-mysql:/usr/local/mysql/bin/mysql_config


--with-openssl:yes


--with-gnutls:no


--enable-extra-opts:no


--with-perl:/usr/bin/perl


--enable-perl-modules:no


--with-cgiurl:/nagios/cgi-bin


--with-trusted-path:/bin:/sbin:/usr/bin:/usr/sbin


--enable-libtap:no


[Root@nagios-server nagios-plugins-1.5]# make && make install

MAKE[2]: Nothing is done for ' install-data-am '.


MAKE[2]: Leaving directory '/usr/local/src/nagios-plugins-1.5/plugins-scripts '


MAKE[1]: Leaving directory '/usr/local/src/nagios-plugins-1.5/plugins-scripts '


Making install in Plugins-root


MAKE[1]: Entering directory '/usr/local/src/nagios-plugins-1.5/plugins-root '


MAKE[2]: Entering directory '/usr/local/src/nagios-plugins-1.5/plugins-root '


/usr/bin/install-c CHECK_DHCP/USR/LOCAL/NAGIOS/LIBEXEC/CHECK_DHCP


Chown ROOT/USR/LOCAL/NAGIOS/LIBEXEC/CHECK_DHCP


chmod ug=rx,u+s/usr/local/nagios/libexec/check_dhcp


/usr/bin/install-c check_icmp/usr/local/nagios/libexec/check_icmp


Chown root/usr/local/nagios/libexec/check_icmp


chmod ug=rx,u+s/usr/local/nagios/libexec/check_icmp


MAKE[2]: Nothing is done for ' install-data-am '.


MAKE[2]: Leaving directory '/usr/local/src/nagios-plugins-1.5/plugins-root '


MAKE[1]: Leaving directory '/usr/local/src/nagios-plugins-1.5/plugins-root '


Making Install in PO


MAKE[1]: Entering directory '/usr/local/src/nagios-plugins-1.5/po '


/bin/mkdir-p/usr/local/nagios/share


Installing Fr.gmo As/usr/local/nagios/share/locale/fr/lc_messages/nagios-plugins.mo


Installing De.gmo As/usr/local/nagios/share/locale/de/lc_messages/nagios-plugins.mo


if test "nagios-plugins" = "gettext-tools"; Then


/bin/mkdir-p/usr/local/nagios/share/gettext/po;


For file in Makefile.in.in Remove-potcdate.sin makevars.template; Todo


/usr/bin/install-c-M 644./$file


/usr/local/nagios/share/gettext/po/$file;


Done


for file in Makevars; Todo


Rm-f/usr/local/nagios/share/gettext/po/$file;


Done


Else


: ;


Fi


MAKE[1]: Leaving directory '/usr/local/src/nagios-plugins-1.5/po '


MAKE[1]: Entering directory '/usr/local/src/nagios-plugins-1.5 '


MAKE[2]: Entering directory '/usr/local/src/nagios-plugins-1.5 '


MAKE[2]: Nothing is done for ' install-exec-am '.


MAKE[2]: Nothing is done for ' install-data-am '.


MAKE[2]: Leaving directory '/usr/local/src/nagios-plugins-1.5 '


MAKE[1]: Leaving directory '/usr/local/src/nagios-plugins-1.5


5.6 Installing the Web Environment (Apache Nginx) and PHP


Omitted here can refer to


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


CentOS 6.2 Compile and install nginx1.2.6+mysql5.5.28+php5.3.20


Http://blog.rekfan.com/articles/141.html


Nginx support for Perl, Java installation and configuration
Http://blog.rekfan.com/articles/393.html
------------------------------------------------------------------------
Apache configuration file httpd.conf:


#setting for Nagios


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


<directory "/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 this directory access authentication


Require Valid-user


</Directory>


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


<directory "/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


</Directory>


Nginx configuration file rekfan_nagios.conf:

server {


Listen 80;


server_name nagios.rekfan.com;


#charset Koi8-r;


#access_log Logs/host.access.log Main;





Location/{


Root/usr/local/nagios/share;


Index index.html index.htm index.shtml index.php;


}





Error_page 404/404.html;





Location/nagios {


Alias/usr/local/nagios/share;


}





location/cgi-bin/images {


Alias/usr/local/nagios/share/images;


}





location/cgi-bin/stylesheets {


Alias/usr/local/nagios/share/stylesheets;


}





Location/cgi-bin {


Alias/usr/local/nagios/sbin;


}





Location ~. php$ {


Root/usr/local/nagios/share;


Fastcgi_pass 127.0.0.1:9000;


Fastcgi_index index.php;


Fastcgi_param script_filename $document _root$fastcgi_script_name;


Include Fastcgi_params;


}





Location ~. (CGI|PL)? $ {


Root/usr/local/nagios/sbin;


Rewrite ^/nagios/cgi-bin/(. *). CGI/$1.cgi break;


Fastcgi_pass Unix:/usr/local/nginx/logs/nginx-fcgi.sock;


Fastcgi_index index.cgi;


Fastcgi_param script_filename $document _root$fastcgi_script_name;


Include Fastcgi_params;


}


}


Vi. configuration Nagios [Nagios-server]


Nagios is mainly used to monitor one or more local hosts and remote information, including native resources and external services. The default Nagios configuration does not have any monitoring content, just some template files. For Nagios to provide services, you must modify the configuration file to increase the hosts and services to monitor, as described in detail below.



6.1 Introduction to the default profile


Nagios The default profile is in the/USR/LOCAL/NAGIOS/ETC directory after the installation is complete.


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


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


File name or directory name | Use


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


CGI.CFG control of CGI access configuration files


Nagios.cfg Nagios Master configuration file


Resource.cfg variable definition files, also known as resource files, define variables in some files to be referenced by other profiles, such as $user1$


Objects objects is a directory in which there are many profile templates that define Nagios objects


The OBJECTS/COMMANDS.CFG command defines a configuration file in which the commands defined can be referenced by other profiles


Objects/contacts.cfg define profiles for contacts and contact groups


OBJECTS/LOCALHOST.CFG defines the configuration file that monitors the local host


Objects/printer.cfg defines a profile template for monitoring a printer, and does not enable this file by default


OBJECTS/SWITCH.CFG defines a configuration file template for the monitoring router, and this file is not enabled by default


Objects/templates.cfg defines a template configuration file for hosts and services that can be referenced in other configuration files


OBJECTS/TIMEPERIODS.CFG defines the configuration file for Nagios monitoring time period


OBJECTS/WINDOWS.CFG Monitor a profile template for the Windows host, and the file is not enabled by default


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


6.2 Relationship between profiles


Several definitions involved in Nagios configuration include: Host, main group, service, service group, contact person, contact Group, monitor time, monitor command, etc., from these definitions, we can see that nagios each configuration file is interrelated and referenced each other.



Successfully configured a Nagios monitoring system, you have to understand the dependencies between each profile and dependent relationship, the most important four points:



First: Define which hosts, host groups, services, and services are monitored;
Second: Define what command to use to achieve this monitoring;
Third: Define the time period of monitoring;
Four: Define the contact and contact groups to notify when a host or service problem occurs.



6.3 Configuration Nagios



In order to clarify the problem more clearly, and for ease of maintenance, it is recommended that you create separate profiles for each of the Nagios defined objects:
• Create hosts.cfg files to define hosts and host group
• Create services.cfg files to define Services
• Define contacts and contact groups with the default Contacts.cfg file
• Use the default Commands.cfg file to define commands
• Define the monitoring time period with the default Timeperiods.cfg
• Use the default Templates.cfg file as a resource reference file



A. Templates.cfg document



Nagios is mainly used for monitoring host resources and services, called objects in Nagios configuration, in order to not have to repeatedly define some monitoring objects, Nagios introduced a template configuration file, some common properties defined as templates for multiple references. This is the role of templates.cfg.
The following details the meaning of each parameter in the following templates.cfg file:



Expand source
B. resource.cfg Documents



Resource.cfg is a Nagios variable definition file with only one row for the file content:




$USER 1$=/usr/local/nagios/libexec
Where the variable $user1$ specifies the path to install the Nagios plug-in, if the plug-in is installed in other paths, just 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 Document



This file exists by default, and can be used without modification, but if new commands need to be added, this file is added.



Expand source
D. hosts.cfg Documents



This file does not exist by default and needs to be created manually, HOSTS.CFG is primarily used to specify the host address to be monitored and related attribute information, which is configured according to the experimental target:





Define Host{


Use Linux-server #引用主机linux-server property information, linux-server the host is defined in Templates.cfg file.


HOST_NAME Nagios-linux #主机名


Alias Nagios-linux #主机别名


Address 192.168.10.12 #被监控的主机地址, this can be IP, can also be a domain name.


}


#定义一个主机组


Define Hostgroup{


The Hostgroup_name bsmart-servers #主机组名称 and can be specified arbitrarily.


Alias Bsmart servers #主机组别名


Members Nagios-linux #主机组成员, where "Nagios-linux" is the host defined above.


}


Note: The localhost.cfg and windows.cfg are the default configuration files under/usr/local/nagios/etc/objects, and localhost.cfg files define the monitoring host itself, windows.cfg A file is a definition of a Windows host, including the definition of host and related services. So in this experiment, the monitoring host (nagios-server) is defined directly in the Localhost.cfg, and the Windows host (nagios-windows) is defined in Windows.cfg. According to their own needs to modify the relevant configuration, in detail as follows:


Localhost.cfg





Define Host{


Use Linux-server; Name of host template to use


; This host definition would 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 check_ping!100.0,20%!500.0,60%


}


Define Service{


Use Local-service; Name of service template to use


HOST_NAME Nagios-server


Service_description Root Partition


Check_command check_local_disk!20%!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





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.10.13; 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_nt! Cpuload!-l 5,80,90


}


Define Service{


Use Generic-service


HOST_NAME nagios-windows


Service_description Memory Usage


Check_command check_nt! Memuse!-w 80-C 90


}


Define Service{


Use Generic-service


HOST_NAME nagios-windows


Service_description c:drive Space


Check_command check_nt! Useddiskspace!-l C-w 80-c 90


}


Define Service{


Use Generic-service


HOST_NAME nagios-windows


Service_description w3svc


Check_command check_nt! servicestate!-d showall-l W3SVC


}


Define Service{


Use Generic-service


HOST_NAME nagios-windows


Service_description Explorer


Check_command check_nt! procstate!-d showall-l Explorer.exe


}


E. services.cfg Documents

This file does not exist by default and needs to be created manually, services.cfg files are primarily used to define monitored 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 are already defined in the corresponding configuration file, so just define the Nagios-linux-related services here, just define a service to detect if it is alive to verify the correctness of the configuration file. The definition of other services will be described later.





Define Contact{


Contact_Name David #联系人的名称, there's no space in this place.


Use Generic-contact #引用generic-contact property information, where "generic-contact" is defined in Templates.cfg file


Alias Nagios Admin


Email david.tang@bsmart.cn


}





Define Contactgroup{


Contactgroup_name TS #联系人组的名称, same cannot be blank


Alias Technical Support #联系人组描述


Members of David #联系人组成员, where "David" is the contact defined above, if more than one contact is separated by a comma


}


G. Timeperiods.cfg documents


This file is used to define the time period for monitoring, and the following is a well configured instance:





#下面是定义一个名为24x7的时间段, that is, monitoring all time periods


Define Timeperiod{


Timeperiod_name 24x7 #时间段的名称, there's no space in this place.


Alias 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


}


#下面是定义一个名为workhours的时间段, that is, the working time 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 Document


This file is used to control related CGI scripts, and if you want to execute CGI scripts on the Nagios Web monitoring interface, such as restarting the Nagios process, turning off Nagios notifications, stopping Nagios host detection, and so on, you need to configure CGI.CFG files.
Because Nagios's web monitoring interface validates that the user is David, you can simply add this user's execute permission to the Cgi.cfg file, and the configuration information that needs to be modified 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 documents



Nagios.cfg The default path is/usr/local/nagios/etc/ Nagios.cfg, is the Nagios core configuration file, all object configuration files must be defined in this file to play its role, where the object configuration file can only be referenced in the Nagios.cfg file.





Log_file=/usr/local/nagios/var/nagios.log # Defines the path of 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, and if there are more object profiles, add it 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 configuration file


CFG_FILE=/USR/LOCAL/NAGIOS/ETC/OBJECTS/WINDOWS.CFG # Windows Host configuration file


Object_cache_file=/usr/local/nagios/var/objects.cache # This variable is used to specify a copy file for all object profiles, or an object buffer file


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 you can define multiple resource files in Nagios.cfg.


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


STATUS_UPDATE_INTERVAL=10 # This variable is used to define the update interval for the state file (that is, Status.dat), in seconds, and the minimum update interval is 1 seconds.


Nagios_user=nagios # This variable specifies which user to run the Nagios process with.


Nagios_group=nagios # This variable is used to specify which user group the Nagios uses to run.


Check_external_commands=1 # This variable is used to set whether to allow Nagios to run CGI commands in the Web monitor interface;


# that is, whether to allow Nagios in the Web interface to perform restart Nagios, stop the host/service check, and other operations;


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


Command_check_interval=10s # This variable is used to set the time interval for nagios detection of an external command if a number is specified plus an "s" (e.g. 10s);


# then the interval of the external detection command is the time interval of this number in seconds;


# if "s" is not used, then the interval of the external Instrumentation command is at the time interval of the value "Time unit".


INTERVAL_LENGTH=60 # This variable specifies the time unit of the Nagios, and the default value is 60 seconds, which is 1 minutes;


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


6.4 Verifying the correctness of the Nagios configuration file


Nagios to verify the configuration file in the very place, only one command to complete:



[Root@nagios-server/]#/usr/local/nagios/bin/nagios-v/usr/local/nagios/etc/nagios.cfg



Nagios Core 4.0.2
Copyright (c) 2009-present Nagios Core Development team and Community Contributors
Copyright (c) 1999-2009 Ethan Galstad
Last modified:11-25-2013
License:gpl



website:http://www.nagios.org
Reading Configuration data ...
Read main config file okay ...
Read object config files okay ...



Running pre-flight check on configuration data ...



Checking objects ...
Checked Services.
Checked 2 hosts.
Checked 2 host groups.
Checked 0 service groups.
Checked 1 Contacts.
Checked 1 Contact groups.
Checked commands.
Checked 5 time periods.
Checked 0 Host Escalations.
Checked 0 Service Escalations.
Checking for circular paths ...
Checked 2 Hosts
Checked 0 Service dependencies
Checked 0 Host Dependencies
Checked 5 Timeperiods
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



Nagios provides this validation feature, which usually prints out the wrong profile and which line in the file, which makes the Nagios configuration very easy, and the alert information is usually negligible because it is generally only recommended.



Seeing the above information indicates that there is no problem, and then start the Nagios service.



Vii. start and stop of Nagios



7.1 Start Nagios



A. Start Nagios with initialization script



[Root@nagios-server/]#/etc/init.d/nagios start
Or
[Root@nagios-server/]# Service Nagios start



B. Manual method to start Nagios



Start the Nagios daemon by using the "-D" parameter of the Nagios command:



[Root@nagios-server/]#/usr/local/nagios/bin/nagios-d/usr/local/nagios/etc/nagios.cfg



7.2 Restart Nagios



The Nagios service needs to be restarted/overloaded when the configuration file is modified to take effect.



A. Restart Nagios by initializing the script



[Root@nagios-server/]#/etc/init.d/nagios Reload
Or
[Root@nagios-server/]#/etc/init.d/nagios Restart
Or
[Root@nagios-server/]# Service Nagios restart



B. Restarting Nagios through the Web monitoring page
You can restart Nagios via the "process Info"-> "Restart the Nagios process" on the Web Monitor page.



C. Manual Smooth Restart
[Root@nagios-server/]# Kill-hup <nagios_pid>



7.3 Stop Nagios



A. Shutting down the Nagios service with initialization scripts



[Root@nagios-server/]#/etc/init.d/nagios Stop
Or
[Root@nagios-server/]# service Nagios stop



B. Stopping Nagios through web monitoring pages
You can stop Nagios by using the "process Info"-> "Shutdown the Nagios process" on the Web Monitor page.



C. Manual way to stop Nagios
[Root@nagios-server/]# Kill <nagios_pid>



Viii. View Initial Configuration



8.1 After the boot completes, log on to the Nagios Web Monitor page http://192.168.10.11/nagios/view the relevant information.
8.2 Click on the left of current Status-> hosts to see that the three hosts defined are all up.
8.3 Click Current Status-> services to view service monitoring.



See Nagios-linux and Nagios-server service status is OK, but Nagios-windows's service status is Critical,status information prompts connection refused. This situation occurs because the plugin is not installed on the nagios-windows and the internal service is not yet viewable. will be explained in detail below.



Using Nrpe to monitor "local information" on remote Linux



The remote Linux host has been monitored for survival, and if the remote machine survives, we can use the Ping tool to monitor it. There are also some remote host services, such as FTP, SSH, HTTP, are open to the service, even if not nagios, we can try to come out, just find a machine to see whether access to these services on the line. But for "local information" like disk capacity, CPU load, Nagios can only monitor its host, but it is a bit powerless for other machines. After all, it is impossible to get this information without the proper permissions of the host being charged. To solve this problem, Nagios has an additional component-"NRPE"-that can be used to monitor the "local information" of the Linux type host.



9.1 NRPE Working principle
The NRPE consists of two parts:
Check_nrpe Plug-in, located on the monitor host
Nrpe Daemon, run on a remote Linux host (usually a monitored machine)






As shown in the above diagram, the entire monitoring process is as follows:



When Nagios needs to monitor a service or resource situation for a remote Linux host:
1.Nagios will run Check_nrpe this plugin and tell it what to check;
The 2.check_nrpe plug-in connects to the remote Nrpe daemon in the form of SSL;
3.NRPE Daemon will run the corresponding Nagios plug-ins to perform the inspection;
4.NRPE Daemon will return the results of the inspection to the Check_nrpe plug-in, the plug-in will be submitted to the Nagios for processing.



Note: NRPE daemon requires Nagios plug-ins to be installed on a remote Linux host, otherwise daemon can not do any monitoring.



9.2 on the monitored machine (nagios-linux)



A. Add User & Set Password
[Root@nagios-client src]# Useradd Nagios
[Root@nagios-client src]# passwd Nagios



B. Installing the Nagios Plugin
[Root@nagios-client src]# tar zxvf nagios-plugins-1.5.tar.gz
[Root@nagios-client src]# CD nagios-plugins-1.5
[Root@nagios-client nagios-plugins-1.5]#./configure--prefix=/usr/local/nagios
[Root@nagios-client nagios-plugins-1.5]# make && make install



After this step is completed, three directory include, Libexec, and share are generated under/usr/local/nagios/.
Modify Directory Permissions
[Root@nagios-client nagios-plugins-1.5]# chown Nagios.nagios/usr/local/nagios
[Root@nagios-client nagios-plugins-1.5]# chown-r nagios.nagios/usr/local/nagios/libexec



C. Installation of Nrpe
[Root@nagios-client nagios-plugins-1.5]# CD/USR/LOCAL/SRC
[Root@nagios-client src]# wget http://sourceforge.net/projects/nagios/files/nrpe-2.x/nrpe-2.15/nrpe-2.15.tar.gz/download
[Root@nagios-client src]# tar zxvf nrpe-2.15.tar.gz
[Root@nagios-client src]# CD nrpe-2.15
[Root@nagios-client nrpe-2.15]#./configure



Configuration Summary for Nrpe 2.15 09-06-2013 * * *:



General Options:
-------------------------
NRPE port:5666
NRPE User:nagios
NRPE Group:nagios
Nagios User:nagios
Nagios Group:nagios



Review the options above for accuracy. If They look okay,
Type ' make all ' to compile the NRPE daemon and client.



[Root@nagios-server nrpe-2.15]# make all



Compile Finished * * *



If the NRPE daemon and client compiled without any errors,
Can continue with the installation or upgrade process.



Read the PDF documentation (NRPE.PDF) for information on the next
Steps you should take to complete the installation or upgrade.



Next, install the Npre plug-in, daemon, and sample configuration files.
C.1 Install Check_nrpe This plugin
[Root@nagios-client nrpe-2.15]# make Install-plugin



CD./src/&& make Install-plugin
MAKE[1]: Entering directory '/USR/LOCAL/SRC/NRPE-2.15/SRC '
/usr/bin/install-c-M 775-o nagios-g nagios-d/usr/local/nagios/libexec
/usr/bin/install-c-M 775-o nagios-g Nagios check_nrpe/usr/local/nagios/libexec
MAKE[1]: Leaving directory '/USR/LOCAL/SRC/NRPE-2.15/SRC '
The monitor needs to install Check_nrpe This plugin, the monitor machine does not need, we install it here only for the purpose of testing.



C.2 Installation Deamon
[Root@nagios-client nrpe-2.15]# make Install-daemon



CD./src/&& make Install-daemon
MAKE[1]: Entering directory '/USR/LOCAL/SRC/NRPE-2.15/SRC '
/usr/bin/install-c-M 775-o nagios-g nagios-d/usr/local/nagios/bin
/usr/bin/install-c-M 775-o nagios-g Nagios Nrpe/usr/local/nagios/bin
MAKE[1]: Leaving directory '/USR/LOCAL/SRC/NRPE-2.15/SRC '
C.3 Installation configuration file
[Root@nagios-client nrpe-2.15]# make Install-daemon-config



/usr/bin/install-c-M 775-o nagios-g nagios-d/usr/local/nagios/etc
/usr/bin/install-c-M 644-o nagios-g Nagios sample-config/nrpe.cfg/usr/local/nagios/etc
[Root@nagios-client nrpe-2.15]#
Now, if you look at the Nagios directory, you'll find 5 directories.
As described in the installation documentation, the Nrpe Deamon is run as a service under XINETD. In this case the XINETD must be installed first, but the general system has been installed by default.



If not installed
[Root@nagios-client nrpe-2.15]# Yum install-y xinetd



D. Installing xinted Scripts
[Root@nagios-client nrpe-2.15]# make install-xinetd



You can see the creation of this file/etc/xinetd.d/nrpe.



Edit this script/etc/xinetd.d/nrpe:
Increase the IP address of the monitoring host after Only_from.
Edit/etc/services file, increase Nrpe service, add a row at the end
Nrpe 5666/tcp # Nrpe



Restart the xinted service
[root@nagios-client nrpe-2.15]# Service xinetd restart
To see if Nrpe has started
[Root@nagios-client nrpe-2.15]# Netstat-an|grep 5666



E. Test Nrpe is otherwise normal work
Use the Check_nrpe installed on the monitor to test that the Nrpe is working properly.
[Root@nagios-client nrpe-2.15]#/usr/local/nagios/libexec/check_nrpe-h localhost
NRPE v2.15
will return the current Nrpe version
That is, it is normal to connect Nrpe daemon locally with Check_nrpe.



Note: In order to work smoothly in the back, note that the local firewall to open 5666 to allow external monitoring machine access.



F. Check_nrpe command usage
View Check_nrpe Command usage
[Root@nagios-client nrpe-2.15]#/usr/local/nagios/libexec/check_nrpe–h
You can see the usage:
Check_nrpe–h monitoring command to be performed by the monitored host-c
Note: The monitor command followed by-C must be defined in the Nrpe.cfg file. That is, Nrpe daemon only runs the commands defined in Nrpe.cfg.



G. View Nrpe's monitoring commands
[Root@nagios-client nrpe-2.15]# Cd/usr/local/nagios/etc
[Root@nagios-client etc]# cat nrpe.cfg |grep-v "^#" |grep-v "^$"
[Root@nagios-client 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
Command[check_users]=/usr/local/nagios/libexec/check_users-w 5-c 10
Command[check_load]=/usr/local/nagios/libexec/check_load-w 15,10,5-c 30,25,20
Command[check_sda1]=/usr/local/nagios/libexec/check_disk-w 20%-C 10%-p/dev/sda1
Command[check_zombie_procs]=/usr/local/nagios/libexec/check_procs-w 5-c 10-s Z
Command[check_total_procs]=/usr/local/nagios/libexec/check_procs-w 150-C 200



The red section is the command name, which is the content that the Check_nrpe-C parameter can connect to, followed by the actual plug-in program (which is very similar to the form defined in Commands.cfg, but written on one line). That is to say 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 above 5 lines define the command is to detect the number of landing users, CPU load, sda1 capacity, zombie process, the total number of processes. The specific meaning of each command is shown in plug-in usage (executing "plugin name –h").



Since-C can only be followed by the commands defined in Nrpe.cfg, that is, now we can only use the five commands defined above.



9.3 On the monitor host (Nagios-server)



Before the Nagios has been run up, now the thing to do is:
• Install Check_nrpe plugin;
• Create a Check_nrpe command definition in commands.cfg, because only commands defined in COMMANDS.CFG can be used in services.cfg;
• Create a monitoring program for the monitored host;



9.3.1 Install Check_nrpe Plugin



[Root@nagios-server src]# tar zxvf nrpe-2.15.tar.gz
[Root@nagios-server src]# CD nrpe-2.15
[Root@nagios-server nrpe-2.15]#./configure
[Root@nagios-server nrpe-2.15]# make all
[Root@nagios-server nrpe-2.15]# make Install-plugin



Just run this step, because only Check_nrpe plug-ins are required.



We've installed the Nrpe on the Nagios-linux, and now we're going to test the communication between the monitor using Check_nrpe and the Nrpe daemon running by the monitor.



See that the Nrpe version information has been correctly returned, stating that everything is OK.



9.3.2 the definition of Check_nrpe in commands.cfg



[Root@nagios-server nrpe-2.15]# Vi/usr/local/nagios/etc/objects/commands.cfg



Add the following on the last side:




# ' Check_nrpe ' command definition
Define Command{
Command_name Check_nrpe # define the command name as Check_nrpe and use this name in Services.cfg.
Command_line $USER 1$/check_nrpe-h $HOSTADDRESS $-C $ARG 1$ #这是定义实际运行的插件程序.
# This command line is written in exactly the way Check_nrpe this command, not knowing the usage of the Check_nrpe–h view.
}
The $arg1$ parameter, followed by-C, is a test command passed to Nrpe Daemon, which has previously said that it must be one of the 5 commands defined in Nrpe.cfg. Use "!" with this parameter when using Check_nrpe in Services.cfg.



9.3.3 defines the monitoring of Nagios-linux hosts



The following allows you to define the monitoring of the Nagios-linux host in Services.cfg.


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 swap usage for nagios-linux. However, the default command for this monitoring function is not defined in nrpe.cfg. What to do? Manually add in Nrpe.cfg, which is the custom Nrpe command.


Now we want to monitor the swap partition, and if the free space is less than 20%, the warning state-> warning, or the critical state-> critical if less than 10%. We can check that we need to use the Check_swap plug-in, the complete command line should be the following.



[Root@nagios-client/]#/usr/local/nagios/libexec/check_swap-w 20%-C 10%



Add the definition of the check_swap command on the monitored machine (nagios-linux)



[Root@nagios-client/]# Vi/usr/local/nagios/etc/nrpe.cfg



Add the following line





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


We know that Check_swap can now be used as a Check_nrpe-c parameter.


The configuration file has been modified, of course, to reboot.


If you are running Nrpe with a separate daemon, you need to reboot manually, if you are running under XINETD, you don't need to.


Since the Nrpe is run under xinetd in this experiment, it is not necessary to restart the service.


Add this Check_swap monitoring program on the Monitor (Nagios-server)





Define Service{


Use Local-service


HOST_NAME Nagios-linux


Service_description Check Swap


Check_command Check_nrpe!check_swap


}


In the same way, I also opened the HTTP service on the nagios-linux, I need to monitor, according to the above practice, on the monitored machine (nagios-linux) to add the definition of check_http command


[Root@nagios-client/]# Vi/usr/local/nagios/etc/nrpe.cfg



Add the following line



?
1
Command[check_http]=/usr/local/nagios/libexec/check_http-i 127.0.0.1
Increase the CHECK_HTTP monitoring program on the Monitor (Nagios-server)




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 and now restart Nagios.



[Root@nagios-server/]# Service Nagios restart



9.3.4 View Configuration



Log on to the Nagios Web Monitor page http://192.168.10.11/nagios/view related information.
As you can see, the monitoring of the related services on Nagios-server and Nagios-linux has been successful, and the services on the nagios-windows have not been defined, as described below.



X. Using NSCP to monitor "local information" on remote windows



Under Nagios's libexec there is check_nt, which is used to check the services of Windows machines. Its function is similar to Check_nrpe. But it also needs to be paired with another software NSCP version 3.0 was previously nsclient++, and it was similar to Nrpe.



NSCP is a collection of Windows Nagios Monitor client. It contains check plugins, Check_nt, Check_nrpe, NSCA client, WMI checks. The monitoring items that are generally required are basically included.



First, installation



Download Address: http://nsclient.org/nscp/downloads, a direct download of the MSI package, note the system version (32-bit 64-bit). As with other software installations under Windows, it is a good thing to go directly to the next step.



A step that requires configuration
Allowed hosts (this is the IP of the Nagios (or other) server)
Here to fill in the Nagios monitor server IP
nsclient Password
Password can be null, if the place set a password, the monitoring side need to add-s parameter plus password authentication
Check the previous four items



Modules Block I do not have WMI check enabled, which is the ability to monitor what is being monitored by writing a local script that invokes the WMI system process on the monitored side.
If you have configured the above configuration, the requirements are changed, you need to change, you can go to the NSCP installation directory, modify the configuration file. An example of its configuration file is as follows:




[/modules]
Checkdisk = 1
Checkeventlog = 1
checkexternalscripts = 1
CHECKNSCP = 1
Checkhelpers = 1
Checksystem = 1
Nrpeserver = 1
Nscaclient = 1
Nsclientserver = 1
; Undocumented section
[/settings/default]
; Allowed Hosts-a comaseparated List of allowed HOSTS. can use Netmasks (/syntax) or * to create ranges.
Allowed hosts = 192.168.10.11
[/modules]
Above I only listed a partial configuration, the configuration square piece to ";" As a comment. Before each item, there is usually a note of what is used.



Second, the controlled-end configuration related



After the default installation is complete, you can use the. If it is not working properly, you can detect it in the following ways.



1, first with the server end of the Check_nrpe and Check_nt plug-ins to be the control of the machine to detect, to see whether normal?
[Root@nagios-server/]#./check_nt-h 192.168.10.13-p 12489-v UPTIME



System Uptime-23 Day (s) 9 hour (s) minute (s)
[Root@nagios-server/]#./check_nrpe-h 192.168.10.13



I (0,4,0,172 2014-02-28) seem to be doing fine ...
If the output is normal, it means normal. Note that the CHECK_NT default detection port is 1248, and the CHECK_NT port provided by NSCP defaults is 12489.



2, if the above output is not normal. Use the following command on the monitoring side to detect if the port is listening properly. That is, confirm whether to start.
Nestat-ano|findstr 5666
Nestat-ano|findstr 12489



If you are listening properly, check to see if the firewall allows you to add ports 5666/tcp 12489/tcp through the firewall –> exception –>.



3, if the port is not found listening, you need to manually open the service.



Services.msc–> nsclient++ Property –> login-> allow service to interact with desktop –> determine



Iii. Nagios server-side configuration



About Nrpe, Nsca block is not new, generally in the detection of other machines, will be configured beforehand. Here we only talk about the following CHECK_NT, configured as follows:




Define Command{
Command_name check_nt
Command_line $USER 1$/check_nt-h $HOSTADDRESS $-P 12489-v $ARG 1$ $ARG 2$
}
If you set a password, where the line command_line, you need to replace the following:



?
1
Command_line $USER 1$/check_nt-h $HOSTADDRESS $-P 12489-s 888888-v $ARG 1$ $ARG 2$
Add the following content to the CFG configuration file for host monitoring:





Define Service{


Use Windows-service,srv-pnp


HOST_NAME nagios-windows


Service_description Uptime


Check_command check_nt! UPTIME


}


Define Service{


Use Windows-service,srv-pnp


HOST_NAME nagios-windows


Service_description CPU Load


Check_command check_nt! Cpuload!-l 5,80,90


}


Define Service{


Use Windows-service,srv-pnp


HOST_NAME nagios-windows


Service_description d:drive Space


Check_command check_nt! Useddiskspace!-l D-w 80-c 90


}


Define Service{


Use Windows-service


HOST_NAME nagios-windows


Service_description Java


Check_command check_nt! procstate!-d showall-l Java.exe


}


Define Service{


Use Windows-service


HOST_NAME nagios-windows


Service_description Explorer


Check_command check_nt! procstate!-d showall-l Exploer.exe


}


Usually in the Windows monitoring of the main use of the Check_nt plug-in, check_nt other uses, can be performed in Nagios server libexec directory./check_nt-h See more help instructions. If you want to use Check_nrpe, you will need to configure it in the Nsclient.ini configuration file in the Nsclient or NSCP installation directory:
CHECK_CPU = checkcpu warn=80 crit=90 time=5m time=1m time=30s
Check_disk = checkdrivesize minwarn=30% mincrit=15% checkall filtertype=fixed



Use the same as the Check_nrpe on Linux:
[Root@nagios-server/]#./check_nrpe-h 192.168.10.13-c check_cpu
OK CPU Load ok.| ' 5m ' =6%;80;90 ' 1m ' =8%;80;90 ' 30s ' =9%;80;90



Xi. configuration of Nagios email alerts



11.1 Installing SendMail Components



First of all, to ensure the complete installation of sendmail related components, we can use the following command to complete the installation of SendMail:
[Root@nagios-server/]# Yum install-y sendmail*



Then restart the SendMail service:



[Root@nagios-server/]# Service SendMail restart



Then send a test message to verify the availability of SendMail:



[Root@nagios-server/]# echo "Hello World" | Mail david.tang@bsmart.cn



11.2 The configuration of the email alert



On top We have simply configured the/usr/local/nagios/etc/objects/contacts.cfg file,
Nagios sends the alert message to the e-mail address in the configuration file.


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.