Ad Widget

Collapse

Managing the number of instances and scheduling for script

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Vitus9856
    Junior Member
    • Jul 2022
    • 2

    #1

    Managing the number of instances and scheduling for script

    There are many hosts, each of which has an item.
    This item have an External Check, which uses a script that returns Numeric (unsigned), which is used in the trigger.
    The frequency of the poll is 1 time per day.
    There are hundreds of such hosts.
    The script polls the whois service, and with intensive polling gets a timeout
    Is there a way to limit script usage in Zabbix to one thread at a time?
    Is there a way to spread the execution of the script throughout the day for different hosts without creating a custom schedule
    Any advice on how to get around this problem?
  • Markku
    Senior Member
    Zabbix Certified SpecialistZabbix Certified ProfessionalZabbix Certified Expert
    • Sep 2018
    • 1781

    #2
    In similar situations instead of using a normal polled item I have used Zabbix trapper item and an external script. I have scheduled that script to run independent of Zabbix using cron, and the script sends the result with zabbix_sender command (or using a Python library). That way I can fully control the execution of the script, and there is no timeout limitations.

    In your case it would be something like this:
    1. The hosts are configured with the trapper items and the triggers
    2. The script is scheduled to run once a day (running for example on the Zabbix server, or wherever suitable)
    3. The script uses Zabbix API to fetch the list of the hosts that need to be handled (filtering using host groups, tags, or something else), or you can even use a hard-coded list of hosts if the list is static
    4. The script executes the whois query one at a time for each of the hosts, sending the results to Zabbix server with zabbix_sender, sleeping for example 5 seconds between each whois query (or whatever value works in the case, as long as the whole script completes before it is started again next day) to prevent rate limiting

    Markku

    Comment

    Working...