Add logging of agent login/logoff
authorMark Spencer <markster@digium.com>
Sat, 14 Feb 2004 04:54:39 +0000 (04:54 +0000)
committerMark Spencer <markster@digium.com>
Sat, 14 Feb 2004 04:54:39 +0000 (04:54 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@2162 65c4cc65-6c06-0410-ace0-fbb531ad65f3

channels/chan_agent.c
doc/queuelog.txt

index fd21df6..04a4e68 100755 (executable)
@@ -1117,8 +1117,10 @@ static int __login_exec(struct ast_channel *chan, void *data, int callbackmode)
        struct agent_pvt *p;
        struct localuser *u;
        struct timeval tv;
+       time_t start;
        char user[AST_MAX_AGENT];
        char pass[AST_MAX_AGENT];
+       char agent[AST_MAX_AGENT] = "";
        char xpass[AST_MAX_AGENT] = "";
        char *errmsg;
        char info[512];
@@ -1291,6 +1293,9 @@ static int __login_exec(struct ast_channel *chan, void *data, int callbackmode)
                                                                "Agent: %s\r\n"
                                                                "Channel: %s\r\n",
                                                                p->agent, chan->name);
+                                                       time(&start);
+                                                       snprintf(agent, sizeof(agent), "Agent/%s", p->agent);
+                                                       ast_queue_log("NONE", chan->uniqueid, agent, "AGENTLOGIN", "%s", chan->name);
                                                        if (option_verbose > 2)
                                                                ast_verbose(VERBOSE_PREFIX_3 "Agent '%s' logged in (format %s/%s)\n", p->agent,
                                                                                                ast_getformatname(chan->readformat), ast_getformatname(chan->writeformat));
@@ -1360,6 +1365,7 @@ static int __login_exec(struct ast_channel *chan, void *data, int callbackmode)
                                                        ast_mutex_unlock(&p->lock);
                                                        if (option_verbose > 2)
                                                                ast_verbose(VERBOSE_PREFIX_3 "Agent '%s' logged out\n", p->agent);
+                                                       ast_queue_log("NONE", chan->uniqueid, agent, "AGENTLOGOFF", "%s|%ld", chan->name, (long)(time(NULL) - start));
                                                        manager_event(EVENT_FLAG_AGENT, "Agentlogoff",
                                                                "Agent: %s\r\n",
                                                                p->agent);
index fc93d24..85da484 100755 (executable)
@@ -19,6 +19,13 @@ queue at the time of disconnect.
 AGENTDUMP
 The agent dumped the caller while listening to the queue announcement.
 
+AGENTLOGIN(channel)
+The agent logged in.  The channel is recorded.
+
+AGENTLOGOFF(channel|logintime)
+The agent logged off.  The channel is recorded, along with the total time
+the agent was logged in.
+
 COMPLETEAGENT(holdtime|calltime|origposition)
 The caller was connected to an agent, and the call was terminated normally
 by the *agent*.  The caller's hold time and the length of the call are both