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

How to install Cloud Monitor Nagios

2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

This article mainly shows you "how to install Cloud Monitoring Nagios". The content is easy to understand and clear. I hope it can help you solve your doubts. Let me lead you to study and learn this article "how to install Cloud Monitoring Nagios".

1. Brief introduction to Nagios

Nagios is an open source monitoring system that can run on the Linux/Unix platform and can be used to monitor the running status of the system and network information. Nagios can monitor specified local or remote hosts and services, while providing exception notification. When the system or service status is abnormal, send an email or SMS alarm * * time to notify the website operation and maintenance personnel, and send a normal email or SMS notification after the status is restored.

two。 Related environment

Host NameIPOS

Archduangr-1192.168.56.10CentOS 6.4x86_64duangr-2192.168.56.11CentOS 6.4x86_64duangr-3192.168.56.12CentOS 6.4x86_64

3. Deployment planning

The Nagios master node needs to be installed:

Nagios

Nagios-plugin

Nrpe

Php

Apache

The Nagios slave node needs to be installed:

Nagios-plugin

Nrpe

Installation path planning

Item value nagios installation path / usr/local/nagiosphp installation path / usr/local/phpapache installation path / usr/local/apache2

4. Code acquisition

Nagios-4.0.2.tar.gz

Nagios-plugins-1.5.tar.gz

Nrpe-2.15.tar.gz

Httpd-2.2.23.tar.gz

Php-5.4.10.tar.gz

5. Premise dependence

5.1 Host environment check (all nodes)

# rpm-q gcc glibc glibc-common gd gd-devel xinetd openssl-devel gcc-4.4.7-3.el6.x86_64 glibc-2.14.1-6.x86_64 glibc-common-2.14.1-6.x86_64 gd-2.0.35-11.el6.x86_64 package gd-devel is not installed package xinetd is not installed openssl-devel-1.0.0-27.el6.x86_64

If it is missing, please install it first. You can download the relevant installation packages from the following mirror websites:

Http://rpm.pbone.net/

Http://mirrors.163.com/centos/6.4/os/x86_64/Packages/

Http://mirrors.sohu.com/centos/6.4/os/x86_64/Packages/

Check again after installation as follows:

# rpm-q gcc glibc glibc-common gd gd-devel xinetd openssl-devel gcc-4.4.7-3.el6.x86_64 glibc-2.14.1-6.x86_64 glibc-common-2.14.1-6.x86_64 gd-2.0.35-11.el6.x86_64 gd-devel-2.0.35-11.el6.x86_64 xinetd-2.3.14-38.el6.x86_64 openssl-devel-1.0.0-27.el6.x86_64

6. Compilation and installation

6.1 create user nagios (all nodes)

Useradd nagios-d / usr/local/nagios passwd nagios (password customization)

6.2 install the nagios main program (master node installation)

Tar-zxf nagios-4.0.2.tar.gz cd nagios-4.0.2. / configure-- prefix=/usr/local/nagios make all make install & & make install-init & & make install-commandmode & & make install-config

Add nagios as a service

Chkconfig-- add nagios chkconfig nagios off chkconfig-- level 35 nagios on chkconfig-- list nagios nagios 0: off 1: close 2: close 3: enable 4: close 5: enable 6: close

6.3 install the nagios plug-in (all nodes are installed)

Tar-zxf nagios-plugins-1.5.tar.gz cd nagios-plugins-1.5. / configure-- prefix=/usr/local/nagios-- with-nagios-user=nagios-- with-nagios-group=nagios make & & make install

If a mysql-related compilation error occurs, it is caused by the modification of the default installation path of mysql. Adjust the with-mysql and re-make.

. / configure-- prefix=/usr/local/nagios-- with-mysql=/usr/local/mysql make & & make install

6.4 install NRPE (install all nodes)

Tar-zxf nrpe-2.15.tar.gz cd nrpe-2.15. / configure-- enable-command-args make all make install-plugin

The following steps only need to be performed on the monitored node

Make install-daemon & & make install-daemon-config & & make install-xinetd

6.4.1 configuration of monitored nodes

