In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article focuses on "the implementation of docker container monitoring". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn "the implementation of docker container monitoring".
This article was written in 2015, and all the content related to the PAAS platform has been completed in 2015Q3. At that time, the version of docker used was 1.6.2. Although the new version of docker was released quickly, the monitoring content mentioned below is roughly the same.
1. What metrics do you need to monitor in docker containers?
Container CPU, memory, IO, network, application survival
Second, how to monitor?
Host monitoring zabbix can be realized, and zabbix is installed inside the container.
(the data is consistent with the host and cannot reflect the real status of the container)
See how others achieve it?
Searching GitHub...
Seagull
You can view and start / stop containers and manage images, but you cannot view the container's use of CPU, memory, IO, network, and so on.
Prometheus
Too big
Docker official stats API
Docker version 1.5 or above is required. There are two ways: command line and API. API is non-interruptive and constantly displays data.
Docker-mon
Command line tool, version 1.5 or above, the display effect is very good, but the data cannot be summarized and the historical data cannot be viewed.
Dockernana
You can monitor the daily cpu, memory and IO of the docker host, but you cannot monitor the resource usage of the container.
CAdvisor
You can check the container's use of CPU, memory and disk, as well as the WEB interface. The disadvantage is that each host needs a container, and the data cannot be summarized and the historical data cannot be viewed.
Figure 1:Docker-mon
Figure 2:cAdvisor
The final script is as follows:
A1roomuser= `cat / cgroup/cpuacct/docker/$i/cpuacct.stat | grep user | awk'{print $2}'`
A1roomsys = `cat / cgroup/cpuacct/docker/$i/cpuacct.stat | grep sys | awk'{print $2}'`
Sleep 5
A2roomuser= `cat / cgroup/cpuacct/docker/$i/cpuacct.stat | grep user | awk'{print $2}'`
A2roomsys = `cat / cgroup/cpuacct/docker/$i/cpuacct.stat | grep sys | awk'{print $2}'`
Cpuall=$ ((a2_user + a2_sys-a1_user-a1_sys))
CPUSTAT= `echo "scale=2;$cpuall/5/100" >
Memory
# @ currently used memory divided by maximum memory limit
[root@BJ-YF-64-7] # cat / cgroup/memory/docker/$DOCKERID/memory.limit_in_bytes
1073741824
[root@BJ-YF-64-7] # cat / cgroup/memory/docker/$DOCKERID/memory.usage_in_bytes
186269696
Network traffic
# @ obtain the network status of the process according to the container PID
PID= `docker inspect-f'{{.State.Pid}}'$i`
A1roomrx = `cat / proc/$PID/net/dev | grep eth2 | awk'{print $2}'`
Number of network connections
# @ obtain the network status of the process according to the container PID
Cat / proc/$PID/net/tcp
4. Preliminary display of shell+InfluxDB+Grafana
Print the results using Shell:
Use InfluxDB+ Grafana to show the results:
5. Connect to Zabbix
If the problem of data display is solved, what about the data alarm? Zabbix
Zabbix a host has N pictures, container 1CPU, container 1 memory, container 2CPU.
Data acquisition is complex and difficult.
Dismantle
Each container runs Zabbix
The data is printed to the container's mapping directory in the host through the shell script.
Historical trend chart
At this point, I believe that everyone on the "docker container monitoring implementation method" have a deeper understanding, might as well to the actual operation of it! Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.