HPE EVA Storage
1752426 Members
5679 Online
108788 Solutions
New Discussion юеВ

Brocade Scripting of commands

 
SOLVED
Go to solution
Kites BM
Regular Advisor

Brocade Scripting of commands

I wish to run few commands to perform Daily Health checks and this I need to do on some 30 switches ( different models and switch types). Few switches have CLI while other few have GUI and both.

Any way by means of which I can trigger executing my set of commands and try sending any alerts(warnings or errors on each switch) noted to my email Id.

Cheers,
BMK
13 REPLIES 13
Prokopets
Respected Contributor

Re: Brocade Scripting of commands

No ideal, but as workaround will work: expect+ssh+crond on some unix\linux server.
Kites BM
Regular Advisor

Re: Brocade Scripting of commands

crond?

can you pls give me an example if possible?

Kites
Bharath_Pingali
Trusted Contributor

Re: Brocade Scripting of commands

Which switch brands are in use?

There are some Fabric management software that should be able to do that.

-Thank You
Bharath
Prokopets
Respected Contributor

Re: Brocade Scripting of commands

Kites, i think that it would be better to divide your task by two:
1) Switch-side scripting: it can be done with expect
2) Alerts: you can get them via snmp.

1) Your expect script can look like this one (a have no brocade by hand for test but i'm pretty sure that it will work):

#!/usr/bin/expect -f
spawn ssh 1.2.3.4 -l admin
log_user 1
match_max 100000
expect "?*login*"
send -- "admin\r"
expect "password:"
send -- "password\r"
send -- "\r"
send -- "switchshow\r"
expect eof

This script will show you output of switchshow command then you can parse it by grep, for example. If you don't want to have a headache with expect, i recommend you to use autoexpect (http://expect.nist.gov/doc/autoexpect.pdf) - it "records" your activity and writes a script by itself, so you can just put in in crontab.

2) As for snmp - it's quite simple, you should just find OID in Brocade's MIB (you can download it from switches support page) and configure snmptrapd.conf to receive traps from switch.
Kites BM
Regular Advisor

Re: Brocade Scripting of commands


Sorry for this late reply.

We have connectivity to switches by ssh and snmp already configured.

I want to know how do I have to schedule connectivity to these switches and send the o/p of commands to my email id.

Cheers,
Kites BM
Prokopets
Respected Contributor

Re: Brocade Scripting of commands

Kites, your approximate plan can look like this:

1) write script using expect (or autoexpect)
2) write another script which executes first one, redirects it's output to temporary file and mails it (it will look like this: cat output_file.log | mail -s 'Subject' mail@domain.com)
3) edit crontab file (depending you unix\linux version syntax may me little different, but "man cron" helps you) and place there your second script there

Well... At least, this way is simple :)
Kites BM
Regular Advisor

Re: Brocade Scripting of commands


Thanks,

I would really love to follow those 3 steps above,but its on win OS that we have ssh (putty)connectivity to those switches.

Any way to get it done on Win OS??

Kites
Prokopets
Respected Contributor

Re: Brocade Scripting of commands

Windows?!
Well... There's at least two ways to upgrade this three steps with step 0)
- install cygwin (http://www.cygwin.com/) on your windows PC.
- use coLinux (http://www.colinux.org/)

Actually, both this ways are little pervert and in theory you can try to use WSH, but in this case i cannot give you any advise as i have nearly no experience with it and i'm not sure that putty can redirect it's output. Anyway, you can at least look at WSH (http://msdn.microsoft.com/en-us/library/9bbdkx3k%28VS.85%29.aspx) until you'll begin to do something with cygwin or colinux.
Kites BM
Regular Advisor

Re: Brocade Scripting of commands


Well, sorry for the late reply.

further to make it happen I tried my bit of efforts ( didn't find time for this long)

>I installed putty.exe on windows server
>I created batch file and scheduled it to run daily at once

The contents of the batch file are

" putty.exe -ssh -v username@hostname -pw -m D:\commands.dat"

>I put my set of switch-commands to be run in commands.dat file on location D:

All is well ....I now want to well organize and capture the output of each command. Send this collected output to a file on D:

Any comments on how I can do this?

Of course, the batch file contents shows the login password - which I believe can be encrypted.

Thanks,
Kites