#include <time.h>
#include <math.h>
#include <sys/time.h>
+#include <cjson/cJSON.h>
#include "sysrepo.h"
#include "sysrepo/values.h"
volatile int exit_application = 0;
+static counterAlarms netconf_alarm_counter = {
+ .normal = 0,
+ .warning = 0,
+ .minor = 0,
+ .major = 0,
+ .critical = 0
+};
+static counterAlarms ves_alarm_counter= {
+ .normal = 0,
+ .warning = 0,
+ .minor = 0,
+ .major = 0,
+ .critical = 0
+};
+
struct faultAlarms
{
int faultId;
printf("Failed to send notification send_dummy_notif\n");
return SR_ERR_OPERATION_FAILED;
}
+ if (oran_fault_alarms[ran].cleared[random_port])
+ {
+ netconf_alarm_counter.normal++;
+ }
+ else
+ {
+ if (strcmp(oran_fault_alarms[ran].faultSeverity, "WARNING") == 0)
+ {
+ netconf_alarm_counter.warning++;
+ }
+ else if (strcmp(oran_fault_alarms[ran].faultSeverity, "MINOR") == 0)
+ {
+ netconf_alarm_counter.minor++;
+ }
+ else if (strcmp(oran_fault_alarms[ran].faultSeverity, "MAJOR") == 0)
+ {
+ netconf_alarm_counter.major++;
+ }
+ else if (strcmp(oran_fault_alarms[ran].faultSeverity, "CRITICAL") == 0)
+ {
+ netconf_alarm_counter.critical++;
+ }
+ }
+
printf("Successfully sent notification with timestamp=\"%s\"\n", dateAndTime);
}
if (isVesAvailable)
{
printf("Could not send Fault VES message\n");
}
+ if (oran_fault_alarms[ran].cleared[random_port])
+ {
+ ves_alarm_counter.normal++;
+ }
+ else
+ {
+ if (strcmp(oran_fault_alarms[ran].faultSeverity, "WARNING") == 0)
+ {
+ ves_alarm_counter.warning++;
+ }
+ else if (strcmp(oran_fault_alarms[ran].faultSeverity, "MINOR") == 0)
+ {
+ ves_alarm_counter.minor++;
+ }
+ else if (strcmp(oran_fault_alarms[ran].faultSeverity, "MAJOR") == 0)
+ {
+ ves_alarm_counter.major++;
+ }
+ else if (strcmp(oran_fault_alarms[ran].faultSeverity, "CRITICAL") == 0)
+ {
+ ves_alarm_counter.critical++;
+ }
+ }
}
+ printf("Writing counters to file...\n");
+ rc = writeStatusNotificationCounters(ves_alarm_counter, netconf_alarm_counter);
+ if (rc != SR_ERR_OK)
+ {
+ printf("Could not write status to file...\n");
+ }
sr_free_values(vnotif, current_num_of_values);
signal(SIGINT, sigint_handler);
signal(SIGPIPE, SIG_IGN);
-
while (!exit_application) {
- notification_delay_period = getFaultNotificationDelayPeriodFromConfigJson();
+ int notif_delay[100], count = 0;
- if (notification_delay_period > 0)
+ rc = getFaultNotificationDelayPeriodFromConfigJson(notif_delay, &count);
+ if (rc != SR_ERR_OK)
{
- send_dummy_notif(session);
+ printf("Could not get fault notification delay period.");
+ sleep(1);
+ continue;
+ }
- sleep(notification_delay_period);
+ if (count > 1)
+ {
+ for (int i = 0; i < count; ++i)
+ {
+ sleep(notif_delay[i]);
+ send_dummy_notif(session);
+ }
}
- else
+ else if (count == 1)
{
- sleep(1);
+ if (notif_delay[0] > 0)
+ {
+ sleep(notif_delay[0]);
+ send_dummy_notif(session);
+ }
+ else
+ {
+ sleep(1);
+ // reset the counters when the notifciation delay period is switched back to 0
+ netconf_alarm_counter.normal = netconf_alarm_counter.warning = \
+ netconf_alarm_counter.minor = netconf_alarm_counter.major = \
+ netconf_alarm_counter.critical = 0;
+
+ ves_alarm_counter.normal = ves_alarm_counter.warning = \
+ ves_alarm_counter.minor = ves_alarm_counter.major = \
+ ves_alarm_counter.critical = 0;
+ }
}
}