本节重点介绍 :

  • ssh探测和icmp探测的配置方法
  • 探测模块中可以使用query_response,过滤响应中的字符串,来决定探测是否成功

ssh探测

配置方法

- job_name: 'blackbox-ssh'
    # metrics的path 注意不都是/metrics
    metrics_path: /probe
    # 传入的参数
    params:
      # 使用ssh_banner模块
      module: [ssh_banner] 
    static_configs:
      - targets:
        - ip1:22   
        - ip2:22  
    relabel_configs:
      - source_labels: [__address__]
        target_label: __param_target
      - source_labels: [__param_target]
        target_label: instance
      - target_label: __address__
        replacement: blackbox_exporter:9115  # The blackbox exporter's real hostname:port.
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.

原理解析

  • 使用ssh_banner模块,对应tcp探针
  • 看配置说明要求返回值中有SSH-2.0-字符串则为探测成功
ssh_banner:
        prober: tcp

        tcp:
            ip_protocol_fallback: true
            query_response:
                - expect: ^SSH-2.0-
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 结果截图

icmp探测

配置方法

- job_name: 'blackbox_icmp'
    metrics_path: /probe
    params:
      module: [icmp]
    static_configs:
      - targets:
        - ip1
        - ip2
        - baidu.com
    relabel_configs:
      - source_labels: [__address__]
        target_label: __param_target
      - source_labels: [__param_target]
        target_label: instance
      - target_label: __address__
        replacement: 127.0.0.1:9115  # The blackbox exporter's real hostname:port.
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.

原理解析

  • 使用icmp模块,对应icmp探针
  • 结果截图

本节重点总结 :

  • ssh探测和icmp探测的配置方法
  • 探测模块中可以使用query_response,过滤响应中的字符串,来决定探测是否成功