DX NetOps

  • 1.  F5 BigIP NCM Script

    Posted Oct 30, 2014 10:44 PM

    Has any one tried creating Spectrum NCM script for F5 Configuration Backups?



  • 2.  Re: F5 BigIP NCM Script

    Posted May 20, 2015 05:29 AM

    Hello.

    Did you get to obtain the configuration of F5 with the NCM finally? I am to trying to get the backup of F5 with NCM, and i´m not sure what is the way because is a device in a linux system. The F5 administrator thinks that perhaps if he could give the configuration in a directory I could create a perl script to read that file...I appreciate any idea.

    Regards!



  • 3.  Re: F5 BigIP NCM Script

    Posted May 20, 2015 09:58 AM

    Hi,

     

    you can write a NCM script which connects via the perl "expect" module to the F5 LTM and fire up a "tmsh save /sys config file config.scf" which will create the config.

    Afterwards you read out this file line by line with cat and peek http://search.cpan.org/~bnegrao/Net-SSH-Expect-1.09/lib/Net/SSH/Expect.pod



  • 4.  Re: F5 BigIP NCM Script

    Posted Jun 29, 2018 12:00 PM

    Anyone have a working script for this?



  • 5.  Re: F5 BigIP NCM Script

    Posted Jul 02, 2018 03:01 AM

    oldshield schrieb:

     

    Anyone have a working script for this?

     

    Yep! Save the following in "Configuration Manager --> F5 Loadbalancer --> Inforamtion --> Capture Running Config. Script" and don't forget to configure Username/Password in Spectrum.

     

     

    #!/opt/SPECTRUM/bin/perl -w
    # Error Codes:
    # 0 = Success
    # 255 = Usage error
    # 254 = Invalid timeout value
    # 252 = Login error
    # 249 = Exec prompt not found error
    # 244 = Error retrieving configuration
    # 245 = Insufficient privileges
    # 253 = Unexpected output
    #

    use strict;
    use warnings;
    use Net::SSH::Expect;

    $ENV{'PATH'} = "/usr/bin:". $ENV{'PATH'};


    ### Main ###
    if( $#ARGV != 4 && $#ARGV != 5 )
    {
    my $errorCode = 1;
    my @data;
    my $errorString = "\nHost $ARGV[0]: \n";

    ($errorCode, @data) = GetConfig( $ARGV[0], $ARGV[1], $ARGV[2], $ARGV[3], 2, 2 );
    }

    sub GetConfig
    {
    my $deviceIP=shift;
    my $user=shift;
    my $pass=shift;
    my $epass=shift;
    my $login_timeout=shift;
    my $capture_timeout=shift;
    my @config;
    my $msg;

    my $ssh = Net::SSH::Expect->new ( host => $deviceIP,
    user => $user,
    password=> $pass,
    raw_pty => 1,
    no_terminal => 0,
    timeout => $login_timeout
    );
    my $login_output;
    eval { $login_output = $ssh->login(); };

    $ssh->send( "tmsh save /sys config file config.scf no-passphrase" );
    sleep 5;

    $ssh->send( "cat /var/local/scf/config.scf" );
    $ssh->timeout( 2 );
    $ssh->peek(0);

    while( my $line = $ssh->read_line() )
    {
    if( $line !~ /config.scf/ )
    {
    print "$line\n";
    }
    }
    $ssh->close();
    }