From 99d83216bad17ef36384d0a99b2879a2a31d3600 Mon Sep 17 00:00:00 2001 From: vvzvlad Date: Thu, 27 Jul 2023 22:55:05 +0700 Subject: [PATCH] update --- modbus_err_stats.py | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/modbus_err_stats.py b/modbus_err_stats.py index 517534a..dfda84e 100755 --- a/modbus_err_stats.py +++ b/modbus_err_stats.py @@ -18,10 +18,11 @@ def parse_config_file(filename): for port in config_data["ports"]: for device in port["devices"]: device_to_port[device["slave_id"]] = port["path"] - device_stats[device["slave_id"]] = {"type": device.get("device_type", "Unknown type"), "errors": 0, "disconnects": 0, "write_failures": 0} + device_stats[device["slave_id"]] = {"type": device.get("device_type", "Unknown type"), "errors": 0, "disconnects": 0, "write_failures": 0, "invalid_crc_errors": 0} # New line return device_to_port, device_stats + def parse_journal(device_to_port, device_stats, skip_lines=10, history=False): cmd = ["journalctl", "-f", "-u", "wb-mqtt-serial"] if not history else ["journalctl", "-u", "wb-mqtt-serial"] p = subprocess.Popen(cmd, stdout=subprocess.PIPE) @@ -37,6 +38,7 @@ def parse_journal(device_to_port, device_stats, skip_lines=10, history=False): match_error = re.search(r'modbus:(\d+): Serial protocol error: request timed out', line) match_disconnect = re.search(r'INFO: \[serial device\] device modbus:(\d+) is disconnected', line) match_write_failure = re.search(r'WARNING: \[modbus\] failed to write: