From 6ed496baa4a2e81d9529d3ccc8710969e9af9339 Mon Sep 17 00:00:00 2001 From: Evan Troy Owen <2evanowen@gmail.com> Date: Thu, 11 Apr 2019 11:19:40 -0600 Subject: [PATCH 1/2] updated systemctl to have sudo in front to match Updated code to have systemctl have sudo in front. Was breaking on some of my hosts without it (ubuntu 16.04) Now matches other lines too Line 340: `sudo -S service` Line 349: `sudo -S service` --- .../modeler/plugins/zenoss/cmd/linux/os_service.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ZenPacks/zenoss/LinuxMonitor/modeler/plugins/zenoss/cmd/linux/os_service.py b/ZenPacks/zenoss/LinuxMonitor/modeler/plugins/zenoss/cmd/linux/os_service.py index 7aaaecb..138eba3 100644 --- a/ZenPacks/zenoss/LinuxMonitor/modeler/plugins/zenoss/cmd/linux/os_service.py +++ b/ZenPacks/zenoss/LinuxMonitor/modeler/plugins/zenoss/cmd/linux/os_service.py @@ -9,7 +9,7 @@ """ -Systemd perf output('systemctl list-units --all --type=service --plain --full --no-page --no-legend') +Systemd perf output('sudo systemctl list-units --all --type=service --plain --full --no-page --no-legend') ... accounts-daemon.service loaded active running Accounts Service @@ -27,10 +27,10 @@ ... -Systemd model output('for i in $(systemctl list-units -t service --all +Systemd model output('for i in $(sudo systemctl list-units -t service --all --no-page --no-legend | sed /not-found/d | cut -d" " -f1) ; do echo "__SPLIT__" ; - systemctl show -p Names,Type,Description,LoadState, + sudo systemctl show -p Names,Type,Description,LoadState, ActiveState,UnitFileState,MainPID,ConditionResult $i ; done'): ... Type=oneshot @@ -326,11 +326,11 @@ def validate_modeling_regex(device, log): if command -v systemctl >/dev/null 2>&1 then echo SYSTEMD - for i in $(systemctl list-units --all --type=service --plain --full --no-page --no-legend | sed /not-found/d | cut -d" " -f1) + for i in $(sudo systemctl list-units --all --type=service --plain --full --no-page --no-legend | sed /not-found/d | cut -d" " -f1) do echo __SPLIT__ echo Title=$i - systemctl show -p Type,Description,ActiveState,UnitFileState,ConditionResult "$i" + sudo systemctl show -p Type,Description,ActiveState,UnitFileState,ConditionResult "$i" done elif command -v initctl >/dev/null 2>&1 then From 45f8d32c87ba9edf3c31f266e29264ee9cea4c7a Mon Sep 17 00:00:00 2001 From: Evan Troy Owen <2evanowen@gmail.com> Date: Thu, 11 Apr 2019 11:30:09 -0600 Subject: [PATCH 2/2] Update zenpack.yaml one more update with a sudo --- ZenPacks/zenoss/LinuxMonitor/zenpack.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ZenPacks/zenoss/LinuxMonitor/zenpack.yaml b/ZenPacks/zenoss/LinuxMonitor/zenpack.yaml index a5c6aba..67c5c01 100755 --- a/ZenPacks/zenoss/LinuxMonitor/zenpack.yaml +++ b/ZenPacks/zenoss/LinuxMonitor/zenpack.yaml @@ -1506,7 +1506,7 @@ device_classes: if command -v systemctl > /dev/null 2>&1 then echo SYSTEMD - systemctl list-units --all --type=service --plain --full --no-page --no-legend + sudo systemctl list-units --all --type=service --plain --full --no-page --no-legend else echo UNKNOWN exit 127