Menu

Problems after upgrade from v1.11 to v1.12

Help
2013-11-14
2013-11-14
  • Michael Schmidt

    Michael Schmidt - 2013-11-14

    Hi Jonathan,

    I recentrly upgraded v1.11 to v1.12 and ran into several problems, which I could all fix.
    Please have a look at the following topics.

    Regards,
    Michael


    DNS

    In our environment network device names do not get resolved by dns, so instead of this we administer all network devices in a local /etc/hosts file.
    Until v1.11 this was working fine, but since v1.12 the determination of IP addresses is done with the procedure getIPfromName in NetDBHelper.pm which obvioulsy does not support name resolution from /etc/hosts.
    I added some code to the procedure and then this is working again:

    sub getIPfromName {
    my $fqdn = shift;
    my $hostip;
    my $res = Net::DNS::Resolver->new;
    my $searchv6 = $res->search( $fqdn, 'AAAA' );
    my $searchv4 = $res->search( $fqdn );

    # Check for IPv6 first
    if ( $searchv6 ) {
    my @rrv6 = $searchv6->answer;
    $hostip = $rrv6[0]->address;
    return $hostip;
    }

    # IPv4
    elsif ( $searchv4 ) {
    my @rrv4 = $searchv4->answer;
    $hostip = $rrv4[0]->address;
    return $hostip;
    }
    else {
    $hostip = inet_ntoa(inet_aton($fqdn));
    if ( !$hostip ) {
    croak( "|ERROR|: DNS lookup failure on $fqdn\n" );
    }
    else {
    return $hostip;
    }

    }
    } # END sub getIPfromName


    Get neigbor infos for nexus devices

    We use telnet to connect to our nexus devices and in the nxoscraper.pl the telnet connect in procedure getCDP does not work.
    This is something I reported before and has not been fixed.

    In file nxoscraper.pl in procedure getCDP I had to change this:

    # Telnet Command
    else {
    @cmdresults = split( /\n/, $session->cmd( String => "show cdp neighbors detail" ) );
    }

    to this:

    # Telnet Command
    else {
    @cmdresults = $session->cmd( String => "show cdp neighbors detail" ) ;
    }


    Import neigbor infos for nexus devices

    Neigbor infos from nexus devices seem to contain newline characters, which break the structure of the nd.csv file.
    To solve this I had to add a chomp on the repective string variable in file nxoscraper.pl in the procedure getCDP.

    # Save Software String
    elsif ( $softNext && $line =~ /^([A-Z|a-z|0-9]+)/ ) {
    $softwareString = $line;
    $softwareString =~ s/\r//g;
    chomp($softwareString);
    $softNext = undef;
    print "$scriptName($PID): |DEBUG|: $remoteDevice software string: $softwareString\n" if $DEBUG>4;
    }


    SSH Sessions to asa devices

    In a separate config, we retrieve information from asa devices. Here we use ssh to connect to the devices. After the upgrade to v1.12 this was not working anymore.
    After looking into the code I realized, that a different function "get_SSH_session" is used in v1.12 to establish an ssh session.
    This is not working at all in our environment, so I hat to switch back to the function "get_cisco_ssh_auto" to get this to work.
    Can you please help me to find out, why the function "get_SSH_session" is not working at all? It is waiting fro a connection until the timeout hits and cancels the action.

    In file asascraper.pl in procedure connectDevice I had to change this:

    eval {
    $session = get_SSH_session( $fqdn, "terminal pager 0" );
    #$session = get_cisco_ssh_auto( $fqdn );

    };

    to this:

    eval {
    #$session = get_SSH_session( $fqdn, "terminal pager 0" );
    $session = get_cisco_ssh_auto( $fqdn );

    };


     
    • Jonathan Yantis

      Jonathan Yantis - 2013-11-14

      Michael,

      Thanks for the excellent feedback and bug fixes. I have applied it to the main branch to run in testing for a couple days and will backport the changes to the 1.12 version soon. If you happen to add any new useful functionality or find any more bugs please let us know.

      Regards,
      Jonathan

      On Nov 14, 2013, at 6:23 AM, "Michael Schmidt" mscsl@users.sf.net wrote:

      Hi Jonathan,

      I recentrly upgraded v1.11 to v1.12 and ran into several problems, which I could all fix.
      Please have a look at the following topics.

      Regards,
      Michael

      DNS

      In our environment network device names do not get resolved by dns, so instead of this we administer all network devices in a local /etc/hosts file.
      Until v1.11 this was working fine, but since v1.12 the determination of IP addresses is done with the procedure getIPfromName in NetDBHelper.pm which obvioulsy does not support name resolution from /etc/hosts.
      I added some code to the procedure and then this is working again:

      sub getIPfromName {
      my $fqdn = shift;
      my $hostip;
      my $res = Net::DNS::Resolver->new;
      my $searchv6 = $res->search( $fqdn, 'AAAA' );
      my $searchv4 = $res->search( $fqdn );

      Check for IPv6 first

      if ( $searchv6 ) {
      my @rrv6 = $searchv6->answer;
      $hostip = $rrv6[0]->address;
      return $hostip;
      }

      IPv4

      elsif ( $searchv4 ) {
      my @rrv4 = $searchv4->answer;
      $hostip = $rrv4[0]->address;
      return $hostip;
      }
      else {
      $hostip = inet_ntoa(inet_aton($fqdn));
      if ( !$hostip ) {
      croak( "|ERROR|: DNS lookup failure on $fqdn\n" );
      }
      else {
      return $hostip;
      }
      }
      } # END sub getIPfromName

      Get neigbor infos for nexus devices

      We use telnet to connect to our nexus devices and in the nxoscraper.pl the telnet connect in procedure getCDP does not work.
      This is something I reported before and has not been fixed.

      In file nxoscraper.pl in procedure getCDP I had to change this:

      Telnet Command

      else {
      @cmdresults = split( /\n/, $session->cmd( String => "show cdp neighbors detail" ) );
      }

      to this:

      Telnet Command

      else {
      @cmdresults = $session->cmd( String => "show cdp neighbors detail" ) ;
      }

      Import neigbor infos for nexus devices

      Neigbor infos from nexus devices seem to contain newline characters, which break the structure of the nd.csv file.
      To solve this I had to add a chomp on the repective string variable in file nxoscraper.pl in the procedure getCDP.

      Save Software String

      elsif ( $softNext && $line =~ /^([A-Z|a-z|0-9]+)/ ) {
      $softwareString = $line;
      $softwareString =~ s/\r//g;
      chomp($softwareString);
      $softNext = undef;
      print "$scriptName($PID): |DEBUG|: $remoteDevice software string: $softwareString\n" if $DEBUG>4;
      }

      SSH Sessions to asa devices

      In a separate config, we retrieve information from asa devices. Here we use ssh to connect to the devices. After the upgrade to v1.12 this was not working anymore.
      After looking into the code I realized, that a different function "get_SSH_session" is used in v1.12 to establish an ssh session.
      This is not working at all in our environment, so I hat to switch back to the function "get_cisco_ssh_auto" to get this to work.
      Can you please help me to find out, why the function "get_SSH_session" is not working at all? It is waiting fro a connection until the timeout hits and cancels the action.

      In file asascraper.pl in procedure connectDevice I had to change this:

      eval {
      $session = get_SSH_session( $fqdn, "terminal pager 0" );

      $session = get_cisco_ssh_auto( $fqdn );

      };

      to this:

      eval {

      $session = get_SSH_session( $fqdn, "terminal pager 0" );

      $session = get_cisco_ssh_auto( $fqdn );
      };

      Problems after upgrade from v1.11 to v1.12

      Sent from sourceforge.net because you indicated interest in https://sourceforge.net/p/netdbtracking/discussion/939989/

      To unsubscribe from further messages, please visit https://sourceforge.net/auth/subscriptions/

       

Log in to post a comment.