mirror of
https://github.com/kernelkit/infix.git
synced 2026-07-30 20:43:02 +02:00
statd: backport finit patch to fix 'show services'
Service descriptions or command arguments may contain special characters
that need to be escaped in JSON strings.
Example:
{
...
"command": "udhcpc -f -p /run/dhcp-client-wan.pid -t 3 -T 5 -A 30 -a1000 -S -R -o -O 1 -O 3 -O 6 -O 12 -O 15 -O 28 -O 42 -i wan -V "NanoPi R2S"",
...
}
Also, wrap add_services() in a try/except instead of testing for keys.
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
@@ -183,22 +183,21 @@ def add_services(out):
|
||||
services = []
|
||||
|
||||
for d in data:
|
||||
if "pid" not in d or "status" not in d or "identity" not in d or "description" not in d:
|
||||
try:
|
||||
services.append({
|
||||
"pid": d["pid"],
|
||||
"name": d["identity"],
|
||||
"status": d["status"],
|
||||
"description": d["description"],
|
||||
"statistics": {
|
||||
"memory-usage": str(d.get("memory", 0)),
|
||||
"uptime": str(d.get("uptime", 0)),
|
||||
"restart-count": int(d.get("restarts", 0))
|
||||
}
|
||||
})
|
||||
except KeyError:
|
||||
continue
|
||||
|
||||
entry = {
|
||||
"pid": d["pid"],
|
||||
"name": d["identity"],
|
||||
"status": d["status"],
|
||||
"description": d["description"],
|
||||
"statistics": {
|
||||
"memory-usage": str(d.get("memory", 0)),
|
||||
"uptime": str(d.get("uptime", 0)),
|
||||
"restart-count": int(d.get("restarts", 0))
|
||||
}
|
||||
}
|
||||
services.append(entry)
|
||||
|
||||
insert(out, "infix-system:services", "service", services)
|
||||
|
||||
def add_software(out):
|
||||
|
||||
Reference in New Issue
Block a user