�
�Udac @` s� d d l m Z m Z m Z e Z i d d 6d g d 6d d 6Z d Z d Z d
Z d d l
Z
d d l m Z d d
l
m Z d d l m Z d e f d � � YZ d � Z e d k r� e � n d S( i ( t absolute_importt divisiont print_functions 1.1t metadata_versiont
deprecatedt statust communityt supported_bys�
---
module: nginx_status_facts
deprecated:
removed_in: '2.13'
why: Deprecated in favour of C(_info) module.
alternative: Use M(nginx_status_info) instead.
short_description: Retrieve nginx status facts.
description:
- Gathers facts from nginx from an URL having C(stub_status) enabled.
version_added: "2.3"
author: "René Moser (@resmo)"
options:
url:
description:
- URL of the nginx status.
required: true
timeout:
description:
- HTTP connection timeout in seconds.
required: false
default: 10
notes:
- See http://nginx.org/en/docs/http/ngx_http_stub_status_module.html for more information.
sJ
# Gather status facts from nginx on localhost
- name: get current http stats
nginx_status_facts:
url: http://localhost/nginx_status
# Gather status facts from nginx on localhost with a custom timeout of 20 seconds
- name: get current http stats
nginx_status_facts:
url: http://localhost/nginx_status
timeout: 20
s]
---
nginx_status_facts.active_connections:
description: Active connections.
returned: success
type: int
sample: 2340
nginx_status_facts.accepts:
description: The total number of accepted client connections.
returned: success
type: int
sample: 81769947
nginx_status_facts.handled:
description: The total number of handled connections. Generally, the parameter value is the same as accepts unless some resource limits have been reached.
returned: success
type: int
sample: 81769947
nginx_status_facts.requests:
description: The total number of client requests.
returned: success
type: int
sample: 144332345
nginx_status_facts.reading:
description: The current number of connections where nginx is reading the request header.
returned: success
type: int
sample: 0
nginx_status_facts.writing:
description: The current number of connections where nginx is writing the response back to the client.
returned: success
type: int
sample: 241
nginx_status_facts.waiting:
description: The current number of idle client connections waiting for a request.
returned: success
type: int
sample: 2092
nginx_status_facts.data:
description: HTTP response as is.
returned: success
type: str
sample: "Active connections: 2340
server accepts handled requests
81769947 81769947 144332345
Reading: 0 Writing: 241 Waiting: 2092
"
N( t
AnsibleModule( t fetch_url( t to_textt NginxStatusFactsc B` s e Z d � Z d � Z RS( c C` s. t j j d � | _ t j j d � | _ d S( Nt urlt timeout( t modulet paramst getR R
( t self( ( sZ /usr/lib/python2.7/site-packages/ansible/modules/web_infrastructure/_nginx_status_facts.pyt __init__l s c C` s� i i d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d 6} t d
t d | j d t d
| j � \ } } | s� t j d d | j | j f � n t | j � d d �} | s� | S| | d d <d } t j
| | t j � } | r�t | j
d � � | d d <t | j
d � � | d d <t | j
d � � | d d <t | j
d � � | d d <t | j
d � � | d d <t | j
d � � | d d <t | j
d � � | d d <n | S( Nt active_connectionst acceptst handledt requestst readingt writingt waitingt datat nginx_status_factsR R t forceR
t msgs? No valid or no response from url %s within %s seconds (timeout)t errorst surrogate_or_stricts� Active connections: ([0-9]+) \nserver accepts handled requests\n ([0-9]+) ([0-9]+) ([0-9]+) \nReading: ([0-9]+) Writing: ([0-9]+) Waiting: ([0-9]+)i i i i i i i ( t NoneR R R t TrueR
t fail_jsonR
t readt ret matcht St intt group( R t resultt responset infoR t exprR% ( ( sZ /usr/lib/python2.7/site-packages/ansible/modules/web_infrastructure/_nginx_status_facts.pyt runp s8 -# ( t __name__t
__module__R R- ( ( ( sZ /usr/lib/python2.7/site-packages/ansible/modules/web_infrastructure/_nginx_status_facts.pyR j s c C` sq t d t d t d t � d t d d d d � � d t � a t � j � } t d
t d | � } t j | � d S( Nt
argument_specR t requiredR
t typeR'