Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00039 #include <signal.h>
00040
00041 #include "../../lib/kcore/statistics.h"
00042
00043 #include "alarm_checks.h"
00044 #include "sub_agent.h"
00045 #include "utilities.h"
00046 #include "snmpObjects.h"
00047 #include "snmpMIBNotifications.h"
00048
00052 int check_msg_queue_alarm(int threshold_to_compare_to)
00053 {
00054 int bytesWaiting = 0;
00055
00056 if (threshold_to_compare_to < 0)
00057 {
00058 return 0;
00059 }
00060
00061 bytesWaiting = get_total_bytes_waiting();
00062
00063 if (bytesWaiting > threshold_to_compare_to)
00064 {
00065 return bytesWaiting;
00066 }
00067
00068 return 0;
00069 }
00070
00071
00074 int check_dialog_alarm(int threshold_to_compare_to)
00075 {
00076 int num_dialogs;
00077
00078 if (threshold_to_compare_to < 0)
00079 {
00080 return 0;
00081 }
00082
00083 num_dialogs = get_statistic("active_dialogs");
00084
00085 if (num_dialogs > threshold_to_compare_to)
00086 {
00087 return num_dialogs;
00088 }
00089
00090 return 0;
00091 }
00092
00096 void run_alarm_check(unsigned int ticks, void * attr)
00097 {
00098 static int msg_queue_minor_threshold;
00099 static int msg_queue_major_threshold;
00100
00101 static int dialog_minor_threshold;
00102 static int dialog_major_threshold;
00103
00104 static char firstRun = 1;
00105
00106 int bytesInMsgQueue;
00107 int numActiveDialogs;
00108
00109
00110 if (firstRun)
00111 {
00112 register_with_master_agent(ALARM_AGENT_NAME);
00113
00114 msg_queue_minor_threshold = get_msg_queue_minor_threshold();
00115 msg_queue_major_threshold = get_msg_queue_major_threshold();
00116
00117 dialog_minor_threshold = get_dialog_minor_threshold();
00118 dialog_major_threshold = get_dialog_major_threshold();
00119
00120 firstRun = 0;
00121 }
00122
00123
00124
00125
00126 agent_check_and_process(0);
00127
00128
00129
00130
00131
00132
00133 bytesInMsgQueue = check_msg_queue_alarm(msg_queue_minor_threshold);
00134
00135 if (bytesInMsgQueue != 0)
00136 {
00137 send_openserMsgQueueDepthMinorEvent_trap(bytesInMsgQueue,
00138 msg_queue_minor_threshold);
00139 }
00140
00141 bytesInMsgQueue = check_msg_queue_alarm(msg_queue_major_threshold);
00142
00143
00144 if (bytesInMsgQueue != 0)
00145 {
00146 send_openserMsgQueueDepthMajorEvent_trap(bytesInMsgQueue,
00147 msg_queue_major_threshold);
00148 }
00149
00150
00151
00152 numActiveDialogs = check_dialog_alarm(dialog_minor_threshold);
00153
00154 if (numActiveDialogs != 0)
00155 {
00156 send_openserDialogLimitMinorEvent_trap(numActiveDialogs,
00157 dialog_minor_threshold);
00158 }
00159
00160 numActiveDialogs = check_dialog_alarm(dialog_major_threshold);
00161
00162 if (numActiveDialogs != 0)
00163 {
00164 send_openserDialogLimitMajorEvent_trap(numActiveDialogs,
00165 dialog_major_threshold);
00166 }
00167 }