Ad Widget

Collapse

Newly-added host not immediately available for adding data

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • michaelNGV
    Junior Member
    • Jul 2022
    • 27

    #1

    Newly-added host not immediately available for adding data

    Hello, in our application we are using in-house software to monitor devices and maintain their status in Zabbix. The in-house software is the source-of-truth for what devices exist so the flow is:

    Code:
    for each device:
        test if it exists in Zabbix and if not, add it with the API `host.create` call, applying a template which gives each host a trapper item and a couple of triggers.
    for each device:
        obtain its 'status' [doesn't matter what that means here] and send a data-point (0 or a 1) as appropriate to the devices trapper item: {"request":"sender data","data":[{"host":"$HOSTNAME","key":"$TRAPPERITEM","value":"0 or 1","clock":epoch}`
    What I've found is that if you send a data point too quickly after creating the host, the data-point is rejected. What I mean is that the response to the `"sender data"` request is:
    Code:
    {"response":"success","info":"processed: 0; failed: 1; total: 1; seconds spent: 0.000022"}
    but if I wait long enough (at least 30 seconds), the response is:
    Code:
    {"response":"success","info":"processed: 1; failed: 0; total: 1; seconds spent: 0.000057"}
    How can I find out, programmatically, when the trapper item is ready to receive data?
  • cyber
    Senior Member
    Zabbix Certified SpecialistZabbix Certified Professional
    • Dec 2006
    • 4807

    #2
    "I think" this is caused by config cache update not yet run.... So no later than "CacheUpdateFrequency" you should be able to send your data. Either have a delay built in or force cache reload on server (https://www.zabbix.com/documentation...server-process)

    Comment

    • michaelNGV
      Junior Member
      • Jul 2022
      • 27

      #3
      It seems strange that Zabbix exposes its internals in this way; it seems that any requests that update Zabbix's state go straight to the database, but don't update the Zabbix server itself.
      Thanks for the link that shows how to force a cache reload via the command-line; is there any programmatic (i.e., API) way to force the reload? I did look but could not see one.

      Comment

      • LenR
        Senior Member
        • Sep 2009
        • 1005

        #4
        You can add a os command call to your program, but the config cache reload must be done on the server and any proxy involved with the host.

        The zabbix API uses the web front-end to interact with the database, the zabbix_server isn't involved.

        Comment

        • michaelNGV
          Junior Member
          • Jul 2022
          • 27

          #5
          OK, thanks, I think I understand ... the API requests go to PHP code which updates the database; the Zabbix server (which as I recall is written in C) is not involved, until it updates itself from the database.

          Comment

          Working...