Module: Zabbix::DnsMonitor

Extended by:
ActiveSupport::Concern
Includes:
Connector
Defined in:
lib/zabbix/dns_monitor.rb

Instance Method Summary collapse

Methods included from Connector

#authenticate_with_cookie, #delete_host_monitor, #delete_trigger_monitor, #zabbix_connector, #zabbix_token

Instance Method Details

#dns_trigger_expression(name) ⇒ Object

生成 DNS 触发器表达式



12
13
14
15
16
17
18
19
20
# File 'lib/zabbix/dns_monitor.rb', line 12

def dns_trigger_expression(name)
  # 定义告警规则
  expression = "{dns_query_with_localdns:net.dns.record[,#{name},A,2,2].diff()}=1 or {dns_query_with_localdns:net.dns.record[,#{name},A,2,2].nodata(5m)}=1"

  # 定义告警恢复规则
  recovery_expression = "{dns_query_with_localdns:net.dns.record[,#{name},A,2,2].diff()}=0 and {dns_query_with_localdns:net.dns.record[,#{name},A,2,2].nodata(5m)}= 0"
  # 返回计算结果
  [expression, recovery_expression]
end