Use of uninitialized value in concatenation (.) or string in slapd_ munin plugin

StackOverflow https://stackoverflow.com/questions/8181793

  •  03-03-2021
  •  | 
  •  

Pregunta

I'm trying to implement the slapd_ munin plugin which is written in perl which I'm pretty much clueless about. The full plugin is available here. The error I'm getting is this one:

Use of uninitialized value in concatenation (.) or string at
/etc/munin/plugins/slapd_localhost line 232, <DATA> line 275.

Line 232 is this one:

 my $searchdn = $ops{$action}->{'search'} . "," . $basedn;

I tried debugging by outputing all the variables/objects as follows:

use Data::Dumper;   # top of script
# [...]
print Dumper(%ops);
print "action = [$action]\n";
print "basedn = [$basedn]\n\n";
my $searchdn = $ops{$action}->{'search'} . "," . $basedn;

When I run it again here is what I obtain:

[...] # 15 other variables belonging to $ops
$VAR16 = {
           'info' => 'The graph shows the number of Waiters',
           'search' => 'cn=Waiters',
           'desc' => 'The current number of Waiters',
           'filter' => '(|(cn=Write)(cn=Read))',
           'title' => 'Number of Waiters',
           'label2' => {
                         'read' => 'Read',
                         'write' => 'Write'
                       },
           'vlabel' => 'Waiters'
         };
action = [localhost]
action = [cn=Monitor]

Use of uninitialized value in concatenation (.) or string at /etc/munin/plugins/slapd_localhost line 237, <DATA> line 275.

Since all the variables seem to be set, I really don't understand the error message I'm getting

Q: Can anybody advise on how debugging this script?

¿Fue útil?

Solución

You should dump a reference to %ops, as in

print Dumper \%ops;

This will make the debug output clearer. To illustrate, consider the output of

#! /usr/bin/perl

use strict;
use warnings;

use Data::Dumper;

my %h = (foo => { bar => 1 }, baz => { quux => 3 });

print "No reference:\n",
      Dumper(%h),
      "\n",
      "Reference:\n",
      Dumper(\%h);

Notice how you see the structure much more clearly in the latter half:

No reference:
$VAR1 = 'baz';
$VAR2 = {
          'quux' => 3
        };
$VAR3 = 'foo';
$VAR4 = {
          'bar' => 1
        };

Reference:
$VAR1 = {
          'baz' => {
                     'quux' => 3
                   },
          'foo' => {
                     'bar' => 1
                   }
        };

You cut out a critical bit of the output. What's the value of $VAR15? Is it "localhost" or something else?

When you print $searchdn, what is its value?

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top