diff --git a/.gitignore b/.gitignore index a35b327..ced88e1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ .idea/ ._* +.DS_Store diff --git a/src/statusengine.c b/src/statusengine.c index cc0b06e..925cffc 100644 --- a/src/statusengine.c +++ b/src/statusengine.c @@ -730,10 +730,11 @@ int statusengine_handle_data(int event_type, void *data){ if((programmdata = (nebstruct_process_data *)data)){ my_object = json_object_new_object(); - json_object_object_add(my_object, "type", json_object_new_int(programmdata->type)); - json_object_object_add(my_object, "flags", json_object_new_int(programmdata->flags)); - json_object_object_add(my_object, "attr", json_object_new_int(programmdata->attr)); - json_object_object_add(my_object, "timestamp", json_object_new_int(programmdata->timestamp.tv_sec)); + json_object_object_add(my_object, "type", json_object_new_int(programmdata->type)); + json_object_object_add(my_object, "flags", json_object_new_int(programmdata->flags)); + json_object_object_add(my_object, "attr", json_object_new_int(programmdata->attr)); + json_object_object_add(my_object, "timestamp", json_object_new_int(programmdata->timestamp.tv_sec)); + json_object_object_add(my_object, "timestamp_usec", json_object_new_int(programmdata->timestamp.tv_usec)); json_object *processdata_object = json_object_new_object(); #if defined NAEMON || defined NAEMON105 || defined NAEMONMASTER || defined NAEMON110 json_object_object_add(processdata_object, "programmname", json_object_new_string("Naemon")); @@ -766,10 +767,11 @@ int statusengine_handle_data(int event_type, void *data){ return 0; } my_object = json_object_new_object(); - json_object_object_add(my_object, "type", json_object_new_int(hoststatusdata->type)); - json_object_object_add(my_object, "flags", json_object_new_int(hoststatusdata->flags)); - json_object_object_add(my_object, "attr", json_object_new_int(hoststatusdata->attr)); - json_object_object_add(my_object, "timestamp", json_object_new_int(hoststatusdata->timestamp.tv_sec)); + json_object_object_add(my_object, "type", json_object_new_int(hoststatusdata->type)); + json_object_object_add(my_object, "flags", json_object_new_int(hoststatusdata->flags)); + json_object_object_add(my_object, "attr", json_object_new_int(hoststatusdata->attr)); + json_object_object_add(my_object, "timestamp", json_object_new_int(hoststatusdata->timestamp.tv_sec)); + json_object_object_add(my_object, "timestamp_usec", json_object_new_int(hoststatusdata->timestamp.tv_usec)); json_object *host_object = json_object_new_object(); host *nag_hoststatus = (host *)hoststatusdata->object_ptr; @@ -843,10 +845,11 @@ int statusengine_handle_data(int event_type, void *data){ return 0; } my_object = json_object_new_object(); - json_object_object_add(my_object, "type", json_object_new_int(servicestatusdata->type)); - json_object_object_add(my_object, "flags", json_object_new_int(servicestatusdata->flags)); - json_object_object_add(my_object, "attr", json_object_new_int(servicestatusdata->attr)); - json_object_object_add(my_object, "timestamp", json_object_new_int(servicestatusdata->timestamp.tv_sec)); + json_object_object_add(my_object, "type", json_object_new_int(servicestatusdata->type)); + json_object_object_add(my_object, "flags", json_object_new_int(servicestatusdata->flags)); + json_object_object_add(my_object, "attr", json_object_new_int(servicestatusdata->attr)); + json_object_object_add(my_object, "timestamp", json_object_new_int(servicestatusdata->timestamp.tv_sec)); + json_object_object_add(my_object, "timestamp_usec", json_object_new_int(servicestatusdata->timestamp.tv_usec)); json_object *service_object = json_object_new_object(); service *nag_servicestatus = (service *)servicestatusdata->object_ptr; @@ -930,10 +933,11 @@ int statusengine_handle_data(int event_type, void *data){ } my_object = json_object_new_object(); - json_object_object_add(my_object, "type", json_object_new_int(servicecheck->type)); - json_object_object_add(my_object, "flags", json_object_new_int(servicecheck->flags)); - json_object_object_add(my_object, "attr", json_object_new_int(servicecheck->attr)); - json_object_object_add(my_object, "timestamp", json_object_new_int(servicecheck->timestamp.tv_sec)); + json_object_object_add(my_object, "type", json_object_new_int(servicecheck->type)); + json_object_object_add(my_object, "flags", json_object_new_int(servicecheck->flags)); + json_object_object_add(my_object, "attr", json_object_new_int(servicecheck->attr)); + json_object_object_add(my_object, "timestamp", json_object_new_int(servicecheck->timestamp.tv_sec)); + json_object_object_add(my_object, "timestamp_usec", json_object_new_int(servicecheck->timestamp.tv_usec)); json_object *servicecheck_object = json_object_new_object(); nebstruct_service_check_data *nag_servicecheck = servicecheck; @@ -982,10 +986,11 @@ int statusengine_handle_data(int event_type, void *data){ if(use_service_perfdata){ my_object = json_object_new_object(); - json_object_object_add(my_object, "type", json_object_new_int(servicecheck->type)); - json_object_object_add(my_object, "flags", json_object_new_int(servicecheck->flags)); - json_object_object_add(my_object, "attr", json_object_new_int(servicecheck->attr)); - json_object_object_add(my_object, "timestamp", json_object_new_int(servicecheck->timestamp.tv_sec)); + json_object_object_add(my_object, "type", json_object_new_int(servicecheck->type)); + json_object_object_add(my_object, "flags", json_object_new_int(servicecheck->flags)); + json_object_object_add(my_object, "attr", json_object_new_int(servicecheck->attr)); + json_object_object_add(my_object, "timestamp", json_object_new_int(servicecheck->timestamp.tv_sec)); + json_object_object_add(my_object, "timestamp_usec", json_object_new_int(servicecheck->timestamp.tv_usec)); json_object *servicecheck_object = json_object_new_object(); SERVICECHECKFIELD_STRING(host_name); @@ -1018,10 +1023,11 @@ int statusengine_handle_data(int event_type, void *data){ } my_object = json_object_new_object(); - json_object_object_add(my_object, "type", json_object_new_int(hostcheck->type)); - json_object_object_add(my_object, "flags", json_object_new_int(hostcheck->flags)); - json_object_object_add(my_object, "attr", json_object_new_int(hostcheck->attr)); - json_object_object_add(my_object, "timestamp", json_object_new_int(hostcheck->timestamp.tv_sec)); + json_object_object_add(my_object, "type", json_object_new_int(hostcheck->type)); + json_object_object_add(my_object, "flags", json_object_new_int(hostcheck->flags)); + json_object_object_add(my_object, "attr", json_object_new_int(hostcheck->attr)); + json_object_object_add(my_object, "timestamp", json_object_new_int(hostcheck->timestamp.tv_sec)); + json_object_object_add(my_object, "timestamp_usec", json_object_new_int(hostcheck->timestamp.tv_usec)); json_object *hostcheck_object = json_object_new_object(); nebstruct_host_check_data *nag_hostcheck = hostcheck; @@ -1077,10 +1083,11 @@ int statusengine_handle_data(int event_type, void *data){ return 0; } my_object = json_object_new_object(); - json_object_object_add(my_object, "type", json_object_new_int(statechange->type)); - json_object_object_add(my_object, "flags", json_object_new_int(statechange->flags)); - json_object_object_add(my_object, "attr", json_object_new_int(statechange->attr)); - json_object_object_add(my_object, "timestamp", json_object_new_int(statechange->timestamp.tv_sec)); + json_object_object_add(my_object, "type", json_object_new_int(statechange->type)); + json_object_object_add(my_object, "flags", json_object_new_int(statechange->flags)); + json_object_object_add(my_object, "attr", json_object_new_int(statechange->attr)); + json_object_object_add(my_object, "timestamp", json_object_new_int(statechange->timestamp.tv_sec)); + json_object_object_add(my_object, "timestamp_usec", json_object_new_int(statechange->timestamp.tv_usec)); json_object *statechange_object = json_object_new_object(); @@ -1137,10 +1144,11 @@ int statusengine_handle_data(int event_type, void *data){ do_logging = 0; my_object = json_object_new_object(); - json_object_object_add(my_object, "type", json_object_new_int(logentry->type)); - json_object_object_add(my_object, "flags", json_object_new_int(logentry->flags)); - json_object_object_add(my_object, "attr", json_object_new_int(logentry->attr)); - json_object_object_add(my_object, "timestamp", json_object_new_int(logentry->timestamp.tv_sec)); + json_object_object_add(my_object, "type", json_object_new_int(logentry->type)); + json_object_object_add(my_object, "flags", json_object_new_int(logentry->flags)); + json_object_object_add(my_object, "attr", json_object_new_int(logentry->attr)); + json_object_object_add(my_object, "timestamp", json_object_new_int(logentry->timestamp.tv_sec)); + json_object_object_add(my_object, "timestamp_usec", json_object_new_int(logentry->timestamp.tv_usec)); json_object *logentry_object = json_object_new_object(); @@ -1163,10 +1171,11 @@ int statusengine_handle_data(int event_type, void *data){ return 0; } my_object = json_object_new_object(); - json_object_object_add(my_object, "type", json_object_new_int(systemcommand->type)); - json_object_object_add(my_object, "flags", json_object_new_int(systemcommand->flags)); - json_object_object_add(my_object, "attr", json_object_new_int(systemcommand->attr)); - json_object_object_add(my_object, "timestamp", json_object_new_int(systemcommand->timestamp.tv_sec)); + json_object_object_add(my_object, "type", json_object_new_int(systemcommand->type)); + json_object_object_add(my_object, "flags", json_object_new_int(systemcommand->flags)); + json_object_object_add(my_object, "attr", json_object_new_int(systemcommand->attr)); + json_object_object_add(my_object, "timestamp", json_object_new_int(systemcommand->timestamp.tv_sec)); + json_object_object_add(my_object, "timestamp_usec", json_object_new_int(systemcommand->timestamp.tv_usec)); json_object *systemcommand_object = json_object_new_object(); @@ -1199,10 +1208,11 @@ int statusengine_handle_data(int event_type, void *data){ return 0; } my_object = json_object_new_object(); - json_object_object_add(my_object, "type", json_object_new_int(_comment->type)); - json_object_object_add(my_object, "flags", json_object_new_int(_comment->flags)); - json_object_object_add(my_object, "attr", json_object_new_int(_comment->attr)); - json_object_object_add(my_object, "timestamp", json_object_new_int(_comment->timestamp.tv_sec)); + json_object_object_add(my_object, "type", json_object_new_int(_comment->type)); + json_object_object_add(my_object, "flags", json_object_new_int(_comment->flags)); + json_object_object_add(my_object, "attr", json_object_new_int(_comment->attr)); + json_object_object_add(my_object, "timestamp", json_object_new_int(_comment->timestamp.tv_sec)); + json_object_object_add(my_object, "timestamp_usec", json_object_new_int(_comment->timestamp.tv_usec)); json_object *comment_object = json_object_new_object(); json_object_object_add(comment_object, "host_name", (_comment->host_name != NULL ? json_object_new_string(_comment->host_name) : NULL)); @@ -1234,10 +1244,11 @@ int statusengine_handle_data(int event_type, void *data){ return 0; } my_object = json_object_new_object(); - json_object_object_add(my_object, "type", json_object_new_int(extcommand->type)); - json_object_object_add(my_object, "flags", json_object_new_int(extcommand->flags)); - json_object_object_add(my_object, "attr", json_object_new_int(extcommand->attr)); - json_object_object_add(my_object, "timestamp", json_object_new_int(extcommand->timestamp.tv_sec)); + json_object_object_add(my_object, "type", json_object_new_int(extcommand->type)); + json_object_object_add(my_object, "flags", json_object_new_int(extcommand->flags)); + json_object_object_add(my_object, "attr", json_object_new_int(extcommand->attr)); + json_object_object_add(my_object, "timestamp", json_object_new_int(extcommand->timestamp.tv_sec)); + json_object_object_add(my_object, "timestamp_usec", json_object_new_int(extcommand->timestamp.tv_usec)); json_object *extcommand_object = json_object_new_object(); json_object_object_add(extcommand_object, "command_string", (extcommand->command_string != NULL ? json_object_new_string(extcommand->command_string) : NULL)); @@ -1260,10 +1271,11 @@ int statusengine_handle_data(int event_type, void *data){ return 0; } my_object = json_object_new_object(); - json_object_object_add(my_object, "type", json_object_new_int(acknowledgement->type)); - json_object_object_add(my_object, "flags", json_object_new_int(acknowledgement->flags)); - json_object_object_add(my_object, "attr", json_object_new_int(acknowledgement->attr)); - json_object_object_add(my_object, "timestamp", json_object_new_int(acknowledgement->timestamp.tv_sec)); + json_object_object_add(my_object, "type", json_object_new_int(acknowledgement->type)); + json_object_object_add(my_object, "flags", json_object_new_int(acknowledgement->flags)); + json_object_object_add(my_object, "attr", json_object_new_int(acknowledgement->attr)); + json_object_object_add(my_object, "timestamp", json_object_new_int(acknowledgement->timestamp.tv_sec)); + json_object_object_add(my_object, "timestamp_usec", json_object_new_int(acknowledgement->timestamp.tv_usec)); json_object *acknowledgement_object = json_object_new_object(); json_object_object_add(acknowledgement_object, "host_name", (acknowledgement->host_name != NULL ? json_object_new_string(acknowledgement->host_name) : NULL)); @@ -1292,10 +1304,11 @@ int statusengine_handle_data(int event_type, void *data){ return 0; } my_object = json_object_new_object(); - json_object_object_add(my_object, "type", json_object_new_int(_flapping->type)); - json_object_object_add(my_object, "flags", json_object_new_int(_flapping->flags)); - json_object_object_add(my_object, "attr", json_object_new_int(_flapping->attr)); - json_object_object_add(my_object, "timestamp", json_object_new_int(_flapping->timestamp.tv_sec)); + json_object_object_add(my_object, "type", json_object_new_int(_flapping->type)); + json_object_object_add(my_object, "flags", json_object_new_int(_flapping->flags)); + json_object_object_add(my_object, "attr", json_object_new_int(_flapping->attr)); + json_object_object_add(my_object, "timestamp", json_object_new_int(_flapping->timestamp.tv_sec)); + json_object_object_add(my_object, "timestamp_usec", json_object_new_int(_flapping->timestamp.tv_usec)); json_object *flapping_object = json_object_new_object(); json_object_object_add(flapping_object, "host_name", (_flapping->host_name != NULL ? json_object_new_string(_flapping->host_name) : NULL)); @@ -1340,10 +1353,12 @@ int statusengine_handle_data(int event_type, void *data){ return 0; } my_object = json_object_new_object(); - json_object_object_add(my_object, "type", json_object_new_int(_downtime->type)); - json_object_object_add(my_object, "flags", json_object_new_int(_downtime->flags)); - json_object_object_add(my_object, "attr", json_object_new_int(_downtime->attr)); - json_object_object_add(my_object, "timestamp", json_object_new_int(_downtime->timestamp.tv_sec)); + json_object_object_add(my_object, "type", json_object_new_int(_downtime->type)); + json_object_object_add(my_object, "flags", json_object_new_int(_downtime->flags)); + json_object_object_add(my_object, "attr", json_object_new_int(_downtime->attr)); + json_object_object_add(my_object, "timestamp", json_object_new_int(_downtime->timestamp.tv_sec)); + json_object_object_add(my_object, "timestamp_usec", json_object_new_int(_downtime->timestamp.tv_usec)); + json_object *downtime_object = json_object_new_object(); json_object_object_add(downtime_object, "host_name", (_downtime->host_name != NULL ? json_object_new_string(_downtime->host_name) : NULL)); @@ -1378,10 +1393,11 @@ int statusengine_handle_data(int event_type, void *data){ return 0; } my_object = json_object_new_object(); - json_object_object_add(my_object, "type", json_object_new_int(notificationdata->type)); - json_object_object_add(my_object, "flags", json_object_new_int(notificationdata->flags)); - json_object_object_add(my_object, "attr", json_object_new_int(notificationdata->attr)); - json_object_object_add(my_object, "timestamp", json_object_new_int(notificationdata->timestamp.tv_sec)); + json_object_object_add(my_object, "type", json_object_new_int(notificationdata->type)); + json_object_object_add(my_object, "flags", json_object_new_int(notificationdata->flags)); + json_object_object_add(my_object, "attr", json_object_new_int(notificationdata->attr)); + json_object_object_add(my_object, "timestamp", json_object_new_int(notificationdata->timestamp.tv_sec)); + json_object_object_add(my_object, "timestamp_usec", json_object_new_int(notificationdata->timestamp.tv_usec)); json_object *notification_data_object = json_object_new_object(); json_object_object_add(notification_data_object, "host_name", (notificationdata->host_name != NULL ? json_object_new_string(notificationdata->host_name) : NULL)); @@ -1417,10 +1433,11 @@ int statusengine_handle_data(int event_type, void *data){ return 0; } my_object = json_object_new_object(); - json_object_object_add(my_object, "type", json_object_new_int(procstats->type)); - json_object_object_add(my_object, "flags", json_object_new_int(procstats->flags)); - json_object_object_add(my_object, "attr", json_object_new_int(procstats->attr)); - json_object_object_add(my_object, "timestamp", json_object_new_int(procstats->timestamp.tv_sec)); + json_object_object_add(my_object, "type", json_object_new_int(procstats->type)); + json_object_object_add(my_object, "flags", json_object_new_int(procstats->flags)); + json_object_object_add(my_object, "attr", json_object_new_int(procstats->attr)); + json_object_object_add(my_object, "timestamp", json_object_new_int(procstats->timestamp.tv_sec)); + json_object_object_add(my_object, "timestamp_usec", json_object_new_int(procstats->timestamp.tv_usec)); json_object *programmstatus_object = json_object_new_object(); json_object_object_add(programmstatus_object, "global_host_event_handler", (procstats->global_host_event_handler != NULL ? json_object_new_string(procstats->global_host_event_handler) : NULL)); @@ -1466,10 +1483,11 @@ int statusengine_handle_data(int event_type, void *data){ } my_object = json_object_new_object(); - json_object_object_add(my_object, "type", json_object_new_int(contactstatus->type)); - json_object_object_add(my_object, "flags", json_object_new_int(contactstatus->flags)); - json_object_object_add(my_object, "attr", json_object_new_int(contactstatus->attr)); - json_object_object_add(my_object, "timestamp", json_object_new_int(contactstatus->timestamp.tv_sec)); + json_object_object_add(my_object, "type", json_object_new_int(contactstatus->type)); + json_object_object_add(my_object, "flags", json_object_new_int(contactstatus->flags)); + json_object_object_add(my_object, "attr", json_object_new_int(contactstatus->attr)); + json_object_object_add(my_object, "timestamp", json_object_new_int(contactstatus->timestamp.tv_sec)); + json_object_object_add(my_object, "timestamp_usec", json_object_new_int(contactstatus->timestamp.tv_usec)); json_object *contactstatus_object = json_object_new_object(); json_object_object_add(contactstatus_object, "contact_name", (tmp_contact->name != NULL ? json_object_new_string(tmp_contact->name) : NULL)); @@ -1497,10 +1515,11 @@ int statusengine_handle_data(int event_type, void *data){ return 0; } my_object = json_object_new_object(); - json_object_object_add(my_object, "type", json_object_new_int(cnd->type)); - json_object_object_add(my_object, "flags", json_object_new_int(cnd->flags)); - json_object_object_add(my_object, "attr", json_object_new_int(cnd->attr)); - json_object_object_add(my_object, "timestamp", json_object_new_int(cnd->timestamp.tv_sec)); + json_object_object_add(my_object, "type", json_object_new_int(cnd->type)); + json_object_object_add(my_object, "flags", json_object_new_int(cnd->flags)); + json_object_object_add(my_object, "attr", json_object_new_int(cnd->attr)); + json_object_object_add(my_object, "timestamp", json_object_new_int(cnd->timestamp.tv_sec)); + json_object_object_add(my_object, "timestamp_usec", json_object_new_int(cnd->timestamp.tv_usec)); json_object *cnd_object = json_object_new_object(); json_object_object_add(cnd_object, "host_name", (cnd->host_name != NULL ? json_object_new_string(cnd->host_name) : NULL)); @@ -1533,10 +1552,11 @@ int statusengine_handle_data(int event_type, void *data){ return 0; } my_object = json_object_new_object(); - json_object_object_add(my_object, "type", json_object_new_int(cnm->type)); - json_object_object_add(my_object, "flags", json_object_new_int(cnm->flags)); - json_object_object_add(my_object, "attr", json_object_new_int(cnm->attr)); - json_object_object_add(my_object, "timestamp", json_object_new_int(cnm->timestamp.tv_sec)); + json_object_object_add(my_object, "type", json_object_new_int(cnm->type)); + json_object_object_add(my_object, "flags", json_object_new_int(cnm->flags)); + json_object_object_add(my_object, "attr", json_object_new_int(cnm->attr)); + json_object_object_add(my_object, "timestamp", json_object_new_int(cnm->timestamp.tv_sec)); + json_object_object_add(my_object, "timestamp_usec", json_object_new_int(cnm->timestamp.tv_usec)); json_object *cnm_object = json_object_new_object(); json_object_object_add(cnm_object, "host_name", (cnm->host_name != NULL ? json_object_new_string(cnm->host_name) : NULL)); @@ -1568,10 +1588,11 @@ int statusengine_handle_data(int event_type, void *data){ return 0; } my_object = json_object_new_object(); - json_object_object_add(my_object, "type", json_object_new_int(event_handler_data->type)); - json_object_object_add(my_object, "flags", json_object_new_int(event_handler_data->flags)); - json_object_object_add(my_object, "attr", json_object_new_int(event_handler_data->attr)); - json_object_object_add(my_object, "timestamp", json_object_new_int(event_handler_data->timestamp.tv_sec)); + json_object_object_add(my_object, "type", json_object_new_int(event_handler_data->type)); + json_object_object_add(my_object, "flags", json_object_new_int(event_handler_data->flags)); + json_object_object_add(my_object, "attr", json_object_new_int(event_handler_data->attr)); + json_object_object_add(my_object, "timestamp", json_object_new_int(event_handler_data->timestamp.tv_sec)); + json_object_object_add(my_object, "timestamp_usec", json_object_new_int(event_handler_data->timestamp.tv_usec)); json_object *ehd_object = json_object_new_object(); json_object_object_add(ehd_object, "host_name", (event_handler_data->host_name != NULL ? json_object_new_string(event_handler_data->host_name) : NULL));