Sponsor: VoiceMeUp - Corporate & Wholesale VoIP Services

VoIP Mailing List Archives
Mailing list archives for the VoIP community
 SearchSearch 

[Freeswitch-users] "show channels" command with duration - patch included


 
Post new topic   Reply to topic    VoIP Mailing List Archives Forum Index -> freeSWITCH Users
View previous topic :: View next topic  
Author Message
freeswitch-users at li...
Guest





PostPosted: Thu Jul 16, 2009 9:21 am    Post subject: [Freeswitch-users] "show channels" command with du Reply with quote

Hi,

I usually find it very useful when I can retrieve a list of the currents
calls along with durations. I noticed that the 'show channels' format
does not include the duration (or the answered timestamp - so that one
can extract it from there). So, I made a patch that includes the
answered timestamp, the answered timestamp in epoch, and the duration in
seconds. Of course these fields remain empty when the call hasn't been
answered yet.

I don't know if anyone else finds this functionality useful, so I am
posting this patch here first (instead of JIRA) in order to get feedback
from the users. If many of you (or the maintainers) find it interesting
I can then proceed in posting it to JIRA.

--
-------------------------------------------
Apostolos Pantsiopoulos
Kinetix Tele.com R & D
email: regs@kinetix.gr
-------------------------------------------

