2 #include "nagios/objects.h"
3 #include "nagios/broker.h"
7 * Returns the current downtime depth of the given object.
8 * "type" should always either be NEBTYPE_DOWNTIME_START or
9 * NEBTYPE_DOWNTIME_STOP. In case of NEBTYPE_DOWNTIME_START,
10 * we know the downtime depth is at least 1, so return that.
11 * This nifty little hack make these functions usable with
12 * the import program, for which "find_host()" will always
15 int dt_depth_host(int type
, char *host_name
)
18 int depth
= (type
== NEBTYPE_DOWNTIME_START
);
20 if ((hst
= find_host(host_name
)))
21 depth
+= hst
->scheduled_downtime_depth
;
26 int dt_depth_svc(int type
, char *host_name
, char *service_description
)
29 int depth
= (type
== NEBTYPE_DOWNTIME_START
);
31 if ((svc
= find_service(host_name
, service_description
)))
32 depth
+= svc
->scheduled_downtime_depth
;
37 extern host
*host_list
, *host_list_tail
;
38 extern service
*service_list
, *service_list_tail
;
39 extern sched_info scheduling_info
;
41 int prime_initial_states(hash_table
*host_states
, hash_table
*svc_states
)
48 * no hosts = no services = nothing to do but warn about it
50 if (!host_list
|| !scheduling_info
.total_hosts
) {
55 arena
= cget_arena(scheduling_info
.total_hosts
, sizeof(int));
59 for (h
= host_list
; h
&& h
!= host_list_tail
; h
= h
->next
) {
63 *state
= CAT_STATE(h
->current_state
, h
->state_type
);
64 hash_add(host_states
, h
->name
, state
);
68 arena
= cget_arena(scheduling_info
.total_services
, sizeof(int));
72 for (s
= service_list
; s
&& s
!= service_list_tail
; s
= s
->next
) {
79 *state
= CAT_STATE(s
->current_state
, s
->state_type
);
80 hash_add2(svc_states
, s
->host_name
, s
->description
, state
);