reading multiple return values from a script

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

Moderators: Developers, Moderators

Post Reply
tuxx
Posts: 5
Joined: Sat Apr 19, 2008 6:17 am

reading multiple return values from a script

Post by tuxx »

hey,

i am trying to read more than one return value from a perl script. I found a guide explaining how to read single return values here:

http://docs.cacti.net/node/46

but i really need more than one value. i've tried things like

Code: Select all

value1:234234 value2:2342 value3:56574
and

Code: Select all

value1:234234
value2:2342
value3:56574
and several other variations as possible output of the script.

nothing seems to work properly. I'm a bit lost and i was unable to find information about this in the forums.

any help is appreciated,
tuxx
noflies
Cacti User
Posts: 83
Joined: Sun Dec 18, 2005 9:30 am

Post by noflies »

The one-line format is correct as in:
ds1:value1 ds2:value2 ds3:value3

See [large] attached graphic for where most people miss the location to add multiple data sources in a data template.

Post the debug output from the corresponding data source as in:
Console -> Management -> Data Sources -> [ds] -> turn on data source debug
Attachments
Multiple-DSs.png
Multiple-DSs.png (264.49 KiB) Viewed 5988 times
User avatar
gandalf
Developer
Posts: 22383
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

Post by gandalf »

Please read about a simple example here: http://docs.cacti.net/node/203
Reinhard
kejsix
Posts: 5
Joined: Fri Jan 25, 2013 8:26 am

Re: reading multiple return values from a script

Post by kejsix »

gandalf, your last link in this topic don´t work, so I ask again similiar question...

i have simple working perl script

Code: Select all

#!/usr/bin/perl
 
use strict;
#use warnings;
 
use LWP::UserAgent;
use HTTP::Cookies; 
use JSON;
 
if (($#ARGV+1) ne 1) {
 exit();
}
 
my $host = $ARGV[0];
my $cookie_jar = HTTP::Cookies->new();
my $browser  = LWP::UserAgent->new();
my $response = '';
my $json = JSON->new();
 
$browser->cookie_jar($cookie_jar);
 
$response = $browser->get(
  "http://${host}/login.cgi"
);
 
$response = $browser->post(
  "http://${host}/login.cgi",
  Content_Type => 'form-data',
  Content => [
    username => 'cacti',
    password => '',
  ],
);
 
$response = $browser->get(
  "http://${host}/120816.1338/status.cgi"
);

my $ccq = ($json->decode($response->content)->{wireless}->{ccq});
my $rssi = ($json->decode($response->content)->{wireless}->{rssi});
my $rxlevel = ($json->decode($response->content)->{wireless}->{signal});

printf ("ccq:$ccq rssi:$rssi rxlevel:$rxlevel");
runing on bash

Code: Select all

root@zeler:/usr/share/cacti/site/scripts# perl ubnt.pl 10.15.225.130
ccq:961 rssi:54 rxlevel:-42
seems ok, in required format... but cacti log tells me:

Code: Select all

01/28/2013 02:40:02 PM - SPINE: Poller[0] Host[60] DS[87] SCRIPT: perl /usr/share/cacti/site/scripts/ubnt.pl 10.15.226.130, output: U
01/28/2013 02:40:02 PM - SPINE: Poller[0] Host[60] ERROR: Empty result [10.15.225.130]: 'perl /usr/share/cacti/site/scripts/ubnt.pl 10.15.226.130'
01/28/2013 02:40:01 PM - SPINE: Poller[0] Host[60] NOTE: There are '1' Polling Items for this Host 
where is problem please?
Attachments
dtemplate.jpg
dtemplate.jpg (298.01 KiB) Viewed 4441 times
datainput.jpg
datainput.jpg (191.46 KiB) Viewed 4441 times
kejsix
Posts: 5
Joined: Fri Jan 25, 2013 8:26 am

Re: reading multiple return values from a script

Post by kejsix »

Ah... solved... just bad margin values in data template 8)
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest