nouveau monitoring pour pile...
|
1 |
# vim: ft=sh |
2 | ||
3 |
function disk_space () { |
|
4 |
local level=(warning severe danger) |
|
5 |
local min=80 |
|
6 |
local inodes=1 |
|
7 |
local taille=2 |
|
8 |
local type= |
|
9 |
df=($(df --sync --output=target,ipcent,pcent /dev/sda* | sed 1d)) |
|
10 |
for ((i=0; i<${#df[@]}; i+=3)); do |
|
11 |
test ${df[i]} == '/usr' -o ${df[i]} == '/' -o ${df[i]} == '/dev' && continue |
|
12 |
for type in inodes taille; do |
|
13 |
test ${df[i+${!type}]/%%} -gt $min \ |
|
14 |
&& l=$(( (${df[i+${!type}]/%%} - $min) / ((100 - $min) / ${#level[@]}) )) \ |
|
15 |
&& l=${l/${#level[@]}/$((${#level[@]}-1))} \ |
|
16 |
&& echo "${level[l]}: ${df[i]} plein à ${df[i+${!type}]} ($type)" |
|
17 |
done |
|
18 |
done |
|
19 |
} |