Nagios--docker Container Monitoring

Source: Internet
Author: User

1. Environment:

# Cat/etc/redhat-release

CentOS Release 6.8 (Final)

# Uname-r

3.10.5-3.el6.x86_64

Nagios Server Host:192.168.70.67 Password:[Email protected]!

Nagios Client Host:192.168.70.52 Password:[Email protected]!

2. version

Nagios version: nagios-3.5.1

Plugin plugin version: nagios-plugins-1.4.16

Nrpe version: nrpe-2.12

installation path: /usr/local/nagios

3. Demand Analysis

purpose of implementation : Implements memory monitoring for Docker containers

Implementation Tools : Monitoring System Nagios

Implementation Principle :

1,nagios client writes dcoker container memory Monitor plugin and opens nrpe Daemon

2, the server Check_nrpe link Client daemon, take the plug-in execution results, return to the Web interface.

4. Client Configuration

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

Add the following configuration:

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

The plugin is as follows:

Vim/usr/local/nagios/libexec/check_docker101

#/bin/bash

Docker_name= ' echo $0|awk-f ' _ ' {print $} '

Docker_id= ' Cat/data/docker_id.txt|grep ${docker_name}|awk ' {print $} '

Total_mem= ' Cat/cgroup/memory/docker/${docker_id}/memory.limit_in_bytes '

Use_mem= ' Cat/cgroup/memory/docker/${docker_id}/memory.usage_in_bytes '

Free= ' echo ${TOTAL_MEM}-${USE_MEM}|BC '

free_mb= ' Expr $FREE/1024/1024|bc '

If [$FREE _mb-ge 100]

Then

echo "Check_meory ok-$FREE _mb M Free"

Exit 0

elif [$FREE _mb-lt 100-a $FREE _MB-GT 30]

Then

echo "Check_meory warning-$FREE _mb M Free"

Exit 1

elif [$FREE _mb-le 30]

Then

echo "Check_meory critical-$FREE _mb M Free"

Exit 2

Else

echo "Check_meory unkown mem lessest"

Exit 3

Fi

Give permission:

chmod 755/usr/local/nagios/libexec/check_docker101

Chown nagios.nagios/usr/local/nagios/libexec/check_docker101

Perform search:

[Email protected] data]#/usr/local/nagios/libexec/check_docker101

Check_meory OK-261 M Free

5. server-side configuration

A: Configuration command File--commands.cfg

Define Command{

Command_name check_docker101

Command_line $USER 1$/check_docker101

}

B: Configure the Hosts file--host.cfg

Define Host{

Use Linux-server

HOST_NAME Docker

Alias Docker

Address 192.168.70.52

Max_check_attempts 3

Normal_check_interval 2

Process_perf_data 1

Action_url/nagios/pnp/index.php?host= $HOSTNAME $

}

C: Config service file--service.cfg

Define Service{

Use Generic-service

HOST_NAME Docker

Service_description docker_mem_101

Check_command check_nrpe!check_docker101

Process_perf_data 1

}

To test the remote plugin with Check_nrpe:

[Email protected] etc]#/usr/local/nagios/libexec/check_nrpe-h 192.168.70.52-c check_docker101

Check_meory OK-261 M Free

Everything is fine.

650) this.width=650; "Src=" Http://s2.51cto.com/wyfs02/M01/8A/54/wKiom1gtVqrzVXNRAADXke5ImZ0242.png-wh_500x0-wm_3 -wmp_4-s_3425479665.png "title=" image 1.png "alt=" Wkiom1gtvqrzvxnraadxke5imz0242.png-wh_50 "/>

This article is from the "11262076" blog, please be sure to keep this source http://11272076.blog.51cto.com/11262076/1873894

Nagios--docker Container 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.