示例#1
0
int handle_kamailioMsgQueueDepthAlarmStatus(netsnmp_mib_handler *handler,
		netsnmp_handler_registration *reginfo,
		netsnmp_agent_request_info   *reqinfo,
		netsnmp_request_info         *requests)
{

	/* The MIB specifications say the scalar should be set to 'clear' if
	 * everything is ok.  According the X731AlarmStatus specification,
	 * this means that no bits are toggled.  So we set the state to zero by
	 * default */
	unsigned int state = 0;
	
	if (check_msg_queue_alarm(msgQueueMinorThreshold)) {
		state |=  TC_ALARM_STATUS_MINOR;
	}

	if (check_msg_queue_alarm(msgQueueMajorThreshold)) {
		state |=  TC_ALARM_STATUS_MAJOR;
	}

	if (reqinfo->mode == MODE_GET) {
		snmp_set_var_typed_value(requests->requestvb, ASN_OCTET_STR,
			(u_char *)&state, 1);
		return SNMP_ERR_NOERROR;
	}

	return SNMP_ERR_GENERR;
}
示例#2
0
int handle_kamailioMsgQueueDepthMajorAlarm(netsnmp_mib_handler *handler,
		netsnmp_handler_registration *reginfo,
		netsnmp_agent_request_info   *reqinfo,
		netsnmp_request_info         *requests)
{
	int x731AlarmState = TC_ALARM_STATE_CLEAR;

	if (check_msg_queue_alarm(msgQueueMajorThreshold)) { 	
		x731AlarmState = TC_ALARM_STATE_MAJOR;
	}
	
	if (reqinfo->mode == MODE_GET) {
		snmp_set_var_typed_value(requests->requestvb, ASN_INTEGER,
			(u_char *) &x731AlarmState, sizeof(int));
		return SNMP_ERR_NOERROR;
	}

	return SNMP_ERR_GENERR;
}
示例#3
0
/* This function will be called periodically from an OpenSIPS timer.  The first
 * time it is called, it will query OPENSER-MIB for configured thresholds.
 */
void run_alarm_check(unsigned int ticks, void * attr) 
{
	static int msg_queue_minor_threshold;
	static int msg_queue_major_threshold;		

	static int dialog_minor_threshold;
	static int dialog_major_threshold;

	static char firstRun = 1;
	
	int bytesInMsgQueue;
	int numActiveDialogs;

	/* We only need to retrieve our thresholds the first time around */
	if (firstRun) 
	{
		register_with_master_agent(ALARM_AGENT_NAME);

		msg_queue_minor_threshold = get_msg_queue_minor_threshold();
		msg_queue_major_threshold = get_msg_queue_major_threshold();

		dialog_minor_threshold = get_dialog_minor_threshold();
		dialog_major_threshold = get_dialog_major_threshold();

		firstRun = 0;
	}
	
	/* We need to have this here in case the master agent fails and is
	 * restarted.  Without it, we won't be able to re-establish or AgentX
	 * connection */
	agent_check_and_process(0); 

	/* Check for MsgQueue alarm conditions */

	/* The retrieved number of bytes will be zero unless
	 * there is an alarm condition.  In this case the number
	 * of bytes will be returned. */
	bytesInMsgQueue = check_msg_queue_alarm(msg_queue_minor_threshold);

	if (bytesInMsgQueue != 0) 
	{
		send_openserMsgQueueDepthMinorEvent_trap(bytesInMsgQueue, 
						msg_queue_minor_threshold);
	}

	bytesInMsgQueue = check_msg_queue_alarm(msg_queue_major_threshold);


	if (bytesInMsgQueue != 0) 
	{
		send_openserMsgQueueDepthMajorEvent_trap(bytesInMsgQueue, 
						msg_queue_major_threshold);
	}

	/* Check for Dialog alarm conditions: */

	numActiveDialogs = 	check_dialog_alarm(dialog_minor_threshold);

	if (numActiveDialogs != 0)
	{
		send_openserDialogLimitMinorEvent_trap(numActiveDialogs,
						dialog_minor_threshold);
	}
	
	numActiveDialogs = check_dialog_alarm(dialog_major_threshold);

	if (numActiveDialogs != 0)
	{
		send_openserDialogLimitMajorEvent_trap(numActiveDialogs,
						dialog_major_threshold);
	}
}