Skip to content

Commit b6c85e9

Browse files
committed
update services artifact to use systemctl plugin
1 parent fef9e4c commit b6c85e9

1 file changed

Lines changed: 8 additions & 16 deletions

File tree

artifacts/definitions/SUSE/Linux/Events/Services.yaml

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,17 @@ name: SUSE.Linux.Events.Services
33
description: |
44
This artifact collects new systemd services events.
55
6-
required_permissions:
7-
- EXECVE
8-
96
precondition: |
107
SELECT OS From info() where OS = 'linux'
118
129
type: CLIENT_EVENT
1310

1411
sources:
1512
- query: |
16-
-- grok pattern to parse systemctl show output
17-
LET pattern = "%{NUMBER:pid}\n\{ path\=%{DATA:process} .*\n%{DATA:description}\n%{DATA:state}\n"
18-
19-
-- local function runs systemctl, parses output and deconstructs dict from grok
20-
LET serviceDetails(name) = SELECT pid, process, description, state
21-
FROM foreach(
22-
row= { SELECT grok(data=stdout, grok=pattern) AS parsed
23-
FROM execve(argv=["systemctl", "show", name, "--value", "--property=ExecMainPID,ExecStart,Description,ActiveState"]) },
24-
column="parsed")
13+
LET serviceDetails(name) = SELECT
14+
ExecMainPID, ExecStart, Description, ActiveState
15+
FROM systemctl(command="show", unit=name,
16+
properties=["ExecStart", "Description", "ExecMainPID", "ActiveState"])
2517
2618
LET serviceStartEvents = SELECT
2719
timestamp(epoch=REALTIME_TIMESTAMP) AS Timestamp,
@@ -39,9 +31,9 @@ sources:
3931
Timestamp,
4032
Service,
4133
"root" AS User,
42-
details.pid AS PID,
43-
details.process AS Process,
44-
details.description AS Description,
45-
details.state AS State
34+
details.ExecMainPID AS PID,
35+
details.ExecStart AS Process,
36+
details.Description AS Description,
37+
details.ActiveState AS State
4638
FROM serviceStartEvents
4739

0 commit comments

Comments
 (0)