Problems with external script, cacti don't get data :(

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

Moderators: Developers, Moderators

User avatar
TheWitness
Developer
Posts: 17007
Joined: Tue May 14, 2002 5:08 pm
Location: MI, USA
Contact:

Post by TheWitness »

Your welcome. It was mostly listening anyway :) Don't know why it was using stderr. That did not make sense.

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?
frivas
Posts: 18
Joined: Thu May 12, 2005 4:11 pm

Post by frivas »

that's true... fping should use stdout, not stderr to output the results... weird :(
but I'm glad that this is solved :)
lga
Posts: 21
Joined: Mon May 23, 2005 4:39 am
Location: Belgium

Post by lga »

Hi,

I've the same problem with a perl script that problem describes by Frivas.

Code: Select all


#!/usr/bin/perl
#------------------------------------------------------------------------------
# poll.pl parse la configuration qos d'un routeur et retrouve les indexes 
#         adéquats pour obtenir la bande passante et les drops pour chaque
#         class-map. 
#------------------------------------------------------------------------------
$router=shift;
$gcn=shift;
die "Usage : poll.pl <router> <gcn>\n" if (($router eq '') || ($gcn eq ''));
$oid=".1.3.6.1.4.1.9.9.166.1"; # référencement de la mib cisco-class-based-qos-mib
$snmpwalk="/usr/local/bin/snmpwalk";
$snmpget="/usr/local/bin/snmpget";

# Interfaces sur lesquelles on a défini une qos.
$oidspecific="$oid.1.1.1.4"; # cbQosIfIndex
@output=`$snmpwalk $router -c $gcn $oidspecific -v 2c`;

$nboutputline=@output;
$counter=0;
while ($counter < $nboutputline)
  {
    chop($output[$counter]);
    $output[$counter] =~ s/ //g;
    @fields=split(/=/,$output[$counter]);
    $value=$fields[1];
    $value=~s/INTEGER://g;
    @key=split(/\./,$fields[0]);
    $nblevel=@key;
    $nblevel--;

    #print("$key[$nblevel];$value\n");
    $PolicyMap{$key[$nblevel]}=$value;
    $counter++;
  }

@objecttype=('','policymap','classmap','matchStatement','queueing','randomDetect','trafficShapping','police','set');
foreach $entry (sort keys %PolicyMap) # Pour chaque Policy-Map,
  {
    # on recherche tous les qos-objets associes
    $oidspecific="$oid.5.1.1.3.$entry"; # cbQosObjectsType
    @output=`$snmpwalk $router -c $gcn $oidspecific -v 2c`;

    $nboutputline=@output;
    $counter=0;
    while ($counter < $nboutputline)
      {
        chop($output[$counter]);
        $output[$counter] =~ s/ //g;
        @fields=split(/=/,$output[$counter]);
        $value=$fields[1];
        $value=~s/INTEGER://g;
        @key=split(/\./,$fields[0]);
        $nblevel=@key;
        $nblevel--;

        #print("$key[$nblevel];$objecttype[$value]\n");
        $key=$entry.".".$key[$nblevel];
        $Object{$key}=$objecttype[$value];
        $counter++;
      }
  }

$u=0;
foreach $entry (sort keys %Object) # Pour chaque qos-objet,
  {
    # on recherche la bande passante utilisee apres application de la policy
    if ($Object{$entry} eq "classmap")
      {
        $oidspecific="$oid.15.1.1.10.$entry"; # cbQosCMPolicyByte64
        $output=`$snmpget $router -c $gcn $oidspecific -v 2c`;
        chop($output);
        $output =~ s/ //g;
        @fields=split(/=/,$output);
        $value=$fields[1];
        #print("$value\n");
        $value =~ s/Counter64://;
        @fields=split(/\./,$entry);
        $Value{$fields[0]}.=":".$value;
        # pour cacti ...
        $out.="classmap_".$u."_bw:".$value." ";

        $oidspecific="$oid.15.1.1.14.$entry"; # cbQosCMDropPkt64
        $output=`$snmpget $router -c $gcn $oidspecific -v 2c`;
        chop($output);
        $output =~ s/ //g;
        @fields=split(/=/,$output);
        $value=$fields[1];
        $value =~ s/Counter64://;
        @fields=split(/\./,$entry);
        $Value{$fields[0]}.=":".$value;

        # pour cacti ...
        $out.="classmap_".$u."_drop:".$value." ";
        $u++;
      }
  }