If it is a monitored node, you need to configure the NRPE daemon to run (run through xinetd)

1. Change the / etc/xinetd.d/nrpe file to allow the nagios master node server to connect

Vi / etc/xinetd.d/nrpe only_from = 127.0.0.1 192.168.56.10

2. Add the following at the end of / etc/services:

Nrpe 5666/tcp # NRPE

3. Increase the support for parameters

Vi / usr/local/nagios/etc/nrpe.cfg dont_blame_nrpe=1

4. Start xinetd

Service xinetd restart

5. Verify whether nrpe is listening

Netstat-at | grep nrpe

6. Test whether nrpe is running properly.

/ usr/local/nagios/libexec/check_nrpe-H localhost NRPE v2.15

6.4.2 Primary Node configuration

If it is the master node of the monitoring service, after the NRPE configuration of all the monitored nodes is completed, you can do the following detection in turn.

/ usr/local/nagios/libexec/check_nrpe-H 192.168.56.11 NRPE v2.15 / usr/local/nagios/libexec/check_nrpe-H 192.168.56.12 NRPE v2.15

6.5 install Apache (primary node installation)

Tar-zxf httpd-2.2.23.tar.gz cd httpd-2.2.23. / configure-- prefix=/usr/local/apache2 make & & make install

6.6 install PHP (primary node installation)

Cd / export/home/tools/soft/php tar-zxf 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

6.7Publishing WEB for PHP using apache

Vi / usr/local/apache2/conf/httpd.conf

.... Listen 80.... DirectoryIndex index.html index.php AddType application/x-httpd-php .php.... # 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 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

Add a user name and password for web access (here the user name is admin, customizable)

/ usr/local/apache2/bin/htpasswd-c / usr/local/nagios/etc/htpasswd admin

Start apache

/ usr/local/apache2/bin/apachectl start

Visit the page: http://192.168.56.10/nagios/

7. Configure Nagios

7.1 configure remote monitored nodes

7.1.1 modify the configuration file

# su-nagios $vi / usr/local/nagios/etc/nrpe.cfg

Modify it to the following configuration:

Command [check _ users] = / usr/local/nagios/libexec/check_users-w $ARG1 $- c $ARG2 $command [check _ load] = / usr/local/nagios/libexec/check_load-w $ARG1 $- c $ARG2 $command [check _ disk] = / usr/local/nagios/libexec/check_disk-w $ARG1 $- c $ARG2 $- p $ARG3 $command [check _ procs] = / usr/local/nagios/libexec/check_procs-w $ARG1 $- c $ARG2 $- s $ARG3 $command [check _ procs_args] = / usr/local/ Nagios/libexec/check_procs $ARG1 $command [check _ swap] = / usr/local/nagios/libexec/check_swap-w $ARG1 $- c $ARG2 $

The above monitoring command functions:

Check_users monitors the number of login users

Check_load monitors CPU load

Check_disk monitors disk usage

Check_procs monitors the number of processes, including RSZDT status

Check_swap monitors SWAP partition usage

7.1.2 restart the xinetd service

After configuring the above command, restart the xinetd service

Service xinetd restart

7.1.3 verify the configuration

Check whether the monitoring command configuration is ok

/ usr/local/nagios/libexec/check_nrpe-H localhost-c check_users-a 5 10 / usr/local/nagios/libexec/check_nrpe-H localhost-c check_load-a 15 localhost 5 30 RSZDT 25 20 / usr/local/nagios/libexec/check_nrpe-H localhost-c check_disk-a 20% 10% / usr/local/nagios/libexec/check_nrpe-H localhost-c check_procs-a 200 400 RSZDT / usr/local/nagios/libexec/check_nrpe-H Localhost-c check_swap-a 20% 10%

7.2 configure the monitoring service master node

7.2.1 cgi.cfg (profile that controls CGI access)

(use nagios users)

Vi / usr/local/nagios/etc/cgi.cfg

Modify the following to add permissions to the admin user:

