Page 1 of 1
custom variables reset with an 'Apply Configuration'?
Posted: Wed Apr 20, 2016 8:08 am
by mon-team
Hi,
I've created a custom variable inside a service template, the variable is inherited by the services using this service template.
The default value is zero.
I'd like to use this variable to store a specific value, different for each service. The important thing is that this value should be stored.
However I've seen that after an 'Apply configuration' the value is restored (for all services) at the default value (zero).
Is this behavior correct?
Is there a way to indicate Nagios that the value must not be restored?
Has someone an idea on how to get the result I'm expecting for?
Regards,
Francesco
Re: custom variables reset with an 'Apply Configuration'?
Posted: Wed Apr 20, 2016 11:41 am
by rkennedy
As an example, can you post the template you're using?
Just to clarify -- are you looking to have a variable saved on-going throughout service restarts?
Re: custom variables reset with an 'Apply Configuration'?
Posted: Wed Apr 20, 2016 12:12 pm
by mon-team
Hi rkennedy,
thanks for your quick reply.
I defined the '_HIDDEN' custom variable in the following template
define service {
name BPPM relationship
service_description Define a custom variable to decide if sending an event to BPPM
use generic-service
_HIDDEN 0
register 0
}
I changed to 1 the variable value for a specific service (which uses this template), by running the external command CHANGE_CUSTOM_SVC_VAR. After launching an 'apply configuration', the variable value has been set back to 0.
I 'd like to keep the saved variable value even after service restarts.
Re: custom variables reset with an 'Apply Configuration'?
Posted: Wed Apr 20, 2016 12:32 pm
by tmcdonald
This looks awfully similar to your other thread which I addressed:
https://support.nagios.com/forum/viewto ... 58#p180358
Please in the future only open one thread per issue so we can focus our efforts in one places instead of two.
Re: custom variables reset with an 'Apply Configuration'?
Posted: Wed Apr 20, 2016 1:01 pm
by rkennedy
To add to what @tmcdonald mentioned - this is expected behavior. I just finished confirming with our development team. If you're looking to store dynamic variables, you'll need to do so a different way.
Re: custom variables reset with an 'Apply Configuration'?
Posted: Thu Apr 21, 2016 2:14 am
by mon-team
Hi all,
sorry for the double post @tmcdonald!
Thanks for the information, the situation is now clear to me.
Do you have any suggestion about storing dynamic variables?
Re: custom variables reset with an 'Apply Configuration'?
Posted: Thu Apr 21, 2016 11:56 am
by rkennedy
You could probably do so fairly easily with flat files, depending on what the information is / how it is used.
Can you provide a bit more information so we can understand what you're looking to accomplish?
Re: custom variables reset with an 'Apply Configuration'?
Posted: Thu Apr 21, 2016 12:37 pm
by mon-team
Hi,
we want to associate a variable to a service. This variable has to be readable and writeable by external scripts which execute some actions based on the variable value.
In the previous example the custom variable _HIDDEN, is used as a flag. An external script (used as event handler), checks if the service is in UNKNOWN state and has "not valid value" as Status information. If so, it sets the variable to 1 and exits, otherwise it execute an action on an third-party tool.
A second external script periodically calculates the number of services having _HIDDEN=1 and the number of those having _HIDDEN=0.
How can we do that?
Re: custom variables reset with an 'Apply Configuration'?
Posted: Thu Apr 21, 2016 5:03 pm
by ssax
The only way I can think of is like rkennedy stated, you would need to write it out to a file (or a DB if you're so inclined).