1
0
Fork 0

Merge pull request #613 from yarda/net-monitor-no-traceback

monitor_net: fixed traceback if stats cannot be read
This commit is contained in:
Jaroslav Škarvada 2024-03-13 10:04:09 +01:00 committed by GitHub
commit 33a54b3c1b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -2,6 +2,9 @@ import tuned.monitors
import os
import re
from tuned.utils.nettool import ethcard
from tuned.utils.commands import commands
cmd = commands()
class NetMonitor(tuned.monitors.Monitor):
@ -30,8 +33,7 @@ class NetMonitor(tuned.monitors.Monitor):
def _updateStat(cls, dev):
files = ["rx_bytes", "rx_packets", "tx_bytes", "tx_packets"]
for i,f in enumerate(files):
with open("/sys/class/net/" + dev + "/statistics/" + f) as statfile:
cls._load[dev][i] = statfile.read().strip()
cls._load[dev][i] = cmd.read_file("/sys/class/net/" + dev + "/statistics/" + f, err_ret = "0").strip()
@classmethod
def update(cls):