Fibre Channel (SAN)

Reply
Regular Visitor
Posts: 1
Registered: ‎01-07-2015

Monitoring error counters on Brocade FOS v6.x with bash scripts

First reset all counters with following scripts (need root acces with ssh public key) :

 

#!/bin/bash
# Reset all counters on Brocade FOS v6.x
# Copyright (C) 2014 Luc Santeramo (l.santeramo@brgm.fr)
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA

# Switch list 
SWLIST="sw0 sw1"

for switch in ${SWLIST}
do
        echo "Reseting port stats on ${switch} enabled ports, vf 128 and 10"
        ssh root@${switch} "\
        for port in \$(/fabos/link_bin/switchshow | grep -v Disabled | awk '{print \$1}' | grep [0-9]);\
        do \
          echo -n \"\$port;\"; \
          /fabos/link_sbin/portstatsclear \$port ; \
        done ; \
        export FABOS_SWITCHNO CURRENT_VF ROLE_ID; FABOS_SWITCHNO=1; CURRENT_VF=10; ROLE_ID=root; \
        for port in \$(/fabos/link_bin/switchshow | grep -v Disabled | awk '{print \$1}' | grep [0-9]);\
        do \
          echo -n \"\$port;\"; \
          /fabos/link_sbin/portstatsclear \$port ; \
        done"
        echo ""
done

 Output will be like :

Reseting port stats on sw0, vf 128 and 10
1;2;5;6;7;12;13;14;15;26;50;51;
Reseting port stats on sw1, vf 128 and 10
1;2;5;6;7;12;13;14;15;26;49;50;51;

 Then check ports with errors few minutes or hours later with following script (need root acces with ssh public key) :

#!/bin/bash
# Reset all counters on Brocade FOS v6.x
# Copyright (C) 2014 Luc Santeramo (l.santeramo@brgm.fr)
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA

# Switch list
SWLIST="sw0 sw1"

# Path to log files
LOGPATH="/tmp/logs"

set -- $(date +%F)
DATE=$1

# Counters gathering in timestamped files
for switch in ${SWLIST}
do
        FILE="$LOGPATH/errors_${switch}-${DATE}.txt"

        # If file is empty or does not exists, add columns description
        [ -z ${FILE} ] || echo "port;er_enc_out;er_rx_c3_timeout;er_tx_c3_timeout;er_c3_dest_unreach;er_other_discard;" > ${FILE}

        echo "Gathering er_enc_out, er_rx_c3_timeout, er_tx_c3_timeout, er_c3_dest_unreach, er_other_discard on ${switch} enabled ports, vf 128 and 10"
        ssh root@${switch} "\
        for port in \$(/fabos/link_bin/switchshow | grep -v Disabled | awk '{print \$1}' | grep [0-9]); \
        do \
           echo -n \"\$port;\";\
           /fabos/link_bin/portstatsshow \$port | grep \"er_enc_out\|er_rx_c3_timeout\|er_tx_c3_timeout\|er_c3_dest_unreach\|er_other_discard\" | awk '{printf \"%d;\",\$2}'; \
           echo \"\" ; \
        done
        export FABOS_SWITCHNO CURRENT_VF ROLE_ID; FABOS_SWITCHNO=1; CURRENT_VF=10; ROLE_ID=root; \
        for port in \$(/fabos/link_bin/switchshow | grep -v Disabled | awk '{print \$1}' | grep [0-9]); \
        do \
           echo -n \"\$port;\";\
           /fabos/link_bin/portstatsshow \$port | grep \"er_enc_out\|er_rx_c3_timeout\|er_tx_c3_timeout\|er_c3_dest_unreach\|er_other_discard\" | awk '{printf \"%d;\",\$2}'; \
           echo \"\" ; \
        done " > ${FILE}
done

# Displaying ports with errors
for switch in ${SWLIST}
do
        FILE="${LOGPATH}/errors_${switch}-${DATE}.txt"
        echo "** $switch"
        grep -v ";0;0;0;0;0;" ${FILE}
done

  Output will be like :

Gathering er_enc_out, er_rx_c3_timeout, er_tx_c3_timeout, er_c3_dest_unreach, er_other_discard on sw0 enabled ports, vf 128 and 10
Gathering er_enc_out, er_rx_c3_timeout, er_tx_c3_timeout, er_c3_dest_unreach, er_other_discard on sw1 enabled ports, vf 128 and 10
** sw0
51;344;234;0;0;0;
** sw1

 Meaning there are er_enc_out and er_rx_c3_timeout errors on port 51 of sw0.

Valued Contributor
Posts: 761
Registered: ‎06-11-2010

Re: Monitoring error counters on Brocade FOS v6.x with bash scripts

nice script, thanks mate!

Join the Community

Get quick and easy access to valuable resource designed to help you manage your Brocade Network.