diff options
author | mh <mh@immerda.ch> | 2010-08-11 09:59:09 +0200 |
---|---|---|
committer | mh <mh@immerda.ch> | 2010-08-11 09:59:09 +0200 |
commit | 0d5407168827cb293abd9f0b5ecd406b16783f01 (patch) | |
tree | 08be0e8abbcb8f85cf030d5f6fdbc79efe39c562 /files/plugins/xen_mem | |
parent | 3ccc8e2495a66ae9681bef64a4034a0e7828bf14 (diff) |
introduce caching for xen plugins
calls to the xen binaries such as xm are quite heavy and we
therefore cache now a lot of the data that is generated for these
plugins and use them as well for the other ones.
Diffstat (limited to 'files/plugins/xen_mem')
-rw-r--r-- | files/plugins/xen_mem | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/files/plugins/xen_mem b/files/plugins/xen_mem index 5e985a5..16d91cf 100644 --- a/files/plugins/xen_mem +++ b/files/plugins/xen_mem @@ -43,7 +43,10 @@ #%# family=auto #%# capabilities=autoconf -XM="/usr/sbin/xm" +# we cache xm list for 5 min for perfomance reasons +((find /var/lib/munin/plugin-state/xm_list.state -mmin -5 2>&1 | grep -qE '^\/var\/lib\/munin\/plugin-state\/xm_list\.state$') && \ + [ `cat /var/lib/munin/plugin-state/xm_list.state | wc -l` -gt 1 ]) || \ + /usr/sbin/xm list | grep -v "^Name .* Console$" > /var/lib/munin/plugin-state/xm_list.state if [ "$1" = "autoconf" ]; then echo yes @@ -60,7 +63,7 @@ if [ "$1" = "config" ]; then echo 'graph_info This graph shows affected memory for each domain.' echo 'Domain_0.label Domain-0' echo 'Domain_0.draw AREA' -$XM list | grep -v 'Mem' | grep -v 'Domain-0' | while read i; do +cat /var/lib/munin/plugin-state/xm_list.state | grep -v 'Mem' | grep -v 'Domain-0' | while read i; do name=`echo $i | awk '{ print $1 }' | sed 's/[\/.-]/_/g'` echo -n "$name.label " echo $i | awk '{ print $1 }' @@ -70,7 +73,7 @@ done exit 0 fi -$XM list | grep -v 'Mem' | while read i; do +cat /var/lib/munin/plugin-state/xm_list.state | grep -v 'Mem' | while read i; do name=`echo $i | awk '{ print $1 }' | sed 's/[\/.-]/_/g'` echo -n "$name.value " echo $i | awk '{ print $3 * 1024 * 1024 }' |