+ return;
+ }
+
+ # Set perfdata from config file
+ sub configfile_set_perfdata {
+ my $keyword = shift;
+ my $conf = $opt2config{perfdata};
+ if (defined $tiny->{$keyword}->{$conf} and $tiny->{$keyword}->{$conf} ne q{}) {
+ if ($tiny->{$keyword}->{$conf} =~ m{$on}ixms) {
+ $opt{perfdata} = 1;
+ }
+ elsif ($tiny->{$keyword}->{$conf} =~ m{$off}ixms) {
+ $opt{perfdata} = undef;
+ }
+ elsif ($tiny->{$keyword}->{$conf} =~ m{\A minimal|multiline \z}xms) {
+ $opt{perfdata} = $tiny->{$keyword}->{$conf};
+ }
+ else {
+ report('other', "CONFIG ERROR: Rvalue for '$conf' must be either boolean, 'minimal' or 'multiline'", $E_UNKNOWN);
+ }
+ }
+ return;
+ }
+
+ # Set temp unit from config file
+ sub configfile_set_tempunit {
+ my $keyword = shift;
+ my $conf = $opt2config{tempunit};
+ if (defined $tiny->{$keyword}->{$conf} and $tiny->{$keyword}->{$conf} ne q{}) {
+ if ($tiny->{$keyword}->{$conf} =~ m{\A C|F|K|R \z}ixms) {
+ $opt{tempunit} = $tiny->{$keyword}->{$conf};
+ }
+ else {
+ report('other', "CONFIG ERROR: Rvalue for '$conf' must one of C/F/K/R", $E_UNKNOWN);
+ }
+ }
+ return;
+ }
+
+ # Set postmsg string from config file
+ sub configfile_set_postmsg {
+ my $keyword = shift;
+ my $conf = $opt2config{postmsg};
+ if (defined $tiny->{$keyword}->{$conf} and $tiny->{$keyword}->{$conf} ne q{}) {
+ $opt{postmsg} = $tiny->{$keyword}->{$conf}; # array ref
+ }
+ return;
+ }
+
+ # Sections in the config file to check for statements
+ my @sections = ();
+
+ # First: Populate the sections array with the global section
+ @sections = ('_');
+
+ # Second: Populate the sections array with host glob pattern (but
+ # not exact match)
+ PATTERN:
+ foreach my $glob (sort keys %{ $tiny }) {
+ next PATTERN if $glob eq '_'; # global section
+ next PATTERN if $glob eq $opt{hostname}; # exact match
+ my $regex = glob2regex($glob); # make regexp
+ if ($opt{hostname} =~ m{$regex}) {
+ push @sections, $glob;
+ }
+ }
+
+ # Third: Populate the sections array with exact hostname
+ if (defined $tiny->{$opt{hostname}}) {
+ push @sections, $opt{hostname};
+ }
+
+ # Loop through the sections array and get options
+ foreach my $sect (@sections) {
+ configfile_adjust_checks($sect);
+ configfile_set_blacklist($sect);
+ configfile_set_timeout($sect);
+ configfile_set_htmlinfo($sect);
+ configfile_set_ok_verbosity($sect);
+ configfile_set_boolean($sect, 'all');
+ configfile_set_boolean($sect, 'info');
+ configfile_set_boolean($sect, 'extinfo');
+ configfile_set_boolean($sect, 'state');
+ configfile_set_boolean($sect, 'shortstate');
+ configfile_set_boolean($sect, 'show_blacklist');
+ configfile_set_boolean($sect, 'ipv6');
+ configfile_set_boolean($sect, 'tcp');
+ configfile_set_boolean($sect, 'legacy_perfdata');
+ configfile_set_boolean($sect, 'hide_servicetag');
+ configfile_set_snmp_version($sect);
+ configfile_set_snmp_community($sect);
+ configfile_set_snmp_port($sect);
+ configfile_set_temp_threshold($sect, 'warning');
+ configfile_set_temp_threshold($sect, 'critical');
+ configfile_set_perfdata($sect);
+ configfile_set_tempunit($sect);
+ configfile_set_postmsg($sect);