Discussion:
[rancid] Searching for Half-duplex Interfaces
Pabon, Nestor
2008-01-11 20:31:47 UTC
Permalink
First of all I want to thank the developers for such a great tool.



I need to discover in a network of 200+ routers, which ones have
FastEthernet interfaces; either 0/0 or 0/1 set to "Half-duplex".



Can someone help me script this query?



My objective is to investigate why they are set to Half-duplex, and then
change them to full or hard code them where appropriate.



Regards,

Nestor
Lance
2008-01-11 20:56:24 UTC
Permalink
use clogin and do a sho int for each interface. the look for half
somewhere in the output of the show interface.
-------- Original Message --------
Subject: [rancid] Searching for Half-duplex Interfaces
Date: Fri, January 11, 2008 1:31 pm
First of all I want to thank the developers for such a great tool.
I need to discover in a network of 200+ routers, which ones have
FastEthernet interfaces; either 0/0 or 0/1 set to "Half-duplex".
Can someone help me script this query?
My objective is to investigate why they are set to Half-duplex, and then
change them to full or hard code them where appropriate.
Regards,
Nestor<hr>_______________________________________________
Rancid-discuss mailing list
http://www.shrubbery.net/mailman/listinfo.cgi/rancid-discuss
Pabon, Nestor
2008-01-11 21:33:32 UTC
Permalink
I'm not sure I conveyed my goal correctly.

If I use clogin or log directly into the router I know I can query
issuing the following:

"sh interface | i Half-duplex"

But this will only return something like:

"Half-duplex, 10Mb/s, 100BaseTX/FX"

I rather do a:

"show int"

And have the output go to a file named

"show-duplex"

And then somehow get a report which will give the device name which had
an interface set to Half-duplex".

Hope this helps.

Regards,
Nestor

-----Original Message-----
From: Lance [mailto:***@gheek.net]
Sent: Friday, January 11, 2008 1:56 PM
To: Pabon, Nestor
Cc: rancid-***@shrubbery.net
Subject: RE: [rancid] Searching for Half-duplex Interfaces

use clogin and do a sho int for each interface. the look for half
somewhere in the output of the show interface.
-------- Original Message --------
Subject: [rancid] Searching for Half-duplex Interfaces
Date: Fri, January 11, 2008 1:31 pm
First of all I want to thank the developers for such a great tool.
I need to discover in a network of 200+ routers, which ones have
FastEthernet interfaces; either 0/0 or 0/1 set to "Half-duplex".
Can someone help me script this query?
My objective is to investigate why they are set to Half-duplex, and then
change them to full or hard code them where appropriate.
Regards,
Nestor<hr>_______________________________________________
Rancid-discuss mailing list
http://www.shrubbery.net/mailman/listinfo.cgi/rancid-discuss
Ed Ravin
2008-01-11 22:29:16 UTC
Permalink
Post by Pabon, Nestor
I'm not sure I conveyed my goal correctly.
If I use clogin or log directly into the router I know I can query
"sh interface | i Half-duplex"
"Half-duplex, 10Mb/s, 100BaseTX/FX"
But if you followed John's instructions (repeated below, with slight edits
for clarity), you would get something much better than that. Note the
regexp which will match things like:

FastEthernet0/0/0 is up, line protocol is up

So you'll see the interface names, and then their duplex settings if
they are Ethernet-based.

--------

for rtr in ...list...
do
clogin -c 'show interfaces | inc (line protocol|duplex|speed)' $rtr >>output.file 2>&1
done
Pabon, Nestor
2008-01-11 23:19:42 UTC
Permalink
So the list of routers is in:

/opt/rancid/data/mpls-routers

Does this mean that

"for rtr in ...list..."

Becomes

"for rtr in /opt/rancid/data/mpls-routers/router.db"

Regards,
Nestor



-----Original Message-----
From: Ed Ravin [mailto:***@panix.com]
Sent: Friday, January 11, 2008 3:29 PM
To: Pabon, Nestor
Cc: rancid-***@shrubbery.net
Subject: Re: [rancid] Re: Searching for Half-duplex Interfaces
Post by Pabon, Nestor
I'm not sure I conveyed my goal correctly.
If I use clogin or log directly into the router I know I can query
"sh interface | i Half-duplex"
"Half-duplex, 10Mb/s, 100BaseTX/FX"
But if you followed John's instructions (repeated below, with slight
edits
for clarity), you would get something much better than that. Note the
regexp which will match things like:

FastEthernet0/0/0 is up, line protocol is up

So you'll see the interface names, and then their duplex settings if
they are Ethernet-based.

--------

