Changeset View
Changeset View
Standalone View
Standalone View
site-modules/profile/manifests/opnsense/monitoring.pp
# Configure the icinga checks and prometheus endpoints for the firewalls | # Configure the icinga checks and prometheus endpoints for the firewalls | ||||
class profile::opnsense::monitoring { | class profile::opnsense::monitoring { | ||||
$fw_hosts = lookup('opnsense::hosts') | $fw_hosts = lookup('opnsense::hosts') | ||||
$fw_prometheus_port = lookup('opnsense::prometheus::port') | $fw_prometheus_port = lookup('opnsense::prometheus::port') | ||||
$fw_prometheus_metrics_path = lookup('opnsense::prometheus::metrics_path') | $fw_prometheus_metrics_path = lookup('opnsense::prometheus::metrics_path') | ||||
$icinga_checks_file = lookup('icinga2::exported_checks::filename') | $icinga_checks_file = lookup('icinga2::exported_checks::filename') | ||||
$icinga_zonename = lookup('icinga2::master::zonename') | $icinga_zonename = lookup('icinga2::master::zonename') | ||||
$fw_hosts.each | $host, $config | { | $fw_hosts.each | $host, $config | { | ||||
$fqdn = $config['fqdn'] | $fqdn = $config['fqdn'] | ||||
$ip = $config['ip'] | $ip = $config['ip'] | ||||
$target = "${fqdn}:${fw_prometheus_port}" | $target = "${fqdn}:${fw_prometheus_port}" | ||||
profile::prometheus::export_scrape_config { $fqdn : | $prometheus_labels = { | ||||
'instance' => $fqdn, # override the instance name to use the fw name instead of pergamon | |||||
} | |||||
profile::prometheus::export_scrape_config { "firewall_${fqdn}" : | |||||
job => 'firewall', | |||||
target => $target, | target => $target, | ||||
scheme => 'http', | scheme => 'http', | ||||
metrics_path => $fw_prometheus_metrics_path, | metrics_path => $fw_prometheus_metrics_path, | ||||
labels => $prometheus_labels, | |||||
} | } | ||||
::icinga2::object::host {$fqdn: | ::icinga2::object::host {$fqdn: | ||||
display_name => $fqdn, | display_name => $fqdn, | ||||
check_command => 'hostalive', | check_command => 'hostalive', | ||||
address => $ip, | address => $ip, | ||||
target => "/etc/icinga2/zones.d/${icinga_zonename}/${fqdn}.conf", | target => "/etc/icinga2/zones.d/${icinga_zonename}/${fqdn}.conf", | ||||
} | } | ||||
Show All 18 Lines |