Exemplo n.º 1
0
/* handles a host that has stopped flapping */
void clear_host_flap(host *hst, double percent_change, double high_threshold, double low_threshold)
{

	if (hst == NULL)
		return;

	log_debug_info(DEBUGL_FLAPPING, 1, "Host '%s' stopped flapping.\n", hst->name);

	/* log a notice - this one is parsed by the history CGI */
	nm_log(NSLOG_INFO_MESSAGE, "HOST FLAPPING ALERT: %s;STOPPED; Host appears to have stopped flapping (%2.1f%% change < %2.1f%% threshold)\n", hst->name, percent_change, low_threshold);

	/* delete the comment we added earlier */
	if (hst->flapping_comment_id != 0)
		delete_host_comment(hst->flapping_comment_id);
	hst->flapping_comment_id = 0;

	/* clear the flapping indicator */
	hst->is_flapping = FALSE;

	broker_flapping_data(NEBTYPE_FLAPPING_STOP, NEBFLAG_NONE, NEBATTR_FLAPPING_STOP_NORMAL, HOST_FLAPPING, hst, percent_change, high_threshold, low_threshold);

	/* send a notification */
	host_notification(hst, NOTIFICATION_FLAPPINGSTOP, NULL, NULL, NOTIFICATION_OPTION_NONE);

	/* should we send a recovery notification? */
	if (hst->check_flapping_recovery_notification == TRUE && hst->current_state == STATE_UP)
		host_notification(hst, NOTIFICATION_NORMAL, NULL, NULL, NOTIFICATION_OPTION_NONE);

	/* clear the recovery notification flag */
	hst->check_flapping_recovery_notification = FALSE;

	return;
}
Exemplo n.º 2
0
/* deletes a scheduled host or service downtime entry from the list in memory */
int delete_downtime(int type, unsigned long downtime_id) {
	scheduled_downtime *this_downtime = NULL;

	/* find the downtime we should remove */
	this_downtime = find_downtime(type, downtime_id);
	if(!this_downtime)
		return ERROR;

	downtime_remove(this_downtime);

	/* first remove the comment associated with this downtime */
	if(this_downtime->type == HOST_DOWNTIME)
		delete_host_comment(this_downtime->comment_id);
	else
		delete_service_comment(this_downtime->comment_id);

#ifdef USE_EVENT_BROKER
	/* send data to event broker */
	broker_downtime_data(NEBTYPE_DOWNTIME_DELETE, NEBFLAG_NONE, NEBATTR_NONE, type, this_downtime->host_name, this_downtime->service_description, this_downtime->entry_time, this_downtime->author, this_downtime->comment, this_downtime->start_time, this_downtime->end_time, this_downtime->fixed, this_downtime->triggered_by, this_downtime->duration, downtime_id, NULL);
#endif

	/* free memory */
	my_free(this_downtime->host_name);
	my_free(this_downtime->service_description);
	my_free(this_downtime->author);
	my_free(this_downtime->comment);
	my_free(this_downtime);
	return OK;
	}
Exemplo n.º 3
0
/* deletes a scheduled host or service downtime entry from the list in memory */
int delete_downtime(int type, unsigned long downtime_id) {
	int result = OK;
	scheduled_downtime *this_downtime = NULL;
	scheduled_downtime *last_downtime = NULL;
	scheduled_downtime *next_downtime = NULL;

#ifdef NSCORE
	pthread_mutex_lock(&icinga_downtime_lock);
#endif

	/* find the downtime we should remove */
	for (this_downtime = scheduled_downtime_list, last_downtime = scheduled_downtime_list; this_downtime != NULL; this_downtime = next_downtime) {
		next_downtime = this_downtime->next;

		/* we found the downtime we should delete */
		if (this_downtime->downtime_id == downtime_id && this_downtime->type == type)
			break;

		last_downtime = this_downtime;
	}

	/* remove the downtime from the list in memory */
	if (this_downtime != NULL) {

		/* first remove the comment associated with this downtime */
		if (this_downtime->type == HOST_DOWNTIME)
			delete_host_comment(this_downtime->comment_id);
		else
			delete_service_comment(this_downtime->comment_id);

#ifdef USE_EVENT_BROKER
		/* send data to event broker */
		broker_downtime_data(NEBTYPE_DOWNTIME_DELETE, NEBFLAG_NONE, NEBATTR_NONE, type, this_downtime->host_name, this_downtime->service_description, this_downtime->entry_time, this_downtime->author, this_downtime->comment, this_downtime->start_time, this_downtime->end_time, this_downtime->fixed, this_downtime->triggered_by, this_downtime->duration, downtime_id, NULL, this_downtime->is_in_effect, this_downtime->trigger_time);
#endif

		if (scheduled_downtime_list == this_downtime)
			scheduled_downtime_list = this_downtime->next;
		else
			last_downtime->next = next_downtime;

		/* free memory */
		my_free(this_downtime->host_name);
		my_free(this_downtime->service_description);
		my_free(this_downtime->author);
		my_free(this_downtime->comment);
		my_free(this_downtime);

		result = OK;
	} else
		result = ERROR;

#ifdef NSCORE
	pthread_mutex_unlock(&icinga_downtime_lock);
#endif

	return result;
}
Exemplo n.º 4
0
/* handles a host that has stopped flapping */
void clear_host_flap(host *hst, double percent_change, double high_threshold, double low_threshold, int is_disabled) {

	log_debug_info(DEBUGL_FUNCTIONS, 0, "clear_host_flap()\n");

	if(hst == NULL)
		return;

	if (is_disabled == 0) {
		log_debug_info(DEBUGL_FLAPPING, 1, "Host '%s' stopped flapping.\n", hst->name);
		/* log a notice - this one is parsed by the history CGI */
		logit(NSLOG_INFO_MESSAGE, FALSE, "HOST FLAPPING ALERT: %s;STOPPED; Host appears to have stopped flapping (%2.1f%% change < %2.1f%% threshold)\n", hst->name, percent_change, low_threshold);
	} else {
		log_debug_info(DEBUGL_FLAPPING, 1, "Disabled flap detection for host '%s'.\n", hst->name);
		/* log a notice - this one is parsed by the history CGI */
		logit(NSLOG_INFO_MESSAGE, FALSE, "HOST FLAPPING ALERT: %s;STOPPED; Disabled flap detection\n", hst->name);
	}

	/* delete the comment we added earlier */
	if(hst->flapping_comment_id != 0)
		delete_host_comment(hst->flapping_comment_id);
	hst->flapping_comment_id = 0;

	/* clear the flapping indicator */
	hst->is_flapping = FALSE;

#ifdef USE_EVENT_BROKER
	/* send data to event broker */
	broker_flapping_data(NEBTYPE_FLAPPING_STOP, NEBFLAG_NONE, NEBATTR_FLAPPING_STOP_NORMAL, HOST_FLAPPING, hst, percent_change, high_threshold, low_threshold, NULL);
#endif

	if (is_disabled == 0) {
		/* send a notification */
		host_notification(hst, NOTIFICATION_FLAPPINGSTOP, NULL, NULL, NOTIFICATION_OPTION_NONE);

		/* should we send a recovery notification? */
		if(hst->check_flapping_recovery_notification == TRUE && hst->current_state == HOST_UP)
			host_notification(hst, NOTIFICATION_NORMAL, NULL, NULL, NOTIFICATION_OPTION_NONE);
	}

	/* clear the recovery notification flag */
	hst->check_flapping_recovery_notification = FALSE;

	return;
	}
