sysmon: Extract _is_process_name
BUG=chromium:838332
TEST=unittests
Change-Id: I722965b5fdcaf9069be470bedab9cccdcaf9e908
Reviewed-on: https://chromium-review.googlesource.com/1048405
Commit-Ready: Prathmesh Prabhu <pprabhu@chromium.org>
Tested-by: Prathmesh Prabhu <pprabhu@chromium.org>
Reviewed-by: Allen Li <ayatane@chromium.org>
diff --git a/scripts/sysmon/proc_metrics.py b/scripts/sysmon/proc_metrics.py
index a30a298..fe59f4b 100644
--- a/scripts/sysmon/proc_metrics.py
+++ b/scripts/sysmon/proc_metrics.py
@@ -47,9 +47,9 @@
test_func=partial(_is_python_module,
'lucifer.cmd.job_reporter')),
_ProcessMetric('lucifer_run_job',
- test_func=_is_lucifer_run_job),
+ test_func=partial(_is_process_name, 'lucifer_run_job')),
_ProcessMetric('apache',
- test_func=_is_apache),
+ test_func=partial(_is_process_name, 'apache2')),
]
self._other_metric = _ProcessMetric('other')
@@ -119,12 +119,7 @@
# This relies on the autoserv script being run directly. The script should
# be named autoserv exactly and start with a shebang that is /usr/bin/python,
# NOT /bin/env
- return proc.name() == 'autoserv'
-
-
-def _is_apache(proc):
- """Return whether a proc is an apache2 process."""
- return proc.name() == 'apache2'
+ return _is_process_name('autoserv', proc)
def _is_python_module(module, proc):
@@ -135,6 +130,6 @@
cmdline[1:3] == ['-m', module])
-def _is_lucifer_run_job(proc):
- """Return whether proc is a lucifer_run_job process."""
- return proc.name() == 'lucifer_run_job'
+def _is_process_name(name, proc):
+ """Return whether process proc is named name."""
+ return proc.name() == name