Ad Widget

Collapse

How to remove devices older than 24 hours?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • definity
    Junior Member
    • Sep 2021
    • 9

    #1

    How to remove devices older than 24 hours?

    So I have got a ping scan going which is finding the machines fine but since my network is DHCP based that means a lot of hosts often are not of the same IP as the days before.

    How can I make it so old hosts are deleted?

    Thanks.
  • Oz_Joris
    Junior Member
    • Sep 2021
    • 19

    #2
    Hello Definity,

    It's tricky to monitor machines that change IP regularly, I guess you use autoregistration. I wonder if using active Zabbix agents could solve the problem so that Zabbix can modify the interface by itself.

    Hoping to help you, Oz_Joris

    Comment

    • splitek
      Senior Member
      • Dec 2018
      • 101

      #3
      Originally posted by Oz_Joris
      Hello Definity,

      It's tricky to monitor machines that change IP regularly, I guess you use autoregistration. I wonder if using active Zabbix agents could solve the problem so that Zabbix can modify the interface by itself.

      Hoping to help you, Oz_Joris
      To monitor devices with dynamic IP check:
      Zabbix Agent - Active Checks (official Zabbix channel) https://www.youtube.com/watch?v=-QTZVWnx6i4

      The question is how to remove hosts older than 24 hours. I think it is only possible by API. But problem is how to know when host is 24 hours old?

      Comment

      • mdudka
        Junior Member
        • Nov 2020
        • 7

        #4
        What I did to delete the old host in my situation, I had to create a python script that was ran on the Zabbix scripts; which passed the Host Target Macro. To activate the script I had a ICMP Ping Item with a Trigger(to trigger when the ICMP Ping Timesout); within the template's for my host.

        Than I created a Trigger action that was directed to the Zabbix script, which ran the python script and using pyzabbix api with sys arguments as the Host Macros, I could perform API Actions such as deleting update and changing the host that was passed to the script automatically. I have a script for python which I had set up a little bit different, so I manipulated to suite this situation.

        Trigger Condition:
        Code:
        max(/TEMPLATENAME/ICMPPINGITEMKEY,#3)=0
        Replace TEMPLATENAME with the template name of the template
        Replace ICMPPINGITEMKEY with the item key associate with a ICMP Ping Item to the Template

        When you create you zabbix script, Make sure it has the Host Target Macro in the exact position as this example below:
        Code:
        python3 ./home/zabbix/PythonScripts/AutoDeleteHost.py {HOST.TARGET.HOST}
        Save the code as AutoDeleteHost.py
        and don't forget to change your Zabbix username and password in the python script.
        https://pastebin.com/WYJH5JrU
        Last edited by mdudka; 04-11-2021, 21:30.

        Comment

        Working...