Fixes for disk usage

This commit is contained in:
Alexandru-Victor Macocian
2025-10-30 17:59:18 +01:00
parent 87b0d2dbbf
commit d6caac4a97
2 changed files with 8 additions and 5 deletions
+2 -2
View File
@@ -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"
+6 -3
View File
@@ -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 {