root / plugins / virtualization / vserver / vserver_limits @ e5ce7492
Historique | Voir | Annoter | Télécharger (3,4 ko)
| 1 | e2c56ade | Chris Wilson, Micah Anderson, Holger Levsen | #!/bin/sh |
|---|---|---|---|
| 2 | # |
||
| 3 | # Copyright (C) 2008 Chris Wilson |
||
| 4 | # Copyright (C) 2006 Holger Levsen |
||
| 5 | # |
||
| 6 | # This program is free software; you can redistribute it and/or |
||
| 7 | # modify it under the terms of the GNU General Public License |
||
| 8 | # as published by the Free Software Foundation; version 2 dated June, |
||
| 9 | # 1991. |
||
| 10 | # |
||
| 11 | # This program is distributed in the hope that it will be useful, |
||
| 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
| 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
| 14 | # GNU General Public License for more details. |
||
| 15 | # |
||
| 16 | # You should have received a copy of the GNU General Public License |
||
| 17 | # along with this program; if not, write to the Free Software |
||
| 18 | # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
||
| 19 | # |
||
| 20 | # Configuration variables |
||
| 21 | # vservers - specify the vservers to include in the graph (default: all) |
||
| 22 | # limits - if true, turn on limit graphing (default: false) |
||
| 23 | # |
||
| 24 | # NOTE: If no configuration variables are set, the defaults will be used |
||
| 25 | |||
| 26 | # Example /etc/munin/plugin-conf.d/munin-node |
||
| 27 | # |
||
| 28 | # [vserver_limits_RSS] |
||
| 29 | # user root |
||
| 30 | # env.vservers 7 18 20 42 |
||
| 31 | # |
||
| 32 | # Graph Vserver resource limits. Useful to help you know when and how often |
||
| 33 | # you changed the limits of each vserver, e.g. because customer needed more |
||
| 34 | # RAM. |
||
| 35 | # |
||
| 36 | # Changelog |
||
| 37 | # version 0.1 - 2006 April xx - Holger Levsen |
||
| 38 | # - initial author |
||
| 39 | # version 0.2 - 2006 April 24 - Micah Anderson <micah@riseup.net> |
||
| 40 | # - Add dynamic arch page size determination |
||
| 41 | # - Some cleanup and clarification |
||
| 42 | # version 0.3 - 2006 May 3 - Micah Anderson <micah@riseup.net> |
||
| 43 | # - Add ability to group vservers via environment vars |
||
| 44 | # - Fix missing close quotes and standardize indents |
||
| 45 | # - Add limit notification |
||
| 46 | # - Update documentation to include info on groups and limits |
||
| 47 | # version 0.4 - 2006 Jun 22 - Micah Anderson <micah@riseup.net> |
||
| 48 | # - Fix error that results if NodeName is set to include a domain name |
||
| 49 | # version 0.5 - 2008 Apr 12 - Chris Wilson <chris+munin@qwirx.com> |
||
| 50 | # - Changed to display limits instead of resource usage |
||
| 51 | # - Adapt to latest vserver kernel (lack of some variables in /proc/virtual) |
||
| 52 | # Note that your vserver names may change if the contents of |
||
| 53 | # /etc/vservers/* do not match the nodenames. Also you must specify |
||
| 54 | # the vservers variable with context IDs (XIDs) rather than names. |
||
| 55 | |||
| 56 | |||
| 57 | scriptname=`basename $0` |
||
| 58 | resource=`echo $scriptname | sed -e 's/.*_//'` |
||
| 59 | vservers="$vservers" |
||
| 60 | |||
| 61 | if [ -z "$vservers" ]; then |
||
| 62 | vservers=`ls -1 /proc/virtual | grep -v info | grep -v status` |
||
| 63 | fi |
||
| 64 | |||
| 65 | if [ "$1" = "config" ]; then |
||
| 66 | echo "graph_title Vserver $resource limits" |
||
| 67 | # echo 'graph_args --base 1024k -l 0' |
||
| 68 | echo "graph_vlabel $resource limits" |
||
| 69 | echo 'graph_category vserver' |
||
| 70 | echo "graph_info Shows current $resource limits for each vserver.'" |
||
| 71 | |||
| 72 | for vserver_xid in $vservers ; do |
||
| 73 | longname=`/usr/sbin/vuname --xid $vserver_xid NODENAME | cut -f2` |
||
| 74 | name=`echo $longname | cut -d. -f1` |
||
| 75 | echo "$vserver_xid.label $name" |
||
| 76 | echo "$vserver_xid.info $resource limits for $longname" |
||
| 77 | echo "$vserver_xid.min 0" |
||
| 78 | echo "$vserver_xid.type GAUGE" |
||
| 79 | done |
||
| 80 | |||
| 81 | exit 0 |
||
| 82 | elif [ "$1" = "suggest" ]; then |
||
| 83 | if [ -z "$vservers" ]; then |
||
| 84 | echo "No vservers running, cannot suggest!" >&2 |
||
| 85 | exit 2 |
||
| 86 | fi |
||
| 87 | vserver1=`echo $vservers | sed -e 's/ .*//'` |
||
| 88 | tail -n +2 /proc/virtual/$vserver1/limit | sed -e 's/:.*//' |
||
| 89 | else |
||
| 90 | for vserver_xid in $vservers; do |
||
| 91 | cat /proc/virtual/$vserver_xid/limit \ |
||
| 92 | | awk -v xid="$vserver_xid" -v res="$resource:" \ |
||
| 93 | '{ if ( $1 == res )
|
||
| 94 | printf "%s.value %d\n", xid, $6 }' |
||
| 95 | done |
||
| 96 | fi |
