Verified Commit d6d71921 authored by Adrian Schollmeyer's avatar Adrian Schollmeyer
Browse files

generator/hosts: Prepare support for custom field remote check configuration

parent b0f905e7
......@@ -52,6 +52,7 @@ class Icinga2Host:
self.xmpp_notifications = []
self.webaccess = []
self.remote_check_method = None
self.nrpe = False
self.apt = None
......@@ -135,6 +136,10 @@ class Icinga2Host:
self.nrpe = True
def set_remote_check_method(self, method):
self.remote_check_method = method
def create_icinga2_config(self):
global j2_env
template = j2_env.get_template("generic-host.j2")
......@@ -238,6 +243,7 @@ class NetBoxParser:
self.host.add_disk_temp)
self.add_apt_check()
self.determine_remote_check_method()
self.add_checks_from_config_context()
......@@ -474,6 +480,21 @@ class NetBoxParser:
pass
def determine_remote_check_method(self):
if self.device:
remote_check_method = self.device.custom_fields["remote_check_method"]
elif self.vm:
remote_check_method = self.vm.custom_fields["remote_check_method"]
else:
assert False, "Object is neither a device nor a VM"
if remote_check_method == "nrpe":
# Backwards compatibility
self.host.enable_nrpe()
self.host.set_remote_check_method(remote_check_method)
def add_checks_from_config_context(self):
try:
if self.device:
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment