Problem with perl script

Post support questions that directly relate to Linux/Unix operating systems.

Moderators: Developers, Moderators

Post Reply
User avatar
rsuinux
Posts: 9
Joined: Mon Oct 06, 2008 3:19 am
Location: Orion Galaxy
Contact:

Problem with perl script

Post by rsuinux »

I test script in perl, and graph whith data output:

Code: Select all

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

print "11";
exit;

__END__
Very simple, isn't it?
But, in cacti.log, the result is bad:

Code: Select all

10/09/2008 02:05:03 PM - CMDPHP: Poller[0] Host[25] DS[46] WARNING: Result from CMD not valid.  Partial Result: 
10/09/2008 02:05:03 PM - CMDPHP: Poller[0] Host[25] DS[46] CMD: perl /usr/local/bin/temp.pl , output: U
I test in console:
# /usr/bin/perl /usr/local/bin/temp.pl
11#
ok, that's good, but, with www-data user: su -l www-data /usr/bin/perl /usr/local/bin/temp.pl
/usr/bin/perl: /usr/bin/perl: cannot execute binary file

Is this script used by www-data or not?
I am puzzled!
Have you any idea?
Remi.
icewalker
Posts: 42
Joined: Tue Sep 09, 2008 2:18 pm

Post by icewalker »

The cacti.log gives you the necessary information. The output from the script is incorrect. Cacti requries output that is formatted in a particular way.

entity:value

You per perl script should look more like this:

Code: Select all

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

print "ssCpuRawUser:11";
exit; 
where ssCpuRawUser is the "entity" you want to graph. Also note, there is not a "\n" at the end of my print. We don't wany any new lines either. Multiple entries would look like the following:

Code: Select all

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

print "ssCpuRawUser:11 ssCpuRawNice:6 ssCpuRawSystem:4";
exit; 
User avatar
rsuinux
Posts: 9
Joined: Mon Oct 06, 2008 3:19 am
Location: Orion Galaxy
Contact:

Post by rsuinux »

icewalker wrote:The cacti.log gives you the necessary information. The output from the script is incorrect. Cacti requries output that is formatted in a particular way.

entity:value

You per perl script should look more like this:

Code: Select all

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

print "ssCpuRawUser:11";
exit; 
where ssCpuRawUser is the "entity" you want to graph. Also note, there is not a "\n" at the end of my print. We don't wany any new lines either. Multiple entries would look like the following:

Code: Select all

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

print "ssCpuRawUser:11 ssCpuRawNice:6 ssCpuRawSystem:4";
exit; 
thank you for your help
I modified my 'script', and the response is clear:

Code: Select all

CMDPHP: Poller[0] Host[25] DS[46] WARNING: Result from CMD not valid.  Partial Result: 
10/09/2008 04:20:03 PM - CMDPHP: Poller[0] Host[25] DS[46] CMD: perl /usr/local/bin/temp.pl , output: U
I did not configured special value for the output in my graph. Is The solution? :roll:
Where is the doc for the script output ?
icewalker
Posts: 42
Joined: Tue Sep 09, 2008 2:18 pm

Post by icewalker »

User avatar
rsuinux
Posts: 9
Joined: Mon Oct 06, 2008 3:19 am
Location: Orion Galaxy
Contact:

Post by rsuinux »

icewalker wrote:I started here.

http://docs.cacti.net/?q=node/300
Ok! Thanks
Remi.
User avatar
TheWitness
Developer
Posts: 17047
Joined: Tue May 14, 2002 5:08 pm
Location: MI, USA
Contact:

Post by TheWitness »

Add a carriage return to the end "\n";

TheWitness
True understanding begins only when we realize how little we truly understand...

Life is an adventure, let yours begin with Cacti!

Author of dozens of Cacti plugins and customization's. Advocate of LAMP, MariaDB, IBM Spectrum LSF and the world of batch. Creator of IBM Spectrum RTM, author of quite a bit of unpublished work and most of Cacti's bugs.
_________________
Official Cacti Documentation
GitHub Repository with Supported Plugins
Percona Device Packages (no support)
Interesting Device Packages


For those wondering, I'm still here, but lost in the shadows. Yearning for less bugs. Who want's a Cacti 1.3/2.0? Streams anyone?
User avatar
rsuinux
Posts: 9
Joined: Mon Oct 06, 2008 3:19 am
Location: Orion Galaxy
Contact:

Post by rsuinux »

With your help, I'm happy to graph metar information!
My perl script return temperature and atmospheric pressure in my city Limoges (france).
example:
http://www.suinot.org/cacti/graph_view. ... &tree_id=1

Very big thank you
(I have just one small problem, but it's another post)

Rémi.
Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests