6 lines
437 B
Bash
6 lines
437 B
Bash
#!/bin/bash
|
|
# Simple disk usage checker using df
|
|
df -B1 / | awk 'NR==2 {
|
|
total=$2; used=$3; free=$4; pct=$5;
|
|
print "{\"path\": \"/\", \"total_bytes\": " total ", \"used_bytes\": " used ", \"free_bytes\": " free ", \"percent_used\": " substr(pct,1,length(pct)-1) ", \"total_gb\": " int(total/(1024*1024*1024)*100)/100 ", \"used_gb\": " int(used/(1024*1024*1024)*100)/100 ", \"free_gb\": " int(free/(1024*1024*1024)*100)/100 "}"
|
|
}' |