100 lines
6.0 KiB
Markdown
Executable File
100 lines
6.0 KiB
Markdown
Executable File
|
|
# DNS availability by Zabbix agent
|
|
|
|
## Overview
|
|
|
|
This template is designed for dns availability monitoring by Zabbix agent via host/posh and doesn't require any external scripts.
|
|
|
|
## Requirements
|
|
|
|
- Zabbix version: 6.0 and higher.
|
|
- [`Define user parameters.`](#define-user-parameters)
|
|
|
|
## Tested versions
|
|
|
|
This template has been tested on:
|
|
|
|
- [Debian GNU/Linux 11](http://ftp.debian.org/debian/dists/bullseye/)
|
|
- [Windows 11](https://www.microsoft.com/en-us/windows/windows-11)
|
|
|
|
### Macros used
|
|
|
|
|Name|Description|Default|
|
|
|----|-----------|-------|
|
|
|{$REQUEST}|address to check availability|`google.com`|
|
|
|{$RESOLVER1}|dns to check availability|`ns3-l2.nic.ru`|
|
|
|{$RESOLVER2}|dns to check availability|`ns4-l2.nic.ru`|
|
|
|{$RESOLVER3}|dns to check availability|`ns8-l2.nic.ru`|
|
|
|{$RESOLVER4}|dns to check availability|`ns4-cloud.nic.ru`|
|
|
|{$RESOLVER5}|dns to check availability|`ns8-cloud.nic.ru`|
|
|
|
|
### Items
|
|
|
|
|Name|Description|Type|Key and additional info|
|
|
|----|-----------|----|-----------------------|
|
|
|DNS request|Address for resolve|Calculated|'dns.request'|
|
|
|DNS resolver 1 address|Resolver address|Calculated|'dns.resolver1.address'|
|
|
|DNS resolver 1 available|Availability of address|Zabbix agent|'dns.resolver1.available[{$REQUEST},{$RESOLVER1}]'|
|
|
|DNS resolver 2 address|Resolver address|Calculated|'dns.resolver2.address'|
|
|
|DNS resolver 2 available|Availability of address|Zabbix agent|'dns.resolver2.available[{$REQUEST},{$RESOLVER2}]'|
|
|
|DNS resolver 3 address|Resolver address|Calculated|'dns.resolver3.address'|
|
|
|DNS resolver 3 available|Availability of address|Zabbix agent|'dns.resolver3.available[{$REQUEST},{$RESOLVER3}]'|
|
|
|DNS resolver 4 address|Resolver address|Calculated|'dns.resolver4.address'|
|
|
|DNS resolver 4 available|Availability of address|Zabbix agent|'dns.resolver4.available[{$REQUEST},{$RESOLVER4}]'|
|
|
|DNS resolver 5 address|Resolver address|Calculated|'dns.resolver5.address'|
|
|
|DNS resolver 5 available|Availability of address|Zabbix agent|'dns.resolver5.available[{$REQUEST},{$RESOLVER5}]'|
|
|
|
|
### Triggers
|
|
|
|
|Name|Description|Expression|Severity|Dependencies and additional info|
|
|
|----|-----------|----------|--------|--------------------------------|
|
|
|{ITEM.VALUE1} not resolved by any DNS||length(last(/DNS availability by Zabbix agent/dns.request))>0 and last(/DNS availability by Zabbix agent/dns.resolver1.available[{$REQUEST},{$RESOLVER1}],#1)<>1 and last(/DNS availability by Zabbix agent/dns.resolver2.available[{$REQUEST},{$RESOLVER2}],#1)<>1 and last(/DNS availability by Zabbix agent/dns.resolver3.available[{$REQUEST},{$RESOLVER3}],#1)<>1 and last(/DNS availability by Zabbix agent/dns.resolver4.available[{$REQUEST},{$RESOLVER4}],#1)<>1 and last(/DNS availability by Zabbix agent/dns.resolver5.available[{$REQUEST},{$RESOLVER5}],#1)<>1|High|Manual close: No|
|
|
|{ITEM.VALUE1} not resolved by {ITEM.VALUE2}||length(last(/DNS availability by Zabbix agent/dns.request))>0 and length(last(/DNS availability by Zabbix agent/dns.resolver1.address))>0 and last(/DNS availability by Zabbix agent/dns.resolver1.available[{$REQUEST},{$RESOLVER1}],#1)<>1|Average|Manual close: No|
|
|
|{ITEM.VALUE1} not resolved by {ITEM.VALUE2}||length(last(/DNS availability by Zabbix agent/dns.request))>0 and length(last(/DNS availability by Zabbix agent/dns.resolver2.address))>0 and last(/DNS availability by Zabbix agent/dns.resolver2.available[{$REQUEST},{$RESOLVER2}],#1)<>1|Average|Manual close: No|
|
|
|{ITEM.VALUE1} not resolved by {ITEM.VALUE2}||length(last(/DNS availability by Zabbix agent/dns.request))>0 and length(last(/DNS availability by Zabbix agent/dns.resolver3.address))>0 and last(/DNS availability by Zabbix agent/dns.resolver3.available[{$REQUEST},{$RESOLVER3}],#1)<>1|Average|Manual close: No|
|
|
|{ITEM.VALUE1} not resolved by {ITEM.VALUE2}||length(last(/DNS availability by Zabbix agent/dns.request))>0 and length(last(/DNS availability by Zabbix agent/dns.resolver4.address))>0 and last(/DNS availability by Zabbix agent/dns.resolver4.available[{$REQUEST},{$RESOLVER4}],#1)<>1|Average|Manual close: No|
|
|
|{ITEM.VALUE1} not resolved by {ITEM.VALUE2}||length(last(/DNS availability by Zabbix agent/dns.request))>0 and length(last(/DNS availability by Zabbix agent/dns.resolver5.address))>0 and last(/DNS availability by Zabbix agent/dns.resolver5.available[{$REQUEST},{$RESOLVER5}],#1)<>1|Average|Manual close: No|
|
|
|
|
### Discovery rules
|
|
|
|
There are no discovery rules in this template.
|
|
|
|
### Item prototypes for Clients discovery
|
|
|
|
There are no item prototypes in this template.
|
|
|
|
### Define user parameters
|
|
|
|
for Linux:
|
|
|
|
```bash
|
|
tee -a /etc/zabbix/zabbix_agentd.conf > /dev/null <<'EOF'
|
|
Timeout=30
|
|
UserParameter=dns.resolver1.available[*], host $1 $2 >> /dev/null && echo 1 || echo 0
|
|
UserParameter=dns.resolver2.available[*], host $1 $2 >> /dev/null && echo 1 || echo 0
|
|
UserParameter=dns.resolver3.available[*], host $1 $2 >> /dev/null && echo 1 || echo 0
|
|
UserParameter=dns.resolver4.available[*], host $1 $2 >> /dev/null && echo 1 || echo 0
|
|
UserParameter=dns.resolver5.available[*], host $1 $2 >> /dev/null && echo 1 || echo 0
|
|
EOF
|
|
|
|
systemctl restart zabbix-agent
|
|
```
|
|
|
|
for Windows:
|
|
|
|
```batch
|
|
powershell.exe
|
|
$text = @"
|
|
Timeout=30
|
|
UserParameter=dns.resolver1.available[*], powershell.exe -Command "if (Resolve-DnsName -Name $1 -Type A -Server $2 -ErrorAction SilentlyContinue) {return '1'}; return '0'"
|
|
UserParameter=dns.resolver2.available[*], powershell.exe -Command "if (Resolve-DnsName -Name $1 -Type A -Server $2 -ErrorAction SilentlyContinue) {return '1'}; return '0'"
|
|
UserParameter=dns.resolver3.available[*], powershell.exe -Command "if (Resolve-DnsName -Name $1 -Type A -Server $2 -ErrorAction SilentlyContinue) {return '1'}; return '0'"
|
|
UserParameter=dns.resolver4.available[*], powershell.exe -Command "if (Resolve-DnsName -Name $1 -Type A -Server $2 -ErrorAction SilentlyContinue) {return '1'}; return '0'"
|
|
UserParameter=dns.resolver5.available[*], powershell.exe -Command "if (Resolve-DnsName -Name $1 -Type A -Server $2 -ErrorAction SilentlyContinue) {return '1'}; return '0'"
|
|
"@
|
|
$text | Out-File -Append "$env:ProgramFiles\Zabbix Agent\zabbix_agentd.conf" -Encoding "UTF8"
|
|
exit
|
|
|
|
sc stop "Zabbix Agent" && sc start "Zabbix Agent"
|
|
```
|