2011-11-18 2 views
1

slapd_ munin 플러그인을 구현하려고합니다.이 플러그인은 perl로 작성되었으므로별로 우경이 없습니다. The full plugin is available here.slapd_ munin plugin의 연결 (.) 또는 문자열에서 초기화되지 않은 값 사용

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

나는 모든 변수를하고 출력하기로 디버깅을 시도/객체는 다음과 같습니다 :

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

라인 (232)이 하나입니다 : 내가 갖는 오류이 하나입니다

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. 

모든 변수가 설정되어있는 것 같아서, 나는 정말로 내가받는 오류 메시지를 이해하지 못한다.

Q : 아무도이 스크립트를 디버깅하는 방법에 대해 조언 할 수 있습니까?

+0

$ basen에 값이 지정 되었습니까? – canavanin

답변

3

당신은

print Dumper \%ops; 

이 디버그 출력이 명확 할 것 같이%ops참조를 덤프해야 . 설명하기 위해, 당신은 후반에 훨씬 더 명확 구조를 볼 방법

#! /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); 

주의의 출력을 고려

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

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

당신은 출력의 중요한 비트를 잘라. $VAR15의 값은 무엇입니까? 그것 "localhost" 또는 다른 것입니까?

$searchdn을 인쇄 할 때 그 값은 무엇입니까?

+0

인쇄가 도움이되었습니다. $ ops 배열에 실제로 플러그인 구성이 포함되어 있고 플러그인 심볼릭 링크를 miscreated (munin에서 symlink 자체를 사용하여 플러그인에 인수를 전달 함) 따라서 실패한 이유가 분명해졌습니다. – Max

+0

도움이 된 것을 기쁘게 생각합니다! –

관련 문제