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.
This commit is contained in:
Mikkel Kirkgaard Nielsen 2018-10-04 19:53:31 +02:00 committed by GitHub
parent 9b3aa2671b
commit 21c28638e3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 7 deletions

View File

@ -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();
#