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:
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
In that discovery rule I have created an item prototype as a dependent item with the key
and the preprocessing rule
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
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
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}]
Code:
host.node.status.[{#ID}]
Code:
$[?(@.id=={#ID})].criticality_id.first()
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
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
Comment