for rtr in ...list...
do
clogin -c 'show interfaces | inc (line protocol|duplex|speed)'
$rtr >>output.file 2>&1
done
Mike Ashcraft
2008-01-11 23:28:21 UTC
Permalink
Close. You need to trim the data in router.db

for rtr in $(cat router.db | cut -d: -f1); do clogin $rtr ... ; done


Mike



-----Original Message-----
From: rancid-discuss-***@shrubbery.net
[mailto:rancid-discuss-***@shrubbery.net] On Behalf Of Pabon, Nestor
Sent: Friday, January 11, 2008 4:20 PM
To: Ed Ravin
Cc: rancid-***@shrubbery.net
Subject: [rancid] Re: Searching for Half-duplex Interfaces

So the list of routers is in:

/opt/rancid/data/mpls-routers

Does this mean that

"for rtr in ...list..."

Becomes

"for rtr in /opt/rancid/data/mpls-routers/router.db"

Regards,
Nestor



-----Original Message-----
From: Ed Ravin [mailto:***@panix.com]
Sent: Friday, January 11, 2008 3:29 PM
To: Pabon, Nestor
Cc: rancid-***@shrubbery.net
Subject: Re: [rancid] Re: Searching for Half-duplex Interfaces
Post by Pabon, Nestor
I'm not sure I conveyed my goal correctly.
If I use clogin or log directly into the router I know I can query
"sh interface | i Half-duplex"
"Half-duplex, 10Mb/s, 100BaseTX/FX"
But if you followed John's instructions (repeated below, with slight
edits
for clarity), you would get something much better than that. Note the
regexp which will match things like:

FastEthernet0/0/0 is up, line protocol is up

So you'll see the interface names, and then their duplex settings if
they are Ethernet-based.

--------

for rtr in ...list...
do
clogin -c 'show interfaces | inc (line protocol|duplex|speed)'
$rtr >>output.file 2>&1
done
Chris Moody
2008-01-11 23:42:44 UTC
Permalink
You can use the shell routine I gave you.

./rancid-config-apply.sh

Put the commands you want to issue to the device into the location
defined in the COMMANDSFILEPATH variable...and then just answer the prompts.

ex>
***@fittipaldi ~ $ cat command-scripts/interface-duplex
show interfaces | inc (line protocol|duplex|speed)

#####
***@fittipaldi ~ $ ./scripts/bash/rancid-config-apply.sh
=====[ Rancid Config Apply Script ]=====

Please enter the nodegroup:
mpls-routers
Please enter name of commands-file:
interface-duplex
...
#####

and the routine will take off from there...only logging into devices
that are flagged as "up" in rancid.

Cheers,
-Chris
Post by Pabon, Nestor
/opt/rancid/data/mpls-routers
Does this mean that
"for rtr in ...list..."
Becomes
"for rtr in /opt/rancid/data/mpls-routers/router.db"
Regards,
Nestor
-----Original Message-----
Sent: Friday, January 11, 2008 3:29 PM
To: Pabon, Nestor
Subject: Re: [rancid] Re: Searching for Half-duplex Interfaces
Post by Pabon, Nestor
I'm not sure I conveyed my goal correctly.
If I use clogin or log directly into the router I know I can query
"sh interface | i Half-duplex"
"Half-duplex, 10Mb/s, 100BaseTX/FX"
But if you followed John's instructions (repeated below, with slight edits
for clarity), you would get something much better than that. Note the
FastEthernet0/0/0 is up, line protocol is up
So you'll see the interface names, and then their duplex settings if
they are Ethernet-based.
--------
for rtr in ...list...
do
clogin -c 'show interfaces | inc (line protocol|duplex|speed)'
$rtr >>output.file 2>&1
done
_______________________________________________
Rancid-discuss mailing list
http://www.shrubbery.net/mailman/listinfo.cgi/rancid-discuss
Pabon, Nestor
2008-01-11 23:51:39 UTC
Permalink
Hi Chris;

I'm trying to incorporate your script, and it is working. The part I'm
lost in is how end up with a file containing the output.

Regards,
Nestor

-----Original Message-----
From: Chris Moody [mailto:***@qualcomm.com]
Sent: Friday, January 11, 2008 4:43 PM
To: Pabon, Nestor
Cc: Ed Ravin; rancid-***@shrubbery.net
Subject: Re: [rancid] Re: Searching for Half-duplex Interfaces

You can use the shell routine I gave you.

./rancid-config-apply.sh

Put the commands you want to issue to the device into the location
defined in the COMMANDSFILEPATH variable...and then just answer the
prompts.

ex>
***@fittipaldi ~ $ cat command-scripts/interface-duplex
show interfaces | inc (line protocol|duplex|speed)

#####
***@fittipaldi ~ $ ./scripts/bash/rancid-config-apply.sh
=====[ Rancid Config Apply Script ]=====

