root / plugins / other / openbsd-memory @ 9ae7e3a9
Historique | Voir | Annoter | Télécharger (991 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 | 9ae7e3a9 | northox | echo "acti.label Active" |
| 6 | echo "used.label Used" |
||
| 7 | echo "total.label Total" |
||
| 8 | echo "free.label Free" |
||
| 9 | echo "swap.label Swap used" |
||
| 10 | 8a481afc | northox | echo "swapt.label Swap total" |
| 11 | exit 0 |
||
| 12 | fi |
||
| 13 | |||
| 14 | # Memory: Real: 14M/69M act/tot Free: 173M Swap: 0K/612M used/tot |
||
| 15 | |||
| 16 | top -un | nawk ' |
||
| 17 | function scale(v) {
|
||
| 18 | if (value ~ /G$/) { sub("G", "", v); v *= 1024 }
|
||
| 19 | else if (v ~ /M$/) sub("M", "", v)
|
||
| 20 | else if (v ~ /K$/) { sub("K", "", v); v /= 1024 }
|
||
| 21 | else v /= 1024 * 1024; |
||
| 22 | return v; |
||
| 23 | } |
||
| 24 | function spliter(v, i) {
|
||
| 25 | split(v,a,"/"); |
||
| 26 | return(a[i]); |
||
| 27 | } |
||
| 28 | /^Memory/ {
|
||
| 29 | acti = scale(spliter($3,1)); |
||
| 30 | 9ae7e3a9 | northox | used = scale(spliter($3,2)); |
| 31 | 8a481afc | northox | free = scale($6); |
| 32 | 9ae7e3a9 | northox | total = used + free; |
| 33 | 8a481afc | northox | swap = scale(spliter($8,1)); |
| 34 | swapt = scale(spliter($8,2)); |
||
| 35 | |||
| 36 | print "acti.value", acti |
||
| 37 | 9ae7e3a9 | northox | print "used.value", used |
| 38 | 8a481afc | northox | print "total.value", total |
| 39 | print "free.value", free |
||
| 40 | print "swap.value", swap |
||
| 41 | print "swapt.value", swapt |
||
| 42 | }' |
