-
Notifications
You must be signed in to change notification settings - Fork 0
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 #85: Added new metrics system.uptime #86
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -228,6 +228,32 @@ monitors: | |
system.filesystem.usage{system.filesystem.state=free}: $5 | ||
system.filesystem.utilization{system.filesystem.state=used}: $6 | ||
system.filesystem.utilization{system.filesystem.state=free}: $7 | ||
system: | ||
simple: | ||
sources: | ||
# Distribution;Version;Kernel | ||
osInformation: | ||
type: commandLine | ||
commandLine: | | ||
os_info=$(cat /etc/os-release | grep -E '^(NAME|VERSION="[0-9].*")' | tr -d '"') | ||
kernel_version=$(cat /proc/version | awk '{print $3}') | ||
echo "$os_info; $kernel_version" | ||
computes: | ||
- type: awk | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This compute step is unnecessary. |
||
script: BEGIN { FS = "=" } { printf $2 ";"} | ||
# Uptime (timestamp) | ||
uptime: | ||
type: commandLine | ||
commandLine: expr $(date +%s) - $(awk '{print int($1)}' /proc/uptime) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Uptime is supposed to be the number of seconds since last boot, which is what we have in Let's merge everything in 1 script: sources:
osInformation:
type: commandLine
commandLine: |
. /etc/os-release
echo "$NAME;$VERSION;`uname -r`;`cut -d. -f1 /proc/uptime`"
mapping:
source: ${source::osInformation}
attributes:
id: $3
name: $1
version: $2
os_version: $3
metrics:
system.uptime: $4 |
||
mapping: | ||
source: ${source::osInformation} | ||
attributes: | ||
id: $3 | ||
name: $1 | ||
version: $2 | ||
os_version: $3 | ||
metrics: | ||
system.uptime: ${source::uptime} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Urgl! @NassimBtk Is this even supported? 😅 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes @bertysentry, I totally forgot we support that 🤦♂️, it will avoid unnecessary joins. |
||
translations: | ||
serviceLoadedTranslationTable: | ||
not-found: "0" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -122,4 +122,8 @@ metrics: | |
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: Timestamp of the system's last startup. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, uptime is the time elapsed since last boot. |
||
type: Gauge | ||
unit: s |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -274,3 +274,26 @@ monitors: | |
system.disk.io_time: $6 | ||
system.disk.operation_time{disk.io.direction="read"}: $7 | ||
system.disk.operation_time{disk.io.direction="write"}: $8 | ||
system: | ||
simple: | ||
sources: | ||
# SerialNumber;Caption;Version;BuildNumber | ||
osInformation: | ||
type: wmi | ||
namespace: root\CIMv2 | ||
query: SELECT SerialNumber, Caption, Version, BuildNumber FROM Win32_OperatingSystem | ||
# Uptime (timestamp) | ||
uptime: | ||
type: wmi | ||
namespace: root\CIMv2 | ||
query: SELECT LastBootUpTime FROM Win32_OperatingSystem | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use |
||
mapping: | ||
source: ${source::osInformation} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. TBH, I think it would be safer to make a table join on |
||
attributes: | ||
id: $1 | ||
serial_number: $1 | ||
name: $2 | ||
version: $4 | ||
os_version: $3 | ||
metrics: | ||
system.uptime: ${source::uptime} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's actually more efficient and robust to "execute"
/etc/os-release
and then echo the required env variables. The below script will achieve the same result with much less processes: