mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-01 16:08:53 +00:00
Reformat everything.
This commit is contained in:
parent
3f2213791a
commit
340ff8586d
1008 changed files with 61301 additions and 58309 deletions
|
|
@ -99,42 +99,43 @@ from ansible.module_utils.common.text.converters import to_text
|
|||
|
||||
|
||||
class NginxStatusInfo:
|
||||
|
||||
def __init__(self):
|
||||
self.url = module.params.get('url')
|
||||
self.timeout = module.params.get('timeout')
|
||||
self.url = module.params.get("url")
|
||||
self.timeout = module.params.get("timeout")
|
||||
|
||||
def run(self):
|
||||
result = {
|
||||
'active_connections': None,
|
||||
'accepts': None,
|
||||
'handled': None,
|
||||
'requests': None,
|
||||
'reading': None,
|
||||
'writing': None,
|
||||
'waiting': None,
|
||||
'data': None,
|
||||
"active_connections": None,
|
||||
"accepts": None,
|
||||
"handled": None,
|
||||
"requests": None,
|
||||
"reading": None,
|
||||
"writing": None,
|
||||
"waiting": None,
|
||||
"data": None,
|
||||
}
|
||||
(response, info) = fetch_url(module=module, url=self.url, force=True, timeout=self.timeout)
|
||||
if not response:
|
||||
module.fail_json(msg=f"No valid or no response from url {self.url} within {self.timeout} seconds (timeout)")
|
||||
|
||||
data = to_text(response.read(), errors='surrogate_or_strict')
|
||||
data = to_text(response.read(), errors="surrogate_or_strict")
|
||||
if not data:
|
||||
return result
|
||||
|
||||
result['data'] = data
|
||||
expr = r'Active connections: ([0-9]+) \nserver accepts handled requests\n ([0-9]+) ([0-9]+) ([0-9]+) \n' \
|
||||
r'Reading: ([0-9]+) Writing: ([0-9]+) Waiting: ([0-9]+)'
|
||||
result["data"] = data
|
||||
expr = (
|
||||
r"Active connections: ([0-9]+) \nserver accepts handled requests\n ([0-9]+) ([0-9]+) ([0-9]+) \n"
|
||||
r"Reading: ([0-9]+) Writing: ([0-9]+) Waiting: ([0-9]+)"
|
||||
)
|
||||
match = re.match(expr, data, re.S)
|
||||
if match:
|
||||
result['active_connections'] = int(match.group(1))
|
||||
result['accepts'] = int(match.group(2))
|
||||
result['handled'] = int(match.group(3))
|
||||
result['requests'] = int(match.group(4))
|
||||
result['reading'] = int(match.group(5))
|
||||
result['writing'] = int(match.group(6))
|
||||
result['waiting'] = int(match.group(7))
|
||||
result["active_connections"] = int(match.group(1))
|
||||
result["accepts"] = int(match.group(2))
|
||||
result["handled"] = int(match.group(3))
|
||||
result["requests"] = int(match.group(4))
|
||||
result["reading"] = int(match.group(5))
|
||||
result["writing"] = int(match.group(6))
|
||||
result["waiting"] = int(match.group(7))
|
||||
return result
|
||||
|
||||
|
||||
|
|
@ -142,8 +143,8 @@ def main():
|
|||
global module
|
||||
module = AnsibleModule(
|
||||
argument_spec=dict(
|
||||
url=dict(type='str', required=True),
|
||||
timeout=dict(type='int', default=10),
|
||||
url=dict(type="str", required=True),
|
||||
timeout=dict(type="int", default=10),
|
||||
),
|
||||
supports_check_mode=True,
|
||||
)
|
||||
|
|
@ -152,5 +153,5 @@ def main():
|
|||
module.exit_json(changed=False, **nginx_status_info)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue