Show
Ignore:
Timestamp:
02/13/08 20:46:00 (10 years ago)
Author:
Theo Schlossnagle <jesus@omniti.com>
git-committer:
Theo Schlossnagle <jesus@omniti.com> 1202935560 +0000
git-parent:

[624c3f92779aef1df9d9b7eda05e93506a07e4cd]

git-author:
Theo Schlossnagle <jesus@omniti.com> 1202935560 +0000
Message:

support 'no check' on console to delete checks as well as 'reload' on console (currently only reloads checks)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • src/modules/http.c

    r87af809 r6e90b3f  
    339339  if(xpath_ctxt) xmlXPathFreeContext(xpath_ctxt); 
    340340} 
     341static void serf_check_info_cleanup(serf_check_info_t *ci) { 
     342  if(ci->connection) { 
     343    serf_connection_close(ci->connection); 
     344    ci->connection = NULL; 
     345  } 
     346  if(ci->fd_event) { 
     347    eventer_remove_fd(ci->fd_event->fd); 
     348    eventer_free(ci->fd_event); 
     349    ci->fd_event = NULL; 
     350  } 
     351  ci->timeout_event = NULL; 
     352  if(ci->pool) apr_pool_destroy(ci->pool); 
     353  memset(ci, 0, sizeof(*ci)); 
     354} 
    341355static int serf_complete(eventer_t e, int mask, 
    342356                         void *closure, struct timeval *now) { 
     
    345359 
    346360  noitLT(nldeb, now, "serf_complete(%s)\n", ccl->check->target); 
    347   generic_log_results(ccl->self, ccl->check); 
    348   if(ci->connection) { 
    349     serf_connection_close(ci->connection); 
    350     ci->connection = NULL; 
    351   } 
    352   if(ci->fd_event) { 
    353     eventer_remove_fd(ci->fd_event->fd); 
    354     eventer_free(ci->fd_event); 
    355     ci->fd_event = NULL; 
    356   } 
    357   ci->timeout_event = NULL; 
    358   apr_pool_destroy(ci->pool); 
    359   memset(ci, 0, sizeof(*ci)); 
     361  if(!NOIT_CHECK_DISABLED(ccl->check) && !NOIT_CHECK_KILLED(ccl->check)) { 
     362    generic_log_results(ccl->self, ccl->check); 
     363  } 
     364  serf_check_info_cleanup(ci); 
    360365  ccl->check->flags &= ~NP_RUNNING; 
    361366  free(ccl); 
     
    777782  return 0; 
    778783} 
     784static void serf_cleanup(noit_module_t *self, noit_check_t *check) { 
     785  serf_check_info_t *sci; 
     786  if(check->fire_event) { 
     787    eventer_remove(check->fire_event); 
     788    free(check->fire_event->closure); 
     789    eventer_free(check->fire_event); 
     790    check->fire_event = NULL; 
     791  } 
     792  sci = check->closure; 
     793  if(sci) { 
     794    serf_check_info_cleanup(sci); 
     795    free(sci); 
     796  } 
     797} 
    779798static int serf_initiate_check(noit_module_t *self, noit_check_t *check, 
    780799                               int once, noit_check_t *cause) { 
     
    808827} 
    809828 
     829static void resmon_cleanup(noit_module_t *self, noit_check_t *check) { 
     830  resmon_check_info_t *rci; 
     831  if(check->fire_event) { 
     832    eventer_remove(check->fire_event); 
     833    free(check->fire_event->closure); 
     834    eventer_free(check->fire_event); 
     835    check->fire_event = NULL; 
     836  } 
     837  rci = check->closure; 
     838  if(rci) { 
     839    if(rci->xpathexpr) free(rci->xpathexpr); 
     840    if(rci->resmod) free(rci->resmod); 
     841    if(rci->resserv) free(rci->resserv); 
     842    if(rci->xml_doc) xmlFreeDoc(rci->xml_doc); 
     843    serf_check_info_cleanup(&rci->serf); 
     844    free(rci); 
     845  } 
     846} 
    810847static int resmon_part_initiate_check(noit_module_t *self, noit_check_t *check, 
    811848                                      int once, noit_check_t *parent) { 
     
    813850  const char *resmod, *resserv; 
    814851  resmon_check_info_t *rci; 
     852 
     853  if(NOIT_CHECK_DISABLED(check) || NOIT_CHECK_KILLED(check)) return 0; 
    815854 
    816855  if(!check->closure) check->closure = calloc(1, sizeof(resmon_check_info_t)); 
     
    873912  serf_config, 
    874913  serf_init, 
    875   serf_initiate_check 
     914  serf_initiate_check, 
     915  serf_cleanup 
    876916}; 
    877917 
     
    884924  resmon_config, 
    885925  serf_init, 
    886   resmon_initiate_check 
     926  resmon_initiate_check, 
     927  resmon_cleanup 
    887928}; 
    888929 
     
    895936  resmon_config, 
    896937  serf_init, 
    897   resmon_part_initiate_check 
     938  resmon_part_initiate_check, 
     939  resmon_cleanup 
    898940}; 
    899941 
  • src/modules/ping_icmp.c

    r1d69a01 r6e90b3f  
    124124  struct ping_closure *pcl = (struct ping_closure *)closure; 
    125125  struct check_info *data; 
    126   ping_icmp_log_results(pcl->self, pcl->check); 
    127   data = (struct check_info *)pcl->check->closure; 
    128   data->timeout_event = NULL; 
     126  if(!NOIT_CHECK_KILLED(pcl->check) && !NOIT_CHECK_DISABLED(pcl->check)) { 
     127    ping_icmp_log_results(pcl->self, pcl->check); 
     128    data = (struct check_info *)pcl->check->closure; 
     129    data->timeout_event = NULL; 
     130  } 
    129131  pcl->check->flags &= ~NP_RUNNING; 
    130132  free(pcl); 
     
    324326  return 0; 
    325327} 
     328static void ping_check_cleanup(noit_module_t *self, noit_check_t *check) { 
     329  struct check_info *ci = (struct check_info *)check->closure; 
     330  if(check->fire_event) { 
     331    eventer_remove(check->fire_event); 
     332    free(check->fire_event->closure); 
     333    eventer_free(check->fire_event); 
     334    check->fire_event = NULL; 
     335  } 
     336  if(ci) { 
     337    if(ci->timeout_event) { 
     338      eventer_remove(ci->timeout_event); 
     339      free(ci->timeout_event->closure); 
     340      eventer_free(ci->timeout_event); 
     341      ci->timeout_event = NULL; 
     342    } 
     343    if(ci->turnaround) free(ci->turnaround); 
     344    free(ci); 
     345  } 
     346} 
    326347static int ping_icmp_send(noit_module_t *self, noit_check_t *check) { 
    327348  struct timeval when, p_int; 
     
    426447 
    427448  if(check->period == 0) return 0; 
     449  if(NOIT_CHECK_DISABLED(check) || NOIT_CHECK_KILLED(check)) return 0; 
    428450 
    429451  /* If we have an event, we know when we intended it to fire.  This means 
     
    456478                                   struct timeval *now) { 
    457479  struct ping_closure *cl = (struct ping_closure *)closure; 
     480  cl->check->fire_event = NULL; 
    458481  ping_icmp_schedule_next(cl->self, &e->whence, cl->check, now); 
    459482  ping_icmp_send(cl->self, cl->check); 
     
    535558  ping_icmp_config, 
    536559  ping_icmp_init, 
    537   ping_icmp_initiate_check 
     560  ping_icmp_initiate_check, 
     561  ping_check_cleanup 
    538562}; 
    539563