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