root / plugins / other / vpsmem @ dd37aaba
Historique | Voir | Annoter | Télécharger (1,69 ko)
| 1 |
#!/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 |
# Cleaned up and translated to english by: Marian Sigler <m@qjym.de>, 2010-08-13 |
| 7 |
# |
| 8 |
#%# capabilities=autoconf |
| 9 |
|
| 10 |
BEANCOUNTERS=/proc/user_beancounters |
| 11 |
|
| 12 |
if [ "$1" == "autoconf" ]; then |
| 13 |
if [ -e $BEANCOUNTERS ]; then |
| 14 |
echo yes |
| 15 |
exit 0 |
| 16 |
else |
| 17 |
echo no |
| 18 |
exit 1 |
| 19 |
fi |
| 20 |
fi |
| 21 |
|
| 22 |
if [ ! -r $BEANCOUNTERS ]; then |
| 23 |
echo "$BEANCOUNTERS not readable" >&2 |
| 24 |
exit 1 |
| 25 |
fi |
| 26 |
|
| 27 |
if [ "$1" == "config" ]; then |
| 28 |
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 |
exit 0 |
| 53 |
fi |
| 54 |
|
| 55 |
if [ -n "$1" ]; then |
| 56 |
echo "Invalid argument: $1" >&2 |
| 57 |
exit 1 |
| 58 |
fi |
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
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
|
