root / plugins / virtualization / vserver / vserver_limit_hits @ e5ce7492
Historique | Voir | Annoter | Télécharger (4,23 ko)
| 1 | fb30a9b2 | 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 | # The first group monitors the vservers named "vserver1 vserver2 |
||
| 29 | # vserver3 vserver4" and looks to see if the resource limit has been |
||
| 30 | # breached, if so it sends a message to nagios via send_nsca, and |
||
| 31 | # sends an email to notify that this has happened. |
||
| 32 | # |
||
| 33 | # The second monitors the vservers "vserver5 vserver6 vserver7" and |
||
| 34 | # has no limit notifications turned on. |
||
| 35 | # |
||
| 36 | # The third monitors all vservers on the system, in one graph, and it has |
||
| 37 | # no limit notifications defined. |
||
| 38 | # |
||
| 39 | # You can use any combination of these to fit your needs. |
||
| 40 | # |
||
| 41 | # |
||
| 42 | # [vsrmem_group1] |
||
| 43 | # user root |
||
| 44 | # env.vservers vserver1 vserver2 vserver3 vserver4 |
||
| 45 | # env.limits 1 |
||
| 46 | # contacts nagios email |
||
| 47 | # contact.nagios.command /usr/bin/send_nsca -H your.nagios-host.here -c /etc/send_nsca.cfg |
||
| 48 | # contact.email.command mail -s "Munin-notification for ${var:group} :: ${var:host}" your@email.address.here
|
||
| 49 | # |
||
| 50 | # [vsrmem_group2] |
||
| 51 | # user root |
||
| 52 | # env.vservers vserver5 vserver6 vserver7 |
||
| 53 | # env.limits 0 |
||
| 54 | # |
||
| 55 | # [vserver_rmemory] |
||
| 56 | # user root |
||
| 57 | # |
||
| 58 | # Graph Vserver RSS usage and limits |
||
| 59 | # |
||
| 60 | # Changelog |
||
| 61 | # version 0.1 - 2006 April xx - Holger Levsen |
||
| 62 | # - initial author |
||
| 63 | # version 0.2 - 2006 April 24 - Micah Anderson <micah@riseup.net> |
||
| 64 | # - Add dynamic arch page size determination |
||
| 65 | # - Some cleanup and clarification |
||
| 66 | # version 0.3 - 2006 May 3 - Micah Anderson <micah@riseup.net> |
||
| 67 | # - Add ability to group vservers via environment vars |
||
| 68 | # - Fix missing close quotes and standardize indents |
||
| 69 | # - Add limit notification |
||
| 70 | # - Update documentation to include info on groups and limits |
||
| 71 | # version 0.4 - 2006 Jun 22 - Micah Anderson <micah@riseup.net> |
||
| 72 | # - Fix error that results if NodeName is set to include a domain name |
||
| 73 | # version 0.5 - 2008 Apr 12 - Chris Wilson <chris+munin@qwirx.com> |
||
| 74 | # - Changed to display limit hits instead of resource usage |
||
| 75 | # - Adapt to latest vserver kernel (lack of some variables in /proc/virtual) |
||
| 76 | # Note that your vserver names may change if the contents of |
||
| 77 | # /etc/vservers/* do not match the nodenames. Also you must specify |
||
| 78 | # the vservers variable with context IDs (XIDs) rather than names. |
||
| 79 | |||
| 80 | scriptname=`basename $0` |
||
| 81 | resource=`echo $scriptname | sed -e 's/.*_//'` |
||
| 82 | vservers="$vservers" |
||
| 83 | |||
| 84 | if [ -z "$vservers" ]; then |
||
| 85 | vservers=`ls -1 /proc/virtual | grep -v info | grep -v status` |
||
| 86 | fi |
||
| 87 | |||
| 88 | if [ "$1" = "config" ]; then |
||
| 89 | echo "graph_title Vserver $resource limit hits" |
||
| 90 | # echo 'graph_args --base 1024k -l 0' |
||
| 91 | echo "graph_vlabel $resource limit hits" |
||
| 92 | echo 'graph_category vserver' |
||
| 93 | echo "graph_info Shows number of hits on $resource limits by each vserver.'" |
||
| 94 | |||
| 95 | for vserver_xid in $vservers ; do |
||
| 96 | longname=`/usr/sbin/vuname --xid $vserver_xid NODENAME | cut -f2` |
||
| 97 | name=`echo $longname | cut -d. -f1` |
||
| 98 | echo "$vserver_xid.label $name" |
||
| 99 | echo "$vserver_xid.info $resource limit hits by $longname" |
||
| 100 | echo "$vserver_xid.critical 1" |
||
| 101 | echo "$vserver_xid.min 0" |
||
| 102 | echo "$vserver_xid.type DERIVE" |
||
| 103 | done |
||
| 104 | |||
| 105 | exit 0 |
||
| 106 | elif [ "$1" = "suggest" ]; then |
||
| 107 | if [ -z "$vservers" ]; then |
||
| 108 | echo "No vservers running, cannot suggest!" >&2 |
||
| 109 | exit 2 |
||
| 110 | fi |
||
| 111 | vserver1=`echo $vservers | sed -e 's/ .*//'` |
||
| 112 | tail -n +2 /proc/virtual/$vserver1/limit | sed -e 's/:.*//' |
||
| 113 | else |
||
| 114 | for vserver_xid in $vservers; do |
||
| 115 | cat /proc/virtual/$vserver_xid/limit \ |
||
| 116 | | awk -v xid="$vserver_xid" -v res="$resource:" \ |
||
| 117 | '{ if ( $1 == res )
|
||
| 118 | printf "%s.value %d\n", xid, $7 }' |
||
| 119 | done |
||
| 120 | fi |
