import: Don't enable indexes unless we've disabled them
[nagios-reports-module.git] / logutils.h
blobd3488ac95747c3764b3b6527da3362e39eb4ae65
1 #ifndef logutils_h__
2 #define logutils_h__
4 #include "ndbneb.h"
5 #include <stdio.h>
6 #include <stdlib.h>
7 #include <sys/stat.h>
8 #include <unistd.h>
9 #include <string.h>
10 #include <stdarg.h>
11 #include <fcntl.h>
12 #include <errno.h>
13 #include "nagios/broker.h"
14 #include "nagios/nebcallbacks.h"
15 #include "hash.h"
17 #define CLR_RESET "\033[m"
18 #define CLR_BOLD "\033[1m"
19 #define CLR_RED "\033[31m"
20 #define CLR_GREEN "\033[32m"
21 #define CLR_BROWN "\033[33m"
22 #define CLR_YELLOW "\033[33m\033[1m"
23 #define CLR_BLUE "\033[34m"
24 #define CLR_MAGENTA "\033[35m"
25 #define CLR_CYAN "\033[36m"
26 #define CLR_BG_RED "\033[41m"
27 #define CLR_BRIGHT_RED "\033[31m\033[1m"
28 #define CLR_BRIGHT_GREEN "\033[32m\033[1m"
29 #define CLR_BRIGHT_BLUE "\033[34m\033[1m"
30 #define CLR_BRIGHT_MAGENTA "\033[35m\033[1m"
31 #define CLR_BRIGHT_CYAN "\033[36m\033[1m"
33 /* for the string code structs */
34 #define add_code(n, s, c) { n, s, sizeof(s) - 1, c, }
35 #define add_ignored(s) add_code(0, s, IGNORE_LINE)
36 #define add_cdef(__nvecs, __define) add_code(__nvecs, #__define, __define)
37 #define get_event_type(str, len) get_string_code(event_codes, str, len)
38 #define get_command_type(str, len) get_string_code(command_codes, str, len)
41 #define IGNORE_LINE 0
42 #define CONCERNS_HOST 50
43 #define CONCERNS_SERVICE 60
45 #define DEL_HOST_DOWNTIME 1
46 #define DEL_SVC_DOWNTIME 2
47 #define SCHEDULE_AND_PROPAGATE_HOST_DOWNTIME 3
48 #define SCHEDULE_AND_PROPAGATE_TRIGGERED_HOST_DOWNTIME 4
49 #define SCHEDULE_HOSTGROUP_HOST_DOWNTIME 5
50 #define SCHEDULE_HOSTGROUP_SVC_DOWNTIME 6
51 #define SCHEDULE_HOST_DOWNTIME 7
52 #define SCHEDULE_HOST_SVC_DOWNTIME 8
53 #define SCHEDULE_SERVICEGROUP_HOST_DOWNTIME 9
54 #define SCHEDULE_SERVICEGROUP_SVC_DOWNTIME 10
55 #define SCHEDULE_SVC_DOWNTIME 11
56 #define ACKNOWLEDGE_HOST_PROBLEM 12
57 #define ACKNOWLEDGE_SVC_PROBLEM 13
58 #define RESTART_PROGRAM 14
60 /* for some reason these aren't defined inside Nagios' headers */
61 #define SERVICE_OK 0
62 #define SERVICE_WARNING 1
63 #define SERVICE_CRITICAL 2
64 #define SERVICE_UNKNOWN 3
66 typedef unsigned int uint;
68 struct naglog_file {
69 time_t first;
70 char *path;
71 uint size;
72 uint cmp;
74 extern struct naglog_file *nfile;
76 struct string_code {
77 int nvecs;
78 const char *str;
79 uint len;
80 int code;
83 extern int debug_level;
84 extern int num_nfile;
85 extern struct naglog_file *cur_file; /* the file we're currently importing */
86 extern uint line_no;
87 extern uint num_unhandled;
88 extern char **strv;
90 extern int vectorize_string(char *str, int nvecs);
91 extern void handle_unknown_event(const char *line);
92 extern void print_unhandled_events(void);
94 extern int parse_notification_reason(const char *str);
95 extern int parse_service_state(const char *str);
96 extern int parse_host_state(const char *str);
97 extern int parse_service_state_gently(const char *str);
98 extern int parse_host_state_gently(const char *str);
99 extern int soft_hard(const char *str);
101 extern void print_interesting_objects(void);
102 extern int add_interesting_object(const char *orig_str);
103 extern int is_interesting_host(const char *host);
104 extern int is_interesting_service(const char *host, const char *service);
105 extern int is_interesting(const char *ptr);
106 extern int is_start_event(const char *ptr);
107 extern int is_stop_event(const char *ptr);
108 extern int add_naglog_path(char *path);
111 extern struct string_code *get_string_code(struct string_code *codes,
112 const char *str, uint len);
114 extern uint warnings;
115 extern void crash(const char *fmt, ...)
116 __attribute__((__format__(__printf__, 1, 2), __noreturn__));
117 extern void pdebug(int lvl, const char *fmt, ...)
118 __attribute__((__format__(__printf__, 2, 3)));
119 #define debug(...) pdebug(1, __VA_ARGS__)
120 extern void warn(const char *fmt, ...);
122 int strtotimet(const char *str, time_t *val);
125 extern uint path_cmp_number(char *path);
126 extern void first_log_time(struct naglog_file *nf);
127 extern int nfile_cmp(const void *p1, const void *p2);
128 extern int nfile_rev_cmp(const void *p1, const void *p2);
130 #endif