Please enter the nodegroup:
mpls-routers
Please enter name of commands-file:
interface-duplex
...
#####

and the routine will take off from there...only logging into devices
that are flagged as "up" in rancid.

Cheers,
-Chris
Post by Pabon, Nestor
/opt/rancid/data/mpls-routers
Does this mean that
"for rtr in ...list..."
Becomes
"for rtr in /opt/rancid/data/mpls-routers/router.db"
Regards,
Nestor
-----Original Message-----
Sent: Friday, January 11, 2008 3:29 PM
To: Pabon, Nestor
Subject: Re: [rancid] Re: Searching for Half-duplex Interfaces
Post by Pabon, Nestor
I'm not sure I conveyed my goal correctly.
If I use clogin or log directly into the router I know I can query
"sh interface | i Half-duplex"
"Half-duplex, 10Mb/s, 100BaseTX/FX"
But if you followed John's instructions (repeated below, with slight edits
for clarity), you would get something much better than that. Note the
FastEthernet0/0/0 is up, line protocol is up
So you'll see the interface names, and then their duplex settings if
they are Ethernet-based.
--------
for rtr in ...list...
do
clogin -c 'show interfaces | inc (line protocol|duplex|speed)'
$rtr >>output.file 2>&1
done
_______________________________________________
Rancid-discuss mailing list
http://www.shrubbery.net/mailman/listinfo.cgi/rancid-discuss
Chris Moody
2008-01-11 23:57:23 UTC
Permalink
Bash shell scripting 101. [ http://tldp.org/LDP/abs/html/ ]
Edit 3 lines of the code.

Insert this after the "read COMMANDSFILE" line:
---
echo "Please enter the name of the file you want to store this data in:"
read OUTPUTFILE
---



and then edit this line:
---
$CLOGINPATH -f $CREDENTIALS -x $COMMANDSFILEPATH/$COMMANDSFILE $i
---

to look like this:
---
$CLOGINPATH -f $CREDENTIALS -x $COMMANDSFILEPATH/$COMMANDSFILE $i >>
$OUTPUTFILE
---

For anyone else wondering what I'm referring to, I wrote a shell wrapper
routine for Nestor a few weeks back. It's only like a 30-second quick
rough draft...

[ http://www.siliconhotrod.com/files/rancid-config-apply.sh ]

Cheers,
-Chris
Post by Pabon, Nestor
Hi Chris;
I'm trying to incorporate your script, and it is working. The part I'm
lost in is how end up with a file containing the output.
Regards,
Nestor
-----Original Message-----
Sent: Friday, January 11, 2008 4:43 PM
To: Pabon, Nestor
Subject: Re: [rancid] Re: Searching for Half-duplex Interfaces
You can use the shell routine I gave you.
./rancid-config-apply.sh
Put the commands you want to issue to the device into the location
defined in the COMMANDSFILEPATH variable...and then just answer the prompts.
ex>
show interfaces | inc (line protocol|duplex|speed)
#####
=====[ Rancid Config Apply Script ]=====
mpls-routers
interface-duplex
...
#####
and the routine will take off from there...only logging into devices
that are flagged as "up" in rancid.
Cheers,
-Chris
Post by Pabon, Nestor
/opt/rancid/data/mpls-routers
Does this mean that
"for rtr in ...list..."
Becomes
"for rtr in /opt/rancid/data/mpls-routers/router.db"
Regards,
Nestor
-----Original Message-----
Sent: Friday, January 11, 2008 3:29 PM
To: Pabon, Nestor
Subject: Re: [rancid] Re: Searching for Half-duplex Interfaces
Post by Pabon, Nestor
I'm not sure I conveyed my goal correctly.
If I use clogin or log directly into the router I know I can query
"sh interface | i Half-duplex"
"Half-duplex, 10Mb/s, 100BaseTX/FX"
But if you followed John's instructions (repeated below, with slight edits
for clarity), you would get something much better than that. Note the
FastEthernet0/0/0 is up, line protocol is up
So you'll see the interface names, and then their duplex settings if
they are Ethernet-based.
--------
for rtr in ...list...
do
clogin -c 'show interfaces | inc (line protocol|duplex|speed)'
$rtr >>output.file 2>&1
done
_______________________________________________
Rancid-discuss mailing list
http://www.shrubbery.net/mailman/listinfo.cgi/rancid-discuss
Pabon, Nestor
2008-01-12 00:37:52 UTC
Permalink
Worked like a charm.

Thank you.

Regards,
Nestor



-----Original Message-----
From: Chris Moody [mailto:***@qualcomm.com]
Sent: Friday, January 11, 2008 4:57 PM
To: Pabon, Nestor
Cc: Ed Ravin; rancid-***@shrubbery.net
Subject: Re: [rancid] Re: Searching for Half-duplex Interfaces

Bash shell scripting 101. [ http://tldp.org/LDP/abs/html/ ]
Edit 3 lines of the code.

Insert this after the "read COMMANDSFILE" line:
---
echo "Please enter the name of the file you want to store this data in:"
read OUTPUTFILE
---



and then edit this line:
---
$CLOGINPATH -f $CREDENTIALS -x $COMMANDSFILEPATH/$COMMANDSFILE $i
---

to look like this:
---
$CLOGINPATH -f $CREDENTIALS -x $COMMANDSFILEPATH/$COMMANDSFILE $i >>
$OUTPUTFILE
---

For anyone else wondering what I'm referring to, I wrote a shell wrapper

routine for Nestor a few weeks back. It's only like a 30-second quick
rough draft...

[ http://www.siliconhotrod.com/files/rancid-config-apply.sh ]

Cheers,
-Chris
Post by Pabon, Nestor
Hi Chris;
I'm trying to incorporate your script, and it is working. The part I'm
lost in is how end up with a file containing the output.
Regards,
Nestor
-----Original Message-----
Sent: Friday, January 11, 2008 4:43 PM
To: Pabon, Nestor
Subject: Re: [rancid] Re: Searching for Half-duplex Interfaces
You can use the shell routine I gave you.
./rancid-config-apply.sh
Put the commands you want to issue to the device into the location
defined in the COMMANDSFILEPATH variable...and then just answer the prompts.
ex>
show interfaces | inc (line protocol|duplex|speed)
#####
=====[ Rancid Config Apply Script ]=====
mpls-routers
interface-duplex
...
#####
and the routine will take off from there...only logging into devices
that are flagged as "up" in rancid.
Cheers,
-Chris
Post by Pabon, Nestor
/opt/rancid/data/mpls-routers
Does this mean that
"for rtr in ...list..."
Becomes
"for rtr in /opt/rancid/data/mpls-routers/router.db"
Regards,
Nestor
-----Original Message-----
Sent: Friday, January 11, 2008 3:29 PM
To: Pabon, Nestor
Subject: Re: [rancid] Re: Searching for Half-duplex Interfaces
Post by Pabon, Nestor
I'm not sure I conveyed my goal correctly.
If I use clogin or log directly into the router I know I can query
"sh interface | i Half-duplex"
"Half-duplex, 10Mb/s, 100BaseTX/FX"
But if you followed John's instructions (repeated below, with slight edits
for clarity), you would get something much better than that. Note the
FastEthernet0/0/0 is up, line protocol is up
So you'll see the interface names, and then their duplex settings if
they are Ethernet-based.
--------
for rtr in ...list...
do
clogin -c 'show interfaces | inc (line protocol|duplex|speed)'
$rtr >>output.file 2>&1
done
_______________________________________________
Rancid-discuss mailing list
http://www.shrubbery.net/mailman/listinfo.cgi/rancid-discuss
john heasley
2008-01-11 21:29:39 UTC
Permalink
Post by Pabon, Nestor
First of all I want to thank the developers for such a great tool.
I need to discover in a network of 200+ routers, which ones have
FastEthernet interfaces; either 0/0 or 0/1 set to "Half-duplex".
Can someone help me script this query?
an snmpwalk of interfaces seems like a better approach. however...

for rtr in ...list...; do
clogin -c 'show interfaces | in (line protocol|duplex|speed)' $rtr \
Post by Pabon, Nestor
output 2>&1
done

or xargs or whatever your fancy. then perl/awk/human/whatever you like to
exclude the uninteresting stuff from the output.
Pabon, Nestor
2008-01-11 22:02:22 UTC
Permalink
This looks interesting.

Got to figure out how to script it.


-----Original Message-----
From: john heasley [mailto:***@shrubbery.net]
Sent: Friday, January 11, 2008 2:30 PM
To: Pabon, Nestor
Cc: rancid-***@shrubbery.net
Subject: Re: [rancid] Searching for Half-duplex Interfaces
Post by Pabon, Nestor
First of all I want to thank the developers for such a great tool.
I need to discover in a network of 200+ routers, which ones have
FastEthernet interfaces; either 0/0 or 0/1 set to "Half-duplex".
Can someone help me script this query?
an snmpwalk of interfaces seems like a better approach. however...

for rtr in ...list...; do
clogin -c 'show interfaces | in (line protocol|duplex|speed)'
$rtr \
Post by Pabon, Nestor
output 2>&1
done

or xargs or whatever your fancy. then perl/awk/human/whatever you like
to
exclude the uninteresting stuff from the output.
Loading...