Discussion:
[rancid] Newbie Question...sorry!
Munroe, James (DSS/MAS)
2007-10-15 10:17:42 UTC
Permalink
Hello,

Could someone please tell me if there is a way to add a variable to a command file for processing with nlogin? For example I want to issue the following command on 170 simliar devices: "get event > tftp 192.168.1.1 <ROUTERNAME>.log" The <ROUTERNAME> needs to be unique for each device. I don't care if it's the device's IP or hostname or whatever...as long as it is unique. Hostname or IP would be nice though :-)

Also when using nlogin or clogin what's the easiest way to specify a large number of remote devices? I've got like 380+ firewalls and routers that I'd like to issue a nlogin/clogin against. I know the command line gives you the option to list each deviceon the same command line...but I was looking for something a little more manageable. I'd eventually like to automate this...or script it.

Any help or tips would be greatly appreciated!!!

Thanks!

Jim
Shawn Morris
2007-10-15 14:12:41 UTC
Permalink
James, in the past when I've needed to do something like this I've
just written a little shell script and had that pass the router name
to the xlogin command. Also you can then just read the list of
routers from a text file, database, etc.
Post by Munroe, James (DSS/MAS)
Hello,
Could someone please tell me if there is a way to add a variable to a command file for processing with nlogin? For example I want to issue the following command on 170 simliar devices: "get event > tftp 192.168.1.1 <ROUTERNAME>.log" The <ROUTERNAME> needs to be unique for each device. I don't care if it's the device's IP or hostname or whatever...as long as it is unique. Hostname or IP would be nice though :-)
Also when using nlogin or clogin what's the easiest way to specify a large number of remote devices? I've got like 380+ firewalls and routers that I'd like to issue a nlogin/clogin against. I know the command line gives you the option to list each deviceon the same command line...but I was looking for something a little more manageable. I'd eventually like to automate this...or script it.
Any help or tips would be greatly appreciated!!!
Thanks!
Jim
_______________________________________________
Rancid-discuss mailing list
http://www.shrubbery.net/mailman/listinfo.cgi/rancid-discuss
--
Shawn Morris
IP Development - NTT America
***@smorris.com/***@ntt.net/***@us.ntt.net
v: +1 214 915 1361 f: +1 815 327 3016
john heasley
2007-10-15 17:40:27 UTC
Permalink
Post by Munroe, James (DSS/MAS)
Could someone please tell me if there is a way to add a variable to a command file for processing with nlogin? For example I want to issue the following command on 170 simliar devices: "get event > tftp 192.168.1.1 <ROUTERNAME>.log" The <ROUTERNAME> needs to be unique for each device. I don't care if it's the device's IP or hostname or whatever...as long as it is unique. Hostname or IP would be nice though :-)
as shawn suggested, process one device at a time and wrap it in a shell script
which passes -E to the script and use -s with your own script OR use -c
instead of -E=.
Post by Munroe, James (DSS/MAS)
Also when using nlogin or clogin what's the easiest way to specify a large number of remote devices? I've got like 380+ firewalls and routers that I'd like to issue a nlogin/clogin against. I know the command line gives you the option to list each deviceon the same command line...but I was looking for something a little more manageable. I'd eventually like to automate this...or script it.
xargs(1)
Chris Stave
2007-10-15 15:57:35 UTC
Permalink
I've made a script to call clogin, our devices are numbered fairly
sequentially, from 10.0.0.1 to 10.0.0.86 with cluster members getting
10.0.1.x and 10.0.2.x , etc...
I put whatever commands I want to run into cmds.txt and then make sure that
the switches I want those commands run on are represented in the script. A
slight change to this would be to put the actual command you want to run in
in place of the cmds.txt, which would make it easy to specify the ip address
as a filename for the log.

This obviously works better if your devices are all similarly numbered.

I've appended the script, but do note that it won't work for you without
changes, but just as an example of how I did it. I suspect that there is a
cleaner way to do the conditional statements, but this way worked for me.
(As a bonus, is there an easy way to avoid the repeated "-o $i =" in the
script below?)

******************************
************************************************************
for (( i = 1; i <= 86; i++ ))
do
/home/rancid/bin/clogin -x /home/rancid/cmds.txt 10.0.0.$i
if [ $i = 6 -o $i = 12 -o $i = 13 -o $i = 14 -o $i = 16 -o $i = 19 -o $i =
23 -o
$i = 27 -o $i = 30 -o $i = 32 -o $i = 37 -o $i = 44 -o $i = 45 -o $i = 46
-o $i
= 48 -o $i = 49 -o $i = 52 -o $i = 53 -o $i = 55 -o $i = 56 -o $i = 57 -o
$i =
58 -o $i = 59 -o $i = 60 -o $i = 61 -o $i = 64 -o $i = 65 -o $i = 70 -o $i =
71
-o $i = 81 -o $i = 72 -o $i = 73 -o $i = 77 -o $i = 82 -o $i = 83 -o $i = 84
-o
$i = 85 -o $i = 86 ]; then
/home/rancid/bin/clogin -x /home/rancid/cmds.txt 10.0.1.$i
fi
if [ $i = 6 -o $i = 12 -o $i = 14 -o $i = 23 -o $i = 37 -o $i = 44 -o $i =
45 -o
$i = 52 -o $i = 53 -o $i = 57 -o $i = 61 -o $i = 64 -o $i = 72 -o $i = 73
-o $i
= 77 -o $i = 83 -o $i = 86 ]; then
/home/rancid/bin/clogin -x /home/rancid/cmds.txt 10.0.2.$i
fi
if [ $i = 6 -o $i = 12 -o $i = 37 -o $i = 53 -o $i = 57 -o $i = 61 -o $i=64
]; t
hen
/home/rancid/bin/clogin -x /home/rancid/cmds.txt 10.0.3.$i
fi
done

*******************************************************************************************************8

good luck with it!
Post by Munroe, James (DSS/MAS)
Hello,
Could someone please tell me if there is a way to add a variable to a
command file for processing with nlogin? For example I want to issue the
following command on 170 simliar devices: "get event > tftp 192.168.1.1<ROUTERNAME>.log" The <ROUTERNAME> needs to be unique for each device. I
don't care if it's the device's IP or hostname or whatever...as long as it
is unique. Hostname or IP would be nice though :-)
Also when using nlogin or clogin what's the easiest way to specify a large
number of remote devices? I've got like 380+ firewalls and routers that I'd
like to issue a nlogin/clogin against. I know the command line gives you
the option to list each deviceon the same command line...but I was looking
for something a little more manageable. I'd eventually like to automate
this...or script it.
Any help or tips would be greatly appreciated!!!
Thanks!
Jim
_______________________________________________
Rancid-discuss mailing list
http://www.shrubbery.net/mailman/listinfo.cgi/rancid-discuss
Mike Ashcraft
2007-10-15 23:52:27 UTC
Permalink
As John H already mentioned, xargs(1) is your friend here.

Start with a text file listing your devices, one per line. If you don't
have this already try cut(1) on your router.db file.

I'll provide a few examples.

Run the commands in cmds.txt on the devices listed in devices.txt:

cat devices.txt | xargs clogin -x cmds.txt

If the commands need to include the device name as James requested,
create a custom script that runs the right command when passed the
devicename. Then pass this script the devices in the list one at a
time:

cat devices.txt | xargs -n1 customscript.sh

Mike

________________________________

From: rancid-discuss-***@shrubbery.net
[mailto:rancid-discuss-***@shrubbery.net] On Behalf Of Chris Stave
Sent: Monday, October 15, 2007 9:58 AM
To: Munroe, James (DSS/MAS)
Cc: rancid-***@shrubbery.net
Subject: [rancid] Re: Newbie Question...sorry!


I've made a script to call clogin, our devices are numbered fairly
sequentially, from 10.0.0.1 <http://10.0.0.1/> to 10.0.0.86
<http://10.0.0.86/> with cluster members getting 10.0.1.x and 10.0.2.x
, etc...
I put whatever commands I want to run into cmds.txt and then make sure
that the switches I want those commands run on are represented in the
script. A slight change to this would be to put the actual command you
want to run in in place of the cmds.txt, which would make it easy to
specify the ip address as a filename for the log.

This obviously works better if your devices are all similarly numbered.

I've appended the script, but do note that it won't work for you without
changes, but just as an example of how I did it. I suspect that there
is a cleaner way to do the conditional statements, but this way worked
for me. (As a bonus, is there an easy way to avoid the repeated "-o $i
=" in the script below?)

******************************
************************************************************
for (( i = 1; i <= 86; i++ ))
do
/home/rancid/bin/clogin -x /home/rancid/cmds.txt 10.0.0.$i
if [ $i = 6 -o $i = 12 -o $i = 13 -o $i = 14 -o $i = 16 -o $i = 19 -o $i
= 23 -o
$i = 27 -o $i = 30 -o $i = 32 -o $i = 37 -o $i = 44 -o $i = 45 -o $i =
46 -o $i
= 48 -o $i = 49 -o $i = 52 -o $i = 53 -o $i = 55 -o $i = 56 -o $i = 57
-o $i =
58 -o $i = 59 -o $i = 60 -o $i = 61 -o $i = 64 -o $i = 65 -o $i = 70 -o
$i = 71
-o $i = 81 -o $i = 72 -o $i = 73 -o $i = 77 -o $i = 82 -o $i = 83 -o $i
= 84 -o
$i = 85 -o $i = 86 ]; then
/home/rancid/bin/clogin -x /home/rancid/cmds.txt 10.0.1.$i
fi
if [ $i = 6 -o $i = 12 -o $i = 14 -o $i = 23 -o $i = 37 -o $i = 44 -o $i
= 45 -o
$i = 52 -o $i = 53 -o $i = 57 -o $i = 61 -o $i = 64 -o $i = 72 -o $i =
73 -o $i
= 77 -o $i = 83 -o $i = 86 ]; then
/home/rancid/bin/clogin -x /home/rancid/cmds.txt 10.0.2.$i
fi
if [ $i = 6 -o $i = 12 -o $i = 37 -o $i = 53 -o $i = 57 -o $i = 61 -o
$i=64 ]; t
hen
/home/rancid/bin/clogin -x /home/rancid/cmds.txt 10.0.3.$i
fi
done

************************************************************************
*******************************8

good luck with it!


On 10/15/07, Munroe, James (DSS/MAS) <***@gnb.ca> wrote:

Hello,

Could someone please tell me if there is a way to add a variable
to a command file for processing with nlogin? For example I want to
issue the following command on 170 simliar devices: "get event > tftp
192.168.1.1 <ROUTERNAME>.log" The <ROUTERNAME> needs to be unique for
each device. I don't care if it's the device's IP or hostname or
whatever...as long as it is unique. Hostname or IP would be nice though
:-)

Also when using nlogin or clogin what's the easiest way to
specify a large number of remote devices? I've got like 380+ firewalls
and routers that I'd like to issue a nlogin/clogin against. I know the
command line gives you the option to list each deviceon the same command
line...but I was looking for something a little more manageable. I'd
eventually like to automate this...or script it.

Any help or tips would be greatly appreciated!!!

Thanks!

Jim
_______________________________________________
Rancid-discuss mailing list
Rancid-***@shrubbery.net
http://www.shrubbery.net/mailman/listinfo.cgi/rancid-discuss

Allen Tsang
2007-10-15 19:05:38 UTC
Permalink
zomg lulz! holy moly i-can-see-forever-levels of phail, this reminds me
of the hijinks that the eventual biz-tech refugees pulled on a daily
basis in CS111 ^^;;;;

Sorry, I'm being mean.... please do a 'man router.db'. most of the
answers to your questions lie there; you specify plenty of conditions
for your routers and will get a nice filtered amount of logging
information via email. it's the whole point of rancid!

OTOH, I see that you're just surfing on the back of the expect script to
run a custom command.... I'll tell you how, but holy moly please learn
to properly write proper bash scripts!!!... (e.g. use a real list, dude,
that's the most ugly if statement I've seen in years and years and years):

LIST="6 12 14 16 19 23"
for element in $LIST do
LOGGING=10.0.0.$element
clogin -x /home/rancid/cmds.txt 10.0.0.$element
done

Use the "LOGGING" environmental variable in your custom clogin script to
output wherever you want your output to be.

repeat if you so desire, for ips in other ranges. And please learn to
script properly! :D

- allen tsang
Post by Chris Stave
I've made a script to call clogin, our devices are numbered fairly
sequentially, from 10.0.0.1 <http://10.0.0.1/> to 10.0.0.86
<http://10.0.0.86/> with cluster members getting 10.0.1.x and 10.0.2.x ,
etc...
I put whatever commands I want to run into cmds.txt and then make sure
that the switches I want those commands run on are represented in the
script. A slight change to this would be to put the actual command you
want to run in in place of the cmds.txt, which would make it easy to
specify the ip address as a filename for the log.
This obviously works better if your devices are all similarly numbered.
I've appended the script, but do note that it won't work for you without
changes, but just as an example of how I did it. I suspect that there
is a cleaner way to do the conditional statements, but this way worked
for me. (As a bonus, is there an easy way to avoid the repeated "-o $i
=" in the script below?)
******************************
************************************************************
for (( i = 1; i <= 86; i++ ))
do
/home/rancid/bin/clogin -x /home/rancid/cmds.txt 10.0.0.$i
if [ $i = 6 -o $i = 12 -o $i = 13 -o $i = 14 -o $i = 16 -o $i = 19 -o $i
= 23 -o
$i = 27 -o $i = 30 -o $i = 32 -o $i = 37 -o $i = 44 -o $i = 45 -o $i =
46 -o $i
= 48 -o $i = 49 -o $i = 52 -o $i = 53 -o $i = 55 -o $i = 56 -o $i = 57
-o $i =
58 -o $i = 59 -o $i = 60 -o $i = 61 -o $i = 64 -o $i = 65 -o $i = 70 -o
$i = 71
-o $i = 81 -o $i = 72 -o $i = 73 -o $i = 77 -o $i = 82 -o $i = 83 -o $i
= 84 -o
$i = 85 -o $i = 86 ]; then
/home/rancid/bin/clogin -x /home/rancid/cmds.txt 10.0.1.$i
fi
if [ $i = 6 -o $i = 12 -o $i = 14 -o $i = 23 -o $i = 37 -o $i = 44 -o $i
= 45 -o
$i = 52 -o $i = 53 -o $i = 57 -o $i = 61 -o $i = 64 -o $i = 72 -o $i =
73 -o $i
= 77 -o $i = 83 -o $i = 86 ]; then
/home/rancid/bin/clogin -x /home/rancid/cmds.txt 10.0.2.$i
fi
if [ $i = 6 -o $i = 12 -o $i = 37 -o $i = 53 -o $i = 57 -o $i = 61 -o
$i=64 ]; t
hen
/home/rancid/bin/clogin -x /home/rancid/cmds.txt 10.0.3.$i
fi
done
*******************************************************************************************************8
good luck with it!
Hello,
Could someone please tell me if there is a way to add a variable to
a command file for processing with nlogin? For example I want to
issue the following command on 170 simliar devices: "get event >
tftp 192.168.1.1 <http://192.168.1.1> <ROUTERNAME>.log" The
<ROUTERNAME> needs to be unique for each device. I don't care if
it's the device's IP or hostname or whatever...as long as it is
unique. Hostname or IP would be nice though :-)
Also when using nlogin or clogin what's the easiest way to specify a
large number of remote devices? I've got like 380+ firewalls and
routers that I'd like to issue a nlogin/clogin against. I know the
command line gives you the option to list each deviceon the same
command line...but I was looking for something a little more
manageable. I'd eventually like to automate this...or script it.
Any help or tips would be greatly appreciated!!!
Thanks!
Jim
_______________________________________________
Rancid-discuss mailing list
http://www.shrubbery.net/mailman/listinfo.cgi/rancid-discuss
------------------------------------------------------------------------
_______________________________________________
Rancid-discuss mailing list
http://www.shrubbery.net/mailman/listinfo.cgi/rancid-discuss
Loading...