Ad Widget

Collapse

Removing dead or "phantom" hosts from Zabbix

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jmedlock
    Junior Member
    • Mar 2021
    • 6

    #1

    Removing dead or "phantom" hosts from Zabbix

    Zabbix Server: 5.2
    Database Engine: mariadb (MySQL)
    Problem: Hosts that have been decommissioned or are no longer in service, reappear in device list after being deleted

    I searched long and hard on this and kept running into dead ends or forums that had a question but no answer. So I decided to look at the
    database to see if maybe I can find an answer. Well, I looked at the
    Code:
    zabbix.dhosts
    and the
    Code:
    zabbix.dservices
    tables. But when I tried to
    remove devices manually, I kept on getting an error because of the Foreign Key. Well, I found an obscure article by complete accident
    that had the answer to my problem. Below is the queries that I put into my mysql instance:

    Code:
    SET FOREIGN_KEY_CHECKS = 0;
    TRUNCATE table $table_name;
    SET FOREIGN_KEY_CHECKS = 1;
    I'll also put the article that I found at the end of this post. But this is essentially disabling the checks that sql does to the foreign
    keys between tables, truncating the dhosts and dservices (respectively) and re-enabling the foreign keys checks.

    After you truncate the table, you will notice that the "Discovery" menu in Monitoring>Discovery is empty or already re-listing devices that
    are discovered. This will keep you from having to painfully remove a Discovery Rule and readding it.

    Hopefully this helps someone else having this issue.

    Command Source: https://www.edureka.co/community/815...int-references
  • Clontarf[X]
    Member
    • Jan 2017
    • 80

    #2
    This is a great little tip, thanks! As far as the problem of phantom hosts being re-added (I actually raised a ticket for this with Zabbix), I fixed this by adding the condition "Discovery status = Up" to all my discovery checks, and so far the problem has not returned. At first I thought this should be the default behaviour, but there are valid use cases for defining other conditions, for example automatically removing a host in a Down status for a period of time.

    Comment

    Working...