community.general.oneandone_monitoring_policy 模块 – 配置 1&1 监控策略
注意
此模块是 community.general 集合(版本 10.1.0)的一部分。
如果您正在使用 ansible 包,您可能已经安装了此集合。它不包含在 ansible-core 中。要检查是否已安装,请运行 ansible-galaxy collection list。
要安装它,请使用:ansible-galaxy collection install community.general。您需要其他要求才能使用此模块,请参阅 要求 获取详细信息。
要在 playbook 中使用它,请指定:community.general.oneandone_monitoring_policy。
概要
- 创建、删除、更新监控策略(并添加/删除端口、进程和服务器)。此模块依赖于 1and1 >= 1.0。 
要求
执行此模块的主机需要以下要求。
- 1and1 
参数
| 参数 | 注释 | 
|---|---|
| 要添加到监控策略的端口。 默认值:  | |
| 要添加到监控策略的进程。 默认值:  | |
| 要添加到监控策略的服务器。 默认值:  | |
| 设置为 true 以使用代理。 | |
| 自定义 API URL。覆盖 ONEANDONE_API_URL 环境变量。 | |
| 由 1&1 提供的身份验证 API 令牌。 | |
| 监控策略描述。maxLength=256 | |
| 用户的电子邮件。maxLength=128 | |
| 用于更新状态的监控策略的标识符(id 或名称)。 | |
| 与 present 状态一起使用的监控策略名称。与 absent 状态一起使用时用作标识符(id 或名称)。maxLength=128 | |
| 将要监控的端口数组。 默认值:  | |
| 警报的情况。 选择 
 | |
| 设置为 true 以发送电子邮件通知。 | |
| 端口号。最小值=1,最大值=65535 | |
| Internet 协议。 选择 
 | |
| 将要监控的进程数组。 默认值:  | |
| 警报的情况。 选择 
 | |
| 进程的名称。maxLength=50 | |
| 要从监控策略中删除的端口。 默认值:  | |
| 要从监控策略中删除的进程。 默认值:  | |
| 要从监控策略中删除的服务器。 默认值:  | |
| 定义监控策略的状态以创建、删除、更新。 选择 
 | |
| 监控策略阈值。每个子选项都有警告和严重,两者都有警报和值子选项。警告用于设置警告警报的限制,严重用于设置严重警报。警报启用警报,值用于提示何时超出该值。 默认值:  | |
| CPU 的消耗限制。 | |
| 硬盘的消耗限制。 | |
| 内部 ping 的响应限制。 | |
| RAM 的消耗限制。 | |
| 传输的消耗限制。 | |
| 要在监控策略上更新的端口。 默认值:  | |
| 要在监控策略上更新的进程。 默认值:  | |
| 在返回之前等待实例处于“正在运行”状态 选择 
 | |
