[quagga-users 13314] Re: bgpd dump file rotation

Kurt Jaeger q-u at opsec.eu
Tue Jul 9 05:56:49 BST 2013


Hi!

> Is there any way to reload bgpd process without the BGP connection down?

I call the script below in my crontab using this:

-----------
# rotate for bgpdumps
10 0 * * * /usr/local/bin/rotatebgpdump
-----------

--------------------

#!/usr/local/bin/perl

#
# This script rotates the bgp update file
# pi, Sat Sep  5 06:43:12 CEST 2009
#

use strict;
use warnings;
use Net::Telnet ();
use Config::Tiny;

my($conf) = '/usr/local/etc/rotatebgpdump.conf';

my $Config = Config::Tiny->new();
$Config = Config::Tiny->read( $conf );

my($prompt, $hostname, $password, $enable);
my($t);

if ( defined($Config) ) {
    $t=$Config->{_}->{prompt};
    if ( defined($t) ) {
        $prompt = $t;
    }
    else {
	die "$0: required parameter 'prompt' missing in config\n";
    }

    $t=$Config->{_}->{host};
    if ( defined($t) ) {
        $hostname = $t;
    }
    else {
	die "$0: required parameter 'host' missing in config\n";
    }

    $t=$Config->{_}->{password};
    if ( defined($t) ) {
        $password = $t;
    }
    else {
	die "$0: required parameter 'password' missing in config\n";
    }

    $t=$Config->{_}->{enable};
    if ( defined($t) ) {
        $enable = $t;
    }
    else {
	die "$0: required parameter 'enable' missing in config\n";
    }
}
else {
	die "$0: cant read config file '$conf'\n";
}

my ($pre);
my ($mat);
my ($i);
my ($timestamp) = `date +%s`;
chomp($timestamp);

#print "hostname: $hostname, $password, $enable\n";

$t = new Net::Telnet ( Timeout => 30, Port => 2605 );
$t->output_log("/tmp/out.ig");
$t->input_log("/tmp/in.ig");
$t->dump_log("/tmp/dump.ig");
$t->open($hostname);

$t->waitfor(String => "Password: ");
$t->print($password);
$t->waitfor(String => $prompt.'> ');
$t->print("enable");
$t->waitfor(String => "Password: ");
$t->print($enable);
$t->waitfor(String => $prompt.'# ');
$t->print("terminal length 0");
($pre, $mat) = $t->waitfor(String => $prompt.'# ');
($pre, $mat) = $t->waitfor(String => $prompt.'# ');
($pre, $mat) = $t->waitfor(String => $prompt.'# ');

# now fetch the number of prefixes per peer
$t->print("conf t");
($pre, $mat) = $t->waitfor(String => $prompt.'(config)# ');
#print "pre3: '$pre'\n";
#print "mat3: '$mat'\n";

my($cmd) = "dump bgp updates /var/log/quagga/".$timestamp;
$t->print($cmd);
($pre, $mat) = $t->waitfor(String => $prompt.'(config)# ');
#print "pre4: '$pre'\n";
#print "mat4: '$mat'\n";

$t->print("exit");
($pre, $mat) = $t->waitfor(String => $prompt.'# ');
#print "pre5: '$pre'\n";
#print "mat5: '$mat'\n";

$t->print("exit");
($pre, $mat) = $t->waitfor(String => $prompt.'# ');
#print "pre6: '$pre'\n";
#print "mat6: '$mat'\n";

exit 0;

----------------

The config file:

----------------
#
# rotatebgpdump config
#

prompt = somecore.somedomain
host = 127.0.0.1
password = c
enable = c
----------------

-- 
pi at opsec.eu            +49 171 3101372                         7 years to go !



More information about the Quagga-users mailing list