Ejemplo n.º 1
0
static void
register_console_rabbitmq_commands() {
  mtev_console_state_t *tl;
  cmd_info_t *showcmd;

  tl = mtev_console_state_initial();
  showcmd = mtev_console_state_get_cmd(tl, "show");
  mtevAssert(showcmd && showcmd->dstate);
  mtev_console_state_add_cmd(showcmd->dstate,
    NCSCMD("rabbitmq", noit_console_show_rabbitmq, NULL, NULL, NULL));
}
Ejemplo n.º 2
0
static void
mtev_lua_general_register_console_commands(mtev_image_t *self) {
  mtev_console_state_t *tl, *luas;

  tl = mtev_console_state_initial();
  luas = mtev_console_state_alloc_empty();

  luas->console_prompt_function = lua_repl_prompt;
  luas->statefree = lua_repl_raw_off;
  mtev_console_state_add_cmd(luas, &console_command_exit);

  mtev_console_state_add_cmd(luas,
    NCSCMD("",  mtev_console_lua_repl_execute, NULL, NULL, self));

  mtev_console_state_add_cmd(tl,
    NCSCMD("lua_general", mtev_console_state_lua, NULL, luas, self));
}
Ejemplo n.º 3
0
static void
register_console_filter_commands() {
  mtev_console_state_t *tl, *filterset_state, *nostate;
  cmd_info_t *confcmd, *conf_t_cmd, *no_cmd;

  tl = mtev_console_state_initial();
  confcmd = mtev_console_state_get_cmd(tl, "configure");
  assert(confcmd && confcmd->dstate);

  conf_t_cmd = mtev_console_state_get_cmd(confcmd->dstate, "terminal");
  assert(conf_t_cmd && conf_t_cmd->dstate);

  nostate = mtev_console_state_alloc();
  mtev_console_state_add_cmd(nostate,
    NCSCMD("rule", noit_console_rule_configure, NULL, NULL, (void *)1));

  filterset_state = mtev_console_state_alloc();
  mtev_console_state_add_cmd(filterset_state,
    NCSCMD("exit", mtev_console_config_cd, NULL, NULL, ".."));
  mtev_console_state_add_cmd(filterset_state,
    NCSCMD("status", noit_console_filter_show, NULL, NULL, NULL));
  mtev_console_state_add_cmd(filterset_state,
    NCSCMD("rule", noit_console_rule_configure, NULL, NULL, NULL));
  mtev_console_state_add_cmd(filterset_state,
    NCSCMD("no", mtev_console_state_delegate, mtev_console_opt_delegate,
           nostate, NULL));

  filterset_state->console_prompt_function = conf_t_filterset_prompt;

  mtev_console_state_add_cmd(conf_t_cmd->dstate,
    NCSCMD("filterset", noit_console_filter_configure,
           NULL, filterset_state, NULL));

  mtev_console_state_add_cmd(conf_t_cmd->dstate,
    NCSCMD("cull", noit_console_filter_cull,
           NULL, NULL, NULL));

  no_cmd = mtev_console_state_get_cmd(conf_t_cmd->dstate, "no");
  assert(no_cmd && no_cmd->dstate);
  mtev_console_state_add_cmd(no_cmd->dstate,
    NCSCMD("filterset", noit_console_filter_configure, NULL, NULL, (void *)1));
}
Ejemplo n.º 4
0
static void
register_console_dns_cache_commands() {
  mtev_console_state_t *tl;
  cmd_info_t *showcmd, *nocmd;

  tl = mtev_console_state_initial();
  showcmd = mtev_console_state_get_cmd(tl, "show");
  assert(showcmd && showcmd->dstate);

  nocmd = mtev_console_state_get_cmd(tl, "no");
  assert(nocmd && nocmd->dstate);

  mtev_console_state_add_cmd(showcmd->dstate,
    NCSCMD("dns_cache", noit_console_show_dns_cache, NULL, NULL, NULL));

  mtev_console_state_add_cmd(tl,
    NCSCMD("dns_cache", noit_console_manip_dns_cache, NULL, NULL, NULL));

  mtev_console_state_add_cmd(nocmd->dstate,
    NCSCMD("dns_cache", noit_console_manip_dns_cache, NULL, NULL, (void *)0x1));
}
Ejemplo n.º 5
0
static
void register_console_config_check_commands() {
  cmd_info_t *showcmd, *nocmd, *confcmd, *conftcmd, *conftnocmd, *lscmd;
  mtev_console_state_t *tl, *_conf_t_check_state, *_unset_state,
                       *_attr_state, *_uattr_state;

  mtev_conf_delete_section_hook_register("checks_protection",
                                         noit_delete_section_impl, NULL);

  tl = mtev_console_state_initial();
  showcmd = mtev_console_state_get_cmd(tl, "show");
  nocmd = mtev_console_state_get_cmd(tl, "no");
  confcmd = mtev_console_state_get_cmd(tl, "configure");
  conftcmd = mtev_console_state_get_cmd(confcmd->dstate, "terminal");
  conftnocmd = mtev_console_state_get_cmd(conftcmd->dstate, "no");
  lscmd = mtev_console_state_get_cmd(conftcmd->dstate, "ls");
  lscmd->func = noit_console_config_show;
  /* attribute <attrname> <value> */
  NEW_STATE(_attr_state);
  mtev_console_state_add_check_attrs(_attr_state, noit_conf_check_set_attr,
                                     "/checks");
 
  /* no attribute <attrname> <value> */
  NEW_STATE(_uattr_state);
  mtev_console_state_add_check_attrs(_uattr_state, noit_conf_check_unset_attr,
                                     "/checks");
  NEW_STATE(_unset_state);
  DELEGATE_CMD(_unset_state, "attribute",
               mtev_console_opt_delegate, _uattr_state);
  ADD_CMD(_unset_state, "config",
          noit_console_config_unsetconfig, NULL, NULL, NULL);

  DELEGATE_CMD(conftnocmd->dstate, "attribute",
               mtev_console_opt_delegate, _uattr_state);
  ADD_CMD(conftnocmd->dstate, "config",
          noit_console_config_unsetconfig, NULL, NULL, NULL);
  ADD_CMD(conftnocmd->dstate, "check",
          noit_console_config_nocheck, NULL, NULL, NULL);
 
  NEW_STATE(_conf_t_check_state);
  _conf_t_check_state->console_prompt_function = conf_t_check_prompt;
  DELEGATE_CMD(_conf_t_check_state, "attribute",
               mtev_console_opt_delegate, _attr_state);
  DELEGATE_CMD(_conf_t_check_state, "no",
               mtev_console_opt_delegate, _unset_state);
  ADD_CMD(_conf_t_check_state, "config",
          noit_console_config_setconfig, NULL, NULL, NULL);
  ADD_CMD(_conf_t_check_state, "status",
          noit_console_show_check, NULL, NULL, NULL);
  ADD_CMD(_conf_t_check_state, "exit",
          mtev_console_config_cd, NULL, NULL, "..");
  ADD_CMD(_conf_t_check_state, "check",
          noit_console_check, noit_console_conf_check_opts,
          _conf_t_check_state, "..");

  ADD_CMD(conftcmd->dstate, "config",
          noit_console_config_setconfig, NULL, NULL, NULL);
  ADD_CMD(conftcmd->dstate, "check",
          noit_console_check, noit_console_conf_check_opts,
          _conf_t_check_state, NULL);

  ADD_CMD(showcmd->dstate, "check",
          noit_console_show_check, noit_console_check_opts, NULL, NULL);

  ADD_CMD(tl, "watch",
          noit_console_watch_check, noit_console_check_opts, NULL, (void *)1);

  ADD_CMD(nocmd->dstate, "watch",
          noit_console_watch_check, noit_console_check_opts, NULL, (void *)0);

  DELEGATE_CMD(conftcmd->dstate, "attribute",
               mtev_console_opt_delegate, _attr_state);

  ADD_CMD(tl, "reload", noit_conf_checks_reload, NULL, NULL, NULL);
}