Index: include/asterisk/manager.h =================================================================== --- include/asterisk/manager.h (revision 89483) +++ include/asterisk/manager.h (working copy) @@ -57,6 +57,7 @@ #define EVENT_FLAG_CONFIG (1 << 7) /* Ability to modify configurations */ #define EVENT_FLAG_DTMF (1 << 8) /* Ability to read DTMF events */ #define EVENT_FLAG_REPORTING (1 << 9) /* Reporting events such as rtcp sent */ +#define EVENT_FLAG_AGI (1 << 10) /* Reporting AGI events */ /* Export manager structures */ #define AST_MAX_MANHEADERS 128 Index: main/manager.c =================================================================== --- main/manager.c (revision 89483) +++ main/manager.c (working copy) @@ -309,6 +309,7 @@ { EVENT_FLAG_CONFIG, "config" }, { EVENT_FLAG_DTMF, "dtmf" }, { EVENT_FLAG_REPORTING, "reporting" }, + { EVENT_FLAG_AGI, "agi" }, { -1, "all" }, { 0, "none" }, }; Index: res/res_agi.c =================================================================== --- res/res_agi.c (revision 89483) +++ res/res_agi.c (working copy) @@ -53,6 +53,7 @@ #include "asterisk/lock.h" #include "asterisk/strings.h" #include "asterisk/agi.h" +#include "asterisk/manager.h" #define MAX_ARGS 128 #define AGI_NANDFS_RETRY 3 @@ -1824,7 +1825,12 @@ char *argv[MAX_ARGS]; int argc = MAX_ARGS, res; agi_command *c; - + const char *ami_res = "Unknown Result"; + char *ami_cmd = ast_strdupa(buf); + manager_event(EVENT_FLAG_AGI, "AGIExec", + "SubEvent: Start\r\n" + "Channel: %s\r\n" + "Command: %s\r\n", chan->name, ami_cmd); parse_args(buf, &argc, argv); if ((c = find_command(argv, 0)) && (!dead || (dead && c->dead))) { /* if this command wasnt registered by res_agi, be sure to usecount @@ -1834,6 +1840,17 @@ res = c->handler(chan, agi, argc, argv); if (c->mod != ast_module_info->self) ast_module_unref(c->mod); + switch (res) { + case RESULT_SHOWUSAGE: ami_res = "Usage"; break; + case AST_PBX_KEEPALIVE: ami_res = "KeepAlive"; break; + case RESULT_FAILURE: ami_res = "Failure"; break; + case RESULT_SUCCESS: ami_res = "Success"; break; + } + manager_event(EVENT_FLAG_AGI, "AGIExec", + "SubEvent: End\r\n" + "Channel: %s\r\n" + "Command: %s\r\n" + "Result: %s\r\n", chan->name, ami_cmd, ami_res); switch(res) { case RESULT_SHOWUSAGE: ast_agi_fdprintf(chan, agi->fd, "520-Invalid command syntax. Proper usage follows:\n"); @@ -1851,8 +1868,18 @@ } } else if ((c = find_command(argv, 0))) { ast_agi_fdprintf(chan, agi->fd, "511 Command Not Permitted on a dead channel\n"); + manager_event(EVENT_FLAG_AGI, "AGIExec", + "SubEvent: End\r\n" + "Channel: %s\r\n" + "Command: %s\r\n" + "Result: %s\r\n", chan->name, ami_cmd, "DeadChannel"); } else { ast_agi_fdprintf(chan, agi->fd, "510 Invalid or unknown command\n"); + manager_event(EVENT_FLAG_AGI, "AGIExec", + "SubEvent: End\r\n" + "Channel: %s\r\n" + "Command: %s\r\n" + "Result: %s\r\n", chan->name, ami_cmd, "Invalid"); } return 0; }