o
    Ìv›ax  ã                   @   s8   d Z ddlZddlmZ ddlmZ G dd„ deƒZdS )uy  
Nginx AMP
=========

Monitor the Nginx process using the status page.

How to read the stats
---------------------

Active connections â€“ Number of all open connections. This doesnâ€™t mean number of users.
A single user, for a single pageview can open many concurrent connections to your server.
Server accepts handled requests â€“ This shows three values.
    First is total accepted connections.
    Second is total handled connections. Usually first 2 values are same.
    Third value is number of and handles requests. This is usually greater than second value.
    Dividing third-value by second-one will give you number of requests per connection handled
    by Nginx. In above example, 10993/7368, 1.49 requests per connections.
Reading â€“ nginx reads request header
Writing â€“ nginx reads request body, processes request, or writes response to a client
Waiting â€“ keep-alive connections, actually it is active â€“ (reading + writing).
This value depends on keepalive-timeout. Do not confuse non-zero waiting value for poor
performance. It can be ignored.

Source reference: https://easyengine.io/tutorials/nginx/status-page/

Configuration file example
--------------------------

[amp_nginx]
# Nginx status page should be enable (https://easyengine.io/tutorials/nginx/status-page/)
enable=true
regex=\/usr\/sbin\/nginx
refresh=60
one_line=false
status_url=http://localhost/nginx_status
é    N)Úlogger)Ú
GlancesAmpc                   @   s,   e Zd ZdZdZdZdZdZdZdd„ Z	d	S )
ÚAmpzGlances' Nginx AMP.ZNginxz1.0z Get Nginx stats from status-pageZ	Nicolargozcontact@nicolargo.comc                 C   sn   t  d | j|  d¡¡¡ t |  d¡¡}|jr$|  |j 	¡ ¡ |  ¡ S t  d | j|  d¡|j
¡¡ |  ¡ S )zUpdate the AMPz${}: Update stats using status URL {}Z
status_urlz#{}: Can not grab status URL {} ({}))r   ÚdebugÚformatÚNAMEÚgetÚrequestsÚokZ
set_resultÚtextÚrstripÚreasonÚresult)ÚselfZprocess_listÚres© r   ú</usr/lib/python3/dist-packages/glances/amps/glances_nginx.pyÚupdateL   s   þz
Amp.updateN)
Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   ZVERSIONZDESCRIPTIONZAUTHORZEMAILr   r   r   r   r   r   ?   s    r   )r   r	   Zglances.loggerr   Zglances.amps.glances_ampr   r   r   r   r   r   Ú<module>   s
   %