1 #ifndef NAGIOS_TEST_STUBS__
2 #define NAGIOS_TEST_STUBS__
3 #include "macros.h"
4 
5 /* Loads of variables + stubbed functions */
6 char *config_file = "etc/nagios.cfg";
7 int      test_scheduling;
8 
9 time_t   program_start;
10 time_t   event_start;
11 
12 int      sigshutdown = FALSE;
13 int      sigrestart = FALSE;
14 
15 int      interval_length = 60;
16 int      service_inter_check_delay_method;
17 int      host_inter_check_delay_method;
18 int      service_interleave_factor_method;
19 int      max_host_check_spread;
20 int      max_service_check_spread;
21 
22 int      command_check_interval;
23 int      check_reaper_interval;
24 int      service_freshness_check_interval;
25 int      host_freshness_check_interval;
26 int      auto_rescheduling_interval;
27 int      host_freshness_check_interval;
28 int      auto_rescheduling_interval;
29 int      auto_rescheduling_window;
30 
31 int      check_external_commands;
32 int      check_orphaned_services;
33 int      check_orphaned_hosts;
34 int      check_service_freshness;
35 int      check_host_freshness;
36 int      auto_reschedule_checks;
37 
38 int      retain_state_information;
39 int      retention_update_interval;
40 
41 int      max_parallel_service_checks;
42 int      currently_running_service_checks;
43 
44 int      status_update_interval;
45 
46 int      log_rotation_method;
47 
48 int      service_check_timeout;
49 
50 int      execute_service_checks = 1;
51 int      execute_host_checks;
52 
53 int      child_processes_fork_twice;
54 
55 int      time_change_threshold;
56 
57 
58 host     *host_list;
59 service  *service_list;
60 
check_for_expired_comment(unsigned long temp_long)61 int check_for_expired_comment(unsigned long temp_long) {}
broker_timed_event(int int1,int int2,int int3,timed_event * timed_event1,struct timeval * timeval1)62 void broker_timed_event(int int1, int int2, int int3, timed_event *timed_event1, struct timeval *timeval1) {}
check_for_expired_downtime(void)63 int check_for_expired_downtime(void) {}
check_for_nagios_updates(int int1,int int2)64 int check_for_nagios_updates(int int1, int int2) {}
get_next_service_notification_time(service * temp_service,time_t time_t1)65 time_t get_next_service_notification_time(service *temp_service, time_t time_t1) {}
save_state_information(int int1)66 int save_state_information(int int1) {}
check_for_external_commands(void)67 int check_for_external_commands(void) {}
check_time_against_period(time_t time_t1,timeperiod * timeperiod)68 int check_time_against_period(time_t time_t1, timeperiod *timeperiod) {}
get_next_log_rotation_time(void)69 time_t get_next_log_rotation_time(void) {}
handle_scheduled_downtime_by_id(unsigned long long1)70 int handle_scheduled_downtime_by_id(unsigned long long1) {}
71 #ifndef TEST_LOGGING
log_host_event(host * hst)72 int log_host_event(host *hst) {}
73 int log_service_event_flag = 0;
log_service_event(service * svc)74 int log_service_event(service *svc) {
75 	log_service_event_flag++;
76 	}
rotate_log_file(time_t time_t1)77 int rotate_log_file(time_t time_t1) {}
logit(int int1,int int2,const char * fmt,...)78 void logit(int int1, int int2, const char *fmt, ...) {}
79 #endif
get_next_host_notification_time(host * temp_host,time_t time_t1)80 time_t get_next_host_notification_time(host *temp_host, time_t time_t1) {}
get_next_valid_time(time_t time_t1,time_t * time_t2,timeperiod * temp_timeperiod)81 void get_next_valid_time(time_t time_t1, time_t *time_t2, timeperiod *temp_timeperiod) {}
82 
83 
84 char *log_file = "var/nagios.log";
85 char *temp_file = "";
86 char *log_archive_path = "var";
87 host *host_list = NULL;
88 service *service_list = NULL;
89 int use_syslog = 0;
90 int log_service_retries;
91 int log_initial_states;
92 unsigned long logging_options = NSLOG_PROCESS_INFO;
93 unsigned long syslog_options;
94 int verify_config;
95 int test_scheduling;
96 time_t last_log_rotation;
97 int log_rotation_method;
98 int daemon_mode = TRUE;
99 char *debug_file = "";
100 int debug_level;
101 int debug_verbosity;
102 unsigned long max_debug_file_size;
103 
grab_host_macros_r(nagios_macros * mac,host * hst)104 int grab_host_macros_r(nagios_macros *mac, host *hst) {}
105 
grab_service_macros_r(nagios_macros * mac,service * svc)106 int grab_service_macros_r(nagios_macros *mac, service *svc) {}
107 
broker_log_data(int a,int b,int c,char * d,unsigned long e,time_t f,struct timeval * g)108 void broker_log_data(int a, int b, int c, char *d, unsigned long e, time_t f, struct timeval *g) {}
109 
clear_volatile_macros_r(nagios_macros * mac)110 int clear_volatile_macros_r(nagios_macros *mac) {}
clear_service_macros_r(nagios_macros * mac)111 int clear_service_macros_r(nagios_macros *mac) {}
clear_host_macros_r(nagios_macros * mac)112 int clear_host_macros_r(nagios_macros *mac) {}
113 
process_macros(char * a,char ** b,int c)114 int process_macros(char *a, char **b, int c) {}
process_macros_r(nagios_macros * mac,char * a,char ** b,int c)115 int process_macros_r(nagios_macros *mac, char *a, char **b, int c) {}
116 
update_host_status(host * hst,int aggregated_dump)117 int update_host_status(host *hst, int aggregated_dump) {}
update_service_status(service * svc,int aggregated_dump)118 int update_service_status(service *svc, int aggregated_dump) {}
update_all_status_data(void)119 int update_all_status_data(void) {}
120 char    *check_result_path = NULL;
process_check_result_queue(char * dirname)121 int process_check_result_queue(char *dirname) {}
find_service(char * host_name,char * svc_desc)122 service * find_service(char *host_name, char *svc_desc) {}
delete_check_result_file(char * fname)123 int delete_check_result_file(char *fname) {}
free_check_result(check_result * info)124 int free_check_result(check_result *info) {}
find_host(char * name)125 host * find_host(char *name) {}
126 int             max_check_reaper_time = DEFAULT_MAX_REAPER_TIME;
read_check_result(void)127 check_result *read_check_result(void) {}
broker_service_check(int type,int flags,int attr,service * svc,int check_type,struct timeval start_time,struct timeval end_time,char * cmd,double latency,double exectime,int timeout,int early_timeout,int retcode,char * cmdline,struct timeval * timestamp)128 int broker_service_check(int type, int flags, int attr, service *svc, int check_type, struct timeval start_time, struct timeval end_time, char *cmd, double latency, double exectime, int timeout, int early_timeout, int retcode, char *cmdline, struct timeval *timestamp) {}
get_raw_command_line(command * a,char * b,char ** c,int d)129 int get_raw_command_line(command *a, char *b, char **c, int d) {}
get_raw_command_line_r(nagios_macros * mac,command * a,char * b,char ** c,int d)130 int get_raw_command_line_r(nagios_macros *mac, command *a, char *b, char **c, int d) {}
131 char *temp_path;
dbuf_init(dbuf * db,int chunk_size)132 int dbuf_init(dbuf *db, int chunk_size) {}
update_check_stats(int check_type,time_t check_time)133 int update_check_stats(int check_type, time_t check_time) {}
set_all_macro_environment_vars_r(nagios_macros * mac,int set)134 int set_all_macro_environment_vars_r(nagios_macros *mac, int set) {}
close_command_file(void)135 int close_command_file(void) {}
reset_sighandler(void)136 void reset_sighandler(void) {}
137 unsigned long   max_debug_file_size = DEFAULT_MAX_DEBUG_FILE_SIZE;
138 int             host_check_timeout = DEFAULT_HOST_CHECK_TIMEOUT;
broker_host_check(int type,int flags,int attr,host * hst,int check_type,int state,int state_type,struct timeval start_time,struct timeval end_time,char * cmd,double latency,double exectime,int timeout,int early_timeout,int retcode,char * cmdline,char * output,char * long_output,char * perfdata,struct timeval * timestamp)139 int broker_host_check(int type, int flags, int attr, host *hst, int check_type, int state, int state_type, struct timeval start_time, struct timeval end_time, char *cmd, double latency, double exectime, int timeout, int early_timeout, int retcode, char *cmdline, char *output, char *long_output, char *perfdata, struct timeval *timestamp) {}
escape_newlines(char * rawbuf)140 char *escape_newlines(char *rawbuf) {}
dbuf_strcat(dbuf * db,char * buf)141 int dbuf_strcat(dbuf *db, char *buf) {}
dbuf_free(dbuf * db)142 int dbuf_free(dbuf *db) {}
143 unsigned long   next_event_id = 0L;
144 unsigned long   next_problem_id = 0L;
145 int             free_child_process_memory = -1;
free_memory(nagios_macros * mac)146 void free_memory(nagios_macros *mac) {}
147 int accept_passive_service_checks = TRUE;
148 int log_passive_checks = TRUE;
149 int use_aggressive_host_checking = FALSE;
handle_service_event(service * svc)150 int handle_service_event(service *svc) {}
151 unsigned long cached_host_check_horizon = DEFAULT_CACHED_HOST_CHECK_HORIZON;
check_for_service_flapping(service * svc,int update,int allow_flapstart_notification)152 void check_for_service_flapping(service *svc, int update, int allow_flapstart_notification) {}
check_for_host_flapping(host * hst,int update,int actual_check,int allow_flapstart_notification)153 void check_for_host_flapping(host *hst, int update, int actual_check, int allow_flapstart_notification) {}
service_notification(service * svc,int type,char * not_author,char * not_data,int options)154 int service_notification(service *svc, int type, char *not_author, char *not_data, int options) {}
155 int obsess_over_services = FALSE;
obsessive_compulsive_service_check_processor(service * svc)156 int obsessive_compulsive_service_check_processor(service *svc) {}
host_notification(host * hst,int type,char * not_author,char * not_data,int options)157 int host_notification(host *hst, int type, char *not_author, char *not_data, int options) {}
158 int             enable_predictive_service_dependency_checks = DEFAULT_ENABLE_PREDICTIVE_SERVICE_DEPENDENCY_CHECKS;
get_first_servicedependency_by_dependent_service(char * host_name,char * svc_description,void ** ptr)159 servicedependency *get_first_servicedependency_by_dependent_service(char *host_name, char *svc_description, void **ptr) {}
get_next_servicedependency_by_dependent_service(char * host_name,char * svc_description,void ** ptr)160 servicedependency *get_next_servicedependency_by_dependent_service(char *host_name, char *svc_description, void **ptr) {}
add_object_to_objectlist(objectlist ** list,void * object_ptr)161 int add_object_to_objectlist(objectlist **list, void *object_ptr) {}
check_pending_flex_service_downtime(service * svc)162 int check_pending_flex_service_downtime(service *svc) {}
compare_strings(char * val1a,char * val2a)163 int compare_strings(char *val1a, char *val2a) {}
update_service_performance_data(service * svc)164 int update_service_performance_data(service *svc) {}
free_objectlist(objectlist ** temp_list)165 int free_objectlist(objectlist **temp_list) {}
166 unsigned long   cached_service_check_horizon = DEFAULT_CACHED_SERVICE_CHECK_HORIZON;
167 timed_event *event_list_low = NULL;
168 timed_event *event_list_low_tail = NULL;
remove_event(timed_event * event,timed_event ** event_list,timed_event ** event_list_tail)169 void remove_event(timed_event *event, timed_event **event_list, timed_event **event_list_tail) {}
reschedule_event(timed_event * event,timed_event ** event_list,timed_event ** event_list_tail)170 void reschedule_event(timed_event *event, timed_event **event_list, timed_event **event_list_tail) {}
process_passive_service_check(time_t check_time,char * host_name,char * svc_description,int return_code,char * output)171 int process_passive_service_check(time_t check_time, char *host_name, char *svc_description, int return_code, char *output) {}
172 int             soft_state_dependencies = FALSE;
173 int             additional_freshness_latency = DEFAULT_ADDITIONAL_FRESHNESS_LATENCY;
get_first_hostdependency_by_dependent_host(char * host_name,void ** ptr)174 hostdependency *get_first_hostdependency_by_dependent_host(char *host_name, void **ptr) {
175 	/* Return NULL so check_host_dependencies returns back */
176 	return NULL;
177 	}
get_next_hostdependency_by_dependent_host(char * host_name,void ** ptr)178 hostdependency *get_next_hostdependency_by_dependent_host(char *host_name, void **ptr) {}
179 int             currently_running_host_checks = 0;
my_system_r(nagios_macros * mac,char * cmd,int timeout,int * early_timeout,double * exectime,char ** output,int max_output_length)180 int my_system_r(nagios_macros *mac, char *cmd, int timeout, int *early_timeout, double *exectime, char **output, int max_output_length) {}
181 int             accept_passive_host_checks = TRUE;
182 int             passive_host_checks_are_soft = DEFAULT_PASSIVE_HOST_CHECKS_SOFT;
183 int             translate_passive_host_checks = DEFAULT_TRANSLATE_PASSIVE_HOST_CHECKS;
184 int             enable_predictive_host_dependency_checks = DEFAULT_ENABLE_PREDICTIVE_HOST_DEPENDENCY_CHECKS;
185 
186 
187 #endif
188