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 alarmInterfaceA and alarmAdditionalInformation. */
63 /***************************************************************************/
64 printf("TestControl: test collector suppress fault fields\n");
66 evel_test_control_scenario(TC_FAULT_SUPPRESS_FIELDS,
72 /***************************************************************************/
73 /* Heartbeat to pick up the suppression change. */
74 /***************************************************************************/
77 /***************************************************************************/
78 /* Raise the same fault. */
79 /***************************************************************************/
80 printf("Raise normal fault ...\n");
85 /***************************************************************************/
86 /* Ask for removal of fault suppression. */
87 /***************************************************************************/
88 printf("TestControl: test collector remove fault suppression\n");
90 evel_test_control_scenario(TC_FAULT_SUPPRESS_NOTHING,
96 /***************************************************************************/
97 /* Heartbeat to pick up the suppression change. */
98 /***************************************************************************/
101 /***************************************************************************/
102 /* Raise the same fault. */
103 /***************************************************************************/
104 printf("Raise normal fault ...\n");
109 /***************************************************************************/
111 /***************************************************************************/
114 printf("Terminated\n");
119 /**************************************************************************//**
120 * Create and send a heatbeat.
121 *****************************************************************************/
122 void demo_heartbeat()
124 EVENT_HEADER * heartbeat = NULL;
125 EVEL_ERR_CODES evel_rc = EVEL_SUCCESS;
127 heartbeat = evel_new_heartbeat();
128 if (heartbeat != NULL)
130 evel_rc = evel_post_event(heartbeat);
131 if (evel_rc != EVEL_SUCCESS)
133 printf("Post failed %d (%s)", evel_rc, evel_error_string());
138 printf("New heartbeat failed");
142 /**************************************************************************//**
143 * Create and send a fault event.
144 *****************************************************************************/
145 void demo_fault(void)
147 EVENT_FAULT * fault = NULL;
148 EVEL_ERR_CODES evel_rc = EVEL_SUCCESS;
150 fault = evel_new_fault("My alarm condition",
151 "It broke very badly",
152 EVEL_PRIORITY_NORMAL,
155 EVEL_VF_STATUS_PREP_TERMINATE);
158 evel_fault_type_set(fault, "Bad things happen...");
159 evel_fault_interface_set(fault, "My Interface Card");
160 evel_fault_addl_info_add(fault, "name1", "value1");
161 evel_fault_addl_info_add(fault, "name2", "value2");
162 evel_fault_addl_info_add(fault, "name3", "value3");
163 evel_fault_addl_info_add(fault, "name4", "value4");
164 evel_rc = evel_post_event((EVENT_HEADER *)fault);
165 if (evel_rc == EVEL_SUCCESS)
167 printf("Post OK!\n");
171 printf("Post Failed %d (%s)\n", evel_rc, evel_error_string());
176 printf("Failed to create event (%s)\n", evel_error_string());
179 printf(" Processed Fault\n");