From 0d5407168827cb293abd9f0b5ecd406b16783f01 Mon Sep 17 00:00:00 2001 From: mh Date: Wed, 11 Aug 2010 09:59:09 +0200 Subject: 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. --- files/plugins/xen_mem | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'files/plugins/xen_mem') 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 }' -- cgit v1.2.3