I have created a discovery that include an item prototype also defines a trigger prototype for this itemprototype. Item prototype will find free space of tables on datatabse . Now I have added this as template to more than 50 hosts . It is working excellent I just need change trigger for such tables on some hosts for example my trigger prototype will fire when free space of each table is les than 1G . but for example on host1 I have table1 also this table exist on host2 now how can define for hosts 2 it does not use from trigger prototype and if free space is less than 10G trigger fire ?
Ad Widget
Collapse
How can override trigger for some items ?
Collapse
X
-
Use custom macros in the trigger expression and override macros at the host level.
-
Thanks . But this is my trigger prototype . As I find out you are saying set value map on the template and override it on the hosts but as you can see I need change value for each items for example want to change trigger on BGTBS to fire if < 30 and for DM_TRANS < 10 for the others without changesUse custom macros in the trigger expression and override macros at the host level.
https://www.zabbix.com/documentation...os/user_macros
Comment
-
Then you need to use user macros with context https://www.zabbix.com/documentation...macros_contextComment
-
As I find out :Then you need to use user macros with context https://www.zabbix.com/documentation...macros_context
At the first step had to define a macro such as {$SIZE} = 1 in my template .
Second step change trigger to last(/TBS/FreeSpace[{#TABLESPACE_NAME}])<{$SIZE} on template
finally we have to add values such as follow
{$SIZE: BGTBS} = 30
{$SIZE: DM_TRANS} = 10
but How should change trigger ?Comment
-
You need to use context already in prototype...
Then you can use general {$SIZE} macro for those Tablespaces where you do not have special context, or don't want to use overridesCode:last(/TBS/FreeSpace[{#TABLESPACE_NAME}])<{$SIZE:"{#TABLESPACE_NAME}"}
and {$SIZE:"<your tablespace name>"} for those cases where you need special value...Comment
-
I am really confused .You need to use context already in prototype...
Then you can use general {$SIZE} macro for those Tablespaces where you do not have special context, or don't want to use overridesCode:last(/TBS/FreeSpace[{#TABLESPACE_NAME}])<{$SIZE:"{#TABLESPACE_NAME}"}
and {$SIZE:"<your tablespace name>"} for those cases where you need special value...
1- As I find out at the first step should add new macro such as {$SIZE} = 1 to my template . Is this correct ?
2- for the next step should change trigger prototype from last(/TBS/FreeSpace[{#TABLESPACE_NAME}])<1 to last(/TBS/FreeSpace[{#TABLESPACE_NAME}])<{$SIZE:"{#TABLESPACE_NAME}"} is this correct ?
3- Finally don't know what is the last step while want to change trigger for some tablespacenames ? Do I have to do changes on each hosts on macro ?Last edited by bab; 18-04-2023, 08:27.Comment
-
1. yes, but it can also be second step..
2. yes
3. If you read the docs on macros with context, then you would notice, that if you create a "general" {$SIZE} macro, it will be used everywhere, where context macro is not defined... You can add also (for example) {$SIZE:"BGTBS"} and {$SIZE:"DM_TRANS"} macros to your template, if you can define values what should fit most of your hosts... for any other mountpoint it will use "general" macro". In case you need to fine tune on host level, you can then add needed macro on host level, which will override template level macro.
This is exactly how contextual macros are used in out-of-the-box templates for filesystems, for example... triggers are created with context, but values for such macros you can define where you need ...
Comment
-
1. yes, but it can also be second step..
2. yes
3. If you read the docs on macros with context, then you would notice, that if you create a "general" {$SIZE} macro, it will be used everywhere, where context macro is not defined... You can add also (for example) {$SIZE:"BGTBS"} and {$SIZE:"DM_TRANS"} macros to your template, if you can define values what should fit most of your hosts... for any other mountpoint it will use "general" macro". In case you need to fine tune on host level, you can then add needed macro on host level, which will override template level macro.
This is exactly how contextual macros are used in out-of-the-box templates for filesystems, for example... triggers are created with context, but values for such macros you can define where you need ...
Thanks. The issue solved just one question
I set this one as event name FreeSpace of Table [{#TABLESPACE_NAME}] is less than {$SIZE:"{#TABLESPACE_NAME}"}G
because I want it detect the size that I have defined as override on the host . Now it is showing 1G for all events although I set {$SIZE:"{#TBSB}"} = 6 on host1 .
How can fix it ?Last edited by bab; 18-04-2023, 23:24.Comment
-
I changed it such as : FreeSpace of Table [{#TABLESPACE_NAME}] is less than {$SIZE}G but another trigger fires with FreeSpace of Table [TBSSPOT] is less than 1G although I set it trigger if less than 5 on this hostComment
-
You still did not notice, what I wrote and what you configured?
Set your trigger name as "FreeSpace of Table [{#TABLESPACE_NAME}] is less than {$SIZE:"{#TABLESPACE_NAME}"}G"
(I hope your trigger expression is still "last(/TBS/FreeSpace[{#TABLESPACE_NAME}])<{$SIZE:"{#TABLESPACE_NAME}"}" ?? )
Create macro {$SIZE} with value 1
Create macro {$SIZE:"TBSSPOT"} with value 5
(additionally) Create macro for any tablespace, what needs a value different from general {$SIZE} macro...
Observe how triggers behave...Comment
-
You still did not notice, what I wrote and what you configured?
Set your trigger name as "FreeSpace of Table [{#TABLESPACE_NAME}] is less than {$SIZE:"{#TABLESPACE_NAME}"}G"
(I hope your trigger expression is still "last(/TBS/FreeSpace[{#TABLESPACE_NAME}])<{$SIZE:"{#TABLESPACE_NAME}"}" ?? )
Create macro {$SIZE} with value 1
Create macro {$SIZE:"TBSSPOT"} with value 5
(additionally) Create macro for any tablespace, what needs a value different from general {$SIZE} macro...
Observe how triggers behave...
Thanks. But before that I was created Create macro {$SIZE:"TBSSPOT"} with value 5 on specific host (override) . But after trigger another shows FreeSpace of Table [TBSSPOT] is less than 1G . Do I have to also add {$SIZE} with value 1 on this host as I have added {$SIZE} with value 1 to template before that.
Comment
-
If you have a macro in template, then you don't need to add it on host level. You should do that only if you want to override a value set in a template macro.. If you have a macro already in host level it will take precedence over the template level macro...
Its all there in docs..Zabbix resolves macros according to the following precedence:- host level macros (checked first)
- macros defined for first level templates of the host (i.e., templates linked directly to the host), sorted by template ID
- macros defined for second level templates of the host, sorted by template ID
- macros defined for third level templates of the host, sorted by template ID, etc.
- global macros (checked last)
In other words, if a macro does not exist for a host, Zabbix will try to find it in the host templates of increasing depth. If still not found, a global macro will be used, if exists.
Comment
Comment