Skip to content

Commit

Permalink
Generate cache file if missing
Browse files Browse the repository at this point in the history
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 munin-monitoring#914, but configuration will get picked up as soon as it is present.
  • Loading branch information
mikini authored Oct 4, 2018
1 parent 9b3aa26 commit 21c2863
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions plugins/disk/du-2
Original file line number Diff line number Diff line change
Expand Up @@ -107,15 +107,16 @@ if( (defined $ARGV[0]) && ($ARGV[0] eq "config") ) {
}

##### fetch
open (FILE, "<", $CACHEFILE) or munin_exit_fail();
while(defined (my $foo = <FILE>)) {
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 = <FILE>)) {
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();

#
Expand Down

0 comments on commit 21c2863

Please sign in to comment.