Although this does not exactly answer your question, it could be a workaround. Consider the following munin plugin:
$ cat /usr/share/munin/plugins/pool_
#!/bin/sh
pool_dir=/tmp/munin-pool
probe=`basename $0 | sed 's|^pool_||'`
test -d $pool_dir/$probe || exit 1
if test "$1" = autoconf; then
test -s $pool_dir/$probe/autoconf || exit 0
cat $pool_dir/$probe/autoconf
elif test "$1" = config; then
test -s $pool_dir/$probe/config || exit 0
cat $pool_dir/$probe/config
else
test -s $pool_dir/$probe/value || exit 0
cat $pool_dir/$probe/value
fi
exit 0
And this crontab:
#!/bin/sh
pool_dir=/tmp/munin-pool
TMPFILE=/tmp/`basename $0`.$$
if test -s $pool_dir/lock; then
pid=`cat $pool_dir/lock`
if ps ax | grep "$pid[ ]" >/dev/null; then
exit 0
fi
fi
test -d $pool_dir || mkdir $pool_dir
echo $$ >$pool_dir/lock
test -d <%=@conf_dir%>/plugins-pool || exit 1
cd /etc/munin/plugins-pool
for probe in *
do
test -d $pool_dir/$probe || mkdir -p $pool_dir/$probe
if ! test -f $pool_dir/$probe/autoconf; then
./$probe autoconf >$TMPFILE
test -s $TMPFILE && mv $TMPFILE $pool_dir/$probe/autoconf
fi
if ! test -f $pool_dir/$probe/config; then
./$probe config >$TMPFILE
test -s $TMPFILE && mv $TMPFILE $pool_dir/$probe/config
fi
./$probe >$TMPFILE
test -s $TMPFILE && mv $TMPFILE $pool_dir/$probe/value
done 2>&1 | awk '{print strftime("[%Y/%m/%d - %H:%M:%S] "), $0}' ><munin-log-dir>/munin-pooler.log
rm -f $pool_dir/lock
exit 0
In /etc/munin/plugin-pool
, I would link the probes whose results I want to cache locally:
ln -sf /usr/share/munin/plugins/some_probe /etc/munin/plugin-pool/
The crontab would iterate over those, keep track of the results in /tmp/munin-pool/
. While the pool_
probe would query that cache:
ln -sf /usr/share/munin/plugins/pool_ /etc/munin/plugins/some_probe
So instead of re-querying a service every five minutes, I can gather metrics from my crontab, on whatever schedule I need. Or, in my use case, if a probe usually exceeds munin query timeout, you're not left with empty graphs.
If we were to scrape some probes on different intervals, without such workaround, then the resulting graphs would only include those points you did gather, and lots of blanks for those we "missed".