Script for suck Cisco 3640

Do u have Cisco Router 3640 ? has experience interface ethernet hangs suddenly, no arp of neighborhood computer, can’t ping to another host, just one solution to resolve : RELOAD !!

If you have this Cisco router 3640 and this in production environment, and have above problem. You will never go sleep well.
Here I make perl script to do reload of router. And then This script scheduled in cron tab.
My problem case and flow chart of my program like following,
My script check by login to router, first check is typing command “show ip bgp summary”,and then checking status BGP of router. If status BGP is “Active”, so we checked to ping ip address of bgp router peer. If success rate is 0 percent, we face the real problem, so doing “reload” command. Otherwise, logout.

Good night, have a nice dream…..

#!/usr/bin/perl
use Net::Telnet ();
$t = new Net::Telnet(Prompt=>’/sindoro/’,Timeout=>15);
$t->open(”202.169.xxx.yyy”);
$t->waitfor(’/Username: $/’) || die “Didnot get username”;
$t->print(”johan”);
$t->waitfor(’/Password: $/’) || die “Did not get password”; $t->print(’put_your_password_telnet_here’);
$t->waitfor(’/sindoro/’) || die “didnot get prompt”;
$t->print(’ena’);
$t->waitfor(’/Password: $/’) || die “Did not get password”;
$t->print(’put_passwd_enable_here’);
$t->waitfor(’/sindoro/’) || die “didnot get prompt”;
@status_openixp=$t->cmd(”show ip bgp summary | in 218.100.xxx.yyy”);
print @status_openixp; ($tmp,$tmp2,$tmp3,$tmp4,$tmp5,$tmp6,$tmp7,$tmp8,$updown,$state)=split(/\s+/,$status_openixp[0]);
print “Uptime BGP: “.$updown.” “.$state.” prefix”;
if ($state =~ /Active/)
{ print “BGP is active”;
@ping_status=$t->cmd(”ping 218.100.xxx.yyy”);
# print @ping_status;
($tmp,$tmp2,$tmp3,$rate,$tmp4)=split(/\s+/,$ping_status[4]);
print “Ping rate: “.$rate.” percent” ;
if ($rate == “0″)
{ $t->print(’reload’);
$t->waitfor(’/confirm/’) || die “gak dapet confirm”;
$t->print(’y’);
}
$t->cmd(’end’);
$t->cmd(’logout’);
}

Thank’s to johan

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s

%d blogger menyukai ini: