Skip to content

Commit

Permalink
Merge pull request #11 from sentrysoftware/8-add-linux-system-connect…
Browse files Browse the repository at this point in the history
…or-to-community-repository

Issue #8: Added Linux Connector to Community repository
  • Loading branch information
NassimBtk authored Jan 15, 2024
2 parents 7340306 + edce9ea commit 552bab7
Show file tree
Hide file tree
Showing 3 changed files with 327 additions and 0 deletions.
178 changes: 178 additions & 0 deletions src/main/connector/system/Linux/Linux.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@
extends:
- ../System/System
metrics:
system.service.status:
description: Service Status
type:
stateSet:
- running
- dead
- exited
connector:
displayName: LinuxOS
platform: Any platform with LinuxOS
reliesOn: Linux OsCommands
information: Gives OS specific information and metrics
detection:
connectionTypes:
- remote
- local
appliesTo:
- linux
criteria:
- type: osCommand
commandLine: /usr/bin/uname -o
expectedResult: GNU/Linux
errorMessage: Not a valid Linux host.
monitors:
cpu:
simple:
type: multiInstance
sources:
source(1):
# cpuId;user;nice;system;idle;iowait
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
}
mapping:
source: ${source::monitors.cpu.simple.sources.source(1)}
attributes:
id: $1
name: ${awk::sprintf("%s %s", "cpu", $1)}
system.cpu.logical_number: $1
metrics:
system.cpu.utilization{system.cpu.state="user"}: rate($2)
system.cpu.utilization{system.cpu.state="nice"}: rate($3)
system.cpu.utilization{system.cpu.state="system"}: rate($4)
system.cpu.utilization{system.cpu.state="idle"}: rate($5)
system.cpu.utilization{system.cpu.state="io_wait"}: rate($6)
system.cpu.time{system.cpu.state="user"}: $2
system.cpu.time{system.cpu.state="nice"}: $3
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
memory:
simple:
sources:
source(1):
# memTotal;memFree;memUsed;memBuffers;memCached;memFreeUtilization;memUsedUtilization;memBuffersUtilization;memCachedUtilization
type: osCommand
commandLine: cat /proc/meminfo
computes:
- type: awk
script: ${file::memory.awk}
mapping:
source: ${source::monitors.memory.simple.sources.source(1)}
attributes:
id: memory_usage
system.memory.limit: $1
metrics:
system.memory.usage{system.memory.usage="free"}: $2
system.memory.usage{system.memory.usage="used"}: $3
system.memory.usage{system.memory.usage="buffers"}: $4
system.memory.usage{system.memory.usage="cached"}: $5
system.memory.utilization{system.memory.usage="free"}: $6
system.memory.utilization{system.memory.usage="used"}: $7
system.memory.utilization{system.memory.usage="buffers"}: $8
system.memory.utilization{system.memory.usage="cached"}: $9
disk:
simple:
type: multiInstance
sources:
source(1):
# 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: 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)}
attributes:
id: $1
system.disk.device: $1
metrics:
system.disk.operations{direction:read}: $2
system.disk.merged{direction:read}: $3
system.disk.operation_time{direction:read}: $4
system.disk.operations{direction:write}: $5
system.disk.merged{direction:write}: $6
system.disk.operation_time{direction:write}: $7
system.disk.io_time: $8
service:
simple:
type: multiInstance
sources:
source(1):
# serviceName;load;active;sub;description
type: osCommand
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: translate
column: 2
translationTable: ${translation::serviceLoadedTranslationTable}
- type: translate
column: 3
translationTable: ${translation::serviceActiveTranslationTable}
mapping:
source: ${source::monitors.service.simple.sources.source(1)}
attributes:
id: $1
description: $5
metrics:
system.service.status{state="loaded"}: $2
system.service.status{state="active"}: $3
system.service.status: $4
filesystem:
simple:
type: multiInstance
sources:
source(1):
# filesystem;mountpoint;type;used;available
type: osCommand
commandLine: /usr/bin/df -B1 --output=source,target,fstype,used,avail
computes:
- type: awk
script: NR > 1 {print $1 "(" $2 ")" ";" $2 ";" $3 ";" $4 ";" $5}
mapping:
source: ${source::monitors.filesystem.simple.sources.source(1)}
attributes:
id: $1
system.filesystem.device: $1
system.filesystem.mountpoint: $2
system.filesystem.type: $3
metrics:
system.filesystem.usage{system.filesystem.state=used}: $4
system.filesystem.usage{system.filesystem.state=free}: $5
translations:
serviceLoadedTranslationTable:
not-found: "0"
loaded: "1"
serviceActiveTranslationTable:
inactive: "0"
active: "1"
24 changes: 24 additions & 0 deletions src/main/connector/system/Linux/memory.awk
Original file line number Diff line number Diff line change
@@ -0,0 +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)
}
125 changes: 125 additions & 0 deletions src/main/connector/system/System/System.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
metrics:
system.cpu.time:
description: Seconds each logical CPU spent on each mode
type: Counter
unit: s
system.cpu.utilization:
description: Difference in system.cpu.time since the last measurement, divided by the elapsed time and number of logical CPUs
type: Gauge
unit: "1"
system.cpu.physical.count:
description: Reports the number of actual physical processor cores on the hardware
type: UpDownCounter
unit: "{cpu}"
system.cpu.logical.count:
description: Reports the number of logical (virtual) processor cores created by the operating system to manage multitasking
type: UpDownCounter
unit: "{cpu}"
system.cpu.frequency:
description: Reports the current frequency of the CPU in Hz
type: Gauge
unit: "{Hz}"
system.memory.usage:
description: Reports memory in use by state
type: UpDownCounter
unit: By
system.memory.limit:
description: Total memory available in the system
type: UpDownCounter
unit: By
system.memory.utilization:
description: Memory utilization for each possible state
type: Gauge
unit: "1"
system.paging.usage:
description: Unix swap or Windows pagefile usage
type: UpDownCounter
unit: By
system.paging.utilization:
description: Memory paging utilization for each possible state
type: Gauge
unit: "1"
system.paging.faults:
description: Count of major and minor page faults
type: Counter
unit: "{fault}"
system.paging.operations:
description: Count of page-in (swap-in) and page-out (swap-out) operations
type: Counter
unit: "{operation}"
system.disk.io:
description: Disk I/O count
type: Counter
unit: By
system.disk.operations:
description: Count of read and write operations
type: Counter
unit: "{operation}"
system.disk.io_time:
description: Time disk spent activated
type: Counter
unit: s
system.disk.operation_time:
description: Sum of the time each operation took to complete
type: Counter
unit: s
system.disk.merged:
description: Count of merged read and write operations
type: Counter
unit: "{operation}"
system.disk.io_transactions_per_seconds:
description: Disk transactions per seconds
type: Gauge
unit: tps
system.disk.io_average_size:
description: Average size in sectors of requests
type: Gauge
unit: "{sectors}"
system.disk.io_average_queue:
description: Average number of requests in the queue waiting to be served
type: Gauge
unit: "{requests}"
system.disk.io_average_wait:
description: Average time taken for I/O requests to be served
type: Gauge
unit: s
system.filesystem.usage:
description: Filesystem usage
type: UpDownCounter
unit: By
system.filesystem.utilization:
description: Filesystem utilization for each possible state
type: Gauge
unit: "1"
system.network.dropped:
description: Count of dropped packets
type: Counter
unit: "{packet}"
system.network.packets:
description: Count of transmitted and received packets
type: Counter
unit: "{packet}"
system.network.errors:
description: Count of network errors detected
type: Counter
unit: "{error}"
system.network.io:
description: Network I/O count
type: Counter
unit: By
system.network.connections:
description: Count of network connections
type: UpDownCounter
unit: "{connection}"
system.processes.count:
description: Total number of processes in each state
type: UpDownCounter
unit: "{process}"
system.processes.created:
description: Total number of processes created over uptime of the host
type: Counter
unit: "{process}"
system.linux.memory.available:
description: An estimate of how much memory is available for starting new applications, without causing swapping
type: UpDownCounter
unit: By

0 comments on commit 552bab7

Please sign in to comment.