Created
August 23, 2012 15:07
-
-
Save victorcastelan/3437537 to your computer and use it in GitHub Desktop.
Cuenta los procesos httpd activos en el server. Útil para conocer conexiones activas.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#/usr/bin/bash | |
#Capturamos Ctrl-C para terminar | |
trap 'echo;echo;echo Proceso terminado Ctrl-C Hasta la vista Baby;echo; exit' SIGINT SIGQUIT; | |
#procesosHttp.sh | |
#victorcastelan@gmail.com | |
pausa=10; | |
header="\n %-10s %8s %10s %10s %10s\n" | |
format="\r %-10s %8s %10s %10s %10s" | |
cuenta=0; | |
httAnterior=0; | |
httActual=0; | |
httMax=0; | |
httDiff=0; | |
echo; | |
echo; | |
echo " procesosHttp"; | |
echo "Cuenta los procesos httpd en un server a intervalos"; | |
echo "regulares. Ctrl-C para terminar"; | |
echo "Intervalo: $pausa seg"; | |
echo | |
printf "$header" "CUENTA" "FECHA" "HTTP" "DIFF" "MAX"; | |
echo "====================================================="; | |
for (( ; ; )); do | |
fecha=$(date +"%T"); | |
httAnterior=$httActual; | |
httActual=$(top -b -n 1 |grep httpd|wc -l); | |
cuenta=$(($cuenta + 1)); | |
httDiff=$(($httActual - $httAnterior)); | |
#httMax | |
if (($httActual > $httMax));then | |
httMax=$httActual; | |
fi | |
#imprime | |
printf "$format" \ | |
"$cuenta" "$fecha" "$httActual" "$httDiff" "$httMax" | |
sleep $pausa; | |
done; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment