You can use puppet-icinga2 which allows collecting information about nodes. On client side you'd create exportable resource (puppet code follows):
@@icinga2::object::host { $::fqdn:
display_name => $::fqdn,
address => $::ipaddress_eth0,
check_command => 'hostalive',
target => "/etc/icinga2/zones.d/${::domain}/hosts.conf",
zone => $::fqdn,
}
@@::icinga2::object::endpoint { "$::fqdn":
host => "$::ipaddress_eth0",
}
@@::icinga2::object::zone { "$::fqdn":
endpoints => [ "$::fqdn", ],
parent => 'master',
}
which will be propagated to master (PuppetDB is required):
Icinga2::Object::Host <<| |>> { }
Icinga2::Object::Endpoint <<| |>> { }
Icinga2::Object::Zone <<| |>> { }
As long as the puppet master has stable DNS you'll have updated zone.conf
. After puppet agent
run on client host information gets registered in PuppetDB. Upon next puppet agent
run on master it will have up-to-date information about the node.
Then you can implement a check from icinga master:
apply Service "ping" to Host {
import "generic-service"
check_command = "ping"
zone = "master" //execute check from master zone
assign where "linux-server" in host.groups
}
Note there are also other automation integrations like Ansible which might offer similar functionality.