root / plugins / system / vpsmem @ ef960abc
Historique | Voir | Annoter | Télécharger (1,69 ko)
| 1 | 6462587e | Michael Richter | #!/bin/bash |
|---|---|---|---|
| 2 | # |
||
| 3 | # Monitors memory usage in openVZ or Virtuozzo |
||
| 4 | # based on http://www.huschi.net/archiv/speicher-anzeigen-mit-vzfree.html |
||
| 5 | # Author: Michael Richter, http://osor.de/ |
||
| 6 | cc0439f1 | Michael Richter, Marian Sigler | # Cleaned up and translated to english by: Marian Sigler <m@qjym.de>, 2010-08-13 |
| 7 | 6462587e | Michael Richter | # |
| 8 | #%# capabilities=autoconf |
||
| 9 | |||
| 10 | cc0439f1 | Michael Richter, Marian Sigler | BEANCOUNTERS=/proc/user_beancounters |
| 11 | |||
| 12 | 6462587e | Michael Richter | if [ "$1" == "autoconf" ]; then |
| 13 | dd37aaba | Michael Richter, Marian Sigler | if [ -e $BEANCOUNTERS ]; then |
| 14 | echo yes |
||
| 15 | exit 0 |
||
| 16 | else |
||
| 17 | echo no |
||
| 18 | exit 1 |
||
| 19 | fi |
||
| 20 | 6462587e | Michael Richter | fi |
| 21 | |||
| 22 | cc0439f1 | Michael Richter, Marian Sigler | if [ ! -r $BEANCOUNTERS ]; then |
| 23 | echo "$BEANCOUNTERS not readable" >&2 |
||
| 24 | exit 1 |
||
| 25 | fi |
||
| 26 | 6462587e | Michael Richter | |
| 27 | if [ "$1" == "config" ]; then |
||
| 28 | cc0439f1 | Michael Richter, Marian Sigler | limit=$(awk '/privvmpages/ {print $5*4096}' $BEANCOUNTERS)
|
| 29 | cut -c9- <<EOF |
||
| 30 | graph_args --base 1024 -l 0 --vertical-label bytes --upper-limit $limit |
||
| 31 | graph_title VPS memory usage |
||
| 32 | graph_category system |
||
| 33 | graph_info Shows memory usage and VPS memory limits. |
||
| 34 | graph_order maxheld held oomguar barrier limit |
||
| 35 | |||
| 36 | held.label held |
||
| 37 | held.draw AREA |
||
| 38 | held.info currently held memory |
||
| 39 | maxheld.label maxheld |
||
| 40 | maxheld.draw AREA |
||
| 41 | maxheld.info maximum held memory |
||
| 42 | oomguar.label guaranteed |
||
| 43 | oomguar.draw LINE2 |
||
| 44 | oomguar.info memory guaranteed for OOM |
||
| 45 | barrier.label barrier |
||
| 46 | barrier.draw LINE2 |
||
| 47 | barrier.info memory usage barrier |
||
| 48 | limit.label limit |
||
| 49 | limit.draw LINE2 |
||
| 50 | limit.info memory usage limit |
||
| 51 | EOF |
||
| 52 | dd37aaba | Michael Richter, Marian Sigler | exit 0 |
| 53 | 6462587e | Michael Richter | fi |
| 54 | |||
| 55 | dd37aaba | Michael Richter, Marian Sigler | if [ -n "$1" ]; then |
| 56 | cc0439f1 | Michael Richter, Marian Sigler | echo "Invalid argument: $1" >&2 |
| 57 | exit 1 |
||
| 58 | fi |
||
| 59 | |||
| 60 | |||
| 61 | |||
| 62 | 6462587e | Michael Richter | |
| 63 | cc0439f1 | Michael Richter, Marian Sigler | awk '/privvmpages/ {print "held.value", $2*4096 "\nmaxheld.value", $3*4096 "\nbarrier.value", $4*4096 "\nlimit.value", $5*4096}' $BEANCOUNTERS
|
| 64 | awk '/oomguarpages/ { print "oomguar.value", $4*4096 }' $BEANCOUNTERS |
