User Tools

Site Tools


storage:brocade_scripts

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
storage:brocade_scripts [2023/11/24 17:53]
manu
storage:brocade_scripts [2024/02/16 18:24] (current)
manu
Line 23: Line 23:
 #          html_tag;​nagios_tag;​reserved;​output #          html_tag;​nagios_tag;​reserved;​output
 #​==================================================================== #​====================================================================
-# version 1.0+# version 1.0 02-2018 eif 
 +# version 1.1 02-2024 eif add port signal strength ​
  
 dir=`dirname $0` dir=`dirname $0`
Line 35: Line 36:
 export logname=$logpath/​$sn.log export logname=$logpath/​$sn.log
 TMPFILE=$logpath/​tempo_file TMPFILE=$logpath/​tempo_file
 +
 +month=$(date "​+%Y-%m"​)
 +archpath=/​storage/​san/​backup/​$month
  
 os=$(uname -s | tr '​A-Z'​ '​a-z'​) os=$(uname -s | tr '​A-Z'​ '​a-z'​)
  
-USER=admin +USER=report 
-listswitch="​sansw1 sansw2" ​       # All SAN switches from all fabric separated by space+listswitch="​swsan01 swsan02" ​       # All SAN switches from all fabric separated by space
  
 #​NAGIOSTAG="​0=OK,​ 1=WARNING, 2=CRITICAL, 3=UNKNOWN"​ #​NAGIOSTAG="​0=OK,​ 1=WARNING, 2=CRITICAL, 3=UNKNOWN"​
Line 46: Line 50:
 COLOR[2]="#​FF2400" ​     # red    #DF013A COLOR[2]="#​FF2400" ​     # red    #DF013A
 COLOR[3]="​yellow" ​      # yellow #F3F781 COLOR[3]="​yellow" ​      # yellow #F3F781
-COLOR[4]="#​56A5EC" ​     # blue+COLOR[4]="#​86EFF6" ​     # blue
 COLOR[5]="#​FFFFFF" ​     # white COLOR[5]="#​FFFFFF" ​     # white
 #FFA500 : orange #FFA500 : orange
-COLOR[6]="#​3090C7" ​     # Blue Ivry for SAN blue+#​COLOR[6]="#​33CAFF" ​     # Blue SAN blue 
 +COLOR[6]="​ #85C1E9" ​     # Blue SAN blue
 COLOR[7]="#​E77471" ​     # Light Coral for SAN red COLOR[7]="#​E77471" ​     # Light Coral for SAN red
  
Line 128: Line 133:
   swdomain=$(grep -i '​^switchDomain:'​ $TMPFILE.tempo | awk -F':'​ '​{print $2}')   swdomain=$(grep -i '​^switchDomain:'​ $TMPFILE.tempo | awk -F':'​ '​{print $2}')
   ssh $USER@$sw "​sfpshow -all" > $logpath/​sfpshow-all_${fabricname}_${switchname}_full   ssh $USER@$sw "​sfpshow -all" > $logpath/​sfpshow-all_${fabricname}_${switchname}_full
-  cat $logpath/​sfpshow-all_${fabricname}_${switchname}_full | egrep '​Slot|Power'​ |  sed '​s/​^Slot/​\n/​g'​ | tr -s ' ' | sed 's/^\ //g' | sed '​s/​Port\ //' | sed '​s/​\//;/'​ | sed '​s/:/;/'​ > $logpath/​sfpshow-all_${fabricname}_${switchname}+  cat $logpath/​sfpshow-all_${fabricname}_${switchname}_full | egrep '​Slot|Power'​ |  sed '​s/​^Slot/​\n/​g'​ | tr -s ' ' | sed 's/^\ //g' | sed '​s/​Port\ //' | sed '​s/​\//;/'​ | sed '​s/:/;/'​ > $logpath/​sfpshow-all_${fabname}_${switchname}
   ssh $USER@$sw "​sfpshow"​ | tr -s ' ' | sed 's/\ //g' | sed '​s/​Slot//'​ | sed '​s/​Port//'​ | cut -d':'​ -f1,5 | sed '​s/​\//;/'​ > $logpath/​sfpshow_${fabricname}_${switchname}   ssh $USER@$sw "​sfpshow"​ | tr -s ' ' | sed 's/\ //g' | sed '​s/​Slot//'​ | sed '​s/​Port//'​ | cut -d':'​ -f1,5 | sed '​s/​\//;/'​ > $logpath/​sfpshow_${fabricname}_${switchname}
   echo "​H3;​0;​TAG;​FABRIC:​ $fabricname ​ SWITCHNAME: $switchname"​ > $logpath/​switchshow_${fabricname}_${switchname}.csv   echo "​H3;​0;​TAG;​FABRIC:​ $fabricname ​ SWITCHNAME: $switchname"​ > $logpath/​switchshow_${fabricname}_${switchname}.csv
Line 151: Line 156:
       sfpspeed="​NA"​       sfpspeed="​NA"​
     fi     fi
 +############################​
     rxpower=$(grepp "​^${port};"​ $logpath/​sfpshow-all_${fabricname}_${switchname} | grep "RX Power" | cut -d';'​ -f2- | sed 's/\ dBm\ /​|dBm|/​g'​)     rxpower=$(grepp "​^${port};"​ $logpath/​sfpshow-all_${fabricname}_${switchname} | grep "RX Power" | cut -d';'​ -f2- | sed 's/\ dBm\ /​|dBm|/​g'​)
     txpower=$(grepp "​^${port};"​ $logpath/​sfpshow-all_${fabricname}_${switchname} | grep "TX Power" | cut -d';'​ -f2- | sed 's/\ dBm\ /​|dBm|/​g'​)     txpower=$(grepp "​^${port};"​ $logpath/​sfpshow-all_${fabricname}_${switchname} | grep "TX Power" | cut -d';'​ -f2- | sed 's/\ dBm\ /​|dBm|/​g'​)
