Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(21)

Unified Diff: infra/services/sysmon/__main__.py

Issue 2106953006: adding os metrics (os name and version) being collected every hour (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: updating system_metrics.clear_os_info to clear all added fields, fixing unit tests for clear Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | infra/services/sysmon/system_metrics.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: infra/services/sysmon/__main__.py
diff --git a/infra/services/sysmon/__main__.py b/infra/services/sysmon/__main__.py
index 806104407ed2c07342999648251b3482d13aa1e5..c1a2ae3c50dacc35d19ed51c0790a6622a7e925a 100644
--- a/infra/services/sysmon/__main__.py
+++ b/infra/services/sysmon/__main__.py
@@ -20,6 +20,30 @@ from infra_libs import ts_mon
class SysMon(outer_loop.Application):
+ def __init__(self):
+ # make sure we call our super's init
+ super(SysMon, self).__init__()
+
+ # SysMon.task is called every minute we want to collect some metrics
+ # (e.g. os_info) only once per hour, so here we count the minutes within
+ # the hour
+ #
+ # NB: the guarantee for each call being a minute comes from
+ # chrome_infra/manifests/sysmon.pp in the puppet repo
+ self._minute_count = 0
+
+ def count_minute(self):
+ """ should be called at the end of each call to self.task """
+ # mark that we were called
+ self._minute_count += 1
+
+ # roll over each day-ish, 60 minutes * 24 hours
+ self._minute_count %= 60 * 24
+
+ def is_hour(self):
+ """ check if this call is on the hour """
+ return self._minute_count % 60 == 0
+
def add_argparse_options(self, parser):
super(SysMon, self).add_argparse_options(parser)
@@ -46,12 +70,20 @@ class SysMon(outer_loop.Application):
system_metrics.get_mem_info()
system_metrics.get_net_info()
system_metrics.get_proc_info()
+ if self.is_hour():
+ # collect once per hour
+ system_metrics.get_os_info()
+ else:
+ # clear on all other minutes
+ system_metrics.clear_os_info()
puppet_metrics.get_puppet_summary()
cipd_metrics.get_cipd_summary()
android_device_metrics.get_device_statuses()
system_metrics.get_unix_time() # must be the last in the list
+
finally:
ts_mon.flush()
+ self.count_minute()
return True
def sleep_timeout(self):
« no previous file with comments | « no previous file | infra/services/sysmon/system_metrics.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698