difference between Data Input Method and Data Queries

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

Moderators: Developers, Moderators

Post Reply
DraGun
Posts: 44
Joined: Thu May 24, 2012 11:21 am

difference between Data Input Method and Data Queries

Post by DraGun »

Hi,

I'd like to understand how cacti works with the scripts.
Is there some priorities for the queries?

We're monitoring a lot of devices (about 10500), and I'm wondering why graphs are ok with XML files and Data Query, and why there are empty data from time to time on the same device with a script (script server or Data Input Method). There is no problem when monitoring in real time. It's like the SNMP queries from the script has no answer from the device. And the XML query has one.

Any idea(s) why the device answers to one method and not the other one? Does Cacti have priorities on some method?

Regards,
Errare humanum est, perseverare diabolicum
User avatar
BSOD2600
Cacti Moderator
Posts: 12171
Joined: Sat May 08, 2004 12:44 pm
Location: USA

Re: difference between Data Input Method and Data Queries

Post by BSOD2600 »

http://docs.cacti.net/manual:088:3a_adv ... 0_overview should address some of these Qs.

What specifically are the script(s) with problems doing to query the data? If launching different environments (bash, perl, powershell, etc) there are overheads which do not scale very well at all when running against a large number of devices.
DraGun
Posts: 44
Joined: Thu May 24, 2012 11:21 am

Re: difference between Data Input Method and Data Queries

Post by DraGun »

Hi,

thanks for the answer :wink:

There is no problems with the scripts when I ran them in shell, even using cacti user. there is nothing wrong in logs or rdd files. juste a timeout from the device, and then a NaN on graphs...

for exemple, the last script I made retrieves data in SNMP, using perl:
[user@host]:~/perl $ snmpwalk -v2c -c cpdea X.X.X.X .1.3.6.1.4.1.6527.3.1.2.33.1.113.1.33.1
SNMPv2-SMI::enterprises.6527.3.1.2.33.1.113.1.33.1.1000 = Counter32: 1
SNMPv2-SMI::enterprises.6527.3.1.2.33.1.113.1.33.1.1001 = Counter32: 0
SNMPv2-SMI::enterprises.6527.3.1.2.33.1.113.1.33.1.1002 = Counter32: 0
SNMPv2-SMI::enterprises.6527.3.1.2.33.1.113.1.33.1.1003 = Counter32: 0
SNMPv2-SMI::enterprises.6527.3.1.2.33.1.113.1.33.1.1004 = Counter32: 2
SNMPv2-SMI::enterprises.6527.3.1.2.33.1.113.1.33.1.1005 = Counter32: 1
SNMPv2-SMI::enterprises.6527.3.1.2.33.1.113.1.33.1.1006 = Counter32: 0
SNMPv2-SMI::enterprises.6527.3.1.2.33.1.113.1.33.1.1007 = Counter32: 1
SNMPv2-SMI::enterprises.6527.3.1.2.33.1.113.1.33.1.1008 = Counter32: 0
SNMPv2-SMI::enterprises.6527.3.1.2.33.1.113.1.33.1.1009 = Counter32: 0
SNMPv2-SMI::enterprises.6527.3.1.2.33.1.113.1.33.1.1011 = Counter32: 0
SNMPv2-SMI::enterprises.6527.3.1.2.33.1.113.1.33.1.1012 = Counter32: 0
SNMPv2-SMI::enterprises.6527.3.1.2.33.1.113.1.33.1.1013 = Counter32: 0
SNMPv2-SMI::enterprises.6527.3.1.2.33.1.113.1.33.1.1014 = Counter32: 0
SNMPv2-SMI::enterprises.6527.3.1.2.33.1.113.1.33.1.1016 = Counter32: 0
SNMPv2-SMI::enterprises.6527.3.1.2.33.1.113.1.33.1.1017 = Counter32: 1
[user@host]:~/perl $ ./nb_abo_pw-ports.pl -h X.X.X.X -pl 10 -z 1 -bo 11 -ppp 1004 -vod_voip 1005 -gp 1006
nb_ppp:2 nb_vod_voip:1 nb_gp:0
Data Input Method uses the script, Data template and Graph template stack the data on the same graph

Graph on lab cacti (75 devices) in attachment, graphs on production cacti are empty.. And this is the same script, same templates, same version...

regards,
Attachments
graph
graph
graph.PNG (25.65 KiB) Viewed 963 times
Errare humanum est, perseverare diabolicum
User avatar
BSOD2600
Cacti Moderator
Posts: 12171
Joined: Sat May 08, 2004 12:44 pm
Location: USA

