dot

packages and services management
Log | Files | Refs | README

commit 821b56480d2d63313a0148ae860b615523277d43
parent 33649cf6ebd538d82b9be06aba263ece482d2a20
Author: Josuah Demangeon <josuah.demangeon@gandi.net>
Date:   Mon, 24 Jul 2017 11:06:14 +0200

bin/monitor: zfs support and better BSDs support

Diffstat:
Mbin/monitor | 20++++++++++++--------
1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/bin/monitor b/bin/monitor @@ -13,10 +13,8 @@ case "$(uname)" in (Solaris) mem=free cpu=id bi='' bo='' b="$disks" ;; esac -disks=$(df | sed -r '1d; s|^/dev/([^ ]*)[^ ] .*|\1|' | sort -u | tr '\n' ' ') - vmstat 2 2 | -awk -v mem="$mem" -v cpu="$cpu" -v bi="$bi" -v bo="$bo" -v disks="$disks" ' +awk -v mem="$mem" -v cpu="$cpu" -v bi="$bi" -v bo="$bo" ' BEGIN { "date +%Y-%m-%d-%H-%M" | getline date @@ -26,21 +24,27 @@ BEGIN { sub(/.*[Ll]oad[^0-9]*/, "", load) sub(/[^0-9.].*/, "", load) - while ("df" | getline) if ($1 ~ "^/dev/") stor += $4 + while ("df" | getline) + if ($1 ~ "^/dev/" || $1 = "zroot") stor += $4 } -NR == 2 { split($0, keys, " ") } +NR == 2 { + split($0, keys, " ") + + for (key in keys) + if (keys[key] ~ /0$/) disks[i++] = keys[key] +} NR >= 4 { for (i = split($0, values, " "); i > 0; i--) table[keys[i]] = values[i] - diskio = table[bi] + table[bo] mem = table[mem] cpu = 100 - table[cpu] + load = load * 100 + diskio = table[bi] + table[bo] - split(disks, diskv, " ") - for (disk in diskv) + for (disk in disks) diskio += table[diskv[disk]] print host " " date " " mem " " cpu " " load " " diskio " " stor