mirror of
https://github.com/AlexMacocian/ServerManagementUtils.git
synced 2026-07-15 15:19:58 +00:00
Fixes for disk usage
This commit is contained in:
@@ -36,8 +36,8 @@ for i in {1..6}; do
|
||||
# Mount point is everything from column 9 onwards
|
||||
mount=$(echo "$line" | awk '{for(i=9;i<=NF;i++) printf "%s%s", $i, (i<NF?" ":""); print ""}')
|
||||
|
||||
# Skip entries with 0 blocks (pseudo filesystems) or starting with dash
|
||||
if [[ -n "$mount" && -n "$used" && -n "$blocks" && "$blocks" != "0" && ! "$filesystem" =~ ^- ]]; then
|
||||
# Skip entries with 0 blocks (pseudo filesystems) or filesystem starting with dash
|
||||
if [[ -n "$mount" && -n "$used" && -n "$blocks" && "$blocks" != "0" && "$filesystem" != "-" ]]; then
|
||||
used_bytes=$((used * 512))
|
||||
total_bytes=$((blocks * 512))
|
||||
echo "$timestamp $mount $used_bytes $total_bytes" >> "$LOGFILE"
|
||||
|
||||
@@ -1,14 +1,17 @@
|
||||
filter {
|
||||
if [type] == "disk" {
|
||||
dissect {
|
||||
mapping => {
|
||||
"message" => "%{timestamp} %{system.disk.mount_point} %{system.disk.used} %{system.disk.total}"
|
||||
# Parse the message: "timestamp mount_point used_bytes total_bytes"
|
||||
# Mount points can have spaces, so we use grok with greedy matching
|
||||
grok {
|
||||
match => {
|
||||
"message" => "^%{TIMESTAMP_ISO8601:timestamp}\s+(?<system.disk.mount_point>.*?)\s+%{NUMBER:system.disk.used:int}\s+%{NUMBER:system.disk.total:int}$"
|
||||
}
|
||||
}
|
||||
|
||||
date {
|
||||
match => ["timestamp", "ISO8601"]
|
||||
target => "@timestamp"
|
||||
remove_field => ["timestamp"]
|
||||
}
|
||||
|
||||
mutate {
|
||||
|
||||
Reference in New Issue
Block a user