/[vz-tools]/trunk/munin/vebc_
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /trunk/munin/vebc_

Parent Directory Parent Directory | Revision Log Revision Log


Revision 61 - (show annotations)
Fri Feb 6 10:02:13 2009 UTC (14 years ago) by dpavlin
File size: 3318 byte(s)
munin plugin for bean counters

http://wiki.openvz.org/Monitoring_openvz_resources_using_munin
1 #!/bin/sh
2 #
3 # Munin's plugin to monitor OpenVZ bean counters.
4 #
5 # $Log$
6 # Revision 1.3 2007/07/19 12:57:00 Jan Tomasek <jan@tomasek.cz>
7 # * rewrited to work with /proc/bc/<VEID>/resources instead of
8 # /proc/user_beancounters, that simplified code and result
9 # is also bit faster.
10 # * added references to OpenVZ wiki
11 # Revision 1.3.1 2008/05/13 01:26:00 Daniel Hahler <http://daniel.hahler.de/>
12 # * Minor fixes
13 # - "exit 0" in "config" block
14 # - Use "echo ${str%% *}" in "suggest", instead of "vals=($str); echo ${vals[0]}"
15 #
16 # Revision 1.3.2 2008/08/09 12:30:00 Christian Rubbert <crubbert@xrc.de>
17 # * Feature
18 # - If only 1 variable is graphed, also display maxheld, barrier and limit
19 #
20 # Original revision taken from:
21 # http://wiki.openvz.org/Monitoring_openvz_resources_using_munin
22 #
23 #%# family=auto
24 #%# capabilities=autoconf suggest
25
26 VEID=`basename $0 | sed -e 's/^vebc_.*_//'`;
27 STATS=`basename $0 | sed -e 's/^vebc_//' -e 's/_[0-9]*$//' -e 's/_/ /g'`
28 x=0; STATSCNT=`for i in $STATS; do x=$[$x+1]; done; echo $x`
29
30 if [ "$1" = "autoconf" ]; then
31 if [ -r /proc/bc/0/resources ]; then
32 echo yes
33 exit 0
34 else
35 echo "no (/proc/bc/0/resources not found)"
36 exit 1
37 fi
38 fi
39
40 if [ "$1" = "suggest" ]; then
41 if [ -r /proc/bc/0/resources ]; then
42 cat /proc/bc/0/resources | while read str; do
43 # Print everything before " "
44 echo ${str%% *}
45 done
46 exit 0
47 else
48 exit 1
49 fi
50 fi
51
52 if [ ! -f /proc/bc/$VEID/resources ]; then
53 exit 0;
54 fi
55
56 if [ "$1" = "config" ]; then
57 #echo "graph_order down up"
58 echo "graph_title VE$VEID: $STATS"
59 echo "graph_vlabel bean counters"
60 echo "graph_category VE$VEID"
61
62 # Note on URLs. General graph info is by munin version 1.2.5
63 # accepted even with HTML code. But for value.info it escapes URL,
64 # I expect that authors of munin will note that in future and put
65 # escaping even for graph.info.
66 echo "graph_info VE bean counters info. Documentation of the OpenVZ resource management is located at <a href=\"
67 http://wiki.openvz.org/UBC\">http://wiki.openvz.org/UBC</a>."
68
69 cat /proc/bc/$VEID/resources | while read name value top warn max stuff ; do
70 for statname in $STATS; do
71 if [ "$name" = "$statname" ]; then
72 URL="http://wiki.openvz.org/$name"
73 if [ "$warn" = "0" ]; then
74 warn=$max
75 fi
76 echo $name.label $name
77 echo $name.warning $warn
78 echo $name.critical $max
79 echo $name.info Description of this resource is located at $URL
80 fi
81 done
82 done
83
84 if [ "$STATSCNT" == "1" ]; then
85 echo maxheld.label Maxheld
86 echo maxheld.draw LINE2
87 echo maxheld.info Maximum value
88 echo barrier.label Barrier
89 echo barrier.draw LINE2
90 echo barrier.info Barrier
91 echo limit.label Limit
92 echo limit.draw LINE2
93 echo limit.info Limit
94 fi
95 exit 0
96 fi;
97
98 cat /proc/bc/$VEID/resources | while read name value top warn max stuff ; do
99 for statname in $STATS; do
100 if [ "$name" = "$statname" ]; then
101 echo $name".value "$value;
102
103 if [ "$STATSCNT" == "1" ]; then
104 echo maxheld.value $top
105 echo barrier.value $warn
106 echo limit.value $max
107 fi
108 fi
109 done
110 done

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26