Guest User

Untitled

a guest
Aug 28th, 2018
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Awk 0.99 KB | None | 0 0
  1. #!/usr/bin/awk -f
  2.  
  3. /switchName:/ \
  4.     {
  5.         switchname=$2
  6.     }
  7.  
  8. /Effective configuration:/ \
  9.     {
  10.         hit=1
  11.     }
  12.  
  13. /alias:/ \
  14.     {
  15.         if(hit == 1)
  16.             {
  17.                 if(NF == 2)
  18.                     {
  19.                         sub(/\r/,"")
  20.                         sub(/\n/,"")
  21.                         alias=$2
  22.                         getline
  23.                         aliaswwn=tolower($1)
  24.                         wwnarray[aliaswwn]=alias
  25.                     }
  26.                 else
  27.                     {
  28.                         sub(/\r/,"")
  29.                         sub(/\n/,"")
  30.                         alias=$2
  31.                         aliaswwn=tolower($3)
  32.                         wwnarray[aliaswwn]=alias
  33.                     }
  34.             }
  35.     }
  36.  
  37. /Online.*FC.*F-Port/ \
  38.     {
  39.         if(hit == 1)
  40.             {
  41.                 portindex=$1
  42.                 portwwn=tolower($NF)
  43.                 connectedwwn[switchname][portindex]=portwwn
  44.                 if(NF >= 10)
  45.                     {
  46.                         portslot[switchname][portindex]=$2"/"$3
  47.                     }
  48.                 else
  49.                     {
  50.                         portslot[switchname][portindex]=$2
  51.                     }
  52.             }
  53.     }
  54.  
  55. END \
  56.     {
  57.         OFS="\t"
  58.         for(i in connectedwwn)
  59.         {
  60.             for(j in connectedwwn[i])
  61.             {
  62.                 k=connectedwwn[i][j]
  63.                 # print wwnarray[k],i,j,portslot[i][j]
  64.                 printf "%-20s %-5s %-6s %s\n",i,j,portslot[i][j],wwnarray[k]
  65.             }
  66.         }
  67.     }
Add Comment
Please, Sign In to add comment