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 #8: Added Linux Connector to Community repository #11

Merged
merged 4 commits into from
Jan 15, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
69 changes: 44 additions & 25 deletions src/main/connector/system/Linux/Linux.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,21 @@ metrics:
- dead
- exited
connector:
displayName: "LinuxOS"
platform: "Any platform with LinuxOS"
reliesOn: "Linux OsCommands"
information: "Gives OS specific information and metrics"
displayName: LinuxOS
platform: Any platform with LinuxOS
reliesOn: Linux OsCommands
information: Gives OS specific information and metrics
detection:
connectionTypes:
- remote
- local
appliesTo:
- "linux"
- linux
criteria:
- type: osCommand
commandLine: "/usr/bin/uname -o"
expectedResult: "GNU/Linux"
errorMessage: "Not a valid Linux host."
- type: osCommand
commandLine: /usr/bin/uname -o
expectedResult: GNU/Linux
errorMessage: Not a valid Linux host.
monitors:
cpu:
simple:
Expand All @@ -46,10 +46,14 @@ monitors:
type: osCommand
commandLine: /usr/bin/cat /proc/stat
computes:
- type: awk
script: /cpu[0-9]/ {sub("cpu",""); print $1 ";" $2 / 1000 ";" $3 / 1000 ";" $4 / 1000 ";" $5 / 1000 ";" $6 / 1000}
- type: awk
script: |
/cpu[0-9]/ {
sub("cpu","");
print $1 ";" $2 / 1000 ";" $3 / 1000 ";" $4 / 1000 ";" $5 / 1000 ";" $6 / 1000
}
mapping:
source: "${source::monitors.cpu.simple.sources.source(1)}"
source: ${source::monitors.cpu.simple.sources.source(1)}
attributes:
id: $1
name: ${awk::sprintf("%s %s", "cpu", $1)}
alexdgilbert marked this conversation as resolved.
Show resolved Hide resolved
Expand All @@ -73,10 +77,10 @@ monitors:
type: osCommand
commandLine: cat /proc/meminfo
computes:
- type: awk
script: "${file::memory.awk}"
- type: awk
script: ${file::memory.awk}
mapping:
source: "${source::monitors.memory.simple.sources.source(1)}"
source: ${source::monitors.memory.simple.sources.source(1)}
attributes:
id: memory_usage
system.memory.limit: $1
Expand All @@ -97,11 +101,19 @@ monitors:
# id;reads;readsMerged;readTime;writes;writesMerged;writeTime;ioTime
type: osCommand
commandLine: cat /proc/diskstats
selectColumns: 3,4,5,7,8,9,11,13
computes:
- type: awk
script: '{print $3 ";" $4 ";" $5 ";" $7 / 1000 ";" $8 ";" $9 ";" $11 / 1000 ";" $13 / 1000}'
- type: divide
column: 2
value: 1000
- type: divide
column: 5
value: 1000
- type: divide
column: 8
value: 1000
mapping:
source: "${source::monitors.disk.simple.sources.source(1)}"
source: ${source::monitors.disk.simple.sources.source(1)}
attributes:
id: $1
system.disk.device: $1
Expand All @@ -120,12 +132,17 @@ monitors:
source(1):
# serviceName;load;active;sub;description
type: osCommand
commandLine: systemctl list-units --type=service --all
commandLine: /usr/bin/systemctl list-units --type=service --all
computes:
- type: awk
script: /\.service/ {sub(/^[^[:alnum:]]+\s*/, ""); sub("\.service", ""); printf $1 ";" $2 ";" $3 ";" $4 ";"; for (i=5; i<=NF; i++) printf "%s ", $i; printf "\n"}
- type: awk
script: |
/\.service/ {
sub(/^[^[:alnum:]]+\s*/, "");
sub("\.service", "");
printf $1 ";" $2 ";" $3 ";" $4 ";"; for (i=5; i<=NF; i++) printf "%s ", $i; printf "\n"
alexdgilbert marked this conversation as resolved.
Show resolved Hide resolved
}
mapping:
source: "${source::monitors.service.simple.sources.source(1)}"
source: ${source::monitors.service.simple.sources.source(1)}
attributes:
id: $1
description: $5
Expand All @@ -141,11 +158,13 @@ monitors:
# filesystem;mountpoint;type;used;available
type: osCommand
commandLine: /usr/bin/df -B1 --output=source,target,fstype,used,avail
separators: \t
selectColumns: 1,2,3,4,5
computes:
- type: awk
script: 'NR > 1 {print $1 "(" $2 ")" ";" $2 ";" $3 ";" $4 ";" $5}'
- type: awk
script: NR > 1 {print $1 "(" $2 ")" ";" $2 ";" $3 ";" $4 ";" $5}
mapping:
source: "${source::monitors.filesystem.simple.sources.source(1)}"
source: ${source::monitors.filesystem.simple.sources.source(1)}
attributes:
id: $1
system.filesystem.device: $1
Expand Down
29 changes: 24 additions & 5 deletions src/main/connector/system/Linux/memory.awk
alexdgilbert marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
/MemTotal/ {memTotal = ($2 * 1024)}
/MemFree/ {memFree = ($2 * 1024); memFreeUtilization = (memFree / memTotal); memUsed = (memTotal - memFree); memUsedUtilization = (memUsed / memTotal)}
/Buffers/ {memBuffers = ($2 * 1024); memBuffersUtilization = (memBuffers / memTotal)}
/Cached/ {memCached = ($2 * 1024); memCachedUtilization = (memCached / memTotal)}
END {printf("%s;%s;%s;%s;%s;%s;%s;%s;%s\n", memTotal, memFree, memUsed, memBuffers, memCached, memFreeUtilization, memUsedUtilization, memBuffersUtilization, memCachedUtilization)}
/MemTotal/ {
memTotal = $2 * 1024
}

/MemFree/ {
memFree = $2 * 1024
memFreeUtilization = memFree / memTotal
memUsed = memTotal - memFree
memUsedUtilization = memUsed / memTotal
}

/Buffers/ {
memBuffers = $2 * 1024
memBuffersUtilization = memBuffers / memTotal
}

/Cached/ {
memCached = $2 * 1024
memCachedUtilization = memCached / memTotal
}

END {
printf("%s;%s;%s;%s;%s;%s;%s;%s;%s\n", memTotal, memFree, memUsed, memBuffers, memCached, memFreeUtilization, memUsedUtilization, memBuffersUtilization, memCachedUtilization)
}