Freemobile munin plugin needs a cache directory to store previous

results.

Let's create it and not expect the user to do it.
This commit is contained in:
theo 2012-03-19 23:14:06 +01:00 committed by Romain Bignon
commit 327cb4f618

View file

@ -41,7 +41,8 @@ use encoding 'iso-8859-1'; # Munin doesn't like utf-8 :-(
use Encode; use Encode;
my @monitored = split / /, $ENV{'freemonitored'} || 'voice sms'; my @monitored = split / /, $ENV{'freemonitored'} || 'voice sms';
my $cachefile = $ENV{'HOME'} . '/.config/weboob/munin/freemobile-munin'; my $cachedir = $ENV{'HOME'} . '/.config/weboob/munin/';
my $cachefile = "$cachedir/freemobile-munin";
my $refreshtime = $ENV{'cache_expire'} || 10_800; my $refreshtime = $ENV{'cache_expire'} || 10_800;
my $weboob = '/usr/bin/env weboob-cli ICapBill get_details coin -f table'; my $weboob = '/usr/bin/env weboob-cli ICapBill get_details coin -f table';
@ -173,6 +174,11 @@ sub fetch {
return 0; return 0;
} }
# Create the munin cache dir if missing
if ( !-d $cachedir ) {
mkdir $cachedir;
}
if ( $ARGV[0] and $ARGV[0] eq 'config' ) { if ( $ARGV[0] and $ARGV[0] eq 'config' ) {
config; config;
} }