Tag: Brocade

Brocade SAN switch automated troubleshooting script

What does this Brocade SAN switch automated troubleshooting script do?

  1. Ping the SAN switch IPs and check the connectivity
  2. Perform basic health check by running switchstatusshow command
  3. Check for CRC and EncOut errors by running porterrshow command
  4. If there are CRC and EncOut errors it clears the port statistics and wait for 20 minutes to monitor the incremental errors on the switch ports using portstatsclear and portshow commands
  5. Check and compare Lr_in & Ols_Out and Lr_out and Ols_in values to detect faulty cable and SFP issue
  6. Generate supportsave files which is required to do further analysis or troubleshooting by switch vendor and FTP the files
  7. Capture all the above output to file and generate email alert to further engage an engineer to continue troubleshooting or log a case with switch vendor

I hope this would help us in proactively monitoring SAN switches and iron out false positives without human intervention.

To download the script please click here and select ‘Brocade Troubleshooting’ from the right pane under Topics.


I believe this could be last blog post of the year 2016…

Belated Merry Christmas and Wish you Happy and Prosperous New Year 2017 in advance to all my followers, readers and visitors!!


How to hide your important files from people without making Hidden folders
1. Go to Desktop and create a new folder
2. Name the folder Internet Explorer
3. Change the folder icon to Internet Explorer
4. Keep it in a corner of the desktop

Now, no one will open internet explorer 😀

Source: http://www.coolcoder.in/2014/02/10-awesome-programming-jokes-of-all-time.html


Create multiple user’s account on multiple Brocade SAN Switches

This blog is a continuation of the previous blog in which I discussed about “Deleting User accounts from Brocade SAN switches” as well as shared the script to do the same.

We wanted to automate onboard/off-board process which we follow when a new team member/s join or depart from the project. LDAP cannot be implemented in the Multi-Tenant environment and customer owned infra. So we targeted automation. Automation means scripting, scripting means PERL to me 🙂

Here is the Perl code which would login to all the switches listed in the “switches_ips.txt” file and create all the user accounts listed in the “users.txt” file. Output would be saved in file “Results.txt”.


Sample output:

Creating users on switch IP:
user1- Account user1 has been successfully added.
user2 – Account user2 has been successfully added.
user3 – Account kaanatar has been successfully added.
user4 – Account niravpat has been successfully added.

admin – Named account already exists

If a user account already exists then it wont create the account again.

Simple, isn’t it? Try it out and let me know if you need help on this…

I wish you all Happy Onam and Happy Varamahalaxmi festivals. God bless you all!

Delete user account on multiple Brocade SAN switches

I work in a SAN environment where we manage about 110+ SAN switches of both Brocade and Cisco models. Due to lucrative market we end up having attrition in the team which leads to clean-up of their user accounts as per security standards or policies. I did not mention how we create a new user’s account when they join our team. I’ll share that script sometime later (so keep browsing my blog…),Thanks to Perl script which takes care of it. Using that Perl script we can create multiple user accounts on multiple switches at one go 🙂

Let’s discuss about deleting an user account which took 6+ productive hours to come up with deletion script !!


Since I’m a die-hard fan of Perl, I wanted to do this using Perl but for some reason, Net::SSH2::Expect module did not gel very well with Window$. Brocade CLI expects user to type “YES” for user delete confirmation. So, I had to learn and equip the old is gold “Expect” programming language… After few hours of trial and errors, I’ve finally succeeded with the script to delete user on multiple switches at one go 😀

Here is the script “expect.sh”

