Enable the system metrics in Docker environment
Story: 2003093 Task: 23185 Change-Id: I9700a6fcb650fbcf983f2a4f145b430876f12429
This commit is contained in:
@@ -1,7 +1,11 @@
|
||||
# (C) Copyright 2015 Hewlett Packard Enterprise Development Company LP
|
||||
|
||||
init_config:
|
||||
|
||||
# process_fs_path: (optional) STRING. It will set up the path of the process
|
||||
# filesystem. By default it's set for: /proc directory.
|
||||
# Example:
|
||||
#
|
||||
# process_fs_path: /rootfs/proc
|
||||
instances:
|
||||
# Cpu check only supports one configured instance
|
||||
- name: cpu_stats
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
# (C) Copyright 2015,2016 Hewlett Packard Enterprise Development Company LP
|
||||
|
||||
init_config:
|
||||
|
||||
# process_fs_path: (optional) STRING. It will set up the path of the process
|
||||
# filesystem. By default it's set for: /proc directory.
|
||||
# Example:
|
||||
#
|
||||
# process_fs_path: /rootfs/proc
|
||||
instances:
|
||||
# Disk check only supports one configured instance
|
||||
- name: disk_stats
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
# (C) Copyright 2015 Hewlett Packard Enterprise Development Company LP
|
||||
|
||||
init_config:
|
||||
|
||||
# process_fs_path: (optional) STRING. It will set up the path of the process
|
||||
# filesystem. By default it's set for: /proc directory.
|
||||
# Example:
|
||||
#
|
||||
# process_fs_path: /rootfs/proc
|
||||
instances:
|
||||
# Load check only supports one configured instance
|
||||
- name: load_stats
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
# (C) Copyright 2015 Hewlett Packard Enterprise Development Company LP
|
||||
|
||||
init_config:
|
||||
|
||||
# process_fs_path: (optional) STRING. It will set up the path of the process
|
||||
# filesystem. By default it's set for: /proc directory.
|
||||
# Example:
|
||||
#
|
||||
# process_fs_path: /rootfs/proc
|
||||
instances:
|
||||
# Memory check only supports one configured instance
|
||||
- name: memory_stats
|
||||
|
||||
@@ -370,6 +370,54 @@ This section documents all the checks that are supplied by the Agent.
|
||||
## System Metrics
|
||||
This section documents the system metrics that are sent by the Agent.
|
||||
|
||||
Docker environment:
|
||||
|
||||
For Docker environment you can enable the system plugins by adding cpu, disk,
|
||||
memory and load yaml files to the monasca-agent-collector container (mount
|
||||
plugin files to /plugins.d/cpu|disk|memory|load.yaml). Additionally you have to
|
||||
specify the path of the host process filesystem. In this case mount host root
|
||||
directory `/` to `/rootfs` in the container. Docker compose example:
|
||||
|
||||
```
|
||||
volumes:
|
||||
- "/:/rootfs:ro"
|
||||
```
|
||||
|
||||
Sample configurations:
|
||||
|
||||
cpu.yaml
|
||||
```
|
||||
init_config:
|
||||
process_fs_path: /rootfs/proc
|
||||
instances:
|
||||
- name: cpu_stats
|
||||
```
|
||||
|
||||
disk.yaml
|
||||
```
|
||||
init_config:
|
||||
process_fs_path: /rootfs/proc
|
||||
instances:
|
||||
- name: disk_stats
|
||||
ignore_filesystem_types: iso9660,tmpfs,nsfs
|
||||
```
|
||||
|
||||
memory.yaml
|
||||
```
|
||||
init_config:
|
||||
process_fs_path: /rootfs/proc
|
||||
instances:
|
||||
- name: memory_stats
|
||||
```
|
||||
|
||||
load.yaml
|
||||
```
|
||||
init_config:
|
||||
process_fs_path: /rootfs/proc
|
||||
instances:
|
||||
- name: load_stats
|
||||
```
|
||||
|
||||
### CPU
|
||||
| Metric Name | Dimensions | Semantics |
|
||||
| ----------- | ---------- | --------- |
|
||||
|
||||
@@ -26,6 +26,12 @@ class Cpu(checks.AgentCheck):
|
||||
|
||||
def __init__(self, name, init_config, agent_config):
|
||||
super(Cpu, self).__init__(name, init_config, agent_config)
|
||||
process_fs_path_config = init_config.get('process_fs_path', None)
|
||||
if process_fs_path_config:
|
||||
psutil.PROCFS_PATH = process_fs_path_config
|
||||
self.log.debug('The path of the process filesystem set to %s', process_fs_path_config)
|
||||
else:
|
||||
self.log.debug('The process_fs_path not set. Use default path: /proc')
|
||||
# psutil.cpu_percent and psutil.cpu_times_percent are called in
|
||||
# __init__ because the first time these two functions are called with
|
||||
# interval = 0.0 or None, it will return a meaningless 0.0 value
|
||||
|
||||
@@ -27,6 +27,12 @@ class Disk(checks.AgentCheck):
|
||||
self._partition_error = set()
|
||||
|
||||
super(Disk, self).__init__(name, init_config, agent_config)
|
||||
process_fs_path_config = init_config.get('process_fs_path', None)
|
||||
if process_fs_path_config:
|
||||
psutil.PROCFS_PATH = process_fs_path_config
|
||||
self.log.debug('The path of the process filesystem set to %s', process_fs_path_config)
|
||||
else:
|
||||
self.log.debug('The process_fs_path not set. Use default path: /proc')
|
||||
|
||||
def _log_once_per_day(self, message):
|
||||
if message in self._partition_error:
|
||||
|
||||
@@ -28,6 +28,7 @@ class Load(checks.AgentCheck):
|
||||
|
||||
def __init__(self, name, init_config, agent_config):
|
||||
super(Load, self).__init__(name, init_config, agent_config)
|
||||
self.process_fs_path_config = init_config.get('process_fs_path', None)
|
||||
|
||||
def check(self, instance):
|
||||
"""Capture load stats
|
||||
@@ -38,6 +39,12 @@ class Load(checks.AgentCheck):
|
||||
|
||||
if util.Platform.is_linux():
|
||||
try:
|
||||
if self.process_fs_path_config:
|
||||
log.debug(
|
||||
'The path of the process filesystem set to %s',
|
||||
self.process_fs_path_config)
|
||||
loadAvrgProc = open(self.process_fs_path_config + '/loadavg', 'r')
|
||||
else:
|
||||
loadAvrgProc = open('/proc/loadavg', 'r')
|
||||
uptime = loadAvrgProc.readlines()
|
||||
loadAvrgProc.close()
|
||||
|
||||
@@ -23,6 +23,12 @@ class Memory(checks.AgentCheck):
|
||||
|
||||
def __init__(self, name, init_config, agent_config):
|
||||
super(Memory, self).__init__(name, init_config, agent_config)
|
||||
process_fs_path_config = init_config.get('process_fs_path', None)
|
||||
if process_fs_path_config:
|
||||
psutil.PROCFS_PATH = process_fs_path_config
|
||||
self.log.debug('The path of the process filesystem set to %s', process_fs_path_config)
|
||||
else:
|
||||
self.log.debug('The process_fs_path not set. Use default path: /proc')
|
||||
|
||||
def check(self, instance):
|
||||
"""Capture memory stats
|
||||
|
||||
Reference in New Issue
Block a user