在 slapd_ munin 插件中的串联 (.) 或字符串中使用未初始化的值
我正在尝试实现 slapd_
munin 插件,该插件是用 perl 编写的,但我对此一无所知。 完整的插件位于此处。我得到的错误是这个:
Use of uninitialized value in concatenation (.) or string at
/etc/munin/plugins/slapd_localhost line 232, <DATA> line 275.
第 232 行是这个:
my $searchdn = $ops{$action}->{'search'} . "," . $basedn;
我尝试通过输出所有变量/对象进行调试,如下所示:
use Data::Dumper; # top of script
# [...]
print Dumper(%ops);
print "action = [$action]\n";
print "basedn = [$basedn]\n\n";
my $searchdn = $ops{$action}->{'search'} . "," . $basedn;
当我再次运行它时,这是我得到的:
[...] # 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.
由于所有变量似乎都已设置,所以我我真的不明白我收到的错误消息
问:任何人都可以建议如何调试此脚本吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您应该将引用转储到
%ops
,如这将使调试输出更清晰。为了说明这一点,请考虑以下输出:
注意您如何在后半部分更清楚地看到结构:
您删除了输出的关键位。
$VAR15
的值是多少?是"localhost"
还是其他?当你打印
$searchdn
时,它的值是多少?You should dump a reference to
%ops
, as inThis will make the debug output clearer. To illustrate, consider the output of
Notice how you see the structure much more clearly in the latter half:
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?