root / plugins / system / openbsd-swap @ d0216f00
Historique | Voir | Annoter | Télécharger (730 octets)
| 1 | 617994ca | northox | #!/bin/sh |
|---|---|---|---|
| 2 | # @author northox <northox@mantor.org> |
||
| 3 | # Mantor Organization |
||
| 4 | # |
||
| 5 | if [ "$1" = "config" ]; then |
||
| 6 | echo "graph_title Swap usage (in MB)" |
||
| 7 | echo 'graph_category system' |
||
| 8 | echo "swap.label Swap used" |
||
| 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 | swap = scale(spliter($8,1)); |
||
| 29 | swapt = scale(spliter($8,2)); |
||
| 30 | |||
| 31 | print "swap.value", swap |
||
| 32 | print "swapt.value", swapt |
||
| 33 | }' |
