Change method of getting PIDs of running processes

Change-Id: I669cd6f4fd52d04de9ed6087719e8910d570505e
This commit is contained in:
Artem 2016-10-05 17:38:22 +03:00
parent 3830c0fdc3
commit e45613ce8c
2 changed files with 15 additions and 10 deletions

View File

@ -66,17 +66,18 @@ def simulate_network_interrupt_on_node(remote, interval=30):
remote.execute(cmd)
def get_pids_of_process(remote, name):
"""Get PIDs of process by its name.
def get_pids_of_process(remote, cmd_pattern):
"""Get PIDS of process by its pattern.
:param remote: SSH connection to the node.
:type remote: SSHClient
:param name: process name.
:type name: str
:returns: list of PIDs.
:param cmd_pattern: command.
:type cmd_pattern: str
:returns: list of PIDS.
:rtype: list
"""
cmd = "pidof {}".format(name)
cmd = "pgrep -f '{}'".format(cmd_pattern)
result = remote.execute(cmd)
if result['exit_code'] != 0:
return []

View File

@ -37,18 +37,22 @@ class LMACollectorPluginApi(base_test.PluginApi):
:returns: list of process IDs indexed by node and process
:rtype: dict
"""
services = ["metric_collector", "log_collector"]
service_version_9 = ["lma_collector"]
pids = {}
processes_count = {
"collectd": 1,
"collectdmon": 1
"collectd ": 1,
"collectdmon ": 1
}
if self.settings.version.startswith("0.9"):
processes_count["hekad"] = 1
processes_count[
"hekad -config[= ]/etc/{}".format(service_version_9)] = 1
else:
# Starting with 0.10, there are one collector for logs and one for
# metrics
processes_count["hekad"] = 2
for service in services:
processes_count["hekad -config[= ]/etc/{}".format(service)] = 1
online_nodes = [node for node in self.helpers.get_all_ready_nodes()
if node["online"]]
for node in online_nodes: