def findDeletedHosts(hostgroup, hosts, ignoredHosts): deletedHosts = [] hostConfigs = server_utils.getHostConfigsForCluster(hostgroup) for hostConfig in hostConfigs: if hostConfig.get('_HOST_UUID') not in ignoredHosts: host = findHostInList(hosts, hostConfig['host_name']) if host is None: deletedHosts.append({'host_name': hostConfig['host_name'], CHANGE_MODE: CHANGE_MODE_REMOVE}) return deletedHosts
def findDeletedHosts(hostgroup, hosts, ignoredHosts): deletedHosts = [] hostConfigs = server_utils.getHostConfigsForCluster(hostgroup) for hostConfig in hostConfigs: if hostConfig.get('_HOST_UUID') not in ignoredHosts: host = findHostInList(hosts, hostConfig['host_name']) if host is None: deletedHosts.append({ 'host_name': hostConfig['host_name'], CHANGE_MODE: CHANGE_MODE_REMOVE }) return deletedHosts
confirmation = getConfirmation( "Do you want to restart Nagios to start monitoring " "newly discovered entities?", "Yes") if confirmation: server_utils.restartNagios() print "Nagios re-started successfully" else: print " CONFIG ERROR! Check your Nagios configuration." sys.exit(utils.PluginStatusCode.CRITICAL) else: print "Start the Nagios service to monitor" # auto mode means write the configurations without asking confirmation elif args.mode == "auto": removed_hosts_count = getRemovedHostsCount(clusterDelta) if removed_hosts_count > 0: hostsInCluster = server_utils.getHostConfigsForCluster( args.cluster) if removed_hosts_count == (len(hostsInCluster) - 1): print "Can't remove all hosts except sync host in " \ "'auto' mode. Run auto discovery manually" sys.exit(utils.PluginStatusCode.CRITICAL) writeDelta(clusterDelta, configManager, args.force, args.nagiosServerIP, args.mode, args.timeout) msg = "Cluster configurations synced successfully from host %s" % \ (args.hostip) print msg msg += formatTextForMail(getSummary(clusterDelta)) sendCustomNotification(args.cluster, msg) if server_utils.isNagiosRunning(): if _verifyNagiosConfig(): server_utils.restartNagios() else: