mirror of
https://github.com/Icinga/icingaweb2-module-director.git
synced 2026-05-28 04:35:53 -04:00
IcingaConfig: check whether get_host succeeded...
...and warn otherwise fixes #1595
This commit is contained in:
parent
07b07bb26e
commit
fd372c6b62
1 changed files with 22 additions and 5 deletions
|
|
@ -533,18 +533,35 @@ globals.directorWarnOnceForThresholds = function() {
|
|||
|
||||
return sprintf(
|
||||
'
|
||||
if (! globals["DirectorOverrideTemplate"]) {
|
||||
const DirectorOverrideVars = "%s"
|
||||
const DirectorOverrideTemplate = "%s"
|
||||
if (! globals[DirectorOverrideTemplate]) {
|
||||
const DirectorOverrideVars = "%s"
|
||||
|
||||
globals.directorWarnedOnceForServiceWithoutHost = false;
|
||||
globals.directorWarnOnceForServiceWithoutHost = function() {
|
||||
if (globals.directorWarnedOnceForServiceWithoutHost == false) {
|
||||
globals.directorWarnedOnceForServiceWithoutHost = true
|
||||
log(
|
||||
LogWarning,
|
||||
"config",
|
||||
"Director: Custom Variable Overrides will not work in this Icinga 2 version. See Director issue #1579"
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
template Service DirectorOverrideTemplate ignore_on_error {
|
||||
/**
|
||||
* Seems that host is missing when used in a service object, works fine for
|
||||
* apply rules
|
||||
*/
|
||||
if (! host) {
|
||||
var host = get_host(host_name)
|
||||
}
|
||||
try {
|
||||
if (! host) {
|
||||
var host = get_host(host_name)
|
||||
}
|
||||
if (! host) {
|
||||
globals.directorWarnOnceForServiceWithoutHost()
|
||||
}
|
||||
} except { globals.directorWarnOnceForServiceWithoutHost() }
|
||||
|
||||
if (vars) {
|
||||
vars += host.vars[DirectorOverrideVars][name]
|
||||
|
|
|
|||
Loading…
Reference in a new issue