| 定义在使用 _wait_for 方法时等待的秒数 默认值:  | |
| 等待放弃之前的时长(以秒为单位) 默认值:  | 
属性
| 属性 | 支持 | 描述 | 
|---|---|---|
| 支持:完整 | 可以在  | |
| 支持:无 | 在差异模式下,将返回有关已更改的内容(或可能需要在  | 
示例
- name: Create a monitoring policy
  community.general.oneandone_monitoring_policy:
    auth_token: oneandone_private_api_key
    name: ansible monitoring policy
    description: Testing creation of a monitoring policy with ansible
    email: your@emailaddress.com
    agent: true
    thresholds:
     -
       cpu:
         warning:
           value: 80
           alert: false
         critical:
           value: 92
           alert: false
     -
       ram:
         warning:
           value: 80
           alert: false
         critical:
           value: 90
           alert: false
     -
       disk:
         warning:
           value: 80
           alert: false
         critical:
           value: 90
           alert: false
     -
       internal_ping:
         warning:
           value: 50
           alert: false
         critical:
           value: 100
           alert: false
     -
       transfer:
         warning:
           value: 1000
           alert: false
         critical:
           value: 2000
           alert: false
    ports:
     -
       protocol: TCP
       port: 22
       alert_if: RESPONDING
       email_notification: false
    processes:
     -
       process: test
       alert_if: NOT_RUNNING
       email_notification: false
    wait: true
- name: Destroy a monitoring policy
  community.general.oneandone_monitoring_policy:
    auth_token: oneandone_private_api_key
    state: absent
    name: ansible monitoring policy
- name: Update a monitoring policy
  community.general.oneandone_monitoring_policy:
    auth_token: oneandone_private_api_key
    monitoring_policy: ansible monitoring policy
    name: ansible monitoring policy updated
    description: Testing creation of a monitoring policy with ansible updated
    email: another@emailaddress.com
    thresholds:
     -
       cpu:
         warning:
           value: 70
           alert: false
         critical:
           value: 90
           alert: false
     -
       ram:
         warning:
           value: 70
           alert: false
         critical:
           value: 80
           alert: false
     -
       disk:
         warning:
           value: 70
           alert: false
         critical:
           value: 80
           alert: false
     -
       internal_ping:
         warning:
           value: 60
           alert: false
         critical:
           value: 90
           alert: false
     -
       transfer:
         warning:
           value: 900
           alert: false
         critical:
           value: 1900
           alert: false
    wait: true
    state: update
- name: Add a port to a monitoring policy
  community.general.oneandone_monitoring_policy:
    auth_token: oneandone_private_api_key
    monitoring_policy: ansible monitoring policy updated
    add_ports:
     -
       protocol: TCP
       port: 33
       alert_if: RESPONDING
       email_notification: false
    wait: true
    state: update
- name: Update existing ports of a monitoring policy
  community.general.oneandone_monitoring_policy:
    auth_token: oneandone_private_api_key
    monitoring_policy: ansible monitoring policy updated
    update_ports:
     -
       id: existing_port_id
       protocol: TCP
       port: 34
       alert_if: RESPONDING
       email_notification: false
     -
       id: existing_port_id
       protocol: TCP
       port: 23
       alert_if: RESPONDING
       email_notification: false
    wait: true
    state: update
- name: Remove a port from a monitoring policy
  community.general.oneandone_monitoring_policy:
    auth_token: oneandone_private_api_key
    monitoring_policy: ansible monitoring policy updated
    remove_ports:
     - port_id
    state: update
- name: Add a process to a monitoring policy
  community.general.oneandone_monitoring_policy:
    auth_token: oneandone_private_api_key
    monitoring_policy: ansible monitoring policy updated
    add_processes:
     -
       process: test_2
       alert_if: NOT_RUNNING
       email_notification: false
    wait: true
    state: update
- name: Update existing processes of a monitoring policy
  community.general.oneandone_monitoring_policy:
    auth_token: oneandone_private_api_key
    monitoring_policy: ansible monitoring policy updated
    update_processes:
     -
       id: process_id
       process: test_1
       alert_if: NOT_RUNNING
       email_notification: false
     -
       id: process_id
       process: test_3
       alert_if: NOT_RUNNING
       email_notification: false
    wait: true
    state: update
- name: Remove a process from a monitoring policy
  community.general.oneandone_monitoring_policy:
    auth_token: oneandone_private_api_key
    monitoring_policy: ansible monitoring policy updated
    remove_processes:
     - process_id
    wait: true
    state: update
- name: Add server to a monitoring policy
  community.general.oneandone_monitoring_policy:
    auth_token: oneandone_private_api_key
    monitoring_policy: ansible monitoring policy updated
    add_servers:
     - server id or name
    wait: true
    state: update
- name: Remove server from a monitoring policy
  community.general.oneandone_monitoring_policy:
    auth_token: oneandone_private_api_key
    monitoring_policy: ansible monitoring policy updated
    remove_servers:
     - server01
    wait: true
    state: update
返回值
常见的返回值记录在 此处,以下是此模块特有的字段
| 键 | 描述 | 
|---|---|
| 有关已处理的监控策略的信息 返回: 总是 示例:  | 