Index: src/mod/applications/mod_commands/mod_commands.c
===================================================================
--- src/mod/applications/mod_commands/mod_commands.c (revision 14256)
+++ src/mod/applications/mod_commands/mod_commands.c (working copy)
@@ -2827,10 +2827,10 @@
}
}
if (strchr(argv[2], '%')) {
- sprintf(sql, "select * from channels where uuid like '%s' or name like '%s' or cid_name like '%s' or cid_num like '%s' order by created_epoch",
+ sprintf(sql, "select *,strftime('%%s',DATETIME('NOW'))-answered_epoch as duration from channels where uuid like '%s' or name like '%s' or cid_name like '%s' or cid_num like '%s' order by created_epoch",
argv[2], argv[2], argv[2], argv[2]);
} else {
- sprintf(sql, "select * from channels where uuid like '%%%s%%' or name like '%%%s%%' or cid_name like '%%%s%%' or cid_num like '%%%s%%' order by created_epoch",
+ sprintf(sql, "select *,strftime('%%s',DATETIME('NOW'))-answered_epoch as duration from channels where uuid like '%%%s%%' or name like '%%%s%%' or cid_name like '%%%s%%' or cid_num like '%%%s%%' order by created_epoch",
argv[2], argv[2], argv[2], argv[2]);

}
@@ -2839,10 +2839,10 @@
as = argv[4];
}
} else {
- sprintf(sql, "select * from channels order by created_epoch");
+ sprintf(sql, "select *,strftime('%%s',DATETIME('NOW'))-answered_epoch as duration from channels order by created_epoch");
}
} else if (!strcasecmp(command, "channels")) {
- sprintf(sql, "select * from channels order by created_epoch");
+ sprintf(sql, "select *,strftime('%%s',DATETIME('NOW'))-answered_epoch as duration from channels order by created_epoch");
if (argv[1] && !strcasecmp(argv[1],"count")) {
holder.justcount = 1;
if (argv[3] && !strcasecmp(argv[2], "as")) {
@@ -2850,7 +2850,7 @@
}
}
} else if (!strcasecmp(command, "distinct_channels")) {
- sprintf(sql, "select * from channels left join calls on "
+ sprintf(sql, "select *,strftime('%%s',DATETIME('NOW'))-answered_epoch as duration from channels left join calls on "
"channels.uuid=calls.caller_uuid where channels.uuid not in (select callee_uuid from calls) order by created_epoch");
if (argv[2] && !strcasecmp(argv[1], "as")) {
as = argv[2];
Index: src/switch_core_sqldb.c
===================================================================
--- src/switch_core_sqldb.c (revision 14256)
+++ src/switch_core_sqldb.c (working copy)
@@ -309,9 +309,21 @@
);

break;
+ case SWITCH_EVENT_CHANNEL_ANSWER:
+ {
+
+ sql = switch_mprintf("update channels set answered='%s',answered_epoch='%ld' where uuid='%s'",
+ switch_event_get_header_nil(event, "event-date-local"),
+ (long)switch_epoch_time_now(NULL),
+ switch_event_get_header_nil(event, "unique-id")
+ );
+
+ }
+ break;
case SWITCH_EVENT_CHANNEL_STATE:
{
char *state = switch_event_get_header_nil(event, "channel-state-number");
+
switch_channel_state_t state_i = CS_DESTROY;

if (!switch_strlen_zero(state)) {
@@ -492,7 +504,9 @@
" read_rate VARCHAR(255),\n"
" write_codec VARCHAR(255),\n"
" write_rate VARCHAR(255),\n"
- " secure VARCHAR(255)\n"
+ " secure VARCHAR(255),\n"
+ " answered VARCHAR(255),\n"
+ " answered_epoch INTEGER\n"
");\ncreate index uuindex on channels (uuid);\n";
char create_calls_sql[] =
"CREATE TABLE calls (\n"
_______________________________________________
FreeSWITCH-users mailing list
FreeSWITCH-users@lists.freeswitch.org
http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
http://www.freeswitch.org
Back to top
anthony.minessale at g...
Guest





PostPosted: Thu Jul 16, 2009 9:22 am    Post subject: [Freeswitch-users] "show channels" command with du Reply with quote

I'm ok with the idea as long as it's thoroughly tested.
If there is any more info you want to save from those events you should consider it now while we are modifying it.
 

On Thu, Jul 16, 2009 at 9:02 AM, <freeswitch-users@lists.freeswitch.org (freeswitch-users@lists.freeswitch.org)> wrote:
Quote:
Hi,

I usually find it very useful when I can retrieve a list of the currents calls along with durations. I noticed that the 'show channels' format does not include the duration (or the answered timestamp - so that one can extract it from there). So, I made a patch that includes the answered timestamp, the answered timestamp in epoch, and the duration in seconds. Of course these fields remain empty when the call hasn't been
answered yet.

I don't know if anyone else finds this functionality useful, so I am posting this patch here first (instead of JIRA) in order to get feedback from the users. If many of you (or the maintainers) find it interesting I can then proceed in posting it to JIRA.

--
-------------------------------------------
Apostolos Pantsiopoulos
Kinetix Tele.com R & D
email: regs@kinetix.gr (regs@kinetix.gr)
-------------------------------------------

Index: src/mod/applications/mod_commands/mod_commands.c
===================================================================
--- src/mod/applications/mod_commands/mod_commands.c    (revision 14256)
+++ src/mod/applications/mod_commands/mod_commands.c    (working copy)
@@ -2827,10 +2827,10 @@
                               }
                       }
                       if (strchr(argv[2], '%')) {
-                               sprintf(sql, "select * from channels where uuid like '%s' or name like '%s' or cid_name like '%s' or cid_num like '%s' order by created_epoch",
+                               sprintf(sql, "select *,strftime('%%s',DATETIME('NOW'))-answered_epoch as duration from channels where uuid like '%s' or name like '%s' or cid_name like '%s' or cid_num like '%s' order by created_epoch",
                                               argv[2], argv[2], argv[2], argv[2]);
                       } else {
-                               sprintf(sql, "select * from channels where uuid like '%%%s%%' or name like '%%%s%%' or cid_name like '%%%s%%' or cid_num like '%%%s%%' order by created_epoch",
+                               sprintf(sql, "select *,strftime('%%s',DATETIME('NOW'))-answered_epoch as duration from channels where uuid like '%%%s%%' or name like '%%%s%%' or cid_name like '%%%s%%' or cid_num like '%%%s%%' order by created_epoch",
                                               argv[2], argv[2], argv[2], argv[2]);

                       }
@@ -2839,10 +2839,10 @@
                               as = argv[4];
                   }
               } else {
-                       sprintf(sql, "select * from channels order by created_epoch");
+                       sprintf(sql, "select *,strftime('%%s',DATETIME('NOW'))-answered_epoch as duration from channels order by created_epoch");
               }
       } else if (!strcasecmp(command, "channels")) {
-               sprintf(sql, "select * from channels order by created_epoch");
+               sprintf(sql, "select *,strftime('%%s',DATETIME('NOW'))-answered_epoch as duration from channels order by created_epoch");
               if (argv[1] && !strcasecmp(argv[1],"count")) {
                   holder.justcount = 1;
                   if (argv[3] && !strcasecmp(argv[2], "as")) {
@@ -2850,7 +2850,7 @@
                   }
               }
       } else if (!strcasecmp(command, "distinct_channels")) {
-               sprintf(sql, "select * from channels left join calls on "
+               sprintf(sql, "select *,strftime('%%s',DATETIME('NOW'))-answered_epoch as duration from channels left join calls on "
                               "channels.uuid=calls.caller_uuid where channels.uuid not in (select callee_uuid from calls) order by created_epoch");
               if (argv[2] && !strcasecmp(argv[1], "as")) {
                       as = argv[2];
Index: src/switch_core_sqldb.c
===================================================================
--- src/switch_core_sqldb.c     (revision 14256)
+++ src/switch_core_sqldb.c     (working copy)
@@ -309,9 +309,21 @@
                                                        );

               break;
+       case SWITCH_EVENT_CHANNEL_ANSWER:
+               {
+
+                       sql = switch_mprintf("update channels set answered='%s',answered_epoch='%ld' where uuid='%s'",
+                                                         switch_event_get_header_nil(event, "event-date-local"),
+                                                        (long)switch_epoch_time_now(NULL),
+                                                        switch_event_get_header_nil(event, "unique-id")
+                                                         );
+
+               }
+               break;
       case SWITCH_EVENT_CHANNEL_STATE:
               {
                       char *state = switch_event_get_header_nil(event, "channel-state-number");
+
                       switch_channel_state_t state_i = CS_DESTROY;

                       if (!switch_strlen_zero(state)) {
@@ -492,7 +504,9 @@
                       "   read_rate  VARCHAR(255),\n"
                       "   write_codec  VARCHAR(255),\n"
                       "   write_rate  VARCHAR(255),\n"
-                       "   secure VARCHAR(255)\n"
+                       "   secure VARCHAR(255),\n"
+                       "   answered  VARCHAR(255),\n"
+                        "   answered_epoch  INTEGER\n"
                       ");\ncreate index uuindex on channels (uuid);\n";
               char create_calls_sql[] =
                       "CREATE TABLE calls (\n"

_______________________________________________
FreeSWITCH-users mailing list
FreeSWITCH-users@lists.freeswitch.org (FreeSWITCH-users@lists.freeswitch.org)
http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
http://www.freeswitch.org




--
Anthony Minessale II

FreeSWITCH http://www.freeswitch.org/
ClueCon http://www.cluecon.com/
Twitter: http://twitter.com/FreeSWITCH_wire

AIM: anthm
MSN:anthony_minessale@hotmail.com ([email]MSN%3Aanthony_minessale@hotmail.com[/email])
GTALK/JABBER/PAYPAL:anthony.minessale@gmail.com ([email]PAYPAL%3Aanthony.minessale@gmail.com[/email])
IRC: irc.freenode.net #freeswitch

FreeSWITCH Developer Conference
sip:888@conference.freeswitch.org ([email]sip%3A888@conference.freeswitch.org[/email])
iax:guest@conference.freeswitch.org/888
googletalk:conf+888@conference.freeswitch.org ([email]googletalk%3Aconf%2B888@conference.freeswitch.org[/email])
pstn:213-799-1400
Back to top
Prometheus001 at gmx.net
Guest





PostPosted: Thu Jul 16, 2009 9:41 am    Post subject: [Freeswitch-users] "show channels" command with du Reply with quote

Well,

that's very useful for us in order to have this info in our FS Operator
panel.

Best regards
Peter

freeswitch-users@lists.freeswitch.org schrieb:
Quote:
Hi,

I usually find it very useful when I can retrieve a list of the
currents calls along with durations. I noticed that the 'show
channels' format does not include the duration (or the answered
timestamp - so that one can extract it from there). So, I made a patch
that includes the answered timestamp, the answered timestamp in epoch,
and the duration in seconds. Of course these fields remain empty when
the call hasn't been
answered yet.

I don't know if anyone else finds this functionality useful, so I am
posting this patch here first (instead of JIRA) in order to get
feedback from the users. If many of you (or the maintainers) find it
interesting I can then proceed in posting it to JIRA.

------------------------------------------------------------------------

_______________________________________________
FreeSWITCH-users mailing list
FreeSWITCH-users@lists.freeswitch.org
http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
http://www.freeswitch.org


_______________________________________________
FreeSWITCH-users mailing list
FreeSWITCH-users@lists.freeswitch.org
http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
http://www.freeswitch.org
Back to top
anthony.minessale at g...
Guest





PostPosted: Thu Jul 16, 2009 10:05 am    Post subject: [Freeswitch-users] "show channels" command with du Reply with quote

I wasn't planning on implementing it but I was just mentioning  that if you were going to do your patch,
consider if there is any other info to store while the patient is on the operating table.

The line we should not cross is to store all the info in the table since, really, you could be collecting those events
in your application as well to store that info.  But for the casual user, some more fields may be interesting.




On Thu, Jul 16, 2009 at 9:37 AM, Apostolos Pantsiopoulos <regs@kinetix.gr (regs@kinetix.gr)> wrote:
Quote:
Now that I come to think of it...

It would be useful if we had the timestamp (and epoch)
of the events PROGRESS and PROGRESS WITH MEDIA so that we can extract
the PDD (Post Dial Delay) which is a very useful statistic.

Adding the user's (for the incoming) and the gateway's (for the
outbound) id would also be useful. In case these fields are empty the
show channels command could ommit the (empty string).

Are you planning to implement them yourselves or should I begin looking
at the code?


Anthony Minessale wrote:
Quote:
I'm ok with the idea as long as it's thoroughly tested.
If there is any more info you want to save from those events you should
consider it now while we are modifying it.


On Thu, Jul 16, 2009 at 9:02 AM, <freeswitch-users@lists.freeswitch.org (freeswitch-users@lists.freeswitch.org)

Quote:
<mailto:freeswitch-users@lists.freeswitch.org (freeswitch-users@lists.freeswitch.org)>> wrote:

    Hi,

    I usually find it very useful when I can retrieve a list of the
    currents calls along with durations. I noticed that the 'show
    channels' format does not include the duration (or the answered
    timestamp - so that one can extract it from there). So, I made a
    patch that includes the answered timestamp, the answered timestamp
    in epoch, and the duration in seconds. Of course these fields remain
    empty when the call hasn't been
    answered yet.

    I don't know if anyone else finds this functionality useful, so I am
    posting this patch here first (instead of JIRA) in order to get
    feedback from the users. If many of you (or the maintainers) find it
    interesting I can then proceed in posting it to JIRA.

    --
    -------------------------------------------
    Apostolos Pantsiopoulos
    Kinetix Tele.com R & D

Quote:
    email: regs@kinetix.gr (regs@kinetix.gr) <mailto:regs@kinetix.gr (regs@kinetix.gr)>

Quote:
    -------------------------------------------

    Index: src/mod/applications/mod_commands/mod_commands.c
    ===================================================================
    --- src/mod/applications/mod_commands/mod_commands.c    (revision 14256)
    +++ src/mod/applications/mod_commands/mod_commands.c    (working copy)
    @@ -2827,10 +2827,10 @@
                                   }
                           }
                           if (strchr(argv[2], '%')) {
    -                               sprintf(sql, "select * from channels
    where uuid like '%s' or name like '%s' or cid_name like '%s' or
    cid_num like '%s' order by created_epoch",
    +                               sprintf(sql, "select
    *,strftime('%%s',DATETIME('NOW'))-answered_epoch as duration from
    channels where uuid like '%s' or name like '%s' or cid_name like
    '%s' or cid_num like '%s' order by created_epoch",
                                                   argv[2], argv[2],
    argv[2], argv[2]);
                           } else {
    -                               sprintf(sql, "select * from channels
    where uuid like '%%%s%%' or name like '%%%s%%' or cid_name like
    '%%%s%%' or cid_num like '%%%s%%' order by created_epoch",
    +                               sprintf(sql, "select
    *,strftime('%%s',DATETIME('NOW'))-answered_epoch as duration from
    channels where uuid like '%%%s%%' or name like '%%%s%%' or cid_name
    like '%%%s%%' or cid_num like '%%%s%%' order by created_epoch",
                                                   argv[2], argv[2],
    argv[2], argv[2]);

                           }
    @@ -2839,10 +2839,10 @@
                                   as = argv[4];
                       }
                   } else {
    -                       sprintf(sql, "select * from channels order
    by created_epoch");
    +                       sprintf(sql, "select
    *,strftime('%%s',DATETIME('NOW'))-answered_epoch as duration from
    channels order by created_epoch");
                   }
           } else if (!strcasecmp(command, "channels")) {
    -               sprintf(sql, "select * from channels order by
    created_epoch");
    +               sprintf(sql, "select
    *,strftime('%%s',DATETIME('NOW'))-answered_epoch as duration from
    channels order by created_epoch");
                   if (argv[1] && !strcasecmp(argv[1],"count")) {
                       holder.justcount = 1;
                       if (argv[3] && !strcasecmp(argv[2], "as")) {
    @@ -2850,7 +2850,7 @@
                       }
                   }
           } else if (!strcasecmp(command, "distinct_channels")) {
    -               sprintf(sql, "select * from channels left join calls
    on "
    +               sprintf(sql, "select
    *,strftime('%%s',DATETIME('NOW'))-answered_epoch as duration from
    channels left join calls on "
                                   "channels.uuid=calls.caller_uuid
    where channels.uuid not in (select callee_uuid from calls) order by
    created_epoch");
                   if (argv[2] && !strcasecmp(argv[1], "as")) {
                           as = argv[2];
    Index: src/switch_core_sqldb.c
    ===================================================================
    --- src/switch_core_sqldb.c     (revision 14256)
    +++ src/switch_core_sqldb.c     (working copy)
    @@ -309,9 +309,21 @@
                                                            );

                   break;
    +       case SWITCH_EVENT_CHANNEL_ANSWER:
    +               {
    +
    +                       sql = switch_mprintf("update channels set
    answered='%s',answered_epoch='%ld' where uuid='%s'",
    +
    switch_event_get_header_nil(event, "event-date-local"),
    +
     (long)switch_epoch_time_now(NULL),
    +
     switch_event_get_header_nil(event, "unique-id")
    +                                                         );
    +
    +               }
    +               break;
           case SWITCH_EVENT_CHANNEL_STATE:
                   {
                           char *state =
    switch_event_get_header_nil(event, "channel-state-number");
    +
                           switch_channel_state_t state_i = CS_DESTROY;

                           if (!switch_strlen_zero(state)) {
    @@ -492,7 +504,9 @@
                           "   read_rate  VARCHAR(255),\n"
                           "   write_codec  VARCHAR(255),\n"
                           "   write_rate  VARCHAR(255),\n"
    -                       "   secure VARCHAR(255)\n"
    +                       "   secure VARCHAR(255),\n"
    +                       "   answered  VARCHAR(255),\n"
    +                        "   answered_epoch  INTEGER\n"
                           ");\ncreate index uuindex on channels (uuid);\n";
                   char create_calls_sql[] =
                           "CREATE TABLE calls (\n"

    _______________________________________________
    FreeSWITCH-users mailing list
    FreeSWITCH-users@lists.freeswitch.org (FreeSWITCH-users@lists.freeswitch.org)


Quote:
    <mailto:FreeSWITCH-users@lists.freeswitch.org (FreeSWITCH-users@lists.freeswitch.org)>
    http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
    UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
    http://www.freeswitch.org




--
Anthony Minessale II

FreeSWITCH http://www.freeswitch.org/
ClueCon http://www.cluecon.com/
Twitter: http://twitter.com/FreeSWITCH_wire

AIM: anthm
MSN:anthony_minessale@hotmail.com ([email]MSN%3Aanthony_minessale@hotmail.com[/email])

Quote:
<mailto:MSN%3Aanthony_minessale@hotmail.com ([email]MSN%253Aanthony_minessale@hotmail.com[/email])>
GTALK/JABBER/PAYPAL:anthony.minessale@gmail.com ([email]PAYPAL%3Aanthony.minessale@gmail.com[/email])

Quote:
<mailto:PAYPAL%3Aanthony.minessale@gmail.com ([email]PAYPAL%253Aanthony.minessale@gmail.com[/email])>
IRC: irc.freenode.net <http://irc.freenode.net> #freeswitch

FreeSWITCH Developer Conference
sip:888@conference.freeswitch.org ([email]sip%3A888@conference.freeswitch.org[/email])

Quote:
<mailto:sip%3A888@conference.freeswitch.org ([email]sip%253A888@conference.freeswitch.org[/email])>
iax:guest@conference.freeswitch.org/888

Quote:
<http://iax:guest@conference.freeswitch.org/888>
googletalk:conf+888@conference.freeswitch.org ([email]googletalk%3Aconf%2B888@conference.freeswitch.org[/email])

Quote:
<mailto:googletalk%3Aconf%2B888@conference.freeswitch.org ([email]googletalk%253Aconf%252B888@conference.freeswitch.org[/email])>
pstn:213-799-1400


------------------------------------------------------------------------

_______________________________________________
FreeSWITCH-users mailing list
FreeSWITCH-users@lists.freeswitch.org (FreeSWITCH-users@lists.freeswitch.org)
http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
http://www.freeswitch.org


--

-------------------------------------------
Apostolos Pantsiopoulos
Kinetix Tele.com R & D
email: regs@kinetix.gr (regs@kinetix.gr)
-------------------------------------------



_______________________________________________
FreeSWITCH-users mailing list
FreeSWITCH-users@lists.freeswitch.org (FreeSWITCH-users@lists.freeswitch.org)
http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
http://www.freeswitch.org





--
Anthony Minessale II

FreeSWITCH http://www.freeswitch.org/
ClueCon http://www.cluecon.com/
Twitter: http://twitter.com/FreeSWITCH_wire

AIM: anthm
MSN:anthony_minessale@hotmail.com ([email]MSN%3Aanthony_minessale@hotmail.com[/email])
GTALK/JABBER/PAYPAL:anthony.minessale@gmail.com ([email]PAYPAL%3Aanthony.minessale@gmail.com[/email])
IRC: irc.freenode.net #freeswitch

FreeSWITCH Developer Conference
sip:888@conference.freeswitch.org ([email]sip%3A888@conference.freeswitch.org[/email])
iax:guest@conference.freeswitch.org/888
googletalk:conf+888@conference.freeswitch.org ([email]googletalk%3Aconf%2B888@conference.freeswitch.org[/email])
pstn:213-799-1400
Back to top
anthony.minessale at g...
Guest





PostPosted: Thu Jul 16, 2009 10:19 am    Post subject: [Freeswitch-users] "show channels" command with du Reply with quote

it doesn't really break anything to add more fields besides the ability to read it but it's already fairly wide as it is.
Thats why we have "show channels as xml"


On Thu, Jul 16, 2009 at 9:50 AM, Michael S Collins <msc@freeswitch.org (msc@freeswitch.org)> wrote:
Quote:
I wonder if it would make sense to create a separate sub-command like
"show channels stats" or something. That way we could put all sorts of
nifty info there without breaking the existing command.

Thoughts?
-MC

Sent from my iPhone

On Jul 16, 2009, at 7:37 AM, Apostolos Pantsiopoulos <regs@kinetix.gr (regs@kinetix.gr)>
wrote:


Quote:
Now that I come to think of it...

It would be useful if we had the timestamp (and epoch)
of the events PROGRESS and PROGRESS WITH MEDIA so that we can extract
the PDD (Post Dial Delay) which is a very useful statistic.

Adding the user's (for the incoming) and the gateway's (for the
outbound) id would also be useful. In case these fields are empty the
show channels command could ommit the (empty string).

Are you planning to implement them yourselves or should I begin
looking
at the code?


Anthony Minessale wrote:
Quote:
I'm ok with the idea as long as it's thoroughly tested.
If there is any more info you want to save from those events you
should
consider it now while we are modifying it.


On Thu, Jul 16, 2009 at 9:02 AM, <freeswitch-users@lists.freeswitch.org (freeswitch-users@lists.freeswitch.org)
<mailto:freeswitch-users@lists.freeswitch.org (freeswitch-users@lists.freeswitch.org)>> wrote:

   Hi,

   I usually find it very useful when I can retrieve a list of the
   currents calls along with durations. I noticed that the 'show
   channels' format does not include the duration (or the answered
   timestamp - so that one can extract it from there). So, I made a
   patch that includes the answered timestamp, the answered timestamp
   in epoch, and the duration in seconds. Of course these fields
remain
   empty when the call hasn't been
   answered yet.

   I don't know if anyone else finds this functionality useful, so
I am
   posting this patch here first (instead of JIRA) in order to get
   feedback from the users. If many of you (or the maintainers)
find it
   interesting I can then proceed in posting it to JIRA.

   --
   -------------------------------------------
   Apostolos Pantsiopoulos
   Kinetix Tele.com R & D
   email: regs@kinetix.gr (regs@kinetix.gr) <mailto:regs@kinetix.gr (regs@kinetix.gr)>
   -------------------------------------------

   Index: src/mod/applications/mod_commands/mod_commands.c

===================================================================
   --- src/mod/applications/mod_commands/mod_commands.c
(revision 14256)
   +++ src/mod/applications/mod_commands/mod_commands.c    (working
copy)
   @@ -2827,10 +2827,10 @@
                                  }
                          }
                          if (strchr(argv[2], '%')) {
   -                               sprintf(sql, "select * from
channels
   where uuid like '%s' or name like '%s' or cid_name like '%s' or
   cid_num like '%s' order by created_epoch",
   +                               sprintf(sql, "select
   *,strftime('%%s',DATETIME('NOW'))-answered_epoch as duration from
   channels where uuid like '%s' or name like '%s' or cid_name like
   '%s' or cid_num like '%s' order by created_epoch",
                                                  argv[2], argv[2],
   argv[2], argv[2]);
                          } else {
   -                               sprintf(sql, "select * from
channels
   where uuid like '%%%s%%' or name like '%%%s%%' or cid_name like
   '%%%s%%' or cid_num like '%%%s%%' order by created_epoch",
   +                               sprintf(sql, "select
   *,strftime('%%s',DATETIME('NOW'))-answered_epoch as duration from
   channels where uuid like '%%%s%%' or name like '%%%s%%' or
cid_name
   like '%%%s%%' or cid_num like '%%%s%%' order by created_epoch",
                                                  argv[2], argv[2],
   argv[2], argv[2]);

                          }
   @@ -2839,10 +2839,10 @@
                                  as = argv[4];
                      }
                  } else {
   -                       sprintf(sql, "select * from channels order
   by created_epoch");
   +                       sprintf(sql, "select
   *,strftime('%%s',DATETIME('NOW'))-answered_epoch as duration from
   channels order by created_epoch");
                  }
          } else if (!strcasecmp(command, "channels")) {
   -               sprintf(sql, "select * from channels order by
   created_epoch");
   +               sprintf(sql, "select
   *,strftime('%%s',DATETIME('NOW'))-answered_epoch as duration from
   channels order by created_epoch");
                  if (argv[1] && !strcasecmp(argv[1],"count")) {
                      holder.justcount = 1;
                      if (argv[3] && !strcasecmp(argv[2], "as")) {
   @@ -2850,7 +2850,7 @@
                      }
                  }
          } else if (!strcasecmp(command, "distinct_channels")) {
   -               sprintf(sql, "select * from channels left join
calls
   on "
   +               sprintf(sql, "select
   *,strftime('%%s',DATETIME('NOW'))-answered_epoch as duration from
   channels left join calls on "
                                  "channels.uuid=calls.caller_uuid
   where channels.uuid not in (select callee_uuid from calls) order
by
   created_epoch");
                  if (argv[2] && !strcasecmp(argv[1], "as")) {
                          as = argv[2];
   Index: src/switch_core_sqldb.c

===================================================================
   --- src/switch_core_sqldb.c     (revision 14256)
   +++ src/switch_core_sqldb.c     (working copy)
   @@ -309,9 +309,21 @@
                                                           );

                  break;
   +       case SWITCH_EVENT_CHANNEL_ANSWER:
   +               {
   +
   +                       sql = switch_mprintf("update channels set
   answered='%s',answered_epoch='%ld' where uuid='%s'",
   +
   switch_event_get_header_nil(event, "event-date-local"),
   +
    (long)switch_epoch_time_now(NULL),
   +
    switch_event_get_header_nil(event, "unique-id")
   +                                                         );
   +
   +               }
   +               break;
          case SWITCH_EVENT_CHANNEL_STATE:
                  {
                          char *state =
   switch_event_get_header_nil(event, "channel-state-number");
   +
                          switch_channel_state_t state_i =
CS_DESTROY;

                          if (!switch_strlen_zero(state)) {
   @@ -492,7 +504,9 @@
                          "   read_rate  VARCHAR(255),\n"
                          "   write_codec  VARCHAR(255),\n"
                          "   write_rate  VARCHAR(255),\n"
   -                       "   secure VARCHAR(255)\n"
   +                       "   secure VARCHAR(255),\n"
   +                       "   answered  VARCHAR(255),\n"
   +                        "   answered_epoch  INTEGER\n"
                          ");\ncreate index uuindex on channels
(uuid);\n";
                  char create_calls_sql[] =
                          "CREATE TABLE calls (\n"

   _______________________________________________
   FreeSWITCH-users mailing list
   FreeSWITCH-users@lists.freeswitch.org (FreeSWITCH-users@lists.freeswitch.org)
   <mailto:FreeSWITCH-users@lists.freeswitch.org (FreeSWITCH-users@lists.freeswitch.org)>
   http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
   UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
   http://www.freeswitch.org




--
Anthony Minessale II

FreeSWITCH http://www.freeswitch.org/
ClueCon http://www.cluecon.com/
Twitter: http://twitter.com/FreeSWITCH_wire

AIM: anthm
MSN:anthony_minessale@hotmail.com ([email]MSN%3Aanthony_minessale@hotmail.com[/email])
<mailto:MSN%3Aanthony_minessale@hotmail.com ([email]MSN%253Aanthony_minessale@hotmail.com[/email])>
GTALK/JABBER/PAYPAL:anthony.minessale@gmail.com ([email]PAYPAL%3Aanthony.minessale@gmail.com[/email])
<mailto:PAYPAL%3Aanthony.minessale@gmail.com ([email]PAYPAL%253Aanthony.minessale@gmail.com[/email])>
IRC: irc.freenode.net <http://irc.freenode.net> #freeswitch

FreeSWITCH Developer Conference
sip:888@conference.freeswitch.org ([email]sip%3A888@conference.freeswitch.org[/email])
<mailto:sip%3A888@conference.freeswitch.org ([email]sip%253A888@conference.freeswitch.org[/email])>
iax:guest@conference.freeswitch.org/888
<http://iax:guest@conference.freeswitch.org/888>
googletalk:conf+888@conference.freeswitch.org ([email]googletalk%3Aconf%2B888@conference.freeswitch.org[/email])
<mailto:googletalk%3Aconf%2B888@conference.freeswitch.org ([email]googletalk%253Aconf%252B888@conference.freeswitch.org[/email])>
pstn:213-799-1400


---
---------------------------------------------------------------------

_______________________________________________
FreeSWITCH-users mailing list
FreeSWITCH-users@lists.freeswitch.org (FreeSWITCH-users@lists.freeswitch.org)
http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
http://www.freeswitch.org


--
-------------------------------------------
Apostolos Pantsiopoulos
Kinetix Tele.com R & D
email: regs@kinetix.gr (regs@kinetix.gr)
-------------------------------------------

_______________________________________________
FreeSWITCH-users mailing list
FreeSWITCH-users@lists.freeswitch.org (FreeSWITCH-users@lists.freeswitch.org)
http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
http://www.freeswitch.org

_______________________________________________
FreeSWITCH-users mailing list
FreeSWITCH-users@lists.freeswitch.org (FreeSWITCH-users@lists.freeswitch.org)
http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
http://www.freeswitch.org





--
Anthony Minessale II

FreeSWITCH http://www.freeswitch.org/
ClueCon http://www.cluecon.com/
Twitter: http://twitter.com/FreeSWITCH_wire

AIM: anthm
MSN:anthony_minessale@hotmail.com ([email]MSN%3Aanthony_minessale@hotmail.com[/email])
GTALK/JABBER/PAYPAL:anthony.minessale@gmail.com ([email]PAYPAL%3Aanthony.minessale@gmail.com[/email])
IRC: irc.freenode.net #freeswitch

FreeSWITCH Developer Conference
sip:888@conference.freeswitch.org ([email]sip%3A888@conference.freeswitch.org[/email])
iax:guest@conference.freeswitch.org/888
googletalk:conf+888@conference.freeswitch.org ([email]googletalk%3Aconf%2B888@conference.freeswitch.org[/email])
pstn:213-799-1400
Back to top
Display posts from previous:   
Post new topic   Reply to topic    VoIP Mailing List Archives Forum Index -> freeSWITCH Users All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group

VoiceMeUp - Corporate & Wholesale VoIP Services