1
0
mirror of https://github.com/thingsboard/thingsboard-gateway synced 2025-10-26 22:31:42 +08:00

Added statistics file examples for different OS

This commit is contained in:
samson0v
2022-11-18 11:42:39 +02:00
parent c1b8354b25
commit f43e9960cf
5 changed files with 72 additions and 7 deletions

View File

@@ -60,11 +60,12 @@ class StatisticsService(Thread):
if time() - self._last_poll >= self._stats_send_period_in_seconds:
data_to_send = {}
for attribute in self._config:
process = subprocess.run(attribute['command'], stdout=subprocess.PIPE, stderr=subprocess.PIPE,
try:
process = subprocess.run(attribute['command'], stdout=subprocess.PIPE, stderr=subprocess.PIPE,
encoding='utf-8', timeout=attribute['timeout'])
if process.returncode != 0:
self._log.error("Statistic parameter raise the exception: %s", process.stderr)
except Exception as e:
self._log.error("Statistic parameter %s raise the exception: %s",
attribute['attributeOnGateway'], e)
continue
value = process.stdout