Advertisement
yacel100

scriptPingServers.sh

May 30th, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.11 KB | None | 0 0
  1. #!/bin/bash
  2. # pingservers.sh
  3. # ==============
  4. # Hace ping a una lista de direcciones IP, revisa si los servidores estan activos o no.
  5. # Escrito por:I. Attir
  6. # http://www.good-linux-tips.com/2014/06/script-checking-if-servers-are-up.html
  7. #
  8. # Modificaciones y traducción al Español por: Francisco J. de la Torre Inguanzo
  9. # http://linuxmanr4.com/2014/06/06/script-en-bash-que-hace-ping-tus-servidores/
  10.  
  11. clear
  12.  
  13. if [ "$1" = "" ] ; then  # No se pasó una lista de ips
  14.    echo "Error: Por favor introduce un nombre de archivo válido, que contenga las direcciones IP para hacer ping."
  15. exit 1
  16. fi
  17. if [ ! -f "$1" ] ; then  # Archivo inválido.
  18.    echo "Error: No puedo encontrar el archivo "$1"."
  19. exit 2
  20. fi
  21.  
  22. echo "(*) Haciendo ping a los servidores contenidos en el archivo "$1", por favor espere..."
  23. echo
  24.  
  25. while read IP
  26. do
  27.    ping -c 3 "$IP" >& /dev/null
  28.    
  29.  if [ "$?" != "0" ] ; then   # Houston, tenemos un problema.
  30.    (echo -n "$IP  " ; date) | tee -a noping.log
  31.    echo -e     "${IP} !!! \e[0;31m[X]\e[1;37m"
  32.    nmap "$IP"
  33.  else echo -e  "$IP \e[1;32m[OK]\e[1;37m"
  34.  fi
  35. done < "$1"
  36. echo
  37. echo "Listo!!!"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement