Hi all
i wanted to extend the net-snmp to monitor my server (i wrote a custom module for FreeRadius). i saw that every one is using perl, so i started learning perl. i started with a simple example (
http://net-snmp.git.sourceforge.net/...s/heads/master) and modified it, i only changed the types and made a function to get the values from a bash script (using radclient).
when i run the script from the command line, it works fine, i can print PING and i get PONG, get and getnext works fine.
if i run snmpd in debug mode, every thing is ok too, snmpwalk works perfectly. however runing it as a service is not working, the sub function i wrote is getting stuck at running the bash script, and i can't figure what is the problem.
currently i am using CentOS 6.2.
here is my function:
Code:
sub callRadclient {
my $type = $_[0];
my $line_num = $_[1] + 1;
my $retline;
my $radclientCmd = "echo \"Message-Authenticator = 0x00, FreeRADIUS-Statistics-Type = $type\" | radclient localhost:18121 status adminsecret | sed '".$line_num."q;d'";
print MYFILE "1\n";
$retline = `$radclientCmd`;
print MYFILE "2\n";
my @lineFromRadclient = split(/ = /, $retline);
chomp($lineFromRadclient[1]);
return $lineFromRadclient[1];
}
i have opened "MYFILE" in /tmp for some debuging, here i get only "1" in it, sometimes i get 2 in the following get request. what i have missed to get this working??!!