-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathdmesg.py
58 lines (50 loc) · 1.57 KB
/
dmesg.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/bin/env python3
"""
on supported systems launch a thread that will follow system messages
to detect serious incidents like oom
"""
import psutil
from async_client import (
ArangoCLIprogressiveTimeoutExecutor,
make_tail_params,
tail_line_result,
delete_tail_params
)
def dmesg_runner(dmesg):
""" thread to run dmesg in """
dmesg.launch()
class DmesgWatcher(ArangoCLIprogressiveTimeoutExecutor):
"""configuration"""
def __init__(self, site_config):
self.params = None
super().__init__(site_config, None)
def launch(self):
# pylint: disable=R0913 disable=R0902
""" dmesg wrapper """
print('------')
args = ['-wT']
verbose = False
self.params = make_tail_params(verbose,
'dmesg ',
self.cfg.test_report_dir / 'dmesg_log.txt')
ret = self.run_monitored(
"dmesg",
args,
params=self.params,
progressive_timeout=9999999,
deadline=self.cfg.deadline,
result_line_handler=tail_line_result,
identifier='0_dmesg'
)
#delete_logfile_params(params)
ret = {}
ret['error'] = self.params['error']
delete_tail_params(self.params)
return ret
def end_run(self):
""" terminate dmesg again """
print(f"killing dmesg {self.params['pid']}")
try:
psutil.Process(self.params['pid']).kill()
except psutil.NoSuchProcess:
print('dmesg already gone?')