[mrtg-developers] SNMPWALK Problem. Problem if using Net_SNMP_util.pm

Carlos Velasco mrtg at nimastelecom.com
Thu Mar 22 22:55:29 CET 2007


Hello,

If one host is down, when performing snmpwalk due to Interface by Name configuration (Target[myrouter]: #2/11:public at wellfleet-fddi.domain), this code will not work as expected.

errmsg is never used in Net_SNMP_util, only in SNMP_util. Its value is undef.
When host is down, the result is @ret defined with 1 element in array, the element is an undef.

The code will result in several delay in mrtg processing, as all nodes are tried and failed, the host is never marked as dead.


MRTG_lib.pm  (line 1623)
    foreach my $node (@nodes) {
        next if $confcache->{___deadhosts}{$hostkey} and time - $confcache->{___deadhosts}{$hostkey} < 300;
        $SNMP_Session::errmsg = undef;
        @ret = snmpwalk(v4onlyifnecessary($host, $ipv4only), $snmpoptions, $node);
        unless ( $SNMP_Session::errmsg){
            foreach my $ret (@ret)
              {
                  my ($oid, $desc) = split(':', $ret, 2);
                  if ($tables{$node} eq 'Ip') {
                      storeincache($confcache,$host,$tables{$node},$oid,$desc);
                  } else {
                      $desc =~ s/[\0- ]+$//; #trailing whitespace is too sick for us
                      $desc =~ s/[\0- ]/ /g; #whitespace is just whitespace
                      storeincache($confcache,$host,$tables{$node},$desc,$oid);
                  }
              };
        } else {
            $confcache->{___deadhosts}{$hostkey} = time
                if $SNMP_Session::errmsg =~ /no response received/;
            debug('coca',"Skipping $node scanning because $host does not seem to support it");
        }


Regards,
Carlos Velasco



More information about the mrtg-developers mailing list