From 21c28638e314ac3bf24e0b586f53fd917060e348 Mon Sep 17 00:00:00 2001 From: Mikkel Kirkgaard Nielsen Date: Thu, 4 Oct 2018 19:53:31 +0200 Subject: [PATCH] Generate cache file if missing Don't exit with error if cache file is missing, instead refrain from sending values and daemonize() in an attempt to generate one. Invocation using 'config' before generation is successful will fail, as mentioned in #914, but configuration will get picked up as soon as it is present. --- plugins/disk/du-2 | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/plugins/disk/du-2 b/plugins/disk/du-2 index 3dc5e6106..b38f55507 100755 --- a/plugins/disk/du-2 +++ b/plugins/disk/du-2 @@ -107,15 +107,16 @@ if( (defined $ARGV[0]) && ($ARGV[0] eq "config") ) { } ##### fetch -open (FILE, "<", $CACHEFILE) or munin_exit_fail(); -while(defined (my $foo = )) { - if ($foo =~ m/(\d+)\s+(.+)/) { - my ($field, $value) = ($2, $1); - clean_path(\$field); - print clean_fieldname($field), ".value ", $value, "\n"; +if (open (FILE, "<", $CACHEFILE)) { + while(defined (my $foo = )) { + if ($foo =~ m/(\d+)\s+(.+)/) { + my ($field, $value) = ($2, $1); + clean_path(\$field); + print clean_fieldname($field), ".value ", $value, "\n"; + } } + close(FILE); } -close(FILE); daemonize(); #