Changeset 832c60c9213032868ca5cf0d28b130c84b19c340

Show
Ignore:
Timestamp:
07/28/11 17:02:43 (6 years ago)
Author:
Theo Schlossnagle <jesus@omniti.com>
git-committer:
Theo Schlossnagle <jesus@omniti.com> 1311872563 -0400
git-parent:

[3aa92a99288199674668d8f00e7767069cb8ef34], [df2e3105cd06d3cc051c0f09fdc00044eeccccd1]

git-author:
Theo Schlossnagle <jesus@omniti.com> 1311872563 -0400
Message:

merge in master

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • configure.in

    r1c72b25 rdf2e310  
    174174AC_CHECK_LIB(posix4, sem_wait, , ) 
    175175AC_CHECK_LIB(pthread, pthread_create, , ) 
     176AC_CHECK_LIB(protobuf-c, protobuf_c_message_get_packed_size, , 
     177             [AC_MSG_ERROR(libprotobuf-c required)]) 
     178 
    176179AC_CHECK_FUNC(uuid_generate, , [ 
    177180  AC_MSG_WARN([uuid_generate not available]) 
     
    204207) 
    205208 
    206 old_LIBS=$LIBS 
    207 old_CFLAGS=$CFLAGS 
     209old_LIBS="$LIBS" 
     210old_CFLAGS="$CFLAGS" 
    208211AC_CHECK_LIB(pq, PQconnectdb, 
    209212        [ 
     
    665668        [--with-javalibdir=PFX  prefix to install java libs (optional)], 
    666669        [JAVA_LIB_DIR=$withval],) 
     670AC_MSG_CHECKING([Resolving javalibdir path...]) 
     671fullpath=$JAVA_LIB_DIR 
     672while test "x$temppath" != "x$fullpath" ; do 
     673  temppath=$fullpath 
     674  fullpath=`eval echo ${fullpath}` 
     675done 
     676fullpath=`echo $fullpath | sed "s~NONE~$SUBPREFIX~"` 
     677JAVA_LIB_DIR=$fullpath 
     678AC_MSG_RESULT([$fullpath]) 
    667679AC_SUBST(JAVA_LIB_DIR) 
    668680 
     
    679691AC_SUBST(ETC_DIR) 
    680692 
    681 if test "x$CC" = "xgcc" ; then 
     693if test -n "`$CC -V 2>&1 | grep 'Sun C'`"; then 
     694  CFLAGS="$CFLAGS -errwarn=%all" 
     695else 
    682696  CFLAGS="$CFLAGS -Werror -Wall" 
    683 else 
    684   CFLAGS="$CFLAGS -errwarn=%all" 
    685697fi 
    686698 
  • src/Makefile.dep

    r520106c r6ca74a6  
     1 
     2bundle.pb-c.o: bundle.pb-c.c bundle.pb-c.h 
    13 
    24noit_capabilities_listener.o: noit_capabilities_listener.c noit_defines.h \ 
     
    3638  noit_console_telnet.h  \ 
    3739  noit_filters.h \ 
    38   utils/noit_log.h jlog/jlog.h jlog/jlog_config.h 
     40  utils/noit_log.h jlog/jlog.h jlog/jlog_config.h bundle.pb-c.h \ 
     41  noit_check_log_helpers.h 
     42 
     43noit_check_log_helpers.o: noit_check_log_helpers.c noit_defines.h \ 
     44  noit_config.h noitedit/strlcpy.h noit_config.h noit_check.h \ 
     45  eventer/eventer.h noit_defines.h utils/noit_log.h noit_defines.h \ 
     46  utils/noit_hash.h noit_config.h utils/noit_atomic.h \ 
     47  eventer/eventer_POSIX_fd_opset.h noit_defines.h eventer/eventer.h \ 
     48  eventer/eventer_SSL_fd_opset.h  \ 
     49  eventer/eventer_jobq.h utils/noit_atomic.h utils/noit_sem.h \ 
     50  utils/noit_hash.h utils/noit_skiplist.h noit_conf.h noit_console.h \ 
     51  noitedit/histedit.h noit_defines.h eventer/eventer.h \ 
     52  noit_console_telnet.h  \ 
     53  noit_check_log_helpers.h  \ 
     54  utils/noit_b64.h noit_config.h \ 
     55  noit_defines.h utils/noit_str.h utils/noit_log.h bundle.pb-c.h 
    3956 
    4057noit_check_resolver.o: noit_check_resolver.c noit_defines.h noit_config.h \ 
     
    347364  noit_defines.h jlog/jlog.h jlog/jlog_config.h noit_jlog_listener.h \ 
    348365  noit_listener.h noit_http.h  \ 
    349   utils/noit_atomic.h noit_rest.h noit_check.h noit_livestream_listener.h \ 
    350   stratcon_realtime_http.h stratcon_jlog_streamer.h stratcon_datastore.h 
     366  utils/noit_atomic.h noit_rest.h noit_check.h noit_check_log_helpers.h \ 
     367  noit_livestream_listener.h stratcon_realtime_http.h \ 
     368  stratcon_jlog_streamer.h stratcon_datastore.h 
    351369 
    352370stratcond.o: stratcond.c noit_defines.h noit_config.h noitedit/strlcpy.h \ 
  • src/Makefile.in

    r3aa92a9 r832c60c  
    7171        noit_console.o noit_console_state.o noit_console_telnet.o \ 
    7272        noit_console_complete.o noit_check_resolver.o \ 
    73         noit_check_tools_shared.o
     73        noit_check_tools_shared.o noit_check_log_helpers.o
    7474        noit_check.o noit_check_log.o noit_check_tools.o \ 
    7575        noit_module.o noit_conf.o noit_conf_checks.o noit_tokenizer.o \ 
    7676        noit_capabilities_listener.o noit_xml.o \ 
    7777        noit_jlog_listener.o noit_livestream_listener.o noit_filters.o \ 
    78         noit_http.o noit_rest.o noit_check_rest.o noit_filters_rest.o 
     78        noit_http.o noit_rest.o noit_check_rest.o noit_filters_rest.o \ 
     79        bundle.pb-c.o 
    7980 
    8081NOIT_LIBS=libudns libnoitedit libeventer libjlog libnoit_utils libnoitjson 
     
    8788        noit_conf.o noit_http.o noit_rest.o noit_tokenizer.o \ 
    8889        noit_capabilities_listener.o noit_module.o \ 
    89         noit_check_tools_shared.o
     90        noit_check_tools_shared.o noit_check_log_helpers.o
    9091        stratcon_realtime_http.o \ 
    9192        stratcon_jlog_streamer.o stratcon_datastore.o \ 
    92         stratcon_iep.o 
     93        stratcon_iep.o \ 
     94        bundle.pb-c.o 
    9395 
    9496STRATCON_LIBS=libudns libnoitedit libeventer libjlog libnoit_utils libnoitjson 
     
    150152 
    151153man/stratcond.usage.h:  make-man 
     154 
    152155 
    153156noitd.o:        man/noitd.usage.h 
  • src/java/Makefile.in

    r1c72b25 r24c830d  
    2626        com/omniti/reconnoiter/EventHandler.java \ 
    2727        com/omniti/reconnoiter/MessageHandler.java \ 
     28        com/omniti/reconnoiter/CheckStatus.java \ 
    2829        com/omniti/reconnoiter/broker/NoitListener.java \ 
    2930        com/omniti/reconnoiter/broker/RabbitBroker.java \ 
     
    3435        com/omniti/reconnoiter/broker/BrokerFactory.java \ 
    3536        com/omniti/reconnoiter/event/NoitEvent.java \ 
     37        com/omniti/reconnoiter/event/NoitBundlev1.java \ 
     38        com/omniti/reconnoiter/event/NoitBundlev2.java \ 
    3639        com/omniti/reconnoiter/event/NoitCheck.java \ 
    3740        com/omniti/reconnoiter/event/NoitStatus.java \ 
     
    8285        lib/cglib-nodep-2.2.jar lib/commons-pool-1.4.jar lib/commons-dbcp-1.2.2.jar \ 
    8386        lib/postgresql-8.3-604.jdbc3.jar lib/rabbitmq-client-2.4.1.jar lib/commons-io-1.2.jar \ 
    84         lib/commons-cli-1.1.jar lib/commons-logging-1.1.1.jar 
     87        lib/commons-cli-1.1.jar lib/commons-logging-1.1.1.jar lib/commons-codec-1.5.jar \ 
     88        lib/protobuf-java-2.4.1.jar 
    8589 
    8690J_SUPPORT=lib/log4j-1.2.15.jar \ 
  • src/java/com/omniti/reconnoiter/StratconMessage.java

    rd483232 r24c830d  
    117117    StratconMessage.registerType(NoitStatus.class); 
    118118    StratconMessage.registerType(NoitMetric.class); 
     119    StratconMessage.registerType(NoitBundlev1.class); 
     120    StratconMessage.registerType(NoitBundlev2.class); 
    119121    StratconMessage.registerType(StratconStatement.class); 
    120122    StratconMessage.registerType(StratconQuery.class); 
  • src/java/run-iep.sh.in

    r4bb6079 r24c830d  
    1616        cglib-nodep-2.2.jar commons-pool-1.4.jar commons-dbcp-1.2.2.jar \ 
    1717        postgresql-8.3-604.jdbc3.jar rabbitmq-client-2.4.1.jar \ 
    18         commons-io-1.2.jar commons-cli-1.1.jar commons-logging-1.1.1.jar" 
     18        commons-io-1.2.jar commons-cli-1.1.jar commons-logging-1.1.1.jar \ 
     19        commons-codec-1.5.jar protobuf-java-2.4.1.jar" 
    1920 
    2021DIRS=". lib @prefix@/java/lib @prefix@/java" 
  • src/lua/src/ldebug.c

    r22d1941 re93b5f6  
    4747    return -1;  /* only active lua functions have current-line information */ 
    4848  else 
    49     return getline(ci_func(ci)->l.p, pc); 
     49    return lua__getline(ci_func(ci)->l.p, pc); 
    5050} 
    5151 
  • src/lua/src/ldebug.h

    r22d1941 re93b5f6  
    1414#define pcRel(pc, p)    (cast(int, (pc) - (p)->code) - 1) 
    1515 
    16 #define getline(f,pc) (((f)->lineinfo) ? (f)->lineinfo[pc] : 0) 
     16#define lua__getline(f,pc)    (((f)->lineinfo) ? (f)->lineinfo[pc] : 0) 
    1717 
    1818#define resethookcount(L)       (L->hookcount = L->basehookcount) 
  • src/lua/src/lvm.c

    r22d1941 re93b5f6  
    6969    Proto *p = ci_func(L->ci)->l.p; 
    7070    int npc = pcRel(pc, p); 
    71     int newline = getline(p, npc); 
     71    int newline = lua__getline(p, npc); 
    7272    /* call linehook when enter a new function, when jump back (loop), 
    7373       or when enter a new line */ 
    74     if (npc == 0 || pc <= oldpc || newline != getline(p, pcRel(oldpc, p))) 
     74    if (npc == 0 || pc <= oldpc || newline != lua__getline(p, pcRel(oldpc, p))) 
    7575      luaD_callhook(L, LUA_HOOKLINE, newline); 
    7676  } 
  • src/lua/src/print.c

    r22d1941 re93b5f6  
    8585  int bx=GETARG_Bx(i); 
    8686  int sbx=GETARG_sBx(i); 
    87   int line=getline(f,pc); 
     87  int line=lua__getline(f,pc); 
    8888  printf("\t%d\t",pc+1); 
    8989  if (line>0) printf("[%d]\t",line); else printf("[-]\t"); 
  • src/modules/lua_noit.c

    rbecc5b1 r032dfff  
    997997  } 
    998998  input = lua_tolstring(L, inputidx, &inlen); 
    999   lua_pushnumber(L, (double)crc32(start, input, inlen)); 
     999  lua_pushnumber(L, (double)crc32(start, (Bytef *)input, inlen)); 
    10001000  return 1; 
    10011001} 
  • src/modules/postgres_ingestor.c

    rd10f13b r4a653ea  
    4444#include "noit_conf.h" 
    4545#include "noit_check.h" 
     46#include "noit_check_log_helpers.h" 
    4647#include "noit_rest.h" 
    4748#include <unistd.h> 
     
    5758#include <errno.h> 
    5859#include "postgres_ingestor.xmlh" 
     60#include "bundle.pb-c.h" 
    5961 
    6062#define DECL_STMT(codename,confname) \ 
     
    10371039  return info ? info->dsn : NULL; 
    10381040} 
     1041static void 
     1042expand_b_record(ds_line_detail **head, ds_line_detail **last, 
     1043                const char *line, int len) { 
     1044  char **outrows; 
     1045  int i, cnt; 
     1046  ds_line_detail *next; 
     1047 
     1048  cnt = noit_check_log_b_to_sm(line, len, &outrows); 
     1049  for(i=0;i<cnt;i++) { 
     1050    if(outrows[i] == NULL) continue; 
     1051    next = calloc(sizeof(*next), 1); 
     1052    next->data = outrows[i]; 
     1053    if(!*head) *head = next; 
     1054    if(*last) (*last)->next = next; 
     1055    *last = next; 
     1056  } 
     1057  if(outrows) free(outrows); 
     1058} 
    10391059static ds_line_detail * 
    10401060build_insert_batch(pg_interim_journal_t *ij) { 
     
    10701090    while(lcp < (buff + len) && 
    10711091          NULL != (cp = strnstrn("\n", 1, lcp, len - (lcp-buff)))) { 
    1072       next = calloc(1, sizeof(*next)); 
    1073       next->data = malloc(cp - lcp + 1); 
    1074       memcpy(next->data, lcp, cp - lcp); 
    1075       next->data[cp - lcp] = '\0'; 
    1076       if(!head) head = next; 
    1077       if(last) last->next = next; 
    1078       last = next; 
     1092      if(lcp[0] == 'B' && lcp[1] != '\0' && lcp[2] == '\t') { 
     1093      /* Bundle records are special and need to be expanded into 
     1094       * traditional records here 
     1095       */ 
     1096        noit_compression_type_t ctype = NOIT_COMPRESS_NONE; 
     1097        switch(lcp[1]) { 
     1098          case '1': /* version 1 */ 
     1099            ctype = NOIT_COMPRESS_ZLIB; /*no break fall through */ 
     1100          case '2': /* version 2 */ 
     1101              expand_b_record(&head, &last, lcp, cp - lcp); 
     1102            break; 
     1103          default: 
     1104            noitL(noit_error, "unknown bundle version %c\n", lcp[1]); 
     1105        } 
     1106      } 
     1107      else { 
     1108        next = calloc(1, sizeof(*next)); 
     1109        next->data = malloc(cp - lcp + 1); 
     1110        memcpy(next->data, lcp, cp - lcp); 
     1111        next->data[cp - lcp] = '\0'; 
     1112        if(!head) head = next; 
     1113        if(last) last->next = next; 
     1114        last = next; 
     1115      } 
    10791116      lcp = cp + 1; 
    10801117    } 
  • src/modules/rabbitmq_driver.c

    r9204e48 r1288bec  
    8484  pthread_mutex_lock(&driver_lock); 
    8585  for(i=0; i<MAX_HOSTS; i++) { 
    86     if(stats.thread_states[i].owner == NULL) { 
     86    if(stats.thread_states[i].owner == (pthread_t)NULL) { 
    8787      stats.thread_states[i].owner = pthread_self(); 
    8888      dr = &stats.thread_states[i]; 
  • src/noit.conf.in

    r4aa2e30 r43d5801  
    5454      <log name="status"/> 
    5555      <log name="metrics"/> 
     56      <log name="bundle"/> 
    5657      <log name="config"/> 
    5758    </feeds> 
  • src/noit_check.c

    r3aa92a9 r832c60c  
    11361136  } 
    11371137 
    1138   /* Write out our status */ 
    1139   noit_check_log_status(check); 
    1140   /* Write out all metrics */ 
    1141   noit_check_log_metrics(check); 
     1138  /* Write out the bundled information */ 
     1139  noit_check_log_bundle(check); 
    11421140  /* count the check as complete */ 
    11431141  check_completion_count++; 
  • src/noit_check.h

    rd10f13b r3081176  
    267267API_EXPORT(void) noit_check_log_status(noit_check_t *check); 
    268268API_EXPORT(void) noit_check_log_delete(noit_check_t *check); 
     269API_EXPORT(void) noit_check_log_bundle(noit_check_t *check); 
    269270API_EXPORT(void) noit_check_log_metrics(noit_check_t *check); 
    270271API_EXPORT(void) noit_check_log_metric(noit_check_t *check, 
  • src/noit_check_log.c

    rd10f13b r076670c  
    4141#include "jlog/jlog.h" 
    4242 
     43#include "bundle.pb-c.h" 
     44#include "noit_check_log_helpers.h" 
     45 
    4346/* Log format is tab delimited: 
    4447 * NOIT CONFIG (implemented in noit_conf.c): 
     
    5659 * METRICS: 
    5760 *  'M' TIMESTAMP UUID NAME TYPE VALUE 
     61 * 
     62 * BUNDLE 
     63 *  'B#' TIMESTAMP UUID TARGET MODULE NAME strlen(base64(gzipped(payload))) base64(gzipped(payload)) 
     64 *   
    5865 */ 
    5966 
     
    6269static noit_log_stream_t metrics_log = NULL; 
    6370static noit_log_stream_t delete_log = NULL; 
     71static noit_log_stream_t bundle_log = NULL; 
     72static noit_boolean use_compression = noit_true; 
     73 
    6474#define SECPART(a) ((unsigned long)(a)->tv_sec) 
    6575#define MSECPART(a) ((unsigned long)((a)->tv_usec / 1000)) 
     
    274284} 
    275285 
     286 
     287static int 
     288_noit_check_log_bundle_metric(noit_log_stream_t ls, Metric *metric, metric_t *m) { 
     289  metric->metrictype = (int)m->metric_type; 
     290 
     291  metric->name = m->metric_name; 
     292  if(m->metric_value.vp != NULL) { 
     293    switch (m->metric_type) { 
     294      case METRIC_INT32: 
     295        metric->has_valuei32 = noit_true; 
     296        metric->valuei32 = *(m->metric_value.i); break; 
     297      case METRIC_UINT32: 
     298        metric->has_valueui32 = noit_true; 
     299        metric->valueui32 = *(m->metric_value.I); break; 
     300      case METRIC_INT64: 
     301        metric->has_valuei64 = noit_true; 
     302        metric->valuei64 = *(m->metric_value.l); break; 
     303      case METRIC_UINT64: 
     304        metric->has_valueui64 = noit_true; 
     305        metric->valueui64 = *(m->metric_value.L); break; 
     306      case METRIC_DOUBLE: 
     307        metric->has_valuedbl = noit_true; 
     308        metric->valuedbl = *(m->metric_value.n); break; 
     309      case METRIC_STRING: 
     310        metric->valuestr = m->metric_value.s; break; 
     311      default: 
     312        return -1; 
     313    } 
     314  } 
     315  return 0; 
     316} 
     317 
     318static int 
     319noit_check_log_bundle_serialize(noit_log_stream_t ls, noit_check_t *check) { 
     320  int rv = 0; 
     321  char uuid_str[256*3+37]; 
     322  noit_hash_iter iter = NOIT_HASH_ITER_ZERO; 
     323  noit_hash_iter iter2 = NOIT_HASH_ITER_ZERO; 
     324  const char *key; 
     325  int klen, i=0, size, j; 
     326  unsigned int out_size; 
     327  stats_t *c; 
     328  void *vm; 
     329  char *buf, *out_buf; 
     330  noit_compression_type_t comp; 
     331  Bundle bundle = BUNDLE__INIT; 
     332  SETUP_LOG(bundle, ); 
     333  MAKE_CHECK_UUID_STR(uuid_str, sizeof(uuid_str), bundle_log, check); 
     334 
     335  // Get a bundle 
     336  c = &check->stats.current; 
     337 
     338  // Set attributes 
     339  bundle.status = malloc(sizeof(Status)); 
     340  status__init(bundle.status); 
     341  bundle.status->available = c->available; 
     342  bundle.status->state = c->state; 
     343  bundle.status->duration = c->duration; 
     344  bundle.status->status = c->status; 
     345 
     346 
     347  // Just count 
     348  while(noit_hash_next(&c->metrics, &iter, &key, &klen, &vm)) { 
     349    bundle.n_metrics++; 
     350  } 
     351 
     352  bundle.metrics = malloc(bundle.n_metrics * sizeof(Metric*)); 
     353 
     354  // Now convert 
     355  while(noit_hash_next(&c->metrics, &iter2, &key, &klen, &vm)) { 
     356    /* If we apply the filter set and it returns false, we don't log */ 
     357    metric_t *m = (metric_t *)vm; 
     358    bundle.metrics[i] = malloc(sizeof(Metric)); 
     359    metric__init(bundle.metrics[i]); 
     360    _noit_check_log_bundle_metric(ls, bundle.metrics[i], m); 
     361    i++; 
     362  } 
     363 
     364  size = bundle__get_packed_size(&bundle); 
     365  buf = malloc(size); 
     366  bundle__pack(&bundle, (uint8_t*)buf); 
     367 
     368  // Compress + B64 
     369  comp = use_compression ? NOIT_COMPRESS_ZLIB : NOIT_COMPRESS_NONE; 
     370  noit_check_log_bundle_compress_b64(comp, buf, size, &out_buf, &out_size); 
     371  rv = noit_log(ls, &(c->whence), __FILE__, __LINE__, 
     372                "B%c\t%lu.%03lu\t%s\t%s\t%s\t%s\t%d\t%.*s\n", 
     373                use_compression ? '1' : '2', 
     374                SECPART(&(c->whence)), MSECPART(&(c->whence)), 
     375                uuid_str, check->target, check->module, check->name, size, 
     376                (unsigned int)out_size, out_buf); 
     377 
     378  free(buf); 
     379  free(out_buf); 
     380  // Free all the resources 
     381  for (j=0; j<i; j++) { 
     382    free(bundle.metrics[j]); 
     383  } 
     384  free(bundle.metrics); 
     385  return rv; 
     386} 
     387 
     388void 
     389noit_check_log_bundle(noit_check_t *check) { 
     390  handle_extra_feeds(check, noit_check_log_bundle_serialize); 
     391  if(!(check->flags & (NP_TRANSIENT | NP_SUPPRESS_STATUS | NP_SUPPRESS_METRICS))) { 
     392    SETUP_LOG(bundle, return); 
     393    noit_check_log_bundle_serialize(bundle_log, check); 
     394  } 
     395} 
     396 
    276397void 
    277398noit_check_log_metric(noit_check_t *check, struct timeval *whence, 
     
    302423 
    303424int 
    304 noit_stats_snprint_metric_value(char *b, int l, metric_t *m) { 
    305   int rv; 
    306   if(!m->metric_value.s) { /* they are all null */ 
    307     rv = snprintf(b, l, "[[null]]"); 
    308   } 
    309   else { 
    310     switch(m->metric_type) { 
    311       case METRIC_INT32: 
    312         rv = snprintf(b, l, "%d", *(m->metric_value.i)); break; 
    313       case METRIC_UINT32: 
    314         rv = snprintf(b, l, "%u", *(m->metric_value.I)); break; 
    315       case METRIC_INT64: 
    316         rv = snprintf(b, l, "%lld", (long long int)*(m->metric_value.l)); break; 
    317       case METRIC_UINT64: 
    318         rv = snprintf(b, l, "%llu", 
    319                       (long long unsigned int)*(m->metric_value.L)); break; 
    320       case METRIC_DOUBLE: 
    321         rv = snprintf(b, l, "%.12e", *(m->metric_value.n)); break; 
    322       case METRIC_STRING: 
    323         rv = snprintf(b, l, "%s", m->metric_value.s); break; 
    324       default: 
    325         return -1; 
    326     } 
    327   } 
    328   return rv; 
    329 } 
    330 int 
    331425noit_stats_snprint_metric(char *b, int l, metric_t *m) { 
    332426  int rv, nl; 
     
    338432  return rv + nl; 
    339433} 
     434 
  • src/noit_http.c

    r0243769 ra918cf4  
    149149  /*noitL(noit_error, "bchain_alloc(%p) : %d\n", n, line);*/ 
    150150  if(!n) return NULL; 
     151  n->type = BCHAIN_INLINE; 
    151152  n->prev = n->next = NULL; 
    152153  n->start = n->size = 0; 
  • src/noit_listener.c

    rc6a5f68 ra29e7fc  
    4747#include "noit_conf.h" 
    4848 
     49static noit_log_stream_t nlerr = NULL; 
     50static noit_log_stream_t nldeb = NULL; 
    4951static noit_hash_table listener_commands = NOIT_HASH_EMPTY; 
    5052noit_hash_table * 
     
    9092    } 
    9193    e->closure = ac; 
     94    noitL(nlerr, "noit_listener[%s] SSL_accept on fd %d [%s]\n", 
     95          eventer_name_for_callback(e->callback), 
     96          e->fd, ac->remote_cn ? ac->remote_cn : "anonymous"); 
    9297    return e->callback(e, mask, e->closure, tv); 
    9398  } 
     
    124129    if(conn >= 0) { 
    125130      eventer_t newe; 
     131      noitL(nlerr, "noit_listener[%s] accepted fd %d\n", 
     132            eventer_name_for_callback(listener_closure->dispatch_callback), 
     133            conn); 
    126134      if(eventer_set_fd_nonblocking(conn)) { 
    127135        close(conn); 
     
    217225  const char *event_name; 
    218226 
    219   noitL(noit_debug, "noit_listener(%s, %d, %d, %d, %s, %p)\n", 
     227  noitL(nldeb, "noit_listener(%s, %d, %d, %d, %s, %p)\n", 
    220228        host, port, type, backlog, 
    221229        (event_name = eventer_name_for_callback(handler))?event_name:"??", 
     
    521529void 
    522530noit_listener_init(const char *toplevel) { 
     531  nlerr = noit_log_stream_find("error/listener"); 
     532  nldeb = noit_log_stream_find("debug/listener"); 
     533  if(!nlerr) nlerr = noit_error; 
     534  if(!nldeb) nldeb = noit_debug; 
    523535  eventer_name_callback("noit_listener_acceptor", noit_listener_acceptor); 
    524536  eventer_name_callback("noit_listener_accept_ssl", noit_listener_accept_ssl); 
  • src/noit_livestream_listener.c

    r47504ca r44b47a0  
    233233  if(!ac->service_ctx || !jcl->feed) { 
    234234    int len; 
    235     jcl = ac->service_ctx = noit_livestream_closure_alloc(); 
     235    if(!ac->service_ctx) ac->service_ctx = noit_livestream_closure_alloc(); 
     236    jcl = ac->service_ctx; 
    236237    /* Setup logger to this channel */ 
     238    noitL(noit_debug, "livestream initializing on fd %d\n", e->fd); 
    237239    if(!jcl->period) { 
    238240      u_int32_t nperiod; 
     
    245247        goto socket_error; 
    246248      } 
     249      noitL(noit_debug, "livestream initializing on fd %d [period %d]\n", 
     250            e->fd, jcl->period); 
    247251    } 
    248252    while(jcl->uuid_read < 36) { 
     
    257261      goto socket_error; 
    258262    } 
     263    noitL(noit_debug, "livestream initializing on fd %d [uuid %s]\n", 
     264          e->fd, jcl->uuid_str); 
    259265 
    260266    jcl->feed = malloc(32); 
  • src/stratcon_datastore.c

    rd10f13b r4b21a98  
    213213  interim_journal_t *ij = NULL; 
    214214  char uuid_str[UUID_STR_LEN+1], *cp1, *cp2; 
     215  char rtype[256]; 
    215216  const char *fqdn = NULL, *dsn = NULL; 
    216217  int storagenode_id = 0; 
    217218  uuid_t checkid; 
    218219  if(!line) return; 
     220  cp1 = strchr(line, '\t'); 
     221  if(cp1 && cp1 - line < sizeof(rtype) - 1) { 
     222    memcpy(rtype, line, cp1 - line); 
     223    rtype[cp1 - line] = '\0'; 
     224  } 
     225  else rtype[0] = '\0'; 
    219226  /* if it is a UUID based thing, find the storage node */ 
    220   switch(*line) { 
     227  switch(*rtype) { 
    221228    case 'C': 
    222229    case 'S': 
    223230    case 'M': 
    224231    case 'D': 
    225       if(line[1] == '\t' && (cp1 = strchr(line+2, '\t')) != NULL && 
     232    case 'B': 
     233      if((cp1 = strchr(cp1+1, '\t')) != NULL && 
    226234         (cp2 = strchr(cp1+1, '\t')) != NULL && 
    227235         (cp2-cp1 >= UUID_STR_LEN)) { 
  • src/stratcon_iep.c

    r0ba1606 r24c830d  
    391391    int line_len = strlen(job->line); 
    392392    int remote_len = strlen(job->remote); 
     393    const char *toff = strchr(job->line, '\t'); 
     394    int token_off = 2; 
     395    if(toff) token_off = toff - job->line + 1; 
    393396 
    394397    job->doc_str = (char*)calloc(line_len + 1 /* \t */ + 
    395398        remote_len + 2, 1); 
    396     strncpy(job->doc_str, job->line, 2); 
     399    strncpy(job->doc_str, job->line, token_off); 
    397400    strncat(job->doc_str, job->remote, remote_len); 
    398401    strncat(job->doc_str, "\t", 1); 
    399     strncat(job->doc_str, job->line + 2, line_len - 2); 
     402    strncat(job->doc_str, job->line + token_off, line_len - token_off); 
    400403 
    401404    /* Don't need to catch error here, next submit will catch it */ 
  • src/stratcon_realtime_http.c

    r65abbae r58f9042  
    4343#include "noit_rest.h" 
    4444#include "noit_check.h" 
     45#include "noit_check_log_helpers.h" 
    4546#include "noit_livestream_listener.h" 
    4647#include "stratcon_realtime_http.h" 
     
    119120} 
    120121int 
    121 stratcon_line_to_javascript(noit_http_session_ctx *ctx, char *buff, 
    122                             u_int32_t inc_id) { 
     122stratcon_line_to_javascript(noit_http_session_ctx *ctx, char *in_buff, 
     123                            u_int32_t *inc_id) { 
    123124  char buffer[1024]; 
    124   char *scp, *ecp, *token
    125   int len
     125  char *scp, *ecp, *token, *buff
     126  int i, len, cnt
    126127  const char *v, *cb = NULL; 
    127128  noit_hash_table json = NOIT_HASH_EMPTY; 
    128129  noit_http_request *req = noit_http_session_request(ctx); 
    129130  char s_inc_id[42]; 
    130  
    131   snprintf(s_inc_id, sizeof(s_inc_id), "script-%08x", inc_id); 
    132   
     131  char **outrows = NULL; 
     132 
    133133  cb = noit_http_request_querystring(req, "cb");  
    134134  for(v = cb; v && *v; v++) 
     
    143143 
    144144#define BAIL_HTTP_WRITE do { \ 
     145  if(outrows) { \ 
     146    for(i=0;i<cnt;i++) if(outrows[i]) free(outrows[i]); \ 
     147    free(outrows); \ 
     148  } \ 
    145149  noit_hash_destroy(&json, NULL, free); \ 
    146150  noitL(noit_error, "javascript emit failed: %s:%s:%d\n", \ 
     
    167171} while(0) 
    168172 
    169   scp = buff; 
    170   PROCESS_NEXT_FIELD(token,len); /* Skip the leader */ 
    171   if(buff[1] == '\t' && (buff[0] == 'M' || buff[0] == 'S')) { 
    172     char target[256], module[256], name[256], uuid_str[UUID_STR_LEN+1]; 
    173     noit_http_request *req = noit_http_session_request(ctx); 
    174     noit_hash_table *qs; 
    175     noit_hash_iter iter = NOIT_HASH_ITER_ZERO; 
    176     const char *key; 
    177     int klen, i=0; 
    178     void *vval; 
    179     char type[2] = { '\0', '\0' }; 
    180     type[0] = buff[0]; 
     173  noitL(noit_error, "recv(%s)\n", in_buff); 
     174  if(in_buff[0] == 'B' && in_buff[1] != '\0' && in_buff[2] == '\t') { 
     175    cnt = noit_check_log_b_to_sm(in_buff, strlen(in_buff), &outrows); 
     176  } 
     177  else { 
     178    cnt = 1; 
     179    outrows = malloc(sizeof(*outrows)); 
     180    outrows[0] = strdup(in_buff); 
     181  } 
     182  for(i=0; i<cnt; i++) { 
     183    buff = outrows[i]; 
     184    if(!buff) continue; 
     185    noitL(noit_error, "recv_xlt(%s)\n", buff); 
     186    scp = buff; 
     187    PROCESS_NEXT_FIELD(token,len); /* Skip the leader */ 
     188    if(buff[1] == '\t' && (buff[0] == 'M' || buff[0] == 'S')) { 
     189      char target[256], module[256], name[256], uuid_str[UUID_STR_LEN+1]; 
     190      noit_http_request *req = noit_http_session_request(ctx); 
     191      noit_hash_table *qs; 
     192      noit_hash_iter iter = NOIT_HASH_ITER_ZERO; 
     193      const char *key; 
     194      int klen, i=0; 
     195      void *vval; 
     196      char type[2] = { '\0', '\0' }; 
     197      type[0] = buff[0]; 
    181198 
    182199#define ra_write(a,b) if(noit_http_response_append(ctx, a, b) == noit_false) BAIL_HTTP_WRITE 
    183200 
    184     snprintf(buffer, sizeof(buffer), "<script id=\"%s\">%s({", s_inc_id, cb); 
    185     ra_write(buffer, strlen(buffer)); 
    186  
    187     qs = noit_http_request_querystring_table(req); 
    188     while(noit_hash_next(qs, &iter, &key, &klen, &vval)) { 
    189       if(!strcmp(key, "cb")) continue; 
    190       noit_hash_store(&json, key, klen, strdup(vval ?(char *)vval : "true")); 
    191     } 
    192     /* Time */ 
    193     noit_hash_store(&json, "script_id", 9, strdup(s_inc_id)); 
    194     noit_hash_store(&json, "type", 4, strdup(type)); 
    195     PROCESS_NEXT_FIELD(token,len); 
    196     noit_hash_store(&json, "time", 4, noit__strndup(token, len)); 
    197     /* UUID */ 
    198     PROCESS_NEXT_FIELD(token,len); 
    199     noit_check_extended_id_split(token, len, target, sizeof(target), 
    200                                  module, sizeof(module), name, sizeof(name), 
    201                                  uuid_str, sizeof(uuid_str)); 
    202     if(*uuid_str) 
    203       noit_hash_store(&json, "id", 2, 
    204                       noit__strndup(uuid_str, strlen(uuid_str))); 
    205     if(*target) 
    206       noit_hash_store(&json, "check_target", 12, 
    207                       noit__strndup(target, strlen(target))); 
    208     if(*module) 
    209       noit_hash_store(&json, "check_module", 12, 
    210                       noit__strndup(module, strlen(module))); 
    211     if(*name) 
    212       noit_hash_store(&json, "check_name", 10, 
    213                       noit__strndup(name, strlen(name))); 
    214     if(buff[0] == 'M') { 
    215       /* name */ 
     201      snprintf(s_inc_id, sizeof(s_inc_id), "script-%08x", (*inc_id)++); 
     202      snprintf(buffer, sizeof(buffer), "<script id=\"%s\">%s({", s_inc_id, cb); 
     203      ra_write(buffer, strlen(buffer)); 
     204 
     205      qs = noit_http_request_querystring_table(req); 
     206      while(noit_hash_next(qs, &iter, &key, &klen, &vval)) { 
     207        if(!strcmp(key, "cb")) continue; 
     208        noit_hash_store(&json, key, klen, strdup(vval ?(char *)vval : "true")); 
     209      } 
     210      /* Time */ 
     211      noit_hash_store(&json, "script_id", 9, strdup(s_inc_id)); 
     212      noit_hash_store(&json, "type", 4, strdup(type)); 
    216213      PROCESS_NEXT_FIELD(token,len); 
    217       noit_hash_store(&json, "metric_name", 11, noit__strndup(token, len)); 
    218       /* type */ 
     214      noit_hash_store(&json, "time", 4, noit__strndup(token, len)); 
     215      /* UUID */ 
    219216      PROCESS_NEXT_FIELD(token,len); 
    220       noit_hash_store(&json, "metric_type", 11, noit__strndup(token, len)); 
    221       /* value */ 
    222       PROCESS_LAST_FIELD(token,len); /* value */ 
    223       noit_hash_store(&json, "value", 5, noit__strndup(token, len)); 
    224     } 
    225     else if(buff[0] == 'S') { 
    226       /* state */ 
    227       PROCESS_NEXT_FIELD(token,len); 
    228       noit_hash_store(&json, "check_state", 11, noit__strndup(token, len)); 
    229       /* availability */ 
    230       PROCESS_NEXT_FIELD(token,len); 
    231       noit_hash_store(&json, "check_availability", 18, noit__strndup(token, len)); 
    232       /* duration */ 
    233       PROCESS_NEXT_FIELD(token,len); 
    234       noit_hash_store(&json, "check_duration_ms", 17, noit__strndup(token, len)); 
    235       /* status */ 
    236       PROCESS_LAST_FIELD(token,len); 
    237       noit_hash_store(&json, "status_message", 14, noit__strndup(token, len)); 
    238     } 
    239  
    240     memset(&iter, 0, sizeof(iter)); 
    241     while(noit_hash_next(&json, &iter, &key, &klen, &vval)) { 
    242       char *val = (char *)vval; 
    243       if(i++) ra_write(",", 1); 
    244       ra_write("\"", 1); 
    245       ra_write(key, klen); 
    246       ra_write("\":\"", 3); 
    247       while(*val) { 
    248         if(*val == '\"' || *val == '\\') { 
    249           ra_write((char *)"\\", 1); 
     217      noit_check_extended_id_split(token, len, target, sizeof(target), 
     218                                   module, sizeof(module), name, sizeof(name), 
     219                                   uuid_str, sizeof(uuid_str)); 
     220      if(*uuid_str) 
     221        noit_hash_store(&json, "id", 2, 
     222                        noit__strndup(uuid_str, strlen(uuid_str))); 
     223      if(*target) 
     224        noit_hash_store(&json, "check_target", 12, 
     225                        noit__strndup(target, strlen(target))); 
     226      if(*module) 
     227        noit_hash_store(&json, "check_module", 12, 
     228                        noit__strndup(module, strlen(module))); 
     229      if(*name) 
     230        noit_hash_store(&json, "check_name", 10, 
     231                        noit__strndup(name, strlen(name))); 
     232      if(buff[0] == 'M') { 
     233        /* name */ 
     234        PROCESS_NEXT_FIELD(token,len); 
     235        noit_hash_store(&json, "metric_name", 11, noit__strndup(token, len)); 
     236        /* type */ 
     237        PROCESS_NEXT_FIELD(token,len); 
     238        noit_hash_store(&json, "metric_type", 11, noit__strndup(token, len)); 
     239        /* value */ 
     240        PROCESS_LAST_FIELD(token,len); /* value */ 
     241        noit_hash_store(&json, "value", 5, noit__strndup(token, len)); 
     242      } 
     243      else if(buff[0] == 'S') { 
     244        /* state */ 
     245        PROCESS_NEXT_FIELD(token,len); 
     246        noit_hash_store(&json, "check_state", 11, noit__strndup(token, len)); 
     247        /* availability */ 
     248        PROCESS_NEXT_FIELD(token,len); 
     249        noit_hash_store(&json, "check_availability", 18, noit__strndup(token, len)); 
     250        /* duration */ 
     251        PROCESS_NEXT_FIELD(token,len); 
     252        noit_hash_store(&json, "check_duration_ms", 17, noit__strndup(token, len)); 
     253        /* status */ 
     254        PROCESS_LAST_FIELD(token,len); 
     255        noit_hash_store(&json, "status_message", 14, noit__strndup(token, len)); 
     256      } 
     257 
     258      memset(&iter, 0, sizeof(iter)); 
     259      while(noit_hash_next(&json, &iter, &key, &klen, &vval)) { 
     260        char *val = (char *)vval; 
     261        if(i++) ra_write(",", 1); 
     262        ra_write("\"", 1); 
     263        ra_write(key, klen); 
     264        ra_write("\":\"", 3); 
     265        while(*val) { 
     266          if(*val == '\"' || *val == '\\') { 
     267            ra_write((char *)"\\", 1); 
     268          } 
     269          if(isprint(*val)) { 
     270            ra_write((char *)val, 1); 
     271          } 
     272          else { 
     273            char od[5]; 
     274            snprintf(od, sizeof(od), "\\%03o", *((unsigned char *)val)); 
     275            ra_write(od, strlen(od)); 
     276          } 
     277          val++; 
    250278        } 
    251         if(isprint(*val)) { 
    252           ra_write((char *)val, 1); 
    253         } 
    254         else { 
    255           char od[5]; 
    256           snprintf(od, sizeof(od), "\\%03o", *((unsigned char *)val)); 
    257           ra_write(od, strlen(od)); 
    258         } 
    259         val++; 
     279        ra_write("\"", 1); 
    260280      } 
    261       ra_write("\"", 1); 
    262     } 
    263     snprintf(buffer, sizeof(buffer), "});</script>\n"); 
    264     ra_write(buffer, strlen(buffer)); 
    265  
    266     if(noit_http_response_flush(ctx, noit_false) == noit_false) BAIL_HTTP_WRITE; 
    267   } 
    268  
    269   noit_hash_destroy(&json, NULL, free); 
     281      snprintf(buffer, sizeof(buffer), "});</script>\n"); 
     282      ra_write(buffer, strlen(buffer)); 
     283 
     284      if(noit_http_response_flush(ctx, noit_false) == noit_false) BAIL_HTTP_WRITE; 
     285    } 
     286 
     287    noit_hash_destroy(&json, NULL, free); 
     288    memset(&json, 0, sizeof(json)); 
     289  } 
     290  if(outrows) { 
     291    for(i=0;i<cnt;i++) if(outrows[i]) free(outrows[i]); 
     292    free(outrows); 
     293  } 
     294 
    270295  return 0; 
    271296 
     
    444469      case REALTIME_HTTP_WANT_BODY: 
    445470        FULLREAD(e, ctx, ctx->body_len); 
    446         if(stratcon_line_to_javascript(ctx->ctx, ctx->buffer, ctx->hack_inc_id++)) goto socket_error; 
     471        if(stratcon_line_to_javascript(ctx->ctx, ctx->buffer, &ctx->hack_inc_id)) goto socket_error; 
    447472        free(ctx->buffer); ctx->buffer = NULL; 
    448473        ctx->state = REALTIME_HTTP_WANT_HEADER; 
  • test/t/000_prereq.t

    rc35ae3a r239594a  
    1 use Test::More tests => 5
     1use Test::More tests => 8
    22my @progs = qw/pg_ctl initdb psql rm/; 
    33 
    44use strict; 
     5 
     6use_ok('testconfig'); 
     7use_ok('apiclient'); 
     8use_ok('stomp'); 
    59 
    610foreach my $prog (@progs) { 
  • test/t/001_db_init.t

    r5715632 r239594a  
    1717close(F); 
    1818`pg_ctl -D $NOIT_TEST_DB -l $NOIT_TEST_DB/serverlog -s -w start`; 
    19 is($?, 0, 'starting postgres'); 
     19SKIP: { 
     20  # This is failing on my Mac which is OBNOXIOUS 
     21  skip "pg_ctl and \$? issues on darwin", 1 if $^O eq 'darwin'; 
     22  is($?, 0, 'starting postgres'); 
     23
    2024 
    2125my $conn = pg(); 
  • test/t/002_db_load.t

    r38385c3 r239594a  
    1 use Test::More tests => 6
     1use Test::More tests => 5
    22use testconfig; 
    33use IPC::Open3; 
     
    1010$conn = pg('reconnoiter','reconnoiter'); 
    1111SKIP: { 
    12   skip 'already created user and db', 2 if($conn); 
     12  skip 'already loaded schema', 1 if($conn); 
    1313  my $cmd = "psql -h localhost -p $NOIT_TEST_DB_PORT postgres " . 
    1414                "-f ../../sql/reconnoiter_ddl_dump.sql"; 
     
    2424  waitpid($pid, 0); 
    2525  is($bad, '', 'no errors during schema load'); 
    26   is($?, 0, 'loaded schema'); 
    2726} 
    2827$conn = pg('reconnoiter','reconnoiter'); 
  • test/t/103_simple_noit.t

    r629726b r6acb955  
    1 use Test::More tests => 9
     1use Test::More tests => 10
    22use XML::LibXML; 
    33use XML::LibXML::XPathContext; 
     
    4646cmp_ok($time_error, '<', $request_duration, 'time skew check'); 
    4747 
     48$c = apiclient->new('localhost', $NOIT_API_PORT); 
    4849@r = $c->get("/checks/show/f7cea020-f19d-11dd-85a6-cb6d3a2207dc"); 
    4950is($r[0], 404, 'get checks'); 
     
    6364is($xpc->findvalue('/check/state/state', $doc), 'good', 'results'); 
    6465 
     66ok(stop_noit, 'stopping noit'); 
    65671; 
  • test/t/104_simple_stratcon.t

    rc35ae3a r6acb955  
    1 use Test::More tests => 9
     1use Test::More tests => 10
    22use XML::LibXML; 
    33use XML::LibXML::XPathContext; 
     
    3333is(@nonoits, 0, 'removed noit'); 
    3434 
     35ok(stop_stratcon, 'stopping stratcon'); 
    35361; 
  • test/t/105_crl_test.t

    rc35ae3a r6acb955  
    1 use Test::More tests => 3
     1use Test::More tests => 4
    22use XML::LibXML; 
    33use XML::LibXML::XPathContext; 
     
    2323}; 
    2424like($@, qr/SSL/, 'request fails with revoked key'); 
     25ok(stop_noit, 'stopping noit'); 
    2526 
    26271; 
  • test/t/106_stratcon_ip.t

    r4157a34 r6acb955  
    1 use Test::More tests => 6
     1use Test::More tests => 7
    22use XML::LibXML; 
    33use XML::LibXML::XPathContext; 
     
    2222isn't($ip, "0.0.0.0", 'is not 0.0.0.0'); 
    2323undef $conn; 
     24ok(stop_stratcon, 'stopping stratcon'); 
    2425 
    25261; 
  • test/t/107_rest_perms.t

    r49b8645 r6acb955  
    1 use Test::More tests => 3
     1use Test::More tests => 4
    22use XML::LibXML; 
    33use XML::LibXML::XPathContext; 
     
    2828 
    2929is($r[0], 403, 'add selfcheck'); 
    30  
     30ok(stop_noit, 'stopping noit'); 
    31311; 
  • test/t/108_noit_strat.t

    re754bda r6acb955  
    1 use Test::More tests => 26
     1use Test::More tests => 32
    22use WWW::Curl::Easy; 
    33use JSON; 
     
    4646 
    4747sleep(1); 
     48 
    4849@r = $c->get("/checks/show/$uuid"); 
    4950is($r[0], 200, 'get checks'); 
     
    139140 
    140141$stomp = stomp->new(); 
    141 $stomp->subscribe('/queue/noit.firehose'); 
     142ok($stomp, 'stomp connection'); 
     143ok($stomp->subscribe('/queue/noit.firehose'), 'subscribed'); 
    142144$payload = $stomp->get({timeout => 6}); 
    143145undef $stomp; 
     
    145147 
    146148$stomp = stomp->new(); 
    147 $stomp->subscribe('/topic/noit.alerts.numeric'); 
     149ok($stomp, 'stomp connection'); 
     150ok($stomp->subscribe('/topic/noit.alerts.numeric'), 'subscribed'); 
    148151$payload = $stomp->get({timeout => 6}); 
    149 eval { $json = from_json($payload); }; 
     152eval { die "no data" unless defined($payload); 
     153       $json = from_json($payload); }; 
    150154is($@, '', 'json numeric payload'); 
    151155undef $stomp; 
     156$json ||= {}; 
    152157like($json->{r}->{uuid} || '', $uuid_re, 'numeric match has uuid'); 
    153158is($json->{r}->{check_module} || '', 'selfcheck', 'modules is set'); 
    154159 
     160ok(stop_noit, 'shutdown noit'); 
     161ok(stop_stratcon, 'shutdown stratcon'); 
    1551621; 
  • test/t/stomp.pm

    re754bda r6acb955  
    2828    my $self = shift; 
    2929    my $opts = shift || {}; 
    30     my $frame = $self->{stomp}->receive_frame($opts); 
    31     return undef unless $frame; 
    32     my $payload = $frame->body; 
    33     $self->{stomp}->ack( { frame => $frame } ); 
     30    my $payload; 
     31    alarm $opts->{timeout} if $opts->{timeout}; 
     32    eval { 
     33        local $SIG{ALRM} = sub { die; }; 
     34        delete $opts->{timeout}; 
     35        my $frame = $self->{stomp}->receive_frame(); 
     36        if ($frame) { 
     37            $payload = $frame->body; 
     38            $self->{stomp}->ack( { frame => $frame } ); 
     39        } 
     40        alarm 0; 
     41    }; 
    3442    return $payload; 
    3543} 
  • test/t/testconfig.pm

    r5f816fc r6acb955  
    99use strict; 
    1010use vars qw/@EXPORT/; 
     11sub mkL { 
     12  my $fd = $_[0]; 
     13  return sub {} unless $ENV{DEBUG_TESTS}; 
     14  return sub { print $fd "[$$] $_[0]\n"; } 
     15}; 
     16sub childL { 
     17  open my $olderr, ">&STDERR"; 
     18  { no warnings 'redefine'; *L = mkL($olderr); } 
     19} 
     20*L = mkL(\*STDERR); 
    1121 
    1222my $noit_pid = 0; 
     
    122132  foreach(@logtypes) { 
    123133    $opts->{logs_error}->{$_} ||= 'false'; 
    124     $opts->{logs_debug}->{$_} ||= 'false'; 
     134    $opts->{logs_debug}->{$_} ||= 'true'; 
    125135  } 
    126136   
     
    144154      <config><extended_id>on</extended_id></config> 
    145155      <outlet name="feed"/> 
     156      <log name="bundle"/> 
    146157      <log name="check"> 
    147158        <outlet name="error"/> 
     
    257268  my $name = shift; 
    258269  my $options = shift; 
    259   $options->{cwd} ||= cwd(); 
     270  $options->{cwd} ||= getcwd(); 
    260271  $options->{modules} = $all_noit_modules unless exists($options->{modules}); 
    261272  $options->{filtersets} = $default_filterset unless exists($options->{filtersets}); 
     
    462473  my $name = shift; 
    463474  my $options = shift; 
    464   $options->{cwd} ||= cwd(); 
     475  L("make_stratcon_config"); 
     476  $options->{cwd} ||= getcwd(); 
     477  L("make_stratcon_config in $options->{cwd}"); 
    465478  $options->{generics} ||= { 'stomp_driver' => { image => 'stomp_driver' }, 
    466479                             'postgres_ingestor' => { image => 'postgres_ingestor' } }; 
     
    469482  my $cwd = $options->{cwd}; 
    470483  my $file = "$cwd/logs/${name}_stratcon.conf"; 
     484  L("make_stratcon_config -> open($file)"); 
    471485  open (my $o, ">$file") || BAIL_OUT("can't write config: $file"); 
    472486  print $o qq{<?xml version="1.0" encoding="utf8" standalone="yes"?>\n}; 
     
    481495  make_iep_config($o, $options); 
    482496  print $o qq{</stratcon>\n}; 
     497  L("make_stratcon_config -> close($file)"); 
    483498  close($o); 
    484499  return $file; 
     
    496511  $options->{name} = $name; 
    497512  return 0 if $noit_pid; 
     513  L("start_noit -> config"); 
    498514  my $conf = make_noit_config($name, $options); 
    499515  $noit_pid = fork(); 
     516  L("noit_pid -> $noit_pid") if ($noit_pid); 
    500517  mkdir "logs"; 
    501518  $noit_log = "logs/${name}_noit.log"; 
    502519  if($noit_pid == 0) { 
     520    L("in child"); 
     521    childL; 
    503522    $noit_pid = $$; 
    504523    $noit_log = "logs/${name}_noit.log"; 
     524    L("in child -> closing stdin"); 
    505525    close(STDIN); 
     526    L("in child -> opening stdin"); 
    506527    open(STDIN, "</dev/null"); 
     528    L("in child -> closing stdout"); 
    507529    close(STDOUT); 
     530    L("in child -> opening stdout"); 
    508531    open(STDOUT, ">/dev/null"); 
     532    L("in child -> closing stderr"); 
    509533    close(STDERR); 
     534    L("in child -> opening err $noit_log"); 
    510535    open(STDERR, ">$noit_log"); 
    511536    my @args = ( 'noitd', '-D', '-c', $conf ); 
     537    L("in child -> exec"); 
    512538    exec { '../../src/noitd' } @args; 
    513539    exit(-1); 
    514540  } 
     541  L("in parent -> noitd($noit_pid)"); 
    515542  return $noit_pid; 
    516543} 
     
    530557  $options->{name} = $name; 
    531558  return 0 if $stratcon_pid; 
     559  L("start_stratcon -> config"); 
    532560  my $conf = make_stratcon_config($name, $options); 
     561  L("start_stratcon -> config($conf)"); 
    533562  $stratcon_pid = fork(); 
     563  L("stratcon_pid -> $stratcon_pid") if($stratcon_pid); 
    534564  mkdir "logs"; 
    535565  $stratcon_log = "logs/${name}_stratcon.log"; 
    536566  if($stratcon_pid == 0) { 
     567    L("in child"); 
     568    childL; 
    537569    $stratcon_pid = $$; 
    538570    $stratcon_log = "logs/${name}_stratcon.log"; 
     
    544576    open(STDERR, ">$stratcon_log"); 
    545577    my @args = ( 'stratcond', '-D', '-c', $conf ); 
     578    L("in child -> exec"); 
    546579    exec { '../../src/stratcond' } @args; 
    547580    exit(-1);