Changeset 1afde4ed656dbe3db947a99cd27b177f5a3f560f
- Timestamp:
- 01/30/08 05:06:13
(5 years ago)
- Author:
- Theo Schlossnagle <jesus@omniti.com>
- git-committer:
- Theo Schlossnagle <jesus@omniti.com> 1201669573 +0000
- git-parent:
[27bd35b5a3e6285c5119854280b9d30b9b869fdf]
- git-author:
- Theo Schlossnagle <jesus@omniti.com> 1201669573 +0000
- Message:
update logging to support faster avoidance, line numbers, filenames, etc.
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| re3c8f10 |
r1afde4e |
|
| 270 | 270 | NULL, 0, |
|---|
| 271 | 271 | &__zerotime); |
|---|
| 272 | | noit_log(noit_debug, &__now, "debug: kevent(%d, [], %d) => %d\n", kqueue_fd, master_kqs->__ke_vec_used, fd_cnt); |
|---|
| | 272 | noitLT(noit_debug, &__now, "debug: kevent(%d, [], %d) => %d\n", kqueue_fd, master_kqs->__ke_vec_used, fd_cnt); |
|---|
| 273 | 273 | if(fd_cnt < 0) { |
|---|
| 274 | | noit_log(noit_error, &__now, "kevent: %s\n", strerror(errno)); |
|---|
| | 274 | noitLT(noit_error, &__now, "kevent: %s\n", strerror(errno)); |
|---|
| 275 | 275 | } |
|---|
| 276 | 276 | master_kqs->__ke_vec_used = 0; |
|---|
| … | … | |
| 284 | 284 | ke_vec, ke_vec_a, |
|---|
| 285 | 285 | &__kqueue_sleeptime); |
|---|
| 286 | | noit_log(noit_debug, &__now, "debug: kevent(%d, [], %d) => %d\n", kqueue_fd, ke_vec_used, fd_cnt); |
|---|
| | 286 | noitLT(noit_debug, &__now, "debug: kevent(%d, [], %d) => %d\n", kqueue_fd, ke_vec_used, fd_cnt); |
|---|
| 287 | 287 | ke_vec_used = 0; |
|---|
| 288 | 288 | if(fd_cnt < 0) { |
|---|
| 289 | | noit_log(noit_error, &__now, "kevent: %s\n", strerror(errno)); |
|---|
| | 289 | noitLT(noit_error, &__now, "kevent: %s\n", strerror(errno)); |
|---|
| 290 | 290 | } |
|---|
| 291 | 291 | else { |
|---|
| … | … | |
| 317 | 317 | if(ke->flags & EV_ERROR) { |
|---|
| 318 | 318 | if(ke->data != EBADF) |
|---|
| 319 | | noit_log(noit_error, &__now, "error: %s\n", strerror(ke->data)); |
|---|
| | 319 | noitLT(noit_error, &__now, "error: %s\n", strerror(ke->data)); |
|---|
| 320 | 320 | continue; |
|---|
| 321 | 321 | } |
|---|
| … | … | |
| 330 | 330 | oldmask = e->mask; |
|---|
| 331 | 331 | cbname = eventer_name_for_callback(e->callback); |
|---|
| 332 | | noit_log(noit_debug, &__now, "kqueue: fire on %d/%x to %s(%p)\n", |
|---|
| 333 | | fd, masks[fd], cbname?cbname:"???", e->callback); |
|---|
| | 332 | noitLT(noit_debug, &__now, "kqueue: fire on %d/%x to %s(%p)\n", |
|---|
| | 333 | fd, masks[fd], cbname?cbname:"???", e->callback); |
|---|
| 334 | 334 | newmask = e->callback(e, masks[fd], e->closure, &__now); |
|---|
| 335 | 335 | masks[fd] = 0; /* indicates we've processed this fd */ |
|---|
| r27bd35b |
r1afde4e |
|
| 109 | 109 | ci->timed_out ? "timeout" : rt, |
|---|
| 110 | 110 | ci->body.l); |
|---|
| 111 | | noit_log(nldeb, NULL, "http(%s) [%s]\n", check->target, human_buffer); |
|---|
| | 111 | noitL(nldeb, "http(%s) [%s]\n", check->target, human_buffer); |
|---|
| 112 | 112 | |
|---|
| 113 | 113 | current.duration = duration.tv_sec * 1000 + duration.tv_usec / 1000; |
|---|
| … | … | |
| 122 | 122 | check_info_t *ci = (check_info_t *)ccl->check->closure; |
|---|
| 123 | 123 | |
|---|
| 124 | | noit_log(nldeb, now, "serf_complete(%s)\n", ccl->check->target); |
|---|
| | 124 | noitLT(nldeb, now, "serf_complete(%s)\n", ccl->check->target); |
|---|
| 125 | 125 | serf_log_results(ccl->self, ccl->check); |
|---|
| 126 | 126 | if(ci->connection) { |
|---|
| … | … | |
| 354 | 354 | struct __unix_apr_socket_t *hack = (struct __unix_apr_socket_t *)pfd->desc.s; |
|---|
| 355 | 355 | |
|---|
| 356 | | noit_log(nldeb, NULL, "serf_eventer_add() => %d\n", |
|---|
| 357 | | hack->socketdes); |
|---|
| | 356 | noitL(nldeb, "serf_eventer_add() => %d\n", hack->socketdes); |
|---|
| 358 | 357 | e = eventer_find_fd(hack->socketdes); |
|---|
| 359 | 358 | if(!e) { |
|---|
| … | … | |
| 394 | 393 | struct __unix_apr_socket_t *hack = (struct __unix_apr_socket_t *)pfd->desc.s; |
|---|
| 395 | 394 | |
|---|
| 396 | | noit_log(nldeb, NULL, "serf_eventer_remove() => %d\n", |
|---|
| 397 | | hack->socketdes); |
|---|
| | 395 | noitL(nldeb, "serf_eventer_remove() => %d\n", hack->socketdes); |
|---|
| 398 | 396 | e = eventer_find_fd(hack->socketdes); |
|---|
| 399 | 397 | if(e) e->mask = 0; |
|---|
| … | … | |
| 413 | 411 | assert(!(check->flags & NP_RUNNING)); |
|---|
| 414 | 412 | check->flags |= NP_RUNNING; |
|---|
| 415 | | noit_log(nldeb, NULL, "serf_initiate(%p,%s)\n", |
|---|
| 416 | | self, check->target); |
|---|
| | 413 | noitL(nldeb, "serf_initiate(%p,%s)\n", |
|---|
| | 414 | self, check->target); |
|---|
| 417 | 415 | |
|---|
| 418 | 416 | /* remove a timeout if we still have one -- we should unless someone |
|---|
| re3c8f10 |
r1afde4e |
|
| 65 | 65 | for(i=0; i<data->expected_count; i++) |
|---|
| 66 | 66 | if(data->turnaround[i] == 0.0) { |
|---|
| 67 | | noit_log(nldeb, NULL, "ping_icmp: %s %d is still outstanding.\n", |
|---|
| 68 | | check->target, i); |
|---|
| | 67 | noitL(nldeb, "ping_icmp: %s %d is still outstanding.\n", |
|---|
| | 68 | check->target, i); |
|---|
| 69 | 69 | return 0; |
|---|
| 70 | 70 | } |
|---|
| … | … | |
| 99 | 99 | "cnt=%d,avail=%0.0f,min=%0.4f,max=%0.4f,avg=%0.4f", |
|---|
| 100 | 100 | (int)cnt, 100.0*avail, min, max, avg); |
|---|
| 101 | | noit_log(nldeb, NULL, "ping_icmp(%s) [%s]\n", check->target, human_buffer); |
|---|
| | 101 | noitL(nldeb, "ping_icmp(%s) [%s]\n", check->target, human_buffer); |
|---|
| 102 | 102 | |
|---|
| 103 | 103 | gettimeofday(¤t.whence, NULL); |
|---|
| … | … | |
| 148 | 148 | if(inlen < 0) { |
|---|
| 149 | 149 | if(errno == EAGAIN || errno == EINTR) break; |
|---|
| 150 | | noit_log(nlerr, now, "ping_icmp recvfrom: %s\n", strerror(errno)); |
|---|
| | 150 | noitLT(nlerr, now, "ping_icmp recvfrom: %s\n", strerror(errno)); |
|---|
| 151 | 151 | break; |
|---|
| 152 | 152 | } |
|---|
| 153 | 153 | iphlen = ip->ip_hl << 2; |
|---|
| 154 | 154 | if((inlen-iphlen) != (sizeof(struct icmp)+sizeof(struct ping_payload))) { |
|---|
| 155 | | noit_log(nlerr, now, |
|---|
| 156 | | "ping_icmp bad size: %d+%d\n", iphlen, inlen-iphlen); |
|---|
| | 155 | noitLT(nlerr, now, |
|---|
| | 156 | "ping_icmp bad size: %d+%d\n", iphlen, inlen-iphlen); |
|---|
| 157 | 157 | continue; |
|---|
| 158 | 158 | } |
|---|
| … | … | |
| 163 | 163 | } |
|---|
| 164 | 164 | if(icp->icmp_id != (((vpsized_uint)self) & 0xffff)) { |
|---|
| 165 | | noit_log(nlerr, now, |
|---|
| | 165 | noitLT(nlerr, now, |
|---|
| 166 | 166 | "ping_icmp not sent from this instance (%d:%d) vs. %d\n", |
|---|
| 167 | 167 | icp->icmp_id, ntohs(icp->icmp_seq), |
|---|
| … | … | |
| 173 | 173 | char uuid_str[37]; |
|---|
| 174 | 174 | uuid_unparse_lower(payload->checkid, uuid_str); |
|---|
| 175 | | noit_log(nlerr, now, |
|---|
| 176 | | "ping_icmp response for unknown check '%s'\n", uuid_str); |
|---|
| | 175 | noitLT(nlerr, now, |
|---|
| | 176 | "ping_icmp response for unknown check '%s'\n", uuid_str); |
|---|
| 177 | 177 | continue; |
|---|
| 178 | 178 | } |
|---|
| … | … | |
| 213 | 213 | |
|---|
| 214 | 214 | if ((proto = getprotobyname("icmp")) == NULL) { |
|---|
| 215 | | noit_log(nlerr, NULL, "Couldn't find 'icmp' protocol\n"); |
|---|
| | 215 | noitL(nlerr, "Couldn't find 'icmp' protocol\n"); |
|---|
| 216 | 216 | return -1; |
|---|
| 217 | 217 | } |
|---|
| … | … | |
| 219 | 219 | data->ipv4_fd = socket(AF_INET, SOCK_RAW, proto->p_proto); |
|---|
| 220 | 220 | if(data->ipv4_fd < 0) { |
|---|
| 221 | | noit_log(nlerr, NULL, "ping_icmp: socket failed: %s\n", |
|---|
| 222 | | strerror(errno)); |
|---|
| | 221 | noitL(nlerr, "ping_icmp: socket failed: %s\n", |
|---|
| | 222 | strerror(errno)); |
|---|
| 223 | 223 | } |
|---|
| 224 | 224 | else { |
|---|
| … | … | |
| 227 | 227 | close(data->ipv4_fd); |
|---|
| 228 | 228 | data->ipv4_fd = -1; |
|---|
| 229 | | noit_log(nlerr, NULL, |
|---|
| 230 | | "ping_icmp: could not set socket non-blocking: %s\n", |
|---|
| 231 | | strerror(errno)); |
|---|
| | 229 | noitL(nlerr, |
|---|
| | 230 | "ping_icmp: could not set socket non-blocking: %s\n", |
|---|
| | 231 | strerror(errno)); |
|---|
| 232 | 232 | } |
|---|
| 233 | 233 | } |
|---|
| … | … | |
| 244 | 244 | data->ipv6_fd = socket(AF_INET6, SOCK_RAW, proto->p_proto); |
|---|
| 245 | 245 | if(data->ipv6_fd < 0) { |
|---|
| 246 | | noit_log(nlerr, NULL, "ping_icmp: socket failed: %s\n", |
|---|
| 247 | | strerror(errno)); |
|---|
| | 246 | noitL(nlerr, "ping_icmp: socket failed: %s\n", |
|---|
| | 247 | strerror(errno)); |
|---|
| 248 | 248 | } |
|---|
| 249 | 249 | else { |
|---|
| … | … | |
| 252 | 252 | close(data->ipv6_fd); |
|---|
| 253 | 253 | data->ipv6_fd = -1; |
|---|
| 254 | | noit_log(nlerr, NULL, |
|---|
| 255 | | "ping_icmp: could not set socket non-blocking: %s\n", |
|---|
| | 254 | noitL(nlerr, |
|---|
| | 255 | "ping_icmp: could not set socket non-blocking: %s\n", |
|---|
| 256 | 256 | strerror(errno)); |
|---|
| 257 | 257 | } |
|---|
| … | … | |
| 279 | 279 | int i; |
|---|
| 280 | 280 | |
|---|
| 281 | | noit_log(nldeb, NULL, "ping_icmp_real_send(%s)\n", pcl->check->target); |
|---|
| | 281 | noitLT(nldeb, now, "ping_icmp_real_send(%s)\n", pcl->check->target); |
|---|
| 282 | 282 | data = noit_module_get_userdata(pcl->self); |
|---|
| 283 | 283 | icp = (struct icmp *)pcl->payload; |
|---|
| … | … | |
| 306 | 306 | } |
|---|
| 307 | 307 | if(i != pcl->payload_len) { |
|---|
| 308 | | noit_log(nlerr, now, "Error sending ICMP packet to %s: %s\n", |
|---|
| | 308 | noitLT(nlerr, now, "Error sending ICMP packet to %s: %s\n", |
|---|
| 309 | 309 | pcl->check->target, strerror(errno)); |
|---|
| 310 | 310 | } |
|---|
| … | … | |
| 324 | 324 | |
|---|
| 325 | 325 | check->flags |= NP_RUNNING; |
|---|
| 326 | | noit_log(nldeb, NULL, "ping_icmp_send(%p,%s,%d,%d)\n", |
|---|
| 327 | | self, check->target, interval, count); |
|---|
| | 326 | noitL(nldeb, "ping_icmp_send(%p,%s,%d,%d)\n", |
|---|
| | 327 | self, check->target, interval, count); |
|---|
| 328 | 328 | |
|---|
| 329 | 329 | /* remove a timeout if we still have one -- we should unless someone |
|---|
| r80235b3 |
r1afde4e |
|
| 74 | 74 | const char *event_name; |
|---|
| 75 | 75 | |
|---|
| 76 | | noit_log(noit_debug, NULL, "noit_listener(%s, %d, %d, %d, %s, %p)\n", |
|---|
| 77 | | host, port, type, backlog, |
|---|
| 78 | | (event_name = eventer_name_for_callback(handler))?event_name:"??", |
|---|
| 79 | | closure); |
|---|
| | 76 | noitL(noit_debug, "noit_listener(%s, %d, %d, %d, %s, %p)\n", |
|---|
| | 77 | host, port, type, backlog, |
|---|
| | 78 | (event_name = eventer_name_for_callback(handler))?event_name:"??", |
|---|
| | 79 | closure); |
|---|
| 80 | 80 | family = AF_INET; |
|---|
| 81 | 81 | rv = inet_pton(family, host, &a); |
|---|
| … | … | |
| 88 | 88 | a.addr4.s_addr = INADDR_ANY; |
|---|
| 89 | 89 | } else { |
|---|
| 90 | | noit_log(noit_stderr, NULL, "Cannot translate '%s' to IP\n", host); |
|---|
| | 90 | noitL(noit_stderr, "Cannot translate '%s' to IP\n", host); |
|---|
| 91 | 91 | return -1; |
|---|
| 92 | 92 | } |
|---|
| … | … | |
| 117 | 117 | if(bind(fd, (struct sockaddr *)&s, |
|---|
| 118 | 118 | (family == AF_INET) ? sizeof(s.addr4) : sizeof(s.addr6)) < 0) { |
|---|
| 119 | | noit_log(noit_stderr, NULL, "bind failed: %s\b", strerror(errno)); |
|---|
| | 119 | noitL(noit_stderr, "bind failed: %s\b", strerror(errno)); |
|---|
| 120 | 120 | close(fd); |
|---|
| 121 | 121 | return -1; |
|---|
| … | … | |
| 152 | 152 | listener_configs = noit_conf_get_sections(NULL, "/noit/listeners/listener", |
|---|
| 153 | 153 | &cnt); |
|---|
| 154 | | noit_log(noit_stderr, NULL, "Found %d /noit/listeners/listener stanzas\n", |
|---|
| 155 | | cnt); |
|---|
| | 154 | noitL(noit_stderr, "Found %d /noit/listeners/listener stanzas\n", cnt); |
|---|
| 156 | 155 | for(i=0; i<cnt; i++) { |
|---|
| 157 | 156 | char address[256]; |
|---|
| … | … | |
| 164 | 163 | if(!noit_conf_get_stringbuf(listener_configs[i], |
|---|
| 165 | 164 | "type", type, sizeof(type))) { |
|---|
| 166 | | noit_log(noit_stderr, NULL, |
|---|
| 167 | | "No type specified in listener stanza %d\n", i+1); |
|---|
| | 165 | noitL(noit_stderr, "No type specified in listener stanza %d\n", i+1); |
|---|
| 168 | 166 | continue; |
|---|
| 169 | 167 | } |
|---|
| 170 | 168 | f = eventer_callback_for_name(type); |
|---|
| 171 | 169 | if(!f) { |
|---|
| 172 | | noit_log(noit_stderr, NULL, |
|---|
| 173 | | "Cannot find handler for listener type: '%s'\n", type); |
|---|
| | 170 | noitL(noit_stderr, |
|---|
| | 171 | "Cannot find handler for listener type: '%s'\n", type); |
|---|
| 174 | 172 | continue; |
|---|
| 175 | 173 | } |
|---|
| … | … | |
| 178 | 176 | port = (unsigned short) portint; |
|---|
| 179 | 177 | if(portint == 0 || (port != portint)) { |
|---|
| 180 | | noit_log(noit_stderr, NULL, |
|---|
| 181 | | "Invalid port [%d] specified in stanza %d\n", port, i+1); |
|---|
| | 178 | noitL(noit_stderr, |
|---|
| | 179 | "Invalid port [%d] specified in stanza %d\n", port, i+1); |
|---|
| 182 | 180 | continue; |
|---|
| 183 | 181 | } |
|---|
| rb09f3a7 |
r1afde4e |
|
| 39 | 39 | dlhandle = dlopen(module_file, RTLD_LAZY | RTLD_GLOBAL); |
|---|
| 40 | 40 | if(!dlhandle) { |
|---|
| 41 | | noit_log(noit_stderr, NULL, "Cannot open image '%s': %s\n", |
|---|
| 42 | | module_file, dlerror()); |
|---|
| | 41 | noitL(noit_stderr, "Cannot open image '%s': %s\n", |
|---|
| | 42 | module_file, dlerror()); |
|---|
| 43 | 43 | return -1; |
|---|
| 44 | 44 | } |
|---|
| … | … | |
| 46 | 46 | dlsymbol = dlsym(dlhandle, name); |
|---|
| 47 | 47 | if(!dlsymbol) { |
|---|
| 48 | | noit_log(noit_stderr, NULL, "Cannot find '%s' in image '%s': %s\n", |
|---|
| 49 | | name, module_file, dlerror()); |
|---|
| | 48 | noitL(noit_stderr, "Cannot find '%s' in image '%s': %s\n", |
|---|
| | 49 | name, module_file, dlerror()); |
|---|
| 50 | 50 | dlclose(dlhandle); |
|---|
| 51 | 51 | return -1; |
|---|
| … | … | |
| 53 | 53 | |
|---|
| 54 | 54 | if(noit_module_validate_magic((noit_module_t *)dlsymbol) == -1) { |
|---|
| 55 | | noit_log(noit_stderr, NULL, "I can't understand module %s\n", name); |
|---|
| | 55 | noitL(noit_stderr, "I can't understand module %s\n", name); |
|---|
| 56 | 56 | dlclose(dlhandle); |
|---|
| 57 | 57 | return -1; |
|---|
| … | … | |
| 92 | 92 | if(!noit_conf_get_stringbuf(sections[i], "image", |
|---|
| 93 | 93 | module_file, sizeof(module_file))) { |
|---|
| 94 | | noit_log(noit_stderr, NULL, |
|---|
| 95 | | "No image defined in module stanza %d\n", i+1); |
|---|
| | 94 | noitL(noit_stderr, "No image defined in module stanza %d\n", i+1); |
|---|
| 96 | 95 | continue; |
|---|
| 97 | 96 | } |
|---|
| 98 | 97 | if(!noit_conf_get_stringbuf(sections[i], "name", |
|---|
| 99 | 98 | module_name, sizeof(module_name))) { |
|---|
| 100 | | noit_log(noit_stderr, NULL, |
|---|
| 101 | | "No name defined in module stanza %d\n", i+1); |
|---|
| | 99 | noitL(noit_stderr, "No name defined in module stanza %d\n", i+1); |
|---|
| 102 | 100 | continue; |
|---|
| 103 | 101 | } |
|---|
| 104 | 102 | if(noit_module_load(module_file, module_name)) { |
|---|
| 105 | | noit_log(noit_stderr, NULL, |
|---|
| 106 | | "Could not load %s:%s\n", module_file, module_name); |
|---|
| | 103 | noitL(noit_stderr, "Could not load %s:%s\n", module_file, module_name); |
|---|
| 107 | 104 | continue; |
|---|
| 108 | 105 | } |
|---|
| … | … | |
| 110 | 107 | module = noit_module_lookup(module_name); |
|---|
| 111 | 108 | if(module->config(module, config)) { |
|---|
| 112 | | noit_log(noit_stderr, NULL, |
|---|
| 113 | | "Configure failed on %s:%s\n", module_file, module_name); |
|---|
| | 109 | noitL(noit_stderr, |
|---|
| | 110 | "Configure failed on %s:%s\n", module_file, module_name); |
|---|
| 114 | 111 | continue; |
|---|
| 115 | 112 | } |
|---|
| 116 | 113 | if(module->init(module)) { |
|---|
| 117 | | noit_log(noit_stderr, NULL, |
|---|
| 118 | | "Initialized failed on %s:%s\n", module_file, module_name); |
|---|
| | 114 | noitL(noit_stderr, |
|---|
| | 115 | "Initialized failed on %s:%s\n", module_file, module_name); |
|---|
| 119 | 116 | continue; |
|---|
| 120 | 117 | } |
|---|
| 121 | | noit_log(noit_stderr, NULL, "Module %s:%s successfully loaded.\n", |
|---|
| 122 | | module_file, module_name); |
|---|
| | 118 | noitL(noit_stderr, "Module %s:%s successfully loaded.\n", |
|---|
| | 119 | module_file, module_name); |
|---|
| 123 | 120 | } |
|---|
| 124 | 121 | } |
|---|
| r27bd35b |
r1afde4e |
|
| 61 | 61 | if(!noit_conf_get_stringbuf(sec[i], "@uuid", |
|---|
| 62 | 62 | uuid_str, sizeof(uuid_str))) { |
|---|
| 63 | | noit_log(noit_stderr, NULL, "check %d has no uuid\n", i+1); |
|---|
| | 63 | noitL(noit_stderr, "check %d has no uuid\n", i+1); |
|---|
| 64 | 64 | continue; |
|---|
| 65 | 65 | } |
|---|
| 66 | 66 | if(uuid_parse(uuid_str, uuid)) { |
|---|
| 67 | | noit_log(noit_stderr, NULL, "check uuid: '%s' is invalid\n", uuid_str); |
|---|
| | 67 | noitL(noit_stderr, "check uuid: '%s' is invalid\n", uuid_str); |
|---|
| 68 | 68 | continue; |
|---|
| 69 | 69 | } |
|---|
| 70 | 70 | if(!noit_conf_get_stringbuf(sec[i], "target", target, sizeof(target))) { |
|---|
| 71 | 71 | if(!noit_conf_get_stringbuf(sec[i], "../target", target, sizeof(target))) { |
|---|
| 72 | | noit_log(noit_stderr, NULL, "check uuid: '%s' has no target\n", |
|---|
| | 72 | noitL(noit_stderr, "check uuid: '%s' has no target\n", |
|---|
| 73 | 73 | uuid_str); |
|---|
| 74 | 74 | continue; |
|---|
| … | … | |
| 77 | 77 | if(!noit_conf_get_stringbuf(sec[i], "module", module, sizeof(module))) { |
|---|
| 78 | 78 | if(!noit_conf_get_stringbuf(sec[i], "../module", module, sizeof(module))) { |
|---|
| 79 | | noit_log(noit_stderr, NULL, "check uuid: '%s' has no module\n", |
|---|
| | 79 | noitL(noit_stderr, "check uuid: '%s' has no module\n", |
|---|
| 80 | 80 | uuid_str); |
|---|
| 81 | 81 | continue; |
|---|
| … | … | |
| 87 | 87 | if(!noit_conf_get_int(sec[i], "period", &period)) { |
|---|
| 88 | 88 | if(!noit_conf_get_int(sec[i], "../period", &period)) { |
|---|
| 89 | | noit_log(noit_stderr, NULL, "check uuid: '%s' has no period\n", uuid_str); |
|---|
| | 89 | noitL(noit_stderr, "check uuid: '%s' has no period\n", uuid_str); |
|---|
| 90 | 90 | continue; |
|---|
| 91 | 91 | } |
|---|
| … | … | |
| 93 | 93 | if(!noit_conf_get_int(sec[i], "timeout", &timeout)) { |
|---|
| 94 | 94 | if(!noit_conf_get_int(sec[i], "../timeout", &timeout)) { |
|---|
| 95 | | noit_log(noit_stderr, NULL, "check uuid: '%s' has no timeout\n", uuid_str); |
|---|
| | 95 | noitL(noit_stderr, "check uuid: '%s' has no timeout\n", uuid_str); |
|---|
| 96 | 96 | continue; |
|---|
| 97 | 97 | } |
|---|
| 98 | 98 | } |
|---|
| 99 | 99 | if(timeout >= period) { |
|---|
| 100 | | noit_log(noit_stderr, NULL, "check uuid: '%s' timeout > period\n", uuid_str); |
|---|
| | 100 | noitL(noit_stderr, "check uuid: '%s' timeout > period\n", uuid_str); |
|---|
| 101 | 101 | timeout = period/2; |
|---|
| 102 | 102 | } |
|---|
| … | … | |
| 104 | 104 | noit_poller_schedule(target, module, name, options, |
|---|
| 105 | 105 | period, timeout, uuid, out_uuid); |
|---|
| 106 | | noit_log(noit_debug, NULL, "loaded uuid: %s\n", uuid_str); |
|---|
| | 106 | noitL(noit_debug, "loaded uuid: %s\n", uuid_str); |
|---|
| 107 | 107 | } |
|---|
| 108 | 108 | } |
|---|
| … | … | |
| 122 | 122 | } |
|---|
| 123 | 123 | else { |
|---|
| 124 | | noit_log(noit_stderr, NULL, "Cannot find module '%s'\n", check->module); |
|---|
| | 124 | noitL(noit_stderr, "Cannot find module '%s'\n", check->module); |
|---|
| 125 | 125 | } |
|---|
| 126 | 126 | } |
|---|
| … | … | |
| 157 | 157 | rv = inet_pton(family, target, &a); |
|---|
| 158 | 158 | if(rv != 1) { |
|---|
| 159 | | noit_log(noit_stderr, NULL, "Cannot translate '%s' to IP\n", target); |
|---|
| | 159 | noitL(noit_stderr, "Cannot translate '%s' to IP\n", target); |
|---|
| 160 | 160 | return -1; |
|---|
| 161 | 161 | } |
|---|
| … | … | |
| 260 | 260 | |
|---|
| 261 | 261 | if(report_change) { |
|---|
| 262 | | noit_log(noit_debug, NULL, "%s/%s -> [%s/%s]\n", |
|---|
| 263 | | check->target, check->module, |
|---|
| 264 | | __noit_check_available_string(check->stats.current.available), |
|---|
| 265 | | __noit_check_state_string(check->stats.current.state)); |
|---|
| 266 | | } |
|---|
| 267 | | } |
|---|
| | 262 | noitL(noit_debug, "%s/%s -> [%s/%s]\n", |
|---|
| | 263 | check->target, check->module, |
|---|
| | 264 | __noit_check_available_string(check->stats.current.available), |
|---|
| | 265 | __noit_check_state_string(check->stats.current.state)); |
|---|
| | 266 | } |
|---|
| | 267 | } |
|---|
| r80235b3 |
r1afde4e |
|
| 40 | 40 | /* First initialize logging, so we can log errors */ |
|---|
| 41 | 41 | noit_log_init(); |
|---|
| 42 | | if(debug) |
|---|
| | 42 | if(debug) { |
|---|
| 43 | 43 | noit_log_stream_add_stream(noit_debug, noit_stderr); |
|---|
| | 44 | noit_debug->enabled = 1; |
|---|
| | 45 | } |
|---|
| | 46 | else { |
|---|
| | 47 | noit_debug->enabled = 0; |
|---|
| | 48 | } |
|---|
| 44 | 49 | noit_log_stream_add_stream(noit_error, noit_stderr); |
|---|
| 45 | 50 | |
|---|
| … | … | |
| 53 | 58 | if(!noit_conf_get_stringbuf(NULL, "/noit/eventer/implementation", |
|---|
| 54 | 59 | conf_str, sizeof(conf_str))) { |
|---|
| 55 | | noit_log(noit_stderr, NULL, "Cannot find '%s' in configuration\n", |
|---|
| 56 | | "/noit/eventer/implementation"); |
|---|
| | 60 | noitL(noit_stderr, "Cannot find '%s' in configuration\n", |
|---|
| | 61 | "/noit/eventer/implementation"); |
|---|
| 57 | 62 | exit(-1); |
|---|
| 58 | 63 | } |
|---|
| 59 | 64 | if(eventer_choose(conf_str) == -1) { |
|---|
| 60 | | noit_log(noit_stderr, NULL, "Cannot choose eventer %s\n", conf_str); |
|---|
| | 65 | noitL(noit_stderr, "Cannot choose eventer %s\n", conf_str); |
|---|
| 61 | 66 | exit(-1); |
|---|
| 62 | 67 | } |
|---|
| 63 | 68 | if(eventer_init() == -1) { |
|---|
| 64 | | noit_log(noit_stderr, NULL, "Cannot init eventer %s\n", conf_str); |
|---|
| | 69 | noitL(noit_stderr, "Cannot init eventer %s\n", conf_str); |
|---|
| 65 | 70 | exit(-1); |
|---|
| 66 | 71 | } |
|---|
| re3c8f10 |
r1afde4e |
|
| 49 | 49 | <timeout>1000</timeout> |
|---|
| 50 | 50 | <check uuid="1b4e28ba-2fa1-11d2-883f-b9a761bde3fc"> |
|---|
| 51 | | <target>66.225.209.7</target> |
|---|
| | 51 | <target>66.225.209.31</target> |
|---|
| | 52 | <config> |
|---|
| | 53 | <url>http://ngm.nationalgeographic.com/ngm/ngm.html</url> |
|---|
| | 54 | <code>302</code> |
|---|
| | 55 | </config> |
|---|
| 52 | 56 | </check> |
|---|
| 53 | 57 | </checkgroup> |
|---|
| rf235ad4 |
r1afde4e |
|
| 170 | 170 | void |
|---|
| 171 | 171 | noit_vlog(noit_log_stream_t ls, struct timeval *now, |
|---|
| | 172 | const char *file, int line, |
|---|
| 172 | 173 | const char *format, va_list arg) { |
|---|
| 173 | 174 | char buffer[4096]; |
|---|
| … | … | |
| 192 | 193 | #ifdef va_copy |
|---|
| 193 | 194 | va_copy(copy, arg); |
|---|
| 194 | | noit_vlog(node->outlet, now, format, copy); |
|---|
| | 195 | noit_vlog(node->outlet, now, file, line, format, copy); |
|---|
| 195 | 196 | va_end(copy); |
|---|
| 196 | 197 | #else |
|---|
| 197 | | noit_vlog(node->outlet, now, format, arg); |
|---|
| | 198 | noit_vlog(node->outlet, now, file, line, format, arg); |
|---|
| 198 | 199 | #endif |
|---|
| 199 | 200 | } |
|---|
| … | … | |
| 201 | 202 | |
|---|
| 202 | 203 | void |
|---|
| 203 | | noit_log(noit_log_stream_t ls, struct timeval *now, const char *format, ...) { |
|---|
| | 204 | noit_log(noit_log_stream_t ls, struct timeval *now, |
|---|
| | 205 | const char *file, int line, const char *format, ...) { |
|---|
| 204 | 206 | va_list arg; |
|---|
| 205 | 207 | va_start(arg, format); |
|---|
| 206 | | noit_vlog(ls, now, format, arg); |
|---|
| | 208 | noit_vlog(ls, now, file, line, format, arg); |
|---|
| 207 | 209 | va_end(arg); |
|---|
| 208 | 210 | } |
|---|
| rf235ad4 |
r1afde4e |
|
| 41 | 41 | API_EXPORT(void) noit_log_stream_free(noit_log_stream_t ls); |
|---|
| 42 | 42 | API_EXPORT(void) noit_vlog(noit_log_stream_t ls, struct timeval *, |
|---|
| | 43 | const char *file, int line, |
|---|
| 43 | 44 | const char *format, va_list arg); |
|---|
| 44 | 45 | API_EXPORT(void) noit_log(noit_log_stream_t ls, struct timeval *, |
|---|
| | 46 | const char *file, int line, |
|---|
| 45 | 47 | const char *format, ...) |
|---|
| 46 | 48 | #ifdef __GNUC__ |
|---|
| 47 | | __attribute__ ((format (printf, 3, 4))) |
|---|
| | 49 | __attribute__ ((format (printf, 5, 6))) |
|---|
| 48 | 50 | #endif |
|---|
| 49 | 51 | ; |
|---|
| 50 | 52 | |
|---|
| | 53 | #define noitLT(ls, t, args...) \ |
|---|
| | 54 | if(ls && ls->enabled) noit_log(ls, t, __FILE__, __LINE__, args) |
|---|
| | 55 | #define noitL(ls, args...) do { \ |
|---|
| | 56 | if(ls && ls->enabled) { \ |
|---|
| | 57 | struct timeval __noitL_now; \ |
|---|
| | 58 | gettimeofday(&__noitL_now, NULL); \ |
|---|
| | 59 | noit_log(ls, &__noitL_now, __FILE__, __LINE__, args); \ |
|---|
| | 60 | } \ |
|---|
| | 61 | } while(0) |
|---|
| | 62 | |
|---|
| 51 | 63 | #endif |
|---|