*** Poller returning a zero value for perl scripts ***

Post general support questions here that do not specifically fall into the Linux or Windows categories.

Moderators: Developers, Moderators

Post Reply
celtic6969
Posts: 17
Joined: Wed Jun 22, 2005 10:43 pm

*** Poller returning a zero value for perl scripts ***

Post by celtic6969 »

I have a strange problem where if I run a perl script manually (as cactiuser) then it returns non-zero values, but when the poller runs automatically it returns zeros :cry:
I have checked permissions, recreated data sources, run through the "troubleshooting NAN values document" and not sure what else to try ...

[root@cactiserver root]# su - cactiuser
[cactiuser@cactiserver cactiuser]$ /usr/bin/php /usr/local/cacti/poller.php
08/10/2007 09:29:08 AM - POLLER: Poller[0] Parsed MULTI output field 'active:3' [map active->active]
08/10/2007 09:29:08 AM - POLLER: Poller[0] Parsed MULTI output field 'idle:7' [map idle->idle]
08/10/2007 09:29:08 AM - POLLER: Poller[0] Parsed MULTI output field 'total:10' [map total->total]
08/10/2007 09:29:08 AM - POLLER: Poller[0] CACTI2RRD: /usr/local/bin/rrdtool update /usr/local/cacti/rra/isdn_router_active_124.rrd --template active:idle:total 1186702146:3:7:10

[root@cactiserver root]# tail /usr/local/cacti/log/cacti.log
08/10/2007 09:40:02 AM - CMDPHP: Poller[0] Host[5] DS[124] CMD: /usr/bin/perl /usr/local/cacti/scripts/bchanstat.pl 10.1.1.1 2 public 161, output: active:0 idle:0 total:0
08/10/2007 09:40:02 AM - POLLER: Poller[0] Parsed MULTI output field 'active:0' [map active->active]
08/10/2007 09:40:02 AM - POLLER: Poller[0] Parsed MULTI output field 'idle:0' [map idle->idle]
08/10/2007 09:40:02 AM - POLLER: Poller[0] Parsed MULTI output field 'total:0' [map total->total]
08/10/2007 09:40:02 AM - POLLER: Poller[0] CACTI2RRD: /usr/local/bin/rrdtool update /usr/local/cacti/rra/isdn_router_active_124.rrd --template active:idle:total 1186702801:0:0:0

Any help would be really appreciated :)
Thanks
celtic6969
Posts: 17
Joined: Wed Jun 22, 2005 10:43 pm

Any ideas please?

Post by celtic6969 »

Bump ...
User avatar
gandalf
Developer
Posts: 22383
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

Post by gandalf »

Please post a script. If I find time to read it ...
Reinhard
celtic6969
Posts: 17
Joined: Wed Jun 22, 2005 10:43 pm

Post by celtic6969 »

gandalf wrote:Please post a script. If I find time to read it ...
Reinhard
Hi Reinhard, thanks for the reply and apologies for cross posting. I'm not sure how to delete the other posts.
Although I get the desired result when running the script from the command line, the script wont work with the poller. I don't have much knowledge of scripting or how it integrates with the poller. Perhaps you can suggest another way of doing it ?

Much Appreciated

#!/usr/bin/perl

$in_hostname = $ARGV[0] if defined $ARGV[0];
$in_version = $ARGV[1] if defined $ARGV[1];
$in_community = $ARGV[2] if defined $ARGV[2];
$in_port = $ARGV[3] if defined $ARGV[3];
$in_oid = ".1.3.6.1.2.1.10.20.1.2.1.1.2";

if ($in_version eq "2")
{
$in_version = "2c";
}

my $_cmd = "/usr/bin/snmpwalk -v $in_version -c $in_community $in_hostname:$in_port $in_oid";

# usage notes
if (
( ! defined $in_hostname ) ||
( ! defined $in_version ) ||
( ! defined $in_community ) ||
( ! defined $in_port )
) {
print "usage: $0 <host> <snmp version> <snmp community> <snmp port>\n";
exit;
}

my @_output = `$_cmd`;
my $_active = 0;
my $_idle = 0;
my $_total = 0;

foreach ( @_output ) {
$_active++ if /active/;
$_idle++ if /idle/;
$_total++ if /active/+/idle/;
}
print "active:$_active idle:$_idle total:$_total";
User avatar
gandalf
Developer
Posts: 22383
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

Post by gandalf »

Which poller are you running, cmd.php or cactid? If cactid, which version (./cactid -- version)
Reinhard
celtic6969
Posts: 17
Joined: Wed Jun 22, 2005 10:43 pm

Post by celtic6969 »

gandalf wrote:Which poller are you running, cmd.php or cactid? If cactid, which version (./cactid -- version)
Reinhard
Hi Reinhard,

I am currently using cmd, although I'm pretty sure I had the same issue when I tried cactid. Do you want me to try cactid again ?
celtic6969
Posts: 17
Joined: Wed Jun 22, 2005 10:43 pm

catid info

Post by celtic6969 »

gandalf wrote:Which poller are you running, cmd.php or cactid? If cactid, which version (./cactid -- version)
Reinhard
Hi Reinhard,

I have tried testing with cactid and also another script, but I still gett the same results. Here is my cactid version info:

[root@cacti reporter]# ./cactid --version
CACTID 0.8.6i Copyright 2002-2006 by The Cacti Group

Usage: cactid [options] [firstid lastid]
Attachments
Comparison of CLI and Poller output
Comparison of CLI and Poller output
script-help.JPG (85.45 KiB) Viewed 2709 times
User avatar
gandalf
Developer
Posts: 22383
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

Post by gandalf »

To be honest, I'm stumped. Are you able to write the contents of the @output array to some arbitrary file while running under cactid/cmd.php?
Reinhard
jarhead
Cacti User
Posts: 59
Joined: Tue Nov 22, 2005 2:24 pm
Location: Portland, Or

Post by jarhead »

I had a similar issue and it turned out to be that user that my poller was running under did not have rights to the file in question. But when I ran from the command line of course I did have rights. Not sure if that helps or not.
Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests