root / plugins / other / openbsd-memory @ 8a481afc
Historique | Voir | Annoter | Télécharger (939 octets)
| 1 | 8a481afc | northox | #!/bin/sh |
|---|---|---|---|
| 2 | if [ "$1" = "config" ]; then |
||
| 3 | echo "graph_title Memory usage (in MB)" |
||
| 4 | echo 'graph_category system' |
||
| 5 | echo "acti.label Active momery" |
||
| 6 | echo "total.label Memory total" |
||
| 7 | echo "free.label Free memory" |
||
| 8 | echo "swap.label Swap in use" |
||
| 9 | echo "swapt.label Swap total" |
||
| 10 | exit 0 |
||
| 11 | fi |
||
| 12 | |||
| 13 | # Memory: Real: 14M/69M act/tot Free: 173M Swap: 0K/612M used/tot |
||
| 14 | |||
| 15 | top -un | nawk ' |
||
| 16 | function scale(v) {
|
||
| 17 | if (value ~ /G$/) { sub("G", "", v); v *= 1024 }
|
||
| 18 | else if (v ~ /M$/) sub("M", "", v)
|
||
| 19 | else if (v ~ /K$/) { sub("K", "", v); v /= 1024 }
|
||
| 20 | else v /= 1024 * 1024; |
||
| 21 | return v; |
||
| 22 | } |
||
| 23 | function spliter(v, i) {
|
||
| 24 | split(v,a,"/"); |
||
| 25 | return(a[i]); |
||
| 26 | } |
||
| 27 | /^Memory/ {
|
||
| 28 | acti = scale(spliter($3,1)); |
||
| 29 | total = scale(spliter($3,2)); |
||
| 30 | free = scale($6); |
||
| 31 | swap = scale(spliter($8,1)); |
||
| 32 | swapt = scale(spliter($8,2)); |
||
| 33 | |||
| 34 | print "acti.value", acti |
||
| 35 | print "total.value", total |
||
| 36 | print "free.value", free |
||
| 37 | print "swap.value", swap |
||
| 38 | print "swapt.value", swapt |
||
| 39 | }' |
