Formatting: Format all python code with black.
This CL is probably not what you're looking for, it's only
automated formatting. Ignore it with
`git blame --ignore-rev <revision>` for this commit.
BUG=b:233893248
TEST=CQ
Change-Id: I66591d7a738d241aed3290138c0f68065ab10a6d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/chromite/+/3879174
Reviewed-by: Mike Frysinger <vapier@chromium.org>
Tested-by: Alex Klein <saklein@chromium.org>
diff --git a/scripts/sysmon/mainlib.py b/scripts/sysmon/mainlib.py
index 498a3d6..261ab39 100644
--- a/scripts/sysmon/mainlib.py
+++ b/scripts/sysmon/mainlib.py
@@ -27,72 +27,73 @@
class _MetricCollector(object):
- """Metric collector class."""
+ """Metric collector class."""
- def __init__(self):
- self._collect_osinfo = _TimedCallback(
- callback=osinfo_metrics.collect_os_info,
- interval=60 * 60)
+ def __init__(self):
+ self._collect_osinfo = _TimedCallback(
+ callback=osinfo_metrics.collect_os_info, interval=60 * 60
+ )
- def __call__(self):
- """Collect metrics."""
- system_metrics.collect_uptime()
- system_metrics.collect_cpu_info()
- system_metrics.collect_disk_info()
- system_metrics.collect_mem_info()
- net_metrics.collect_net_info()
- proc_metrics.collect_proc_info()
- system_metrics.collect_load_avg()
- puppet_metrics.collect_puppet_summary()
- git_metrics.collect_git_metrics()
- self._collect_osinfo()
- system_metrics.collect_unix_time() # must be just before flush
- metrics.Flush()
+ def __call__(self):
+ """Collect metrics."""
+ system_metrics.collect_uptime()
+ system_metrics.collect_cpu_info()
+ system_metrics.collect_disk_info()
+ system_metrics.collect_mem_info()
+ net_metrics.collect_net_info()
+ proc_metrics.collect_proc_info()
+ system_metrics.collect_load_avg()
+ puppet_metrics.collect_puppet_summary()
+ git_metrics.collect_git_metrics()
+ self._collect_osinfo()
+ system_metrics.collect_unix_time() # must be just before flush
+ metrics.Flush()
class _TimedCallback(object):
- """Limits callback to one call in a given interval."""
+ """Limits callback to one call in a given interval."""
- def __init__(self, callback, interval):
- """Initialize instance.
+ def __init__(self, callback, interval):
+ """Initialize instance.
- Args:
- callback: function to call
- interval: Number of seconds between allowed calls
- """
- self._callback = callback
- self._interval = interval
- self._last_called = float('-inf')
+ Args:
+ callback: function to call
+ interval: Number of seconds between allowed calls
+ """
+ self._callback = callback
+ self._interval = interval
+ self._last_called = float("-inf")
- def __call__(self):
- if time.time() >= self._next_call:
- self._callback()
- self._last_called = time.time()
+ def __call__(self):
+ if time.time() >= self._next_call:
+ self._callback()
+ self._last_called = time.time()
- @property
- def _next_call(self):
- return self._last_called + self._interval
+ @property
+ def _next_call(self):
+ return self._last_called + self._interval
def main():
- parser = commandline.ArgumentParser(
- description=__doc__,
- default_log_level='DEBUG')
- parser.add_argument(
- '--interval',
- default=60,
- type=int,
- help='time (in seconds) between sampling system metrics')
- opts = parser.parse_args()
- opts.Freeze()
+ parser = commandline.ArgumentParser(
+ description=__doc__, default_log_level="DEBUG"
+ )
+ parser.add_argument(
+ "--interval",
+ default=60,
+ type=int,
+ help="time (in seconds) between sampling system metrics",
+ )
+ opts = parser.parse_args()
+ opts.Freeze()
- # This call returns a context manager that doesn't do anything, so we
- # ignore the return value.
- ts_mon_config.SetupTsMonGlobalState('sysmon', auto_flush=False)
- # The default prefix is '/chrome/infra/'.
- interface.state.metric_name_prefix = (interface.state.metric_name_prefix
- + 'chromeos/sysmon/')
+ # This call returns a context manager that doesn't do anything, so we
+ # ignore the return value.
+ ts_mon_config.SetupTsMonGlobalState("sysmon", auto_flush=False)
+ # The default prefix is '/chrome/infra/'.
+ interface.state.metric_name_prefix = (
+ interface.state.metric_name_prefix + "chromeos/sysmon/"
+ )
- collector = _MetricCollector()
- loop.SleepLoop(callback=collector,
- interval=opts.interval).loop_forever()
+ collector = _MetricCollector()
+ loop.SleepLoop(callback=collector, interval=opts.interval).loop_forever()