#! /bin/expect
set timeout 20
set user [lindex $argv 0]
set password [lindex $argv 1]
set prompt “(%|#|\\$|%\]) $”
;# — main activity
proc dostuff { currentswitch} {

;# do something with currentswitch

send — “userconfig –delete vinay\r”
set fd [open ./swlist.txt r]
set sws [read -nonewline $fd]
close $fd
foreach sw [split $sws”\n” ] {
spawn /usr/bin/ssh $user@$sw
while (1) {
expect {
“no)? ” {
send — “yes\r”
“password: ” {
send — “$password\r”
“>” {
send — “userconfig –delete vinay\ryes\r”
expect “>”
send — “exit\r”
expect eof

I know, hold your breath… Let me try to decode this for you and how to do copy-paste and use this in your setup.

PFB list of things to have, before we run this on management server

1. cygwin – Install cygwin

2. Expect – A good blog on howto install cygwin, Expect and ssh

3. swtlist.txt – A file having IP addresses of SAN switches

Now, copy both expect.sh and swlist.txt to a path e.g. /home/vinay/ [Under C:\ drive look for “cygwin” directory  C:\cygwin\home\<users> if you installed cygwin in C drive]

Launch cygwin and run the command “./expect.sh <username> <password>”

Note: I’ve same username and password across all switches. Hence its friendly to run the scripts. Some of the Brocade firmware versions are not compatible with the command “userconfig –delete <username>”. Please read the manual and replace the command accordingly,

After, you start the script using above command sit back and relax to watch the automation of user deletion!!!

Disclaimer: I’m not responsible for any outages, P1’s, Major Incidents etc by running this script in your setup. Use it with your brains by applying thought (little extra needed here…). Leave a comment if you need help to tweak this script…

Courtesy: iconfinder.com for the image and amsathishkumar.wordpress.com for the blog on cygwin, Expect and ssh installation

Brocade SAN switches port count

We manage more than 100+ SAN switches in our storage infrastructure. Keeping track of port availability, status and count are hectic capacity management tasks. If we need to get this data manually, we need to login to each switch, run commands, grab output, do the math and tabulate values. Storage admin job is not an easy one to do!!

Using PERL script we can simplify these tasks. Below PERL script would help us to get above information in a matter of seconds. This output can be exported to excel for further beatification 🙂

use Net::SSH2;
use POSIX;
use MIME::Lite;
open (INPUT, "emc_switch_ips.txt");
my @ip =< INPUT>;
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
my $datestring = sprintf("%02d_%02d_%02d_%02d_%4d",$hour,$min,($mon+1),$mday,($year + 1900));
open OUTPUT, '+>', "emc_result-$datestring.txt" or die $!;
STDOUT->fdopen( \*OUTPUT, 'w' ) or die $!; # redirecting the STDOUT to file
open (PASS, "pass");
use constant BUFLEN => 10_0000 ;
my $user = "admin";
my $password = ;
my $cmdlet = ("switchshow | grep id");
foreach $switch(@ip){
print "$switch - Total number of ports\n";
my $ssh = Net::SSH2->new();
                print("Connection Failed\n");
                print("Authentication Failed");
my $channel = $ssh->channel();
my $command = $channel->exec("$cmdlet") or die $_;
	my $read = $channel->read($buf, BUFLEN );
	warn 'More than ', BUFLEN, ' characters in listing' if $read >= BUFLEN;
	print $buf;
my @data = split (/\n/,$buf);
for ($i=0;$i<$len;$i++){
#print "@data[$i] \n";
@on[$i] = grep (/Online/,@data[$i]);
@no[$i] = grep (/No_Light/,@data[$i]);
#print "Online: @on[$i] \n";
#print "Offline: @no[$i] \n";

We need to have a text file with SAN switches IP addresses called “emc_switch_ips.txt” also we need to store user password in a file called “pass”. Thats it! go to shell / CMD and execute the file which gives below output.

– Total number of ports
0 0 010000 id N8 No_Light FC
1 1 010100 id N8 No_Light FC
2 2 010200 id N8 No_Light FC
3 3 010300 id N8 No_Light FC
4 4 010400 id N8 No_Light FC
5 5 010500 id N8 No_Light FC
6 6 010600 id N8 No_Light FC
7 7 010700 id N8 No_Light FC
8 8 010800 id N8 No_Light FC (No POD License) Disabled
9 9 010900 id N8 No_Light FC (No POD License) Disabled
10 10 010a00 id N8 No_Light FC (No POD License) Disabled
11 11 010b00 id N8 No_Light FC (No POD License) Disabled
12 12 010c00 id N8 No_Light FC (No POD License) Disabled
13 13 010d00 id N8 No_Light FC (No POD License) Disabled
14 14 010e00 id N8 No_Light FC (No POD License) Disabled
15 15 010f00 id N8 No_Light FC (No POD License) Disabled
On-line Ports= 0
Offline Ports= 16
Total Ports = 16
Overall Total On-line Ports = 0
Overall Total Offline Ports = 16
Overall Total Ports = 16

How to check your Brocade SAN Switch is ready to use for 8 GBps?

Its time to say bye to 1-2-4 GBps and say hi to 8 GBps. So how do you know whether your SAN switch is ready to plugin 8 GBps SFP’s?

Here is the command

slotshow -m

Above command show the info about the blades connected to the slots, no. of ports in each blade and the port speed. “FC8” means 8 GBps “FC4” means 4 GBps supported by the switch blades. Remember, if you have 1 GBps / GBICs then we cant use them with 8 GBps supported Blades.