aboutsummaryrefslogtreecommitdiffstats
path: root/res/res_agi.c
diff options
context:
space:
mode:
authortilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2007-12-14 17:29:27 +0000
committertilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2007-12-14 17:29:27 +0000
commitcc8c8c385cfe89dfb3a68b4c2b9992e39f81bb8a (patch)
tree2d79abf3cf690d6393685d64a36585adcf82d5ce /res/res_agi.c
parent06927ebe4352d8318b10bd275df25176bafab7e6 (diff)
Publish the AGI events to manager.
Reported by: moy Patch by: moy,tilghman (Closes issue #11337) git-svn-id: http://svn.digium.com/svn/asterisk/trunk@92999 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'res/res_agi.c')
-rw-r--r--res/res_agi.c38
1 files changed, 37 insertions, 1 deletions
diff --git a/res/res_agi.c b/res/res_agi.c
index 61bd9f5b7..9747bdb11 100644
--- a/res/res_agi.c
+++ b/res/res_agi.c
@@ -53,6 +53,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include "asterisk/agi.h"
#include "asterisk/version.h"
#include "asterisk/speech.h"
+#include "asterisk/manager.h"
#define MAX_ARGS 128
#define AGI_NANDFS_RETRY 3
@@ -2150,7 +2151,15 @@ static int agi_handle_command(struct ast_channel *chan, AGI *agi, char *buf, int
char *argv[MAX_ARGS];
int argc = MAX_ARGS, res;
agi_command *c;
-
+ const char *ami_res = "Unknown Result";
+ char *ami_cmd = ast_strdupa(buf);
+ int command_id = ast_random(), resultcode = 200;
+
+ manager_event(EVENT_FLAG_CALL, "AGIExec",
+ "SubEvent: Start\r\n"
+ "Channel: %s\r\n"
+ "CommandId: %d\r\n"
+ "Command: %s\r\n", chan->name, command_id, 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
@@ -2160,6 +2169,19 @@ static int agi_handle_command(struct ast_channel *chan, AGI *agi, char *buf, int
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"; resultcode = 520; break;
+ case AST_PBX_KEEPALIVE: ami_res = "KeepAlive"; resultcode = 210; break;
+ case RESULT_FAILURE: ami_res = "Failure"; resultcode = -1; break;
+ case RESULT_SUCCESS: ami_res = "Success"; resultcode = 200; break;
+ }
+ manager_event(EVENT_FLAG_CALL, "AGIExec",
+ "SubEvent: End\r\n"
+ "Channel: %s\r\n"
+ "CommandId: %d\r\n"
+ "Command: %s\r\n"
+ "ResultCode: %d\r\n"
+ "Result: %s\r\n", chan->name, command_id, ami_cmd, resultcode, ami_res);
switch(res) {
case RESULT_SHOWUSAGE:
ast_agi_fdprintf(chan, agi->fd, "520-Invalid command syntax. Proper usage follows:\n");
@@ -2177,8 +2199,22 @@ static int agi_handle_command(struct ast_channel *chan, AGI *agi, char *buf, int
}
} 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_CALL, "AGIExec",
+ "SubEvent: End\r\n"
+ "Channel: %s\r\n"
+ "CommandId: %d\r\n"
+ "Command: %s\r\n"
+ "ResultCode: 511\r\n"
+ "Result: Command not permitted on a dead channel\r\n", chan->name, command_id, ami_cmd);
} else {
ast_agi_fdprintf(chan, agi->fd, "510 Invalid or unknown command\n");
+ manager_event(EVENT_FLAG_CALL, "AGIExec",
+ "SubEvent: End\r\n"
+ "Channel: %s\r\n"
+ "CommandId: %d\r\n"
+ "Command: %s\r\n"
+ "ResultCode: 510\r\n"
+ "Result: Invalid or unknown command\r\n", chan->name, command_id, ami_cmd);
}
return 0;
}