community.general.nginx_status_info 模块 – 获取 Nginx 状态信息

注意

此模块是 community.general 集合(版本 10.1.0)的一部分。

如果您正在使用 ansible 包,您可能已经安装了这个集合。 它不包含在 ansible-core 中。 要检查是否已安装,请运行 ansible-galaxy collection list

要安装它,请使用: ansible-galaxy collection install community.general

要在 playbook 中使用它,请指定: community.general.nginx_status_info

概要

  • 从启用了 stub_status 的 URL 中收集 Nginx 的信息。

参数

参数

注释

timeout

integer

HTTP 连接超时(以秒为单位)。

默认值: 10

url

字符串 / 必需

Nginx 状态的 URL。

属性

属性

支持

描述

check_mode

支持: 完全

此操作不会修改状态。

可以在 check_mode 中运行并返回更改的状态预测,而无需修改目标。

diff_mode

支持: N/A

此操作不会修改状态。

当处于 diff 模式时,将返回已更改的内容的详细信息(或可能需要在 check_mode 中更改的内容)。

备注

示例

# Gather status info from nginx on localhost
- name: Get current http stats
  community.general.nginx_status_info:
    url: https://127.0.0.1/nginx_status
  register: result

# Gather status info from nginx on localhost with a custom timeout of 20 seconds
- name: Get current http stats
  community.general.nginx_status_info:
    url: https://127.0.0.1/nginx_status
    timeout: 20
  register: result

返回值

常见的返回值已在此处记录,以下是此模块特有的字段

描述

accepts

integer

接受的客户端连接总数。

返回: 成功

示例: 81769947

active_connections

integer

活动连接数。

返回: 成功

示例: 2340

data

字符串

按原样返回的 HTTP 响应。

返回: 成功

示例: "Active connections: 2340 \nserver accepts handled requests\n 81769947 81769947 144332345 \nReading: 0 Writing: 241 Waiting: 2092 \n"

handled

integer

处理的连接总数。 通常,除非达到某些资源限制,否则此参数的值与 accepts 相同。

返回: 成功

示例: 81769947

reading

integer

Nginx 正在读取请求标头的当前连接数。

返回: 成功

示例: 0

requests

integer

客户端请求总数。

返回: 成功

示例: 144332345

waiting

integer

当前等待请求的空闲客户端连接数。

返回: 成功

示例: 2092

writing

integer

Nginx 正在将响应写回客户端的当前连接数。

返回: 成功

示例: 241

作者

  • René Moser (@resmo)