Default_user_name=admin authorized_for_system_information=nagiosadmin,admin authorized_for_configuration_information=nagiosadmin,admin authorized_for_system_commands=nagiosadmin,admin authorized_for_all_services=nagiosadmin,admin authorized_for_all_hosts=nagiosadmin,admin authorized_for_all_service_commands=nagiosadmin,admin authorized_for_all_host_commands=nagiosadmin,admin

7.2.2 nagios.cfg (nagios main profile)

(use nagios users)

Vi / usr/local/nagios/etc/nagios.cfg

# cfg_file=/export/home/nagios/etc/objects/localhost.cfg (comment out) cfg_dir=/export/home/nagios/etc/servers

The main configuration file declares that the storage path of the monitoring script is. / servers. This directory does not exist by default and needs to be created manually.

Nagios reads all files under the servers directory with the suffix .cfg as configuration files.

Cd / usr/local/nagios/etc mkdir servers cd servers

7.2.3 define the host group for monitoring

Declare a monitoring host group and add all three hosts mentioned in the host environment to the monitoring.

Vi / export/home/nagios/etc/servers/group.cfg

The new document reads as follows:

Define hostgroup {hostgroup_name duangr-server alias duangr Server members duangr-1,duangr-2,duangr-3}

Explain the configuration above:

Hostgroup_name: the name of the host group, which can be specified at will

Alias: alias for host group, which can be specified at will

Members: a member of the host group, with multiple host names separated by commas. In addition, the host name must be the same as the host_name in define host.

The definition of the host, which will be discussed later.

7.2.4 define the host to monitor

Let's start defining a specific host

7.2.4.1 Local Host Monitoring configuration

Define the local host duangr-1 first

Vi / export/home/nagios/etc/servers/duangr-1.cfg

The new document reads as follows:

Define host {use linux-server host_name duangr-1 alias duangr-1 address 192.168.56.10} define service {use local-service host_name Duangr-1 service_description Host Alive check_command check-host-alive} define service {use local-service host_name duangr-1 service_description Users check_command Check_local_users!20!50} define service {use local-service host_name duangr-1 service_description CPU check_command check_local_load!5.0,4.0,3.0!10.0,6.0,4.0} define service { Use local-service host_name duangr-1 service_description Disk Root check_command checkpoints localizations disk20% "10%" /} define service {use local-service host_name Duangr-1 service_description Disk Home check_command checkpoints localizations disk20% output 10% exportaport home} define service {use local-service host_name duangr-1 service_description Zombie Procs check_command check_local_procs!5!10!Z} define service {use local-service host_name duangr-1 service_description Total Procs check_command check_local_procs!250!400!RSZDT } define service {use local-service host_name duangr-1 service_description Swap Usage check_command check_local_swap!20!10}

Note: since this host is also the host of the monitoring service master node, you can use the relevant commands of check_local_* to monitor.

Common monitoring items have been configured in this file.

7.2.4.2 remote host monitoring configuration

Then define the remote host duangr-2 and duangr-3

Before defining the monitoring of a remote host, you need to define the check_nrpe command

Vi / usr/local/nagios/etc/objects/commands.cfg

Add the following to the * face of the file:

# 'check_nrpe' command definition define command {command_name check_nrpe command_line $USER1 $/ check_nrpe-H $HOSTADDRESS$-t 30-c $ARG1 $} define command {command_name check_nrpe_args command_line $USER1 $/ check_nrpe-H $HOSTADDRESS$-t 30-c $ARG1 $- a $ARG2 $}

Define the monitoring configuration for duangr-2 hosts

$vi / usr/local/nagios/etc/servers/duangr-2.cfg

The new document reads as follows:

