An environmental background
- Monitor host a:192.168.24.231; monitored host b:192.168.24.233
- A/b host, SSH connection via public key [ Operation B Host does not need to enter password, see note: http://app.yinxiang.com/l/ACQDOta4_v1IEr_WI6aufZVFEux9o1ou6ts/]
Two monitoring targets and test results host a monitors the following information on Host B:
- Number of containers that are running (yellow)
- Number of containers already defined (green)
- Number of collapsed containers (red)
Three overall steps
- B Host collects Docker container information
- Monitor host a gets the collected information from the B host
- Customizing Cacti Data Entry methods
- customizing cacti Data templates
- customizing cacti Graphics templates
- Apply Graph Template
Four specific implementation of 1 Host B, the capture Docker information script as follows: dockermonitor.sh
- # Cd/home
- # Vim Dockermonitor.sh
- # chmod +x dockermonitor.sh
PS: Total number of containers: all_function_n Number of containers running: Running_function crash container data: Crashed_function execution results are as follows: 2 Host A, get the collected letters on Host B Interest
- #cd/var/www/html/cacti/scripts
- #vim testdocker.sh
Running result: ps:host for monitored host ip:192.168.24.231 3 custom Data Input Method (1) console->collection methods->data Input Meth Od->add PS
- where <ip>: Monitored host ip:192.168.24.233
- Input Type should select Script/command because the custom script is running
- Dockermonitor.sh is the script defined in step 2
(2) Pop-up page Input fields ==>addps:
- Hostname, also can not fill in, if fill in, IP parameter defaults to device Id
- Field[input] as input parameter
(3) Popup page Output fields ==>add PS:
- The box diagram should be the same as the output parameters in the script, there are multiple output parameters, continue to add the dot, and the output format in the script is: "Running_function: Quantity crashed_function: Quantity all_function: Quantity"
4 Custom Data Template (1) console->templates->data Templates =>addps
- Name, which is the title of this template
- The name in data source refers to the names of the sources, which are generally used in the "|host_description| -Name "format, when applying the template, Host_description will be replaced by the name of the monitoring machine
- Data input method Here we just created the data input method can be, if there are multiple words, save later, the upper right corner will be a new link, click can continue to create
- If there is more than one input, the custom Data area will appear below, this refers to the input parameter area, where you can give the input parameter a value, you can also let it enter the template when the application
- At this point, the data Input method and the data template are linked together.
5 Custom Graph Template (1) console->templates->graph Templates =>add Specific Add graph template items as follows: PS
- Consolidation Function should choose average, otherwise it will not be a graphic
- The first one here is the data source that selects the data Template we created earlier, because there may be multiple outputs, so it may also have multiple, so we can create one, notice that color here is for display, and Graph Item type is the type of display, For example, area is displayed as a block, Text format is to give this output a name
- Once created, if you want to create a legend for this output, then add to the graph item type->legend, notice that the graph item inputs above is created automatically, usually without processing, to this, graph The templates has been completed and is then applied.
6 Apply Graph Templates Select Console->management->devices Create the machine you want to apply to, define the input parameters, etc., the following steps, slightly
Cacti custom scripts to monitor Docker information (Script/command mode)