mirror of
https://github.com/thingsboard/thingsboard-gateway
synced 2025-10-26 22:31:42 +08:00
Added timeout parameter
This commit is contained in:
@@ -1,25 +1,31 @@
|
||||
[
|
||||
{
|
||||
"timeout": 100,
|
||||
"command": ["/bin/sh", "-c", "ps -A -o cpu,%mem | awk '{cpu += $1}END{print cpu}'"],
|
||||
"attributeOnGateway": "CPU"
|
||||
},
|
||||
{
|
||||
"timeout": 100,
|
||||
"command": ["/bin/sh", "-c", "ps -A -o %cpu,%mem | awk '{mem += $2}END{print mem}'"],
|
||||
"attributeOnGateway": "Memory"
|
||||
},
|
||||
{
|
||||
"timeout": 100,
|
||||
"command": ["/bin/sh", "-c", "ipconfig getifaddr en0"],
|
||||
"attributeOnGateway": "IP address"
|
||||
},
|
||||
{
|
||||
"timeout": 100,
|
||||
"command": ["/bin/sh", "-c", "sw_vers -productName"],
|
||||
"attributeOnGateway": "OS"
|
||||
},
|
||||
{
|
||||
"timeout": 100,
|
||||
"command": ["/bin/sh", "-c", "uptime"],
|
||||
"attributeOnGateway": "Uptime"
|
||||
},
|
||||
{
|
||||
"timeout": 100,
|
||||
"command": ["/bin/sh", "-c", "system_profiler SPUSBDataType"],
|
||||
"attributeOnGateway": "USBs"
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ class StatisticsService(Thread):
|
||||
data_to_send = {}
|
||||
for attribute in self._config:
|
||||
process = subprocess.run(attribute['command'], stdout=subprocess.PIPE, stderr=subprocess.PIPE,
|
||||
encoding='utf-8')
|
||||
encoding='utf-8', timeout=attribute['timeout'])
|
||||
|
||||
if process.returncode != 0:
|
||||
self._log.error("Statistic parameter raise the exception: %s", process.stderr)
|
||||
|
||||
Reference in New Issue
Block a user