Define host {use linux-server host_name duangr-2 alias duangr-2 address 192.168.56.11} define service {use local-service host_name Duangr-2 service_description Host Alive check_command check-host-alive} define service {use local-service host_name duangr-2 service_description Users check_command check_nrpe_args ! check_users!5 10} define service {use local-service host_name duangr-2 service_description CPU check_command check_nrpe_args!check_load!15,10,5 30,25,20} define service {use Local-service host_name duangr-2 service_description Disk Root check_command checkpoints nrpedal argscheck checkpoints diskstores 20% 10% /} define service {use local-service host_name duangr -2 service_description Disk / export/home check_command checknrpeaked argscheck checkpoints disk20% / export/home} define service {use local-service host_name duangr-2 service_description Procs Zombie check _ command checknrpeaked argscheck checking procsaries 5 10 Z} define service {use local-service host_name duangr-2 service_description Procs Total check_command checkpointing nrpedal argschecking checking procspacking args! "- w400-c600" } define service {use local-service host_name duangr-2 service_description Swap Usage check_command checkout nrpedal argscheck checkout swapping 20%} The following are the monitoring of some commonly used processes, mainly those related to the cloud platform; Monitor the crond process define service {use local-service host_name duangr-2 service_description PS: crond check_command checkchecknrpeaked argscheck check procsprocsprocess ARGs! "- c1v 1-Ccrond"} Monitor the zookeeper process define service {use local-service host_name duangr-2 service_description PS: QuorumPeerMain check_command checkchecknrpeaked argscheck check procsprocsprocess ARGs! "- C1 virtual 1-Cjava-aserver.quorum.QuorumPeerMain"} Monitor the slave node process define service {use local-service host_name duangr-2 service_description PS: supervisor check_command checking nrpeaked argscheck checklists procsslave ARGs! "- C1 use local-service host_name duangr-2 service_description PS 1-Cjava-adaemon.supervisor"} Monitoring the master node process of storm define service {use local-service host_name duangr-2 service_description PS: nimbus check_command checkpointing nrpeaked argschecking checking procsaggregargs! "- C1 use local-service host_name duangr-2 service_description PS 1-Cjava-adaemon.nimbus"} Monitor the MetaQ process define service {use local-service host_name duangr-2 service_description PS: MetaQ check_command checkchecknrpeaked argscheck check procsprocsprocess ARGs! "- C1 virtual 1-Cjava-ametamorphosis-server-w"} Monitor the Redis process define service {use local-service host_name duangr-2 service_description PS: redis-server check_command checkchecknrpeaked argscheck check procsprocsprocess ARGs! "- c1v 1-Credis-server"} Monitor the NameNode process of the hadoop master node define service {use local-service host_name duangr-2 service_description PS: NameNode check_command checkchecknrpeaked argschecking checklists procscompresargs! "- C1 virtual 1-Cjava-aserver.namenode.NameNode"} Monitor the SecondaryNameNode process of the hadoop master node define service {use local-service host_name duangr-2 service_description PS: SecondaryNameNode check_command checkchecknrpeaked argschecking checklists procscompresargs! "- C1 virtual 1-Cjava-aserver.namenode.SecondaryNameNode"} Monitor the ResourceManager process of the hadoop master node define service {use local-service host_name duangr-2 service_description PS: ResourceManager check_command checkchecknrpeaked argschecking checklists procscompresargs! "- C1 virtual 1-Cjava-aserver.resourcemanager.ResourceManager"} Monitor the hadoop slave node DataNode process define service {use local-service host_name duangr-2 service_description PS: DataNode check_command checkpointing nrpedal argschecking checking procsslave ARGs! "- c1virtual 1-Cjava-aserver.datanode.DataNode"} Monitor the hadoop slave node NodeManager process define service {use local-service host_name duangr-2 service_description PS: NodeManager check_command checkpointing nrpedal argschecking checking procsslave ARGs! "- c1virtual 1-Cjava-aserver.nodemanager.NodeManager"}

Note that since duangr-2 is a remote host, use the check_nrpe_args command to monitor.

The commonly used monitoring items have been configured in this file, and the related process monitoring of hadoop, storm, zookeeper, metaq and redis is also included. The main monitoring idea is to determine whether the process exists.

Define the monitoring configuration for duangr-3 hosts

Vi duangr-3.cfg

The content is similar to duangr-2.cfg, only need to modify host_name, alias, address.

7.2.4.3 Mail Monitoring

Define the email address of the monitor

Vi / usr/local/nagios/etc/objects/contacts.cfg

Define contact {contact_name nagiosadmin; Short name of user use generic-contact; Inherit default values from generic-contact template (defined above) alias Nagios Admin Full name of user email yourname@domain.com

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