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_vm | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'files/plugins/xen_vm') diff --git a/files/plugins/xen_vm b/files/plugins/xen_vm index a0dc0b7..a69b5fe 100644 --- a/files/plugins/xen_vm +++ b/files/plugins/xen_vm @@ -45,6 +45,11 @@ 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 exit 0 @@ -61,7 +66,7 @@ if [ "$1" = "config" ]; then exit 0 fi -domains=`$XM list | wc -l` +domains=`cat /var/lib/munin/plugin-state/xm_list.state | wc -l` echo -n "domains.value " echo $(($domains-2)) -- cgit v1.2.3