Ad Widget

Collapse

Monitoring nodes status from a database view

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • vg1228
    Junior Member
    • Mar 2024
    • 2

    #1

    Monitoring nodes status from a database view

    Hi everyone,

    I am currently running zabbix 6.0.22 and have been tasked to monitor a list of nodes. The data source for those nodes is a view in a database, said view only lists the nodes that are reporting an error.
    In the view we have, amongst other things:
    • name
    • id
    • value
    • unit
    • criticality_id

    I have so far created a master item (Type: External check) that executes a script that reads the view and prints a JSON output.

    I have also created a discovery rule as a dependent item with macros to map all the fields listed above ($.field_name) and with the key
    Code:
    host.node.[{#ID}]
    In that discovery rule I have created an item prototype as a dependent item with the key
    Code:
    host.node.status.[{#ID}]
    and the preprocessing rule
    Code:
    $[?(@.id=={#ID})].criticality_id.first()
    to capture the criticality_id as a value for the item (discover and create enabled are both checked).
    There are also 4 trigger prototypes corresponding to the 4 possible values of criticality_id that trigger the right level (info, warn crit, ...) from the value of the item. The trigger prototypes all use an expression like
    Code:
    last(/host1/host.node.status.[{#ID}])=4 and nodata(/host1/host.node.status.[{#ID}],310)=0
    the nodata clause after the "and" will stop alerting when the node is no longer in the view.

    All this seem to work properly, I get the alerts and the recovery notifications, however there is one detail that I have not been able to fix/work out.

    As I understand the discovery rule will only create the items/triggers but the value will not be populated until the next execution of the script of the master item. Which means that if I target an execution every 5 minutes the alert itself will not get triggered before 2 execution and in the worst case ~14 minutes after the view itself has been updated. Is it possible to retrieve and use the value on discovering the items and not have to wait for two executions of the master item script or force another execution of the script? Am I going about this completely wrong ?

    Thanks for reading and for any input you might have.

    Regards,

    Vincent
  • Hamardaban
    Senior Member
    Zabbix Certified SpecialistZabbix Certified Professional
    • May 2019
    • 2713

    #2
    You understand correctly.
    There is one trick: you need to poll the master item often, and in the LLD rule in preprocessing, the first step is to remove all frequently changing keys\values from json and the second step is to discard the value what has not changed.
    This is so that the detection does not work too often, but the data is received often.

    Comment

    • vg1228
      Junior Member
      • Mar 2024
      • 2

      #3
      Hi,
      Thanks for your reply, I will give that a shot and report back. Sorry for the delay the notification email escaped me.
      Vincent

      Comment

      Working...