I want to get service status details (Loaded, enabled, active, running, since, Main PID) in machine readable form and I know that systemd tools have --output=json
option, but if I do:
systemctl status servicename --output=json --plain
I see something like:
● snapd.service - Snappy daemon
Loaded: loaded (/lib/systemd/system/snapd.service; enabled; vendor preset: enabled)
Active: active (running) since Mon 2018-04-16 11:20:07 MSK; 4h 45min ago
Main PID: 738 (snapd)
Tasks: 10 (limit: 4915)
CGroup: /system.slice/snapd.service
└─738 /usr/lib/snapd/snapd
{ "__CURSOR" : "s=461ecb6a4b814913acd57572cd1e1c82;...
Journal records are in JSON. But how to get the service status in JSON if it's possible?