•
Monitorización de nginx mediante nginx_status (similar a server-status)
Para monitorizar las conexiones a nginx de una forma similar al server-status lo podemos hacer mediante el modulo stub status
Para ello tendremos que tener compilado el nginx con la opción –with-http_stub_status_module. A continuación podemos habilitarlo mediante la opción stub_status on:
server
{
listen 80;
server_name localhost 10.10.5.32 _;
access_log off;
error_log off;
location /server-status
{
stub_status on;
access_log off;
allow 127.0.0.1;
deny all;
}
location /
{
root /var/www/void;
}
}
En este caso vemos como podremos acceder al server-status por IP solo desde localhost.
Podemos monitorizar la conexiones mediante un simple script de Nagios:
#!/bin/bash
STATUS=server-status
# lynx -dump http://10.11.11.11/
# Active connections: 6
# server accepts handled requests
# 2666 2666 4851
# Reading: 0 Writing: 1 Waiting: 5
ACTIVE=$(lynx -dump http://$1/$STATUS | grep "Active connections" | awk '{ print $NF }')
READING=$(lynx -dump http://$1/$STATUS | grep "Reading" | sed 's#Reading: *\([0-9]*\) .*#\1#')
WRITING=$(lynx -dump http://$1/$STATUS | grep "Reading" | sed 's#.* Writing: *\([0-9]*\) .*#\1#')
WAITING=$(lynx -dump http://$1/$STATUS | grep "Reading" | sed 's#.* Waiting: *\([0-9]*\)#\1#')
echo "Active connections: $ACTIVE Reading: $READING Writing: $WRITING Waiting: $WAITING | 'active'=$ACTIVE 'reading'=$READING 'writing'=$WRITING 'waiting'=$WAITING"
El cual combinándolo con RRDtool y n2rrd podremos obtener un gráfico de la evolución de las conexiones al nginx:
En el siguiente ejemplo podemos ver otro ejemplo del gráfico diario de conexiones según el stub_status:
Podemos ver a continuación el equivalente semanal:
Relacionados
Imprimir



Deja un comentario: