Search code examples
zabbix

How are linked userid and hostid in Zabbix database?


I want to create SQL script for DB Zabbix (3.4, MySQL version) where will filter by userid and date and get information about hosts (for example created/changed hosts, add/changed media send information).

How are linked userid and hostid?

p.s.

mediatypeid

select * from zabbix.media med
join zabbix.users us ON us.userid=med.userid
join zabbix.media_type med_t on med_t.mediatypeid=med.mediatypeid
where
1=1
and med_t.mediatypeid=4

auditlog

select FROM_UNIXTIME(log.clock),
log.* from zabbix.auditlog log
join zabbix.users us on us.userid=log.userid

Solution

  • User IDs and host IDs are not directly connected. The best you can hope for is using the information in the auditlog and auditlog_details tables, but keep in mind that many operations are not properly registered in the auditlog, especially in older versions.