Line 156: Line 162:
     # get color for fabric     # get color for fabric
     NAGIOSTAG=0     NAGIOSTAG=0
 +# for linux    suff=$(echo $fabricname | tr [:alpha:] ' ' | awk '​{print $1}')
     suff=$(echo $fabricname | rev | cut -c1)     suff=$(echo $fabricname | rev | cut -c1)
     modulo=$(echo $(($suff % 2)) )     modulo=$(echo $(($suff % 2)) )
Line 270: Line 277:
 done done
 } }
 +
  
 #​---------------------------- #​----------------------------
Line 286: Line 294:
   for i in $(ls $logpath/​swsan_${fabricname}_switchshow_*.csv)   for i in $(ls $logpath/​swsan_${fabricname}_switchshow_*.csv)
   do   do
-    cat $i | grep '​^TD;'​ >> $logpath/​san_result.csv+    cat $i | grep '​^TD;' ​| rev | cut -d';'​ -f2- | rev >> $logpath/​san_result.csv
   done   done
     echo "​H3;​0;​TAG;​Alias defined in Fabric ${fabricname} but not connected"​ | tee $logpath/​swsan_${fabricname}_unused.csv     echo "​H3;​0;​TAG;​Alias defined in Fabric ${fabricname} but not connected"​ | tee $logpath/​swsan_${fabricname}_unused.csv
     echo "​TH;​4;​TAG;​alias;​number of defined zones;zone name" | tee -a $logpath/​swsan_${fabricname}_unused.csv     echo "​TH;​4;​TAG;​alias;​number of defined zones;zone name" | tee -a $logpath/​swsan_${fabricname}_unused.csv
  
-    sed '​1d'​ $logpath/​san_result.csv | grep ";​Online;"​ | rev | cut -d';'​ -f2 | rev | sed '​s/​(no_alias)//'​ | sed '​s/​(multiples_alias)//'​ | sed '/​^$/​d'​ | grep -v "​(ISL)"​ | tr ' ' '​\n'​ | sed '​s/​$/;/'​ > $logpath/san_result1.csv+    sed '​1d'​ $logpath/​san_result.csv | grep ";​Online;"​ | rev | cut -d';'​ -f2 | rev | sed '​s/​(no_alias)//'​ | sed '​s/​(multiples_alias)//'​ | sed '/​^$/​d'​ | grep -v "​(ISL)"​ | tr ' ' '​\n'​ | sed '​s/​$/;/'​ > $logpath/saesult1.csv
  
     for alias in $(cat $filename | grep '​^alias'​ | cut -d'​.'​ -f2- | cut -d':'​ -f1 | sort | uniq)     for alias in $(cat $filename | grep '​^alias'​ | cut -d'​.'​ -f2- | cut -d':'​ -f1 | sort | uniq)
Line 479: Line 487:
 send_wiki() send_wiki()
 { {
-htmlinventory=$logpath/​san_switchshow.html +dokupath=/​var/​www/​html/​archives/​inventory/​san
-dokupath=/​var/​www/​html/​data/pages/​inventory/​san +
-dokuhost=dokuwiki01+
 dokuuser=apache dokuuser=apache
 dokugrp=apache dokugrp=apache
  
-#​file_exist=$(ssh $dokuhost "ls $dokupath/​$xlsmonthly > /dev/null 2>&​1"​ ;echo $?) +for file1 in san_switchshow.html san_unused_alias.html san_full_config.txt 
-#echo ${file_exist} +do 
-#if [ ${file_exist} != 0 ] +  ​sudo su root -"/bin/cp $logpath/$file1 $dokupath"​ 
-#then +done 
- echo "​Creating monthly file hmcscan_ALL-server_${cur_month}.xls"​ + 
-#  scp -p $xlsinventory $dokuhost:​$dokupath/​$xlsmonthly +sudo su root -c "/​bin/​chown -R $dokuuser.$dokugrp ​$dokupath" 
-#  scp $dokuhost:​$dokupath/​$dokufilename $logpath + 
-#  echo "\n\nhttp://dokuwiki01/​data/​pages/​inventory/​hmcscan/​$xlsmonthly"​ >> ​$logpath/$dokufilename +# Archive 
-#  scp -p $logpath/​$dokufilename $dokuhost:$dokupath +if [ ! -$archpath/san_switchshow.html ] 
-#else +then 
-#  echo "​Monthly file available, not creating+  for file1 in san_switchshow.html ​san_unused_alias.html san_full_config.txt 
-#fi +  do 
-# +    cp $logpath/$file1 $archpath 
-scp --$htmlinventory ​$dokuhost:$dokupath +  done 
-scp -p -r $logpath/​san_unused_alias.html ​$dokuhost:​$dokupath +fi 
-scp -p -r $logpath/san_full_config.txt ​$dokuhost:​$dokupath +
-#scp -p $xlsinventory ​$dokuhost:$dokupath +
-ssh $dokuhost "chown -R $dokuuser.$dokugrp $dokupath"​+
 } }
  
Line 532: Line 536:
  
 main > $logname 2>&1 main > $logname 2>&1
 +
 </​code>​ </​code>​
  
storage/brocade_scripts.1700844821.txt.gz · Last modified: 2023/11/24 17:53 by manu