Some ideas and workflows for Nagios configuration monitoring

Source: Internet
Author: User

Nagios's monitoring principle: actually very simple. We have installed the Nrpe service on the server side, then all the client data is collected through this Nrpe and uploaded to the Nagios server, which is called by Nagios to generate.

Working process:

(1) The client has defined, in the Nrpe.cfg file, the way the module is called or the Nagios-identified command:

For example: Command[check_ips]=/usr/local/nrpe/libexec/ip_conn.sh 8000 10000 (scripts written by yourself)

(2) server side through Check_nrpe-h 192.168.1.1-c chekc_ips. This command sentence can be mobile to the client for this script data.

(3) and then we define a server.cfg on the server to collect this service for the host that shuts down the computer.

Server-side: Nagios's parsing process:

(1) When the Nagios service starts, it goes back to loading the data in the Nagios.cfg file. Inside is the type of monitoring we define: (Cfg_file=/usr/local/nagios/etc/objects/192.168.10.1.cfg #这一句我地宫一的这台主机文件存放的位置)

(2) Create 192.168.10.1.cfg This file in the above directory. The type of monitoring is defined inside.

(3) and contacts.cfg you can create a contact for yourself and send an email to your email address.

#当然还有一些文件: Command.cfg used when monitoring this machine. If you start an error. Said there was no such command. Then you can go to the command.cfg below to add it.

Example of a self-scripting monitoring service alarm:

On client operations:

1. Create a new Check_nginx file in the/usr/local/nagios/libexec/directory: content as follows

#!/bin/bash
nginx= '/usr/bin/pgrep nginx '
If ["$nginx"! = ""]
Then
echo "Nginx is run"
Exit 0
Fi
If ["$nginx" = ""]
Then
Exit 1
Fi

#exit0表示正常. #exit1表示报警

2. Edit nrpe.cfg file Add command # to executable permissions and users:

Command[check_nginx]=/usr/local/nagios/libexec/check_nginx

3, the server side, to see if the connection is successful Nrpe client, not successful to see the firewall, and nrpe.cfg allow add server IP address:

[Email protected] objects]#/usr/local/nagios/libexec/check_nrpe-h 192.168.10.9
NRPE v2.12

4. Whether the test module collects data (the following is received):

[Email protected] objects]#/usr/local/nagios/libexec/check_nrpe-h 192.168.10.9-c Check_nginx
Nginx is run

5. Edit 192.168.10.9.cfg file to add this service:

Define Service{
Use Generic-service
HOST_NAME 192.168.10.9
Service_description Check_nginx
Check_command Check_nrpe!check_nginx
Notifications_enabled 1
Check_period 24x7
Max_check_attempts 3
Normal_check_interval 10
Retry_check_interval 1
Contact_groups Admins
Notification_options W,u,c,r
Notification_interval 120
Notification_period 24x7

}

6, and then restart it can be monitored.

650) this.width=650; "title=" nginx.jpg "alt=" wkiom1sgtota9ai3aaecqftpzvo469.jpg "src=" http://s3.51cto.com/wyfs02/ M01/54/94/wkiom1sgtota9ai3aaecqftpzvo469.jpg "/>

Here are some examples of monitoring scripts: monitoring concurrency:

#!/bin/sh
#xiaoluo
#2014.11.4

Ip_conns= ' Netstat-an | grep TCP | grep EST | Wc-l '

If [$ip _conns-lt]
Then
echo "Ok-connect is $ip _conns"
Exit 0
Fi
If [$ip _conns-gt $1-a $ip _conns-lt]
Then
echo "Warning-connect is $ip _conns"
Exit 1
Fi
If [$ip _CONNS-GT]
Then
echo "Critical-connect is $ip _conns"
Exit2
Fi

2, Nrpe Add command: Command[check_ips]=/usr/local/nagios/libexec/check_ips 4000 8000 (4000 alarm. 8000 severe)

#编写脚本注意事项:

are judged by if and then by the return value:

Then exit 0 means normal.

EXIT1 indicates an alarm.

Exit2 indicates severe #这3个人跟我们写的脚本没有直接关系只是给nrpe的一个信号

To this, feel changed hand, meet the problem of friends can exchange. Like monitoring MySQL master-slave, you can write a monitor two states whether all are yes and then judge in If. Give the number of values to exit.

This article is from the "Little Luo" blog, please be sure to keep this source http://xiaoluoge.blog.51cto.com/9141967/1587997

Some ideas and workflows for Nagios configuration monitoring

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.