Re: difference between Data Input Method and Data Queries

Post by BSOD2600 »

1) perl for snmpwalks? Any reason you dont want to use net-snmp binaries instead?
2) retrieving a few OIDs would be much more efficient using the native Cacti methods than a script interpreter - use the Generic OID data template.
3) For prod system, increased the cacti logging level yet? A timeout from the device sounds like a firewall/config issue. if you manually perform the same query from the PROD cacti system, same result?
DraGun
Posts: 44
Joined: Thu May 24, 2012 11:21 am

Re: difference between Data Input Method and Data Queries

Post by DraGun »

Hello,

3) there is no issue manually performing the script. works fine. I can't turn on the logging level on production site. Virtual machine uses too many ressources on logging and graphs are empty then..

1)/2) I don't know how to stack values from choosing OIDs "index" on the same graph.

Regards
Errare humanum est, perseverare diabolicum
User avatar
Happiness0
Cacti User
Posts: 63
Joined: Wed Oct 29, 2014 5:01 am
Contact:

Re: difference between Data Input Method and Data Queries

Post by Happiness0 »

Perhaps using get_bulk_request can improve the performance of your script and avoid timeout's?

Roughly tested :

Code: Select all

#!/user/bin/perl
use strict;
use warnings;
use Net::SNMP qw(oid_lex_sort oid_base_match snmp_dispatcher);
sub getSNMP {
    my ($session, $error, $OID_ifTable) = @_;
    if (!defined $session) {
        printf "ERROR: %s.\n", $error;
        exit 1;
    }

    my %table; # Hash to store the results

    my $result = $session->get_bulk_request(
       -varbindlist    => [ $OID_ifTable ],
       -callback       => [ \&tableCallback, \%table, $OID_ifTable],
       -maxrepetitions => 10,
    );

    if (!defined $result) {
        printf "ERROR: %s\n", $session->error();
        $session->close();
        exit 1;
    }

    # Now initiate the SNMP message exchange.

    snmp_dispatcher();
    return %table;

}
sub tableCallback {
    my ($session, $table, $OID_ifTable) = @_;
    if (!defined $session) {
        printf "ERROR: %s\n", $session->error();
        exit 1;
    }
    my $list = $session->var_bind_list();
    if (!defined $list) {
        printf "ERROR: %s\n", $session->error();
        return;
    }

# Loop through each of the OIDs in the response and assign
# the key/value pairs to the reference that was passed with
# the callback. Make sure that we are still in the table
# before assigning the key/values.

    my @names = $session->var_bind_names();
    my $next  = undef;
    my $i;
    while (@names) {
        $next = shift @names;
        if (!oid_base_match($OID_ifTable, $next)) {
            return; # Table is done.
        }
        $i = [$next =~ /(\d+)$/]->[0];
        $table->{$i} = $list->{$next};
    }

# Table is not done, send another request, starting at the last
# OBJECT IDENTIFIER in the response. No need to include the
# calback argument, the same callback that was specified for the
# original request will be used.

    my $result = $session->get_bulk_request(
        -varbindlist    => [ $next ],
        -maxrepetitions => 10,
    );

    if (!defined $result) {
        printf "ERROR: %s.\n", $session->error();
    }
    return;
}

my ($session, $error) = Net::SNMP->session(
    -hostname    => 'X.X.X.X',
    -community   => 'cpdea',
    -nonblocking => 1,
    -translate   => [-octetstring => 0],
    -version     => 'snmpv2c',
    -port       => 161
) or die "Session: $!";
my %table= getSNMP($session, $error, 'SNMPv2-SMI::enterprises.6527.3.1.2.33.1.113.1.33.1');
my %oid = (
    1004 => 'nb_ppp',
    1005 => 'nb_vod_voip',
    1006 => 'nb_gp',
);
print join (':', ($oid{$_}, $table{$_})) . ' ' for keys %oid;

DraGun
Posts: 44
Joined: Thu May 24, 2012 11:21 am

Re: difference between Data Input Method and Data Queries

Post by DraGun »

Hi,

I tried your script, but I have either blank graphs, either incorrect values. Data were inverted on graphs. I tried to sort the output to always have the same order, but still the same.

So I got back to my script, improving it.
On device with few SNMP requests, it works fine. But on device with a lot of graphs, I still have sometimes empty data.

The script now retrieves data, if none, wait 5 sec, then tries again. Still having retries and timeout in the SNMP session.

I'll wait till the end of the week to see if it's better..
Errare humanum est, perseverare diabolicum
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests