diff options
author | Christian Breunig <christian@breunig.cc> | 2023-03-29 08:00:33 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-29 08:00:33 +0200 |
commit | 454a49dfc1e2c08f72e9f9ae9a4a90818be76ae3 (patch) | |
tree | cdcbfaa6e046e3b0c9f41561b5e68e58c1839dde /python/vyos/ifconfig/operational.py | |
parent | 1221bfa29ee8b081cb6d958c914f0a8ac847bc3a (diff) | |
parent | a1c9c36c917a23d4cc3d5a9bbdd92c18829679b7 (diff) | |
download | vyos-1x-454a49dfc1e2c08f72e9f9ae9a4a90818be76ae3.tar.gz vyos-1x-454a49dfc1e2c08f72e9f9ae9a4a90818be76ae3.zip |
Merge pull request #1916 from jestabro/clear-counters
interfaces: T4885: add 'clear interfaces counters' to op-mode
Diffstat (limited to 'python/vyos/ifconfig/operational.py')
-rw-r--r-- | python/vyos/ifconfig/operational.py | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/python/vyos/ifconfig/operational.py b/python/vyos/ifconfig/operational.py index 33e8614f0..dc2742123 100644 --- a/python/vyos/ifconfig/operational.py +++ b/python/vyos/ifconfig/operational.py @@ -143,15 +143,17 @@ class Operational(Control): except IOError: return no_stats - def clear_counters(self, counters=None): - clear = self._stats_all if counters is None else [] - stats = self.load_counters() + def clear_counters(self): + stats = self.get_stats() for counter, value in stats.items(): - stats[counter] = 0 if counter in clear else value + stats[counter] = value self.save_counters(stats) def reset_counters(self): - os.remove(self.cachefile(self.ifname)) + try: + os.remove(self.cachefile(self.ifname)) + except FileNotFoundError: + pass def get_stats(self): """ return a dict() with the value for each interface counter """ |