[Asterisk-Users] [PATCH] show agents in manager

Jean-Denis Girard jd-girard at esoft.pf
Tue Feb 25 13:52:59 MST 2003


Hi list,

This little patch adds a "show agents" command to asterisk manager, 
similar to what I did previously for IAX peers.


-- 
Jean-Denis Girard

====================================================
Essential Software - Ingénierie Informatique
Solutions Linux & Open Source en Polynésie française
----------------------------------------------------
http://www.esoft.pf/
Tél: (689) 54 12 95
====================================================
-------------- next part --------------
diff -Naur asterisk-20030224-isdn/channels/chan_agent.c asterisk-20030224-isdn-chan_agents/channels/chan_agent.c
--- asterisk-20030224-isdn/channels/chan_agent.c	2002-12-09 07:27:03.000000000 -1000
+++ asterisk-20030224-isdn-chan_agents/channels/chan_agent.c	2003-02-25 09:21:16.000000000 -1000
@@ -469,6 +469,16 @@
 	{ "show", "agents", NULL }, agents_show, 
 	"Show status of agents", show_agents_usage, NULL };
 
+/* JDG: callback to display agents in manager */
+static int manager_show_agents( struct mansession *s, struct message *m )
+{
+	char *a[] = { "show", "agents" };
+	int ret;
+	ret = agents_show( s->fd, 2, a );
+	ast_cli( s->fd, "\r\n" );
+	return ret;
+} /* /JDG */
+
 STANDARD_LOCAL_USER;
 LOCAL_USER_DECL;
 
@@ -506,7 +516,7 @@
 	if (chan->_state != AST_STATE_UP)
 		res = ast_answer(chan);
 	if (!res) {
-		if( opt_user )
+		if( opt_user && strlen(opt_user) )
 			strncpy( user, opt_user, AST_MAX_AGENT );
 		else
 			res = ast_app_getdata(chan, "agent-user", user, sizeof(user) - 1, 0);
@@ -655,6 +665,7 @@
 	}
 	ast_register_application(app, login_exec, synopsis, descrip);
 	ast_cli_register(&cli_show_agents);
+	ast_manager_register( "Agents", 0, manager_show_agents, "List Agents" );
 	/* Read in the config */
 	read_agent_config();
 	return 0;


More information about the asterisk-users mailing list