Exemplo n.º 5
0
/* handles the details for a host when flap detection is disabled (globally or per-host) */
void handle_host_flap_detection_disabled(host *hst)
{

	log_debug_info(DEBUGL_FUNCTIONS, 0, "handle_host_flap_detection_disabled()\n");

	if (hst == NULL)
		return;

	/* if the host was flapping, remove the flapping indicator */
	if (hst->is_flapping == TRUE) {

		hst->is_flapping = FALSE;

		/* delete the original comment we added earlier */
		if (hst->flapping_comment_id != 0)
			delete_host_comment(hst->flapping_comment_id);
		hst->flapping_comment_id = 0;

		/* log a notice - this one is parsed by the history CGI */
		logit(NSLOG_INFO_MESSAGE, FALSE, "HOST FLAPPING ALERT: %s;DISABLED; Flap detection has been disabled\n", hst->name);

#ifdef USE_EVENT_BROKER
		/* send data to event broker */
		broker_flapping_data(NEBTYPE_FLAPPING_STOP, NEBFLAG_NONE, NEBATTR_FLAPPING_STOP_DISABLED, HOST_FLAPPING, hst, hst->percent_state_change, 0.0, 0.0, NULL);
#endif

		/* send a notification */
		host_notification(hst, NOTIFICATION_FLAPPINGDISABLED, NULL, NULL, NOTIFICATION_OPTION_NONE);

		/* should we send a recovery notification? */
		if (hst->check_flapping_recovery_notification == TRUE && hst->current_state == HOST_UP)
			host_notification(hst, NOTIFICATION_NORMAL, NULL, NULL, NOTIFICATION_OPTION_NONE);

		/* clear the recovery notification flag */
		hst->check_flapping_recovery_notification = FALSE;
	}

	/* update host status */
	update_host_status(hst, FALSE);

	return;
}
Exemplo n.º 6
0
/* handles a host that has stopped flapping */
void clear_host_flap(host *hst, double percent_change, double high_threshold, double low_threshold) {

	log_debug_info(DEBUGL_FUNCTIONS, 0, "clear_host_flap()\n");

	if (hst == NULL)
		return;

	log_debug_info(DEBUGL_FLAPPING, 1, "主机 '%s' 已停止抖动.\n", hst->name);

	/* log a notice - this one is parsed by the history CGI */
	logit(NSLOG_INFO_MESSAGE, FALSE, "主机抖动警告: %s;停止; 主机似乎已经停止抖动 (%2.1f%% 变化 < %2.1f%% 阙值)\n", hst->name, percent_change, low_threshold);

	/* delete the comment we added earlier */
	if (hst->flapping_comment_id != 0)
		delete_host_comment(hst->flapping_comment_id);
	hst->flapping_comment_id = 0;

	/* clear the flapping indicator */
	hst->is_flapping = FALSE;

#ifdef USE_EVENT_BROKER
	/* send data to event broker */
	broker_flapping_data(NEBTYPE_FLAPPING_STOP, NEBFLAG_NONE, NEBATTR_FLAPPING_STOP_NORMAL, HOST_FLAPPING, hst, percent_change, high_threshold, low_threshold, NULL);
#endif

	/* send a notification */
	host_notification(hst, NOTIFICATION_FLAPPINGSTOP, NULL, NULL, NOTIFICATION_OPTION_NONE);

	/* should we send a recovery notification? */
	if (hst->check_flapping_recovery_notification == TRUE && hst->current_state == HOST_UP)
		host_notification(hst, NOTIFICATION_NORMAL, NULL, NULL, NOTIFICATION_OPTION_NONE);

	/* clear the recovery notification flag */
	hst->check_flapping_recovery_notification = FALSE;

	return;
}