Verified Commit 6c1c6f3a authored by Adrian Schollmeyer's avatar Adrian Schollmeyer
Browse files

generic-host: Retrieve smart drives from NetBox inventory

The NetBox inventory provides a good way to configure which drives are
present in a device and which of them shall be checked with which using
which check script (the latter is done with tags).

This commit updates the information retrieval for smart/smart-sectors
from config context to obtaining a list of inventory items with the tags
monitoring-check-smart and monitoring-check-smart-sectors.
parent bdc16022
......@@ -253,6 +253,19 @@ def create_icinga2_host_object_from_netbox(netbox, device_name):
for ssh_port in ssh_ports:
host.add_ssh(ssh_port)
monitored_inventory_smart = netbox.dcim.inventory_items.filter(
device_id = device.id,
tag = "monitoring-check-smart"
)
for inventory_item in monitored_inventory_smart:
host.add_smart(inventory_item.name)
monitored_inventory_smart_sectors = netbox.dcim.inventory_items.filter(
device_id = device.id,
tag = "monitoring-check-smart-sectors"
)
for inventory_item in monitored_inventory_smart_sectors:
host.add_smart_sectors(inventory_item.name)
try:
monitoring_config_context = device.config_context["monitoring"]
......@@ -269,18 +282,6 @@ def create_icinga2_host_object_from_netbox(netbox, device_name):
except KeyError:
pass
try:
for smart in monitoring_config_context["smart"]:
host.add_smart(smart)
except KeyError:
pass
try:
for smart_sector in monitoring_config_context["smart_sectors"]:
host.add_smart_sectors(smart_sector)
except KeyError:
pass
try:
if monitoring_config_context["nrpe_enabled"]:
host.enable_nrpe()
......
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