--- app_agents.c.original 2008-09-12 16:05:27.000000000 -0430 +++ app_agents.c 2008-09-12 16:38:06.000000000 -0430 @@ -920,9 +920,42 @@ return CLI_SUCCESS; } +/*! \brief CLI command to show all available agents */ +static char *agents2_show_available(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) +{ + struct agent2_agent *agent; + struct ao2_iterator i; + int total_available = 0; + + switch (cmd) { + case CLI_INIT: + e->command = "agents2 show available"; + e->usage = + "Usage: agents2 show available\n" + " Provides a list of all available agents.\n"; + return NULL; + case CLI_GENERATE: + return NULL; + } + + i = ao2_iterator_init(agents, 0); + + for (; (agent = ao2_iterator_next(&i)); ao2_ref(agent, -1)) { + ast_cli(a->fd, "%s(%s) %s\n", agent->name, agent2_type2text(agent->type), agent2_state2text(agent->state)); + if (!(agent->state == AGENT2_STATE_NONE || agent->state == AGENT2_STATE_HANGUP)) { + total_available++; + } + } + + ast_cli(a->fd, "%d agents available\n\n", total_available); + + return CLI_SUCCESS; +} + /*! \brief CLI commands to interact with things */ static struct ast_cli_entry cli_agents2[] = { AST_CLI_DEFINE(agents2_show, "Show status of agents"), + AST_CLI_DEFINE(agents2_show_available, "Show all available agents"), }; /*! \brief Function called when module should be reloaded */