Data Input method + script - no data

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

Moderators: Developers, Moderators

Post Reply
polityk
Posts: 6
Joined: Sun May 19, 2013 9:43 am

Data Input method + script - no data

Post by polityk »

As this is my forst post, at the begining I would like to say hi to everyone on this forum and big thanks to all the people involved in CACTI, great job and a wonderful project.
I am quite new to CACTI so I might ask some obvious questions ;)

What I need to do is graph modulation type of a wireless link (Alvarion WiMAX CPE).
I get the data via SNMP and this is great, but the result is a string like: "QAM64-5/6", so afaik there is no way of putting it on graph.
Some time ago i have managed to make a script which associated my SNMP gathered strings with numbers 0-9 and it works fine.
Then manually i have managed to place the data in RRD and create graphs, run all in crontab and voila:
Image


Now I want to move this to CACTI, I have created another script so the gathered data is integer 1-9.

I have created a data input method, data template and graph template according to http://forums.cacti.net/viewtopic.php?t=11288 on other tutorials.
but all i get is NaN on my graph... even found an exapmle with script that generates random data, but i get the same NaN.
Tested the script in shell and it gets the data as planned, when the user is switched to 'cacti' it also works.
Tried to look for hints in the log, but unfortunatelly did not find any... probably my lack of knowledge.
Any help would be much appreciated. Maybe there is another way of doing this?

Cacti 0.8.8.a with spine + some plugins
Running on FreeBSD 9.0
Below is my setup.

Script:
(just started learning perl ;) )

Code: Select all

#!/usr/bin/perl

use warnings;
use Getopt::Long;
use POSIX;

my $snmp_timeout = "5";
my $read_community = "public";
$target_ip = $ARGV[0];

sub modtoval() {
#replace strings with integer values
        if ($_[0] eq "qpsk-ctc-1/2 4 repetitions"){$_[0] = 1}
                elsif ($_[0] eq "qpsk-ctc-1/2 2 repetitions"){$_[0] = 2}
                elsif ($_[0] eq "qpsk-ctc-1/2"){$_[0] = 3}
                elsif ($_[0] eq "qpsk-ctc-3/4"){$_[0] = 4}
                elsif ($_[0] eq "qam16-ctc-1/2"){$_[0] = 5}
                elsif ($_[0] eq "qam16-ctc-3/4"){$_[0] = 6}
                elsif ($_[0] eq "qam64-ctc-2/3"){$_[0] = 7}
                elsif ($_[0] eq "qam64-ctc-3/4"){$_[0] = 8}
                elsif ($_[0] eq "qam64-ctc-5/6"){$_[0] = 9}
}

#SNMP Query
my $downmod= `/usr/local/bin/snmpget -t $snmp_timeout -v 1 -c $read_community -Oqv $target_ip 1.3.6.1.4.1.10529.300.1.1.6.0`;
my $upmod= `/usr/local/bin/snmpget -t $snmp_timeout -v 1 -c $read_community -Oqv $target_ip 1.3.6.1.4.1.10529.300.1.1.5.0`;

#strip unnecessary
$upmod =~ m/"(.+?)"/;
$upmod = $1;
$downmod =~ m/"(.+?)"/;
$downmod = $1;

#replace strings with ints
$downmod = &modtoval($downmod);
$upmod = &modtoval($upmod);

#print data
print "down_mod:" . $downmod . " up_mod:" . $upmod;
Data Input Method:
Data input
Data input
data-input.png (44.66 KiB) Viewed 1168 times
Data Template:
data template
data template
data-template.png (78.76 KiB) Viewed 1168 times
Graph Template:
graph template
graph template
graph.png (105.64 KiB) Viewed 1168 times
Results:
graph results
graph results
results.png (115.74 KiB) Viewed 1168 times
cacti.log (probably too much of it):
cacti.log.txt
(728.01 KiB) Downloaded 84 times
User avatar
BSOD2600
Cacti Moderator
Posts: 12171
Joined: Sat May 08, 2004 12:44 pm
Location: USA

Re: Data Input method + script - no data

Post by BSOD2600 »

1) have you tried using a regex to parse the number in the output when using a cacti snmp data query? For example http://docs.cacti.net/manual:088:3a_adv ... _in_action or the [SNMP - Interface Statistics] <path_cacti>/resource/snmp_queries/interface.xml for examples.

2) [ip address] in the data template custom data section should be checked.

3) your posted cacti.log doesnt contain a polling cycle. Notice you're not able to find Cacti running your Perl script?
polityk
Posts: 6
Joined: Sun May 19, 2013 9:43 am

Re: Data Input method + script - no data

Post by polityk »

1) no, just thought my approach was easier....
I'l try to do this, but this is not only parsing the output, i need to represent names as numbers.

2) wouldnt this make me enter the ip address every time I create a graph?
I need to take the IP automatically from host.
p.s. tried this and still the same result

3) This was my assumption, but i wasnt sure how it should appear in logs.
Now looking into logs 24hrs old i do not see any reference to my script...
So where to look ?
polityk
Posts: 6
Joined: Sun May 19, 2013 9:43 am

Re: Data Input method + script - no data

Post by polityk »

I think i am getting somewhere.... but not sure...

When running from shell "spine -H 389" (where 389 is my host ID) i get somewhere in the logs:

Code: Select all

05/20/2013 09:08:42 PM - SPINE: Poller[0] Host[389] TH[1] DS[3031] SCRIPT: /usr/bin/perl /usr/local/share/cacti/scripts/alvr_cpe_mod.pl 10.100.2.1, output: down_mod:9 up_mod:9
and

Code: Select all

05/20/2013 09:08:43 PM - SPINE: Poller[0] DEVDBG: SQL:'INSERT INTO poller_output (local_data_id, (...ommited...) 'down_mod:9 up_mod:9')
so this works i guess.. ? values 9 and 9 are correct for this host
but this does not update rrd anyway....

when running the same with "sudo -u cacti" there is:

Code: Select all

Insecure dependency in `` while running setgid at /usr/local/share/cacti/scripts/alvr_cpe_mod.pl line 21.
05/20/2013 09:08:30 PM - SPINE: Poller[0] Host[389] ERROR: Empty result [10.100.2.1]: '/usr/bin/perl /usr/local/share/cacti/scripts/alvr_cpe_mod.pl 10.100.2.1'
05/20/2013 09:08:30 PM - SPINE: Poller[0] Host[389] TH[1] DS[3031] SCRIPT: /usr/bin/perl /usr/local/share/cacti/scripts/alvr_cpe_mod.pl 10.100.2.1, output: U
So probably permissions problem... but where? the script is 777...
Maybe the command in data input methods should use sudo?

update:
Running poller as root fixed the issue, so definatelly a permissions problem.
I will try to find out where exactly is the issue when i get some free time.
Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests