static void register_console_check_commands() { noit_console_state_t *tl; cmd_info_t *showcmd; tl = noit_console_state_initial(); showcmd = noit_console_state_get_cmd(tl, "show"); assert(showcmd && showcmd->dstate); noit_console_state_add_cmd(showcmd->dstate, NCSCMD("checks", noit_console_show_checks, NULL, NULL, NULL)); noit_console_state_add_cmd(showcmd->dstate, NCSCMD("watches", noit_console_show_watchlist, NULL, NULL, NULL)); }
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)); }
noit_console_state_t * noit_console_state_alloc(void) { noit_console_state_t *s; s = calloc(1, sizeof(*s)); noit_skiplist_init(&s->cmds); noit_skiplist_set_compare(&s->cmds, cmd_info_compare, cmd_info_comparek); noit_console_state_add_cmd(s, NCSCMD("apply", noit_console_generic_apply, NULL, NULL, NULL)); noit_console_state_add_cmd(s, &console_command_help); return s; }
void noit_console_add_help(const char *topic, console_cmd_func_t topic_func, console_opt_func_t ac) { noit_console_state_t *s = console_command_help.dstate; if(!s) { console_command_help.dstate = s = calloc(1, sizeof(*s)); noit_skiplist_init(&s->cmds); noit_skiplist_set_compare(&s->cmds, cmd_info_compare, cmd_info_comparek); } noit_console_state_add_cmd(s, NCSCMD(topic, topic_func, ac, NULL, NULL)); }
static void register_console_fq_commands() { noit_console_state_t *tl; cmd_info_t *showcmd; tl = noit_console_state_initial(); showcmd = noit_console_state_get_cmd(tl, "show"); assert(showcmd && showcmd->dstate); noit_console_state_add_cmd(showcmd->dstate, NCSCMD("fq", noit_console_show_fq, NULL, NULL, NULL)); }
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)); }
noit_console_state_t * noit_console_mksubdelegate(noit_console_state_t *parent, const char *cmd) { noit_console_state_t *child; cmd_info_t *existing; existing = noit_console_state_get_cmd(parent, cmd); if(existing) return existing->dstate; child = noit_console_state_alloc(); noit_console_state_add_cmd(parent, NCSCMD(cmd, noit_console_state_delegate, noit_console_opt_delegate, child, NULL)); return child; }
static void register_console_dns_cache_commands() { noit_console_state_t *tl; cmd_info_t *showcmd, *nocmd; tl = noit_console_state_initial(); showcmd = noit_console_state_get_cmd(tl, "show"); assert(showcmd && showcmd->dstate); nocmd = noit_console_state_get_cmd(tl, "no"); assert(nocmd && nocmd->dstate); noit_console_state_add_cmd(showcmd->dstate, NCSCMD("dns_cache", noit_console_show_dns_cache, NULL, NULL, NULL)); noit_console_state_add_cmd(tl, NCSCMD("dns_cache", noit_console_manip_dns_cache, NULL, NULL, NULL)); noit_console_state_add_cmd(nocmd->dstate, NCSCMD("dns_cache", noit_console_manip_dns_cache, NULL, NULL, (void *)0x1)); }
void noit_console_state_add_check_attrs(noit_console_state_t *state, console_cmd_func_t f, const char *scope) { int i; for(i = 0; i < sizeof(valid_attrs)/sizeof(valid_attrs[0]); i++) { if(strcmp(valid_attrs[i].scope, scope)) continue; noit_console_state_add_cmd(state, NCSCMD(valid_attrs[i].name, f, NULL, NULL, &valid_attrs[i])); } }
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)); }