6 #include "evel_test_control.h"
8 /*****************************************************************************/
9 /* Local prototypes. */
10 /*****************************************************************************/
11 static void demo_heartbeat();
12 static void demo_fault(void);
14 int main(int argc, char ** argv)
16 printf("\nHello AT&T Vendor Event world!\n");
22 "Usage: %s <FQDN>|<IP address> <port> "
23 "<username> <password>\n", argv[0]);
27 char * api_fqdn = argv[1];
28 int api_port = atoi(argv[2]);
31 /***************************************************************************/
33 /***************************************************************************/
34 if (evel_initialize(api_fqdn, /* FQDN */
36 NULL, /* optional path */
37 NULL, /* optional topic */
38 api_secure, /* HTTPS? */
39 argv[3], /* Username */
40 argv[4], /* Password */
41 EVEL_SOURCE_VIRTUAL_MACHINE, /* Source type */
42 "EVEL training demo", /* Role */
45 fprintf(stderr, "\nFailed to initialize the EVEL library!!!\n");
50 printf("\nInitialization completed\n");
53 /***************************************************************************/
55 /***************************************************************************/
56 printf("Raise normal fault ...\n");
61 /***************************************************************************/
62 /* Ask for suppression of pairs (under "alarmAdditionalInformation") with */
63 /* names "name1" and "name2". */
64 /***************************************************************************/
65 printf("TestControl: test collector suppress fault pairs\n");
67 evel_test_control_scenario(TC_FAULT_SUPPRESS_PAIRS,
73 /***************************************************************************/
74 /* Heartbeat to pick up the suppression change. */
75 /***************************************************************************/
78 /***************************************************************************/
79 /* Raise the same fault. */
80 /***************************************************************************/
81 printf("Raise normal fault ...\n");
86 /***************************************************************************/
87 /* Ask for removal of fault suppression. */
88 /***************************************************************************/
89 printf("TestControl: test collector remove fault suppression\n");
91 evel_test_control_scenario(TC_FAULT_SUPPRESS_NOTHING,
97 /***************************************************************************/
98 /* Heartbeat to pick up the suppression change. */
99 /***************************************************************************/
102 /***************************************************************************/
103 /* Raise the same fault. */
104 /***************************************************************************/
105 printf("Raise normal fault ...\n");
110 /***************************************************************************/
112 /***************************************************************************/
115 printf("Terminated\n");
120 /**************************************************************************//**
121 * Create and send a heatbeat.
122 *****************************************************************************/
123 void demo_heartbeat()
125 EVENT_HEADER * heartbeat = NULL;
126 EVEL_ERR_CODES evel_rc = EVEL_SUCCESS;
128 heartbeat = evel_new_heartbeat();
129 if (heartbeat != NULL)
131 evel_rc = evel_post_event(heartbeat);
132 if (evel_rc != EVEL_SUCCESS)
134 printf("Post failed %d (%s)", evel_rc, evel_error_string());
139 printf("New heartbeat failed");
143 /**************************************************************************//**
144 * Create and send a fault event.
145 *****************************************************************************/
146 void demo_fault(void)
148 EVENT_FAULT * fault = NULL;
149 EVEL_ERR_CODES evel_rc = EVEL_SUCCESS;
151 fault = evel_new_fault("My alarm condition",
152 "It broke very badly",
153 EVEL_PRIORITY_NORMAL,
156 EVEL_VF_STATUS_PREP_TERMINATE);
159 evel_fault_type_set(fault, "Bad things happen...");
160 evel_fault_interface_set(fault, "My Interface Card");
161 evel_fault_addl_info_add(fault, "name1", "value1");
162 evel_fault_addl_info_add(fault, "name2", "value2");
163 evel_fault_addl_info_add(fault, "name3", "value3");
164 evel_fault_addl_info_add(fault, "name4", "value4");
165 evel_rc = evel_post_event((EVENT_HEADER *)fault);
166 if (evel_rc == EVEL_SUCCESS)
168 printf("Post OK!\n");
172 printf("Post Failed %d (%s)\n", evel_rc, evel_error_string());
177 printf("Failed to create event (%s)\n", evel_error_string());
180 printf(" Processed Fault\n");