aboutsummaryrefslogtreecommitdiff
path: root/pkgs/status_engine/host_perfdata.patch
blob: 0c8a20b41450cea29192eb597d22e6d816bb0bc7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
diff --git a/src/statusengine.c b/src/statusengine.c
index cc0b06e..2a18dec 100644
--- a/src/statusengine.c
+++ b/src/statusengine.c
@@ -304,6 +304,7 @@ int enable_ocsp = 0;
 
 int use_restart_data=1;
 int use_service_perfdata=0;
+int use_host_perfdata=0;
 
 int statusengine_process_config_var(char *arg);
 int statusengine_process_module_args(char *args);
@@ -612,6 +613,9 @@ int statusengine_process_config_var(char *arg) {
 	} else if (!strcmp(var, "use_service_perfdata")) {
 		use_service_perfdata = atoi(val);
 		logswitch(NSLOG_INFO_MESSAGE, "start with enabled use_service_perfdata");
+	} else if (!strcmp(var, "use_host_perfdata")) {
+		use_host_perfdata = atoi(val);
+		logswitch(NSLOG_INFO_MESSAGE, "start with enabled use_host_perfdata");
 	} else {
 		return ERROR;
 	}
@@ -1067,6 +1071,24 @@ int statusengine_handle_data(int event_type, void *data){
 					json_object_put(my_object);
 					free(raw_command);
 
+					if(use_host_perfdata){
+						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 *hostcheck_object = json_object_new_object();
+						HOSTCHECKFIELD_STRING(host_name);
+						HOSTCHECKFIELD_STRING(perf_data);
+						json_object_object_add(hostcheck_object, "start_time", json_object_new_int64(nag_hostcheck->start_time.tv_sec));
+
+						json_object_object_add(my_object, "hostcheck", hostcheck_object);
+						const char* json_string = json_object_to_json_string(my_object);
+						statusengine_send_job("statusngin_host_perfdata", (void *)json_string);
+
+						json_object_put(my_object);
+					}
 				}
 				break;