Cacti (home)ForumsDocumentation
Cacti: offical forums and support
It is currently Tue Mar 26, 2019 7:44 pm

All times are UTC - 5 hours




Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: poller executes script getting incorrect output
PostPosted: Thu Mar 14, 2019 10:26 am 
Offline

Joined: Wed May 09, 2012 11:03 am
Posts: 16
Hi all. I am facing a problem for which i could not find a solution, event reading some posts regarding similar issues.
When i executed script from shell with user www-data:
$ id
uid=33(www-data) gid=33(www-data) grupos=33(www-data)
$ perl /usr/share/cacti/site/scripts/Gateway_modbus.pl xxx 300041 1
30523$ exit

Executed by poller:
03/14/2019 12:16:32 PM - CMDPHP: Poller[0] Host[1037] DS[31521] CMD: perl /usr/share/cacti/site/scripts/Gateway_modbus.pl xxxx 300041 1, output: U

I tried:
1) verified script permisions, and owners (shown in paste above)
2) tried different scripts written in shell, perl and python, same results
3) redirected output to file and search for special characters, nothing noticed
4) Even so, added some string cleaning comands, to remove special characters in output. No changes.
5) cleaned poller cache, without knowing exactly what i could achive with this, but following recomendation of one post with similar issue (no changes)
6) reboot host

Scripts is as follows:

------------------
#!/usr/bin/perl

# chequea que se pase un parametro
if ( @ARGV != 3 )
{
print "Uso es: $0 <ip o hostname> <direccion> <count>\n";
exit;
}


$host=$ARGV[0];
$direccion=$ARGV[1];
$count=$ARGV[2];
$valor;

open(COMANDO, "modbus read -p 502 $host $direccion $count | ");
$salida = <COMANDO>;
close(COMANDO);

#command exit example
#modbus read -p 502 xxxx 300041 1
#300041 30517


# extract second value
if ($salida =~ /(\d+)\s+(\d+)/) {
$valor=$2;
}
chomp($valor);
print $valor;


-----------------


Also, if i add a line $valor=12345; just before print then things works as expected and poller shows correct result
I ve run out of ideas of what to try. I have some graphs with script input, and working ok. Its the first time i find this kind of problem, and also never found a problem in cacti so hard and so long to solve, so any help will be greatly appreciated


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 7 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  

Protected by Anti-Spam ACP Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group