I’m trying to figure out why this does not work. Could anybody please point me to the problem?
Goal: to have a service active for all hosts that have an OS of type DD.
templates.conf:
template Host “generic-DD” {
import “generic-host”
vars.os = “DD”
vars.notification[“mail”] = {
groups = [ “Storage-L3”,“Storage-L2” ]
}
}
hosts.conf:
object Host “serverXXX”{
import “generic-DD”
address = “serverXXX.domain.com ”
vars.has_vtl = true
vars.dc = “datacenter-name”
}
services.conf:
apply Service “FS2 total compression” {
import “generic-service”
display_name = “FS2 total compression factor”
check_command = “check_datadomain”
vars.type = “total_compr”
assign where host.vars.os == “DD”
}
Somehow, this does not show up in the webinterface. What am I doing wrong?
dnsmichi
(Michael Friedrich)
July 15, 2019, 1:21pm
2
Hi,
what’s the output of
icinga2 --version
icinga2 daemon -C
icinga2 object list --type Host --name serverXXX
icinga2 object list --type Service --name *FS2*
Cheers,
Michael
icinga2 --version
icinga2 - The Icinga 2 network monitoring daemon (version: v2.6.3)
Copyright © 2012-2017 Icinga Development Team ( — )
License GPLv2+: GNU GPL version 2 or later < — >
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Application information:
Installation root: /usr
Sysconf directory: /etc
Run directory: /run
Local state directory: /var
Package data directory: /usr/share/icinga2
State path: /var/lib/icinga2/icinga2.state
Modified attributes path: /var/lib/icinga2/modified-attributes.conf
Objects path: /var/cache/icinga2/icinga2.debug
Vars path: /var/cache/icinga2/icinga2.vars
PID path: /run/icinga2/icinga2.pid
System information:
Platform: Red Hat Enterprise Linux Server
Platform version: 7.2 (Maipo)
Kernel: Linux
Kernel version: 3.10.0-327.36.1.el7.x86_64
Architecture: x86_64
Build information:
Compiler: GNU 4.8.5
Build host: unknown
icinga2 daemon -C
information/cli: Icinga application loader (version: v2.6.3)
information/cli: Loading configuration file(s).
information/ConfigItem: Committing config item(s).
information/ConfigItem: Instantiated 1 SyslogLogger.
information/ConfigItem: Instantiated 1 Zone.
information/ConfigItem: Instantiated 1 FileLogger.
information/ConfigItem: Instantiated 1 Endpoint.
information/ConfigItem: Instantiated 290 Notifications.
information/ConfigItem: Instantiated 2 NotificationCommands.
information/ConfigItem: Instantiated 1 ScheduledDowntime.
information/ConfigItem: Instantiated 67 CheckCommands.
information/ConfigItem: Instantiated 1 Downtime.
information/ConfigItem: Instantiated 12 HostGroups.
information/ConfigItem: Instantiated 1 IcingaApplication.
information/ConfigItem: Instantiated 1 EventCommand.
information/ConfigItem: Instantiated 33 Hosts.
information/ConfigItem: Instantiated 8 Users.
information/ConfigItem: Instantiated 4 UserGroups.
information/ConfigItem: Instantiated 3 TimePeriods.
information/ConfigItem: Instantiated 13 ServiceGroups.
information/ConfigItem: Instantiated 364 Services.
information/ConfigItem: Instantiated 1 ExternalCommandListener.
information/ConfigItem: Instantiated 1 IdoMysqlConnection.
information/ConfigItem: Instantiated 1 NotificationComponent.
information/ConfigItem: Instantiated 1 PerfdataWriter.
information/ConfigItem: Instantiated 1 CheckerComponent.
information/ScriptGlobal: Dumping variables to file ‘/var/cache/icinga2/icinga2.vars’
information/cli: Finished validating the configuration file(s).
icinga2 object list --type Host --name serverXXX
Object ‘serverXXX’ of type ‘Host’:
% declared in ‘/etc/icinga2/adient/hosts.conf’, lines 133:1-133:22
__name = “serverXXX”
action_url = “”
address = “serverXXX.domain.com ”
% = modified in ‘/etc/icinga2/adient/hosts.conf’, lines 135:2-135:34
address6 = “”
check_command = “hostalive”
% = modified in ‘/etc/icinga2/adient/templates.conf’, lines 23:2-23:28
check_interval = 60
% = modified in ‘/etc/icinga2/adient/templates.conf’, lines 21:2-21:20
check_period = “”
check_timeout = null
command_endpoint = “”
display_name = “serverXXX”
enable_active_checks = true
enable_event_handler = true
enable_flapping = false
enable_notifications = true
enable_passive_checks = true
enable_perfdata = true
event_command = “”
flapping_threshold = 30
groups = [ ]
icon_image = “”
icon_image_alt = “”
max_check_attempts = 3
% = modified in ‘/etc/icinga2/adient/templates.conf’, lines 20:2-20:23
name = “serverXXX”
notes = “”
notes_url = “”
package = “_etc”
retry_interval = 30
% = modified in ‘/etc/icinga2/adient/templates.conf’, lines 22:2-22:21
templates = [ “serverXXX”, “generic-DD”, “generic-host” ]
% = modified in ‘/etc/icinga2/adient/hosts.conf’, lines 133:1-133:22
% = modified in ‘/etc/icinga2/adient/templates.conf’, lines 75:1-75:26
% = modified in ‘/etc/icinga2/adient/templates.conf’, lines 19:1-19:28
type = “Host”
vars
dc = “datacenter-name”
% = modified in ‘/etc/icinga2/adient/hosts.conf’, lines 137:2-137:17
has_vtl = true
% = modified in ‘/etc/icinga2/adient/hosts.conf’, lines 136:2-136:20
notification
mail
% = modified in ‘/etc/icinga2/adient/templates.conf’, lines 78:2-80:2
groups = [ “Storage-L3”, “Storage-L2” ]
os = “DD”
% = modified in ‘/etc/icinga2/adient/templates.conf’, lines 77:2-77:15
volatile = false
zone = “”
icinga2 object list --type Service --name FS2
dnsmichi
(Michael Friedrich)
July 15, 2019, 2:11pm
4
Config validation and the generated host object looks fairly ok, only the Icinga 2 version is very dated and may contain bugs. I’d suggest to use packages.icinga.com as package source instead of Debian/Ubuntu upstream.
Yea, I know about the version. Issue is that the repos are controlled by a different, very conservative and not cooperative team. Thats really an issue and the reason why I try to work with a version as long as possible.
So, finally you confirmed that I did not fuck up the config. I’ll continue my thinking about this…
dnsmichi
(Michael Friedrich)
July 16, 2019, 6:56am
6
If apply rules don’t match, Icinga logs a warning at least. If it doesn’t, I’d verify if the config files are actually included, e.g. with icinga2 daemon -C -x notice | grep <applyrulefile>.conf
.
Okay. This is completely my fault and I’m very sorry!
I messed up the comments of inactive services and VIM did not display properly that I’m working in a commented area. I now cleaned up the file and everything works as planned.
Thank you!