Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #94: Remove Process monitor job from Linux and create a new connector for process monitoring in Linux #109

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
15 commits
Select commit Hold shift + click to select a range
06f64ea
Issue #94: Remove Process monitor job from Linux and create a new con…
SafaeAJ Aug 9, 2024
fa71b1f
Issue #94: Remove Process monitor job from Linux and create a new con…
SafaeAJ Aug 9, 2024
d631558
Issue #94: Remove Process monitor job from Linux and create a new con…
SafaeAJ Aug 16, 2024
4312298
Merge branch 'feature/issue-94-remove-process-monitor-job-from-linux-…
SafaeAJ Aug 16, 2024
81853dc
Issue #94: Remove Process monitor job from Linux and create a new con…
SafaeAJ Aug 16, 2024
e6347a5
Merge remote-tracking branch 'remotes/origin/main' into feature/issue…
SafaeAJ Aug 16, 2024
629e456
Issue #94: Remove Process monitor job from Linux and create a new con…
SafaeAJ Aug 27, 2024
f1d866a
Issue #94: Remove Process monitor job from Linux and create a new con…
SafaeAJ Aug 27, 2024
cc7b8c4
Issue #94: Remove Process monitor job from Linux and create a new con…
SafaeAJ Aug 28, 2024
5a76feb
Issue #94: Remove Process monitor job from Linux and create a new con…
SafaeAJ Aug 29, 2024
71648a6
Merge remote-tracking branch 'remotes/origin/main' into feature/issue…
SafaeAJ Aug 29, 2024
d8596e6
Issue #94: Remove Process monitor job from Linux and create a new con…
SafaeAJ Aug 29, 2024
4a9eb8b
Issue #94: Remove Process monitor job from Linux and create a new con…
SafaeAJ Aug 29, 2024
fa8daff
Issue #94: Remove Process monitor job from Linux and create a new con…
SafaeAJ Aug 29, 2024
06aaff6
Issue #94: Remove Process monitor job from Linux and create a new con…
SafaeAJ Sep 2, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 0 additions & 19 deletions src/main/connector/system/Linux/Linux.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,25 +50,6 @@ monitors:
system.cpu.time{system.cpu.state="system"}: $4
system.cpu.time{system.cpu.state="idle"}: $5
system.cpu.time{system.cpu.state="io_wait"}: $6
process:
simple:
sources:
procrb:
type: commandLine
commandLine: (cat /proc/stat)
computes:
- type: awk
script: |
/procs_/ {s = s ";" $2}
END {print s}
mapping:
source: ${source::procrb}
attributes:
id: $1
name: $2
metrics:
system.cpu.process{system.cpu.process="running"}: $2
system.cpu.process{system.cpu.process="blocked"}: $3
memory:
simple:
sources:
Expand Down
102 changes: 102 additions & 0 deletions src/main/connector/system/LinuxProcess/LinuxProcess.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
extends:
- ../System/System
connector:
displayName: Linux - Processes (ps)
platforms: Any Linux system
reliesOn: Linux ps command
information: Monitors performance metrics (CPU, memory, etc.) of the processes that match the specified criteria in `matchName`, `matchCommand`, and `matchUser`.
detection:
connectionTypes:
- remote
- local
appliesTo:
- linux
disableAutoDetection: true
criteria:
SafaeAJ marked this conversation as resolved.
Show resolved Hide resolved
- type: commandLine
commandLine: /usr/bin/which ps || /bin/which ps
expectedResult: /bin/ps
errorMessage: Not a valid Linux host.
tags: [ system, linux ]
monitors:
process:
simple:
sources:
process:
type: commandLine
commandLine: /bin/ps --no-headers -e -w -o pid,ppid,comm,user,time,pmem,rss,vsz,thcount,etime,command
computes:
- type: awk
script: |
{
pid = $1
ppid = $2
comm = $3
user = $4
cpuTime = $5
mem = $6
rss = $7 * 1024
vsz = $8 * 1024
thcount= $9
elapsedTime = $10

# Converting cpuTime to seconds
cpuElementCount = split(cpuTime, cpuTimeElements, "[-:]");
if (cpuElementCount == 3) {
cpuSeconds = cpuTimeElements[1] * 3600 + cpuTimeElements[2] * 60 + cpuTimeElements[3];
} else if (cpuElementCount == 4) {
cpuSeconds = cpuTimeElements[1] * 3600 * 24 + cpuTimeElements[2] * 3600 + cpuTimeElements[3] * 60 + cpuTimeElements[4];
}

# Converting elapsedTime to seconds
elapsedElementCount = split(elapsedTime, elapsedTimeElements, "[-:]");
if (elapsedElementCount == 2) {
elapsedSeconds = elapsedTimeElements[1] * 60 + elapsedTimeElements[2];
} else if (elapsedElementCount == 3) {
elapsedSeconds = elapsedTimeElements[1] * 3600 + elapsedTimeElements[2] * 60 + elapsedTimeElements[3];
} else if (elapsedElementCount == 4) {
elapsedSeconds = elapsedTimeElements[1] * 3600 * 24 + elapsedTimeElements[2] * 3600 + elapsedTimeElements[3] * 60 + elapsedTimeElements[4];
}

# Concatenate the full command from $11 to $NF
command = ""
for (i = 11; i <= NF; i++) {
command = command $i " "
}
# Remove the trailing space
command = substr(command, 1, length(command)-1)
gsub(";", "", command)

SafaeAJ marked this conversation as resolved.
Show resolved Hide resolved
printf "%s;%s;%s;%s;%s;%s;%s;%s;%s;%s;%s\n", pid,ppid,comm,user,cpuSeconds,mem,rss,vsz,thcount,elapsedSeconds,command
}
# Filter by process name
- type: keepOnlyMatchingLines
column: 3
regExp: '${var::matchName}'
# Filter by process command
SafaeAJ marked this conversation as resolved.
Show resolved Hide resolved
- type: keepOnlyMatchingLines
column: 11
regExp: '${var::matchCommand}'
# Filter by process user
- type: keepOnlyMatchingLines
column: 4
regExp: '${var::matchUser}'
mapping:
# pid;ppid;comm;user;cpuSeconds;mem;rss;vsz;thcount;elapsedSeconds;command
source: ${source::process}
attributes:
SafaeAJ marked this conversation as resolved.
Show resolved Hide resolved
id: $1
process.id: $1
process.parent.id: $2
process.name: $3
process.match.name: ${var::matchName}
process.match.command: ${var::matchCommand}
process.match.user: ${var::matchUser}
metrics:
process.cpu.utilization: rate($5)
process.cpu.time: $5
process.memory.utilization: $6
process.memory.usage: $7
process.memory.virtual: $8
process.thread.count: $9
process.time: $10
30 changes: 29 additions & 1 deletion src/main/connector/system/System/System.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,38 @@ metrics:
description: Total number of processes created over uptime of the host
type: Counter
unit: "{process}"
process.cpu.utilization:
description: CPU utilization of the process
type: Gauge
unit: "1"
process.cpu.time:
description: CPU time consumed by the process in seconds during its lifetime.
type: Counter
unit: s
process.memory.utilization:
description: Memory utilization of the process
type: Gauge
unit: "1"
process.memory.usage:
description: The amount of physical memory in use by the process
type: UpDownCounter
unit: By
process.memory.virtual:
description: The amount of committed virtual memory for the process
type: UpDownCounter
unit: By
process.thread.count:
description: Process threads count
type: UpDownCounter
unit: "{thread}"
process.time:
description: Life time of the process
type: UpDownCounter
unit: s
system.linux.memory.available:
description: An estimate of how much memory is available for starting new applications, without causing swapping
type: UpDownCounter
unit: By
unit: By
system.uptime:
description: System uptime in seconds indicates how long the host has been running since its last boot
type: Gauge
Expand Down