Nagios: Update plugin for defining hosts and host groups
This renames the check_update_prometheus_hosts plugin to be more representative of what the current functionality does, which is to simply define nagios hosts. This also updates the behavior of the plugin to no longer force a reload of nagios via a hangup signal when attempting to update the hosts file. The result is a significant reduction in the logs output by the Nagios service, which will better enable tracking history of service checks and hosts. Instead of this plugin being run as a recurring check, it can now be run as an init container for the Nagios pod so Nagios has a comprehensive list of its hosts and host groups before starting the service Change-Id: Ife2cdf2112db3798dbde73bafe436ef3c0c8a870 Signed-off-by: Steve Wilkerson <sw5822@att.com>
This commit is contained in:
@@ -113,20 +113,6 @@ def update_config_file(object_file_loc):
|
||||
|
||||
with open(object_file_loc, 'w+') as object_file:
|
||||
object_file.write("{} \n {}".format(nagios_hosts, nagios_hostgroups))
|
||||
reload_nagios()
|
||||
|
||||
|
||||
def reload_nagios():
|
||||
try:
|
||||
# NOTE(srwilkers): We need the worker PIDs parent, which is the
|
||||
# grandparent of the running process
|
||||
worker_pid = os.getpid()
|
||||
grandparent_pid = os.popen("ps -p %d -oppid=" % os.getppid()).read().strip()
|
||||
os.kill(int(grandparent_pid), signal.SIGHUP)
|
||||
except Exception as e:
|
||||
print('Unable to reload Nagios with new host configuration')
|
||||
print('Nagios worker PID: {}. Nagios worker grandparent PID: {}'.format(worker_pid, grandparent_pid))
|
||||
sys.exit(NAGIOS_CRITICAL)
|
||||
|
||||
|
||||
def get_nagios_hostgroups(node_list):
|
Reference in New Issue
Block a user