# On alimente la DB
foreach $entry (sort keys %PolicyMap) # Pour chaque policy-map,
  {
    $data=$Value{$entry}.":U:U"; # on ajoute des valeurs Unknow pour la future classmap video
    $interface=$PolicyMap{$entry};
    $rrdname="/usr/local/mrtg-2/db/WinSwde/qos/".$router."_qos_".$interface.".rrd";
    #$maj=`/usr/local/rrdtool-1.0.45/bin/rrdtool update $rrdname $data`;
    print ("$out\n");
  }

In cacti log:


05/23/2005 11:45:04 AM - POLLER: Poller[0] Parsed MULTI output field 'class_default:183108800' [map class_default->class_default]
05/23/2005 11:45:04 AM - POLLER: Poller[0] Parsed MULTI output field 'class_bsi:28438141' [map class_bsi->class_bsi]
05/23/2005 11:45:04 AM - POLLER: Poller[0] Parsed MULTI output field 'class_bus:448205483' [map class_bus->class_bus]
05/23/2005 11:45:04 AM - POLLER: Poller[0] Parsed MULTI output field 'class_priority:98542952' [map class_priority->class_priority]
05/23/2005 11:45:04 AM - POLLER: Poller[0] Parsed MULTI output field 'class_undef:7827063' [map class_undef->class_undef]
05/23/2005 11:45:04 AM - POLLER: Poller[0] Parsed MULTI output field 'class_default:754050245' [map class_default->class_default]
05/23/2005 11:45:04 AM - POLLER: Poller[0] Parsed MULTI output field 'class_bsi:90486731' [map class_bsi->class_bsi]
05/23/2005 11:45:04 AM - POLLER: Poller[0] Parsed MULTI output field 'class_bus:1602218251' [map class_bus->class_bus]
05/23/2005 11:45:04 AM - POLLER: Poller[0] Parsed MULTI output field 'class_priority:707548059' [map class_priority->class_priority]
05/23/2005 11:45:04 AM - POLLER: Poller[0] Parsed MULTI output field 'class_undef:13167626' [map class_undef->class_undef]

05/23/2005 12:00:21 PM - POLLER: Poller[0] CACTI2RRD: /usr/bin/rrdtool update /usr/local/cacti-0.8.6b/rra/wdir01_classmap_5_bw_7544.rrd --template 1116842401:U
OK u:0.08 s:0.20 r:19.47
ERROR: Not enough arguments
OK u:0.08 s:0.20 r:19.47
05/23/2005 12:00:21 PM - POLLER: Poller[0] CACTI2RRD: /usr/bin/rrdtool update /usr/local/cacti-0.8.6b/rra/sbxrv02_5min_cpu_964.rrd --template 5min_cpu 1116842401:62


I use cactid as poller ...
Do you have an idea on this problem ?

Thks a lot

Lionel.
User avatar
TheWitness
Developer
Posts: 17007
Joined: Tue May 14, 2002 5:08 pm
Location: MI, USA
Contact:

Post by TheWitness »

Do you have this problem using cmd.php? If not, then I would suspect that you have a trailing blank in your script output or an extra blank within the code. The validation logic is very touchy and more so in Cactid.

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?
lga
Posts: 21
Joined: Mon May 23, 2005 4:39 am
Location: Belgium

Post by lga »

TheWitness wrote:Do you have this problem using cmd.php? If not, then I would suspect that you have a trailing blank in your script output or an extra blank within the code. The validation logic is very touchy and more so in Cactid.

TheWitness

I use poller.php with cactid 0.8.6d
With cmd.php, this script works well.
User avatar
TheWitness
Developer
Posts: 17007
Joined: Tue May 14, 2002 5:08 pm
Location: MI, USA
Contact:

Post by TheWitness »

You should then trim the output before you return it from the script. This will fix the issue.

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?
lga
Posts: 21
Joined: Mon May 23, 2005 4:39 am
Location: Belgium

Post by lga »

TheWitness wrote:You should then trim the output before you return it from the script. This will fix the issue.

TheWitness

Thks the problem is solved

I use a function trim before return the string :

Code: Select all

sub trim {

  my $string = shift;
  for ($string) {
          s/^\s+//;
          s/\s+$//;
  }
  return $string;
}
User avatar
GLR
Cacti User
Posts: 55
Joined: Mon Jul 21, 2008 5:45 am
Location: Paris suburbs, France
Contact:

Export Graph template ?

Post by GLR »

About Cisco QoS stats :
I also see those threads and will have a look at them :
http://forums.cacti.net/viewtopic.php?t=7401
http://forums.cacti.net/viewtopic.php?t=17775
Cacti 0.8.8b + spine 0.8.8b
on Debian / Apache 2.2 / PHP 5.2 / MySQL 5.0
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests