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

Apostolos Pantsiopoulos regs at kinetix.gr
Thu Jul 16 08:10:53 PDT 2009


OK I 'll start implementing the progress timestamp field.

The only reason I mentioned the user/gateway id field is that FS admins 
gain a lot by looking at a row of "show channels" result and be able to 
see who is the caller and who is the callee.

Anthony Minessale wrote:
> 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 at freeswitch.org 
> <mailto:msc at freeswitch.org>> wrote:
> 
>     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 at kinetix.gr <mailto:regs at kinetix.gr>>
>     wrote:
> 
>      > 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:
>      >> 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 at lists.freeswitch.org
>     <mailto:freeswitch-users at lists.freeswitch.org>
>      >> <mailto:freeswitch-users at lists.freeswitch.org
>     <mailto:freeswitch-users at 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 at kinetix.gr <mailto:regs at kinetix.gr>
>     <mailto:regs at kinetix.gr <mailto:regs at 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 at lists.freeswitch.org
>     <mailto:FreeSWITCH-users at lists.freeswitch.org>
>      >>    <mailto:FreeSWITCH-users at lists.freeswitch.org
>     <mailto:FreeSWITCH-users at 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 at hotmail.com
>     <mailto:MSN%3Aanthony_minessale at hotmail.com>
>      >> <mailto:MSN%3Aanthony_minessale at hotmail.com
>     <mailto:MSN%253Aanthony_minessale at hotmail.com>>
>      >> GTALK/JABBER/PAYPAL:anthony.minessale at gmail.com
>     <mailto:PAYPAL%3Aanthony.minessale at gmail.com>
>      >> <mailto:PAYPAL%3Aanthony.minessale at gmail.com
>     <mailto:PAYPAL%253Aanthony.minessale at gmail.com>>
>      >> IRC: irc.freenode.net <http://irc.freenode.net>
>     <http://irc.freenode.net> #freeswitch
>      >>
>      >> FreeSWITCH Developer Conference
>      >> sip:888 at conference.freeswitch.org
>     <mailto:sip%3A888 at conference.freeswitch.org>
>      >> <mailto:sip%3A888 at conference.freeswitch.org
>     <mailto:sip%253A888 at conference.freeswitch.org>>
>      >> iax:guest at conference.freeswitch.org/888
>     <http://iax:guest@conference.freeswitch.org/888>
>      >> <http://iax:guest@conference.freeswitch.org/888>
>      >> googletalk:conf+888 at conference.freeswitch.org
>     <mailto:googletalk%3Aconf%2B888 at conference.freeswitch.org>
>      >> <mailto:googletalk%3Aconf%2B888 at conference.freeswitch.org
>     <mailto:googletalk%253Aconf%252B888 at conference.freeswitch.org>>
>      >> pstn:213-799-1400
>      >>
>      >>
>      >> ---
>      >>
>     ---------------------------------------------------------------------
>      >>
>      >> _______________________________________________
>      >> FreeSWITCH-users mailing list
>      >> FreeSWITCH-users at lists.freeswitch.org
>     <mailto:FreeSWITCH-users at 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 at kinetix.gr <mailto:regs at kinetix.gr>
>      > -------------------------------------------
>      >
>      > _______________________________________________
>      > FreeSWITCH-users mailing list
>      > FreeSWITCH-users at lists.freeswitch.org
>     <mailto:FreeSWITCH-users at 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 at lists.freeswitch.org
>     <mailto:FreeSWITCH-users at 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 at hotmail.com 
> <mailto:MSN%3Aanthony_minessale at hotmail.com>
> GTALK/JABBER/PAYPAL:anthony.minessale at gmail.com 
> <mailto:PAYPAL%3Aanthony.minessale at gmail.com>
> IRC: irc.freenode.net <http://irc.freenode.net> #freeswitch
> 
> FreeSWITCH Developer Conference
> sip:888 at conference.freeswitch.org 
> <mailto:sip%3A888 at conference.freeswitch.org>
> iax:guest at conference.freeswitch.org/888 
> <http://iax:guest@conference.freeswitch.org/888>
> googletalk:conf+888 at conference.freeswitch.org 
> <mailto:googletalk%3Aconf%2B888 at conference.freeswitch.org>
> pstn:213-799-1400
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> FreeSWITCH-users mailing list
> FreeSWITCH-users at 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 at kinetix.gr
-------------------------------------------




More information about the FreeSWITCH-users mailing list