简体   繁体   English

在连接(。)中使用未初始化的值或在slapd_ munin插件中使用字符串

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

I'm trying to implement the slapd_ munin plugin which is written in perl which I'm pretty much clueless about. 我正在尝试实现用perl编写的slapd_ munin插件,我几乎无能为力。 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: 232行是这一行:

 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? 问:有人可以就如何调试此脚本提出建议吗?

You should dump a reference to %ops , as in 您应该转储对%ops引用 ,如

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 ? $VAR15的价值是$VAR15 Is it "localhost" or something else? "localhost"还是其他?

When you print $searchdn , what is its value? 当您打印$searchdn ,它的价值是什么?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM