You've already forked scripts-random
Add first scripts
This commit is contained in:
49
01_bash/speed_web.sh
Executable file
49
01_bash/speed_web.sh
Executable file
@@ -0,0 +1,49 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Este es un script de Bash para comprobar el código de estado de una lista de URLs
|
||||
# y utilizando el comando \time mide el tiempo de respuesta de cada solicitud.
|
||||
#
|
||||
# Uso:
|
||||
# chmod +x speed_web.sh
|
||||
# ./speed_web.sh http://ejemplo.com https://google.com http://otroejemplo.com
|
||||
#
|
||||
|
||||
COLOR_RED='\033[0;31m'
|
||||
COLOR_BLUE='\033[0;34m'
|
||||
COLOR_MAGENTA='\033[0;35m'
|
||||
COLOR_CYAN='\033[0;36m'
|
||||
COLOR_GRAY='\033[0;37m'
|
||||
COLOR_RESET='\033[0m'
|
||||
|
||||
# Control de salida con Ctrl + C
|
||||
function ctrl_c() {
|
||||
echo -e "${COLOR_RED}\n\n[!] Saliendo... \n${COLOR_RESET}"
|
||||
tput cnorm
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Ctrl+C
|
||||
trap ctrl_c SIGINT
|
||||
|
||||
check_url() {
|
||||
url="$1"
|
||||
echo -e "\n${COLOR_MAGENTA}[+] Comprobación URL:${COLOR_RESET}${COLOR_BLUE} $url${COLOR_RESET}"
|
||||
# Captura la salida de \time y curl por separado
|
||||
time_output=$({ /usr/bin/time -f "User mode: %U\nKernel mode: %S\nCPU: %P" curl -o /dev/null -L -s -w "\nCódigo de respuesta: %{http_code}\nTamaño del contenido: %{size_download} bytes\nTipo de contenido: %{content_type}\nDirección IP del servidor: %{remote_ip}\nTiempo de resolución DNS: %{time_namelookup} segundos\n" "$url"; } 2>&1)
|
||||
if [[ $? -eq 0 ]]; then
|
||||
echo -e "${COLOR_CYAN}$time_output${COLOR_RESET}"
|
||||
else
|
||||
echo -e "${COLOR_RED}\n\n[!] Error: No se pudo acceder a la URL${COLOR_RESET}"
|
||||
fi
|
||||
echo -e "${COLOR_CYAN}\n------------------------------------------${COLOR_RESET}"
|
||||
}
|
||||
|
||||
if [ $# -eq 0 ]; then
|
||||
echo -e "${COLOR_RED}\n\n[!] Error: Introduce argumentos.${COLOR_RESET}"
|
||||
echo -e "${COLOR_BLUE}\n\tUso: $0 [URL1] [URL2] ...\n${COLOR_RESET}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
for url in "$@"; do
|
||||
check_url "$url"
|
||||
done
|
||||
Reference in New Issue
Block a user