Changeset 204ecdc5ad373fb076d81ab8a63fc09df931be4e

Show
Ignore:
Timestamp:
03/12/12 19:21:44 (2 years ago)
Author:
Theo Schlossnagle <jesus@omniti.com>
git-committer:
Theo Schlossnagle <jesus@omniti.com> 1331580104 -0400
git-parent:

[7b18dcb59ee3691758518fa01123a4a42d43ad54]

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

hookable log phases

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • src/noit_check.c

    r46b9cf0 r204ecdc  
    6161  (closure,check,stats,m)) 
    6262 
     63NOIT_HOOK_IMPL(check_passive_log_stats, 
     64  (noit_check_t *check), 
     65  void *, closure, 
     66  (void *closure, noit_check_t *check), 
     67  (closure,check)) 
     68 
     69NOIT_HOOK_IMPL(check_log_stats, 
     70  (noit_check_t *check), 
     71  void *, closure, 
     72  (void *closure, noit_check_t *check), 
     73  (closure,check)) 
     74 
    6375/* 20 ms slots over 60 second for distribution */ 
    6476#define SCHEDULE_GRANULARITY 20 
     
    509521noit_check_t * 
    510522noit_check_clone(uuid_t in) { 
     523  int i; 
    511524  noit_check_t *checker, *new_check; 
    512525  void *vcheck; 
     
    533546  new_check->config = calloc(1, sizeof(*new_check->config)); 
    534547  noit_hash_merge_as_dict(new_check->config, checker->config); 
     548  for(i=0; i<reg_module_id; i++) { 
     549    noit_hash_table *src_mconfig; 
     550    src_mconfig = noit_check_get_module_config(checker, i); 
     551    if(src_mconfig) { 
     552      noit_hash_table *t = calloc(1, sizeof(*new_check->config)); 
     553      noit_hash_merge_as_dict(t, src_mconfig); 
     554      noit_check_set_module_config(new_check, i, t); 
     555    } 
     556  } 
    535557  return new_check; 
    536558} 
     
    13091331    memcpy(&backup, &wcheck->stats.current, sizeof(stats_t)); 
    13101332    memcpy(&wcheck->stats.current, newstate, sizeof(stats_t)); 
    1311     /* Write out our status */ 
    1312     noit_check_log_status(wcheck); 
    1313     /* Write out all metrics */ 
    1314     noit_check_log_metrics(wcheck); 
     1333 
     1334    if(check_passive_log_stats_hook_invoke(check) == NOIT_HOOK_CONTINUE) { 
     1335      /* Write out our status */ 
     1336      noit_check_log_status(wcheck); 
     1337      /* Write out all metrics */ 
     1338      noit_check_log_metrics(wcheck); 
     1339    } 
    13151340    /* Swap them back out */ 
    13161341    memcpy(&wcheck->stats.current, &backup, sizeof(stats_t)); 
     
    13631388  } 
    13641389 
    1365   /* Write out the bundled information */ 
    1366   noit_check_log_bundle(check); 
     1390  if(check_log_stats_hook_invoke(check) == NOIT_HOOK_CONTINUE) { 
     1391    /* Write out the bundled information */ 
     1392    noit_check_log_bundle(check); 
     1393  } 
    13671394  /* count the check as complete */ 
    13681395  check_completion_count++; 
  • src/noit_check.h

    r46b9cf0 r204ecdc  
    335335                (void *closure, noit_check_t *check, stats_t *stats, metric_t *m)) 
    336336 
     337NOIT_HOOK_PROTO(check_passive_log_stats, 
     338                (noit_check_t *check), 
     339                void *, closure, 
     340                (void *closure, noit_check_t *check)) 
     341 
     342NOIT_HOOK_PROTO(check_log_stats, 
     343                (noit_check_t *check), 
     344                void *, closure, 
     345                (void *closure, noit_check_t *check)) 
     346 
    337347#endif 
  • src/noit_check_log.c

    r16ce152 r204ecdc  
    11/* 
    2  * Copyright (c) 2007, OmniTI Computer Consulting, Inc. 
     2 * Copyright (c) 2007-2012, OmniTI Computer Consulting, Inc. 
    33 * All rights reserved. 
    44 * 
  • src/noit_check_tools.h

    r46b9cf0 r204ecdc  
    105105 *   effect for this instrumentation point.</para> 
    106106 *   </section> 
     107 *   <section><title>check_log_stats</title> 
     108 *   <programlisting> 
     109 *     noit_hook_return_t (*f)(void *closure, noit_check_t *check); 
     110 *   </programlisting> 
     111 *   <para>The check_log_stats is called when a check logs a metrics 
     112 *   bundle.</para> 
     113 *   <para>If NOIT_HOOK_DONE is returned, normal logging is averted.</para> 
     114 *   </section> 
     115 *   <section><title>check_passive_log_stats</title> 
     116 *   <programlisting> 
     117 *     noit_hook_return_t (*f)(void *closure, noit_check_t *check); 
     118 *   </programlisting> 
     119 *   <para>The check_passive_log_stats is called when a check logs a 
     120 *   metric immediately.</para> 
     121 *   <para>If NOIT_HOOK_DONE is returned, normal logging is averted.</para> 
     122 *   </section> 
    107123 * </section> 
    108124 */