linux_system: apply Router uma-events hack to System too

LinuxSystem is used for packet capture hosts, which tend to run the same
hardware and OS as LinuxRouter. They have the same problems
(crbug.com/839164) with unbounded file growth in
/var/lib/metrics/uma-events, so move the hack there instead.

This hack is harmless for devices that don't have the file (e.g., if we
ever go back to supporting packet capture hosts running
non-Chrome-OS-based OS).

BUG=chromium:1017496
TEST=wifi_matfunc

Change-Id: I0ff0e418fda4731ea563e749cc6d48da6fab3b0a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/autotest/+/1879475
Tested-by: Brian Norris <briannorris@chromium.org>
Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org>
Reviewed-by: Harpreet Grewal <harpreet@chromium.org>
Commit-Queue: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com>
diff --git a/server/site_linux_router.py b/server/site_linux_router.py
index cfab7cc..1d578f3 100644
--- a/server/site_linux_router.py
+++ b/server/site_linux_router.py
@@ -119,8 +119,6 @@
     _RNG_AVAILABLE = '/sys/class/misc/hw_random/rng_available'
     _RNG_CURRENT = '/sys/class/misc/hw_random/rng_current'
 
-    _UMA_EVENTS = '/var/lib/metrics/uma-events'
-
     def get_capabilities(self):
         """@return iterable object of AP capabilities for this system."""
         caps = set()
@@ -188,12 +186,6 @@
         self.dhcpd_conf = '/tmp/dhcpd.%s.conf'
         self.dhcpd_leases = '/tmp/dhcpd.leases'
 
-        # TODO(crbug.com/839164): some routers fill their stateful partition
-        # with uncollected metrics.
-        if self.host.path_exists(self._UMA_EVENTS):
-            self.host.run('truncate -s 0 %s' % self._UMA_EVENTS,
-                          ignore_status=True)
-
         # Log the most recent message on the router so that we can rebuild the
         # suffix relevant to us when debugging failures.
         last_log_line = self.host.run('tail -1 /var/log/messages',
diff --git a/server/site_linux_system.py b/server/site_linux_system.py
index 07720b1..d63e8d3 100644
--- a/server/site_linux_system.py
+++ b/server/site_linux_system.py
@@ -48,6 +48,8 @@
     MAC_BIT_MULTICAST = 0x1
     MAC_RETRY_LIMIT = 1000
 
+    _UMA_EVENTS = '/var/lib/metrics/uma-events'
+
 
     @property
     def capabilities(self):
@@ -123,6 +125,12 @@
         self._bridge_interface = None
         self._virtual_ethernet_pair = None
 
+        # TODO(crbug.com/839164): some routers fill their stateful partition
+        # with uncollected metrics.
+        if self.host.path_exists(self._UMA_EVENTS):
+            self.host.run('truncate -s 0 %s' % self._UMA_EVENTS,
+                          ignore_status=True)
+
 
     @property
     def phy_list(self):