Changeset 48647bb29c7c49cc39e67ce571de2d505a3e44e0

Show
Ignore:
Timestamp:
11/19/09 16:00:52 (4 years ago)
Author:
Theo Schlossnagle <jesus@omniti.com>
git-committer:
Theo Schlossnagle <jesus@omniti.com> 1258646452 +0000
git-parent:

[3cc39daeab088197d7fad92abc8414227ff26df3]

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

enable -l/-L for noitd, just like we did for stratcond

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • src/noit.conf.in

    rd38990d r48647bb  
    1919      <error> 
    2020        <outlet name="error"/> 
     21        <log name="error/collectd"/> 
     22        <log name="error/dns"/> 
    2123        <log name="error/eventer"/> 
     24        <log name="error/external"/> 
     25        <log name="error/lua"/> 
     26        <log name="error/mysql"/> 
    2227        <log name="error/ping_icmp"/> 
    23         <log name="error/serf"/> 
     28        <log name="error/postgres"/> 
     29        <log name="error/selfcheck"/> 
    2430        <log name="error/snmp"/> 
     31        <log name="error/ssh2"/> 
    2532      </error> 
    2633      <debug> 
     34        <outlet name="debug"/> 
     35        <log name="debug/collectd" disabled="true"/> 
     36        <log name="debug/dns" disabled="true"/> 
    2737        <log name="debug/eventer" disabled="true"/> 
     38        <log name="debug/external" disabled="true"/> 
     39        <log name="debug/lua" disabled="true"/> 
     40        <log name="debug/mysql" disabled="true"/> 
    2841        <log name="debug/ping_icmp" disabled="true"/> 
    29         <log name="debug/serf" disabled="false"/> 
     42        <log name="debug/postgres" disabled="true"/> 
     43        <log name="debug/selfcheck" disabled="true"/> 
    3044        <log name="debug/snmp" disabled="true"/> 
     45        <log name="debug/ssh2" disabled="true"/> 
    3146      </debug> 
    3247    </components> 
  • src/noitd.c

    rf0555be r48647bb  
    7070static int foreground = 0; 
    7171static int debug = 0; 
     72static char **enable_logs; 
     73static int enable_logs_cnt = 0; 
     74static char **disable_logs; 
     75static int disable_logs_cnt = 0; 
    7276 
    7377#include "man/noitd.usage.h" 
     
    8387  return; 
    8488} 
     89 
     90void cli_log_switches() { 
     91  int i; 
     92  noit_log_stream_t ls; 
     93  for(i=0; i<enable_logs_cnt; i++) { 
     94    ls = noit_log_stream_find(enable_logs[i]); 
     95    if(!ls) noitL(noit_error, "No such log: '%s'\n", enable_logs[i]); 
     96    if(ls && !ls->enabled) { 
     97      noitL(noit_error, "Enabling %s\n", enable_logs[i]); 
     98      ls->enabled = 1; 
     99    } 
     100  } 
     101  for(i=0; i<disable_logs_cnt; i++) { 
     102    ls = noit_log_stream_find(disable_logs[i]); 
     103    if(!ls) noitL(noit_error, "No such log: '%s'\n", enable_logs[i]); 
     104    if(ls && ls->enabled) { 
     105      noitL(noit_error, "Disabling %s\n", disable_logs[i]); 
     106      ls->enabled = 0; 
     107    } 
     108  } 
     109} 
    85110void parse_clargs(int argc, char **argv) { 
    86111  int c; 
    87   while((c = getopt(argc, argv, "hc:dDu:g:t:")) != EOF) { 
     112  enable_logs = calloc(argc, sizeof(*enable_logs)); 
     113  disable_logs = calloc(argc, sizeof(*disable_logs)); 
     114  while((c = getopt(argc, argv, "hc:dDu:g:t:l:L:")) != EOF) { 
    88115    switch(c) { 
    89116      case 'h': 
    90117        usage(argv[0]); 
    91118        exit(1); 
     119        break; 
     120      case 'l': 
     121        enable_logs[enable_logs_cnt++] = strdup(optarg); 
     122        break; 
     123      case 'L': 
     124        disable_logs[disable_logs_cnt++] = strdup(optarg); 
    92125        break; 
    93126      case 'u': 
     
    243276  } 
    244277  noit_conf_log_init(APPNAME); 
     278  cli_log_switches(); 
    245279  if(noit_security_usergroup(user, group, noit_true)) { 
    246280    noitL(noit_stderr, "Failed to regain privileges, exiting.\n");