Gather urls from nginx\apache configs then outputs in Zabbix Low Level Discovery format.
Use --use-data-property
option for Zabbix < 4.2 (see details in Options section).
- Copy
vhdt
to/usr/bin
. - Copy zabbix agent config
vhost-discovery.conf
to/etc/zabbix/zabbix-agent.d/vhost-discovery.conf
- Import
vhost-discovery-template.xml
to Zabbix Server. - Update permissions:
chmod +x /usr/bin/vhdt
chown -R zabbix: /var/log/zabbix
setfacl -Rm u:zabbix:rx /etc/nginx/conf.d
setfacl -Rm u:zabbix:rx /etc/nginx/sites-enabled
- Add
Virtual Hosts
template to target host. - (Optional) Use wszl tool. It creates web-scenarios+triggers based on vhost items.
Tool looking for nginx\apache configuration files then creates data structures for Low Level Discovery:
- domain
- url
Example: server_name toys.com www.toys.com
Domain toys.com
will be collected.
Create issue if you want all domains and explain it.
If your vhost has row:
return 301 http...
Not inside location
directive, it will be excluded from results.
Add _http
postfix for domain with http protocol. For example: http://somesite.ru
will be:
{
"{#NAME}":"somesite.ru_http",
"{#URL}":"http://somesite.ru"
}
Tool ignores hosts which don't have server_name
property.
Option: --work-dir
or -d
Default value: /etc/zabbix
Enable recursive scan for sub-directories.
Option: -r
Default value: false
Option: --nginx-vhosts-path
or -n
Default value: /etc/nginx/conf.d
Option: --apache-vhosts-path
or -a
Default value: /etc/httpd/conf.d
Standard ports: 80, 443
Option: --include-custom-ports
Example: http://somehost.ru:3823
.
Option: --ignore-by-masks
or -i
Example:
vhdt -i "^test,rfid$,demo"
Will ignore vhosts with domain names starts with test
or ends with rfid
or contain demo
.
Zabbix 4.2 has JSON format:
{
"data": []
}
Later versions don't support data
property. Use --use-data-property
option for that.
[
{
"{#NAME}":"somesite.ru",
"{#URL}":"https://somesite.ru"
},
{
"{#NAME}":"15.128.42.21:2231",
"{#URL}":"http://15.128.42.21:2231"
}
]
Log: /var/log/zabbix/vhdt.log
.
Fix:
setfacl -Rm u:zabbix:rx /etc/nginx/conf.d
or
setfacl -Rm u:zabbix:rx /etc/nginx/sites-enabled
Use --log-level
option if you want to switch logging level.
Supported levels: debug
, error
, warn
, trace
, info
, off
--log-level=off
Thanks for project support, testing and feedback: