Advertisement
Guest User

Extraction Infos Postes IP

a guest
Jun 18th, 2019
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.88 KB | None | 0 0
  1. #!/bin/sh
  2. # UpDate 23/04/2019
  3. # STRYK
  4.  
  5. DefRole () {
  6.    
  7.     if [ $(role) != "MAIN" ]; then
  8.    
  9.         echo -e "Cet utilitaire doit être utilisé sur la \033[41mcpu MAIN\033[0m"
  10.         exit
  11.        
  12.     fi
  13.    
  14. }
  15.  
  16. GoAction () {
  17.  
  18.     CountList=0
  19.     MaxIpt=$(tool ippstat status set | grep -c OK)
  20.     echo -e "\033[05;01;32;44mRécupération des informations des IpTouch en cours\033[0m"
  21.    
  22.     # Clear LogFile
  23.     echo "Mcdu;Nom;Prenom;Type;@IP;@MAC;Serial">CustomEdsbr.csv
  24.  
  25.     for Mcdu in `tool ippstat mac | grep Ipt | cut -d '|' -f 5`; do
  26.    
  27.         InStat=$(tool terminfo d $Mcdu | grep SERVICE | cut -d '|' -f 4 | cut -d " " -f 2)
  28.        
  29.         if [ $InStat = "IN" ]; then
  30.  
  31.             DevName=$(echo -e 'Subscriber\n4\n1\n3\nAnnu_Name\n\n2\n'$Mcdu'\n' | mgr -line -nodico | grep 'Annu_Name' | cut -d ':' -f2 | cut -c 2-)
  32.             DevFirstName=$(echo -e 'Subscriber\n4\n1\n3\nAnnu_First_Name\n\n2\n'$Mcdu'\n' | mgr -line -nodico | grep 'Annu_First_Name' | cut -d ':' -f2 | cut -c 2-)
  33.             DevType=$(echo -e 'Subscriber\n4\n1\n3\nStation_Type\n\n2\n'$Mcdu'\n' | mgr -line -nodico | grep 'Station_Type' | cut -d ':' -f2 | cut -c 2-)
  34.             DevAdip=$(tool ippstat status d $Mcdu | grep "IP Address is" | cut -d ':' -f 2)
  35.             DevMac=$(echo -e '10\n3\n'$Mcdu'\n\n0\n' | tool ippstat | grep $Mcdu | cut -d '|' -f4 | tr -d ' ')
  36.             DevSN=$(echo -e 'Noe_Parameters\n4\n1\n'$Mcdu'\n3\nSerial_Number\n\n2\n\n' | mgr -line -nodico | grep 'Serial_Number' | sort -u | cut -d ':' -f2 | cut -c 2-)
  37.  
  38.             CountList=$(($CountList + 1))
  39.            
  40.             echo "$Mcdu;$DevName;$DevFirstName;$DevType;$DevAdip;$DevMac;$DevSN" >>CustomEdsbr.csv
  41.            
  42.         fi
  43.        
  44.     done
  45.    
  46.     echo Travail terminé - $CountList Postes Listés sur un total de $MaxIpt!
  47.     echo Fichier disponible: /usr2/mtcl/CustomEdsbr.csv
  48.    
  49. }
  50.  
  51. DefRole
  52. GoAction
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement