[asterisk-commits] file: branch group/stasis_cache_usage r392950 - /team/group/stasis_cache_usag...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Wed Jun 26 09:01:27 CDT 2013
Author: file
Date: Wed Jun 26 09:01:24 2013
New Revision: 392950
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=392950
Log:
Incorporate review feedback.
Modified:
team/group/stasis_cache_usage/main/cli.c
team/group/stasis_cache_usage/main/manager.c
team/group/stasis_cache_usage/main/manager_bridging.c
team/group/stasis_cache_usage/main/manager_channels.c
Modified: team/group/stasis_cache_usage/main/cli.c
URL: http://svnview.digium.com/svn/asterisk/team/group/stasis_cache_usage/main/cli.c?view=diff&rev=392950&r1=392949&r2=392950
==============================================================================
--- team/group/stasis_cache_usage/main/cli.c (original)
+++ team/group/stasis_cache_usage/main/cli.c Wed Jun 26 09:01:24 2013
@@ -948,7 +948,7 @@
if (concise) {
ast_cli(a->fd, CONCISE_FORMAT_STRING, cs->name, cs->context, cs->exten, cs->priority, ast_state2str(cs->state),
S_OR(cs->appl, "(None)"),
- cs->data,
+ cs->data,
cs->caller_number,
cs->accountcode,
cs->peeraccount,
@@ -978,7 +978,7 @@
}
}
ao2_iterator_destroy(&it_chans);
-
+
if (!concise) {
numchans = ast_active_channels();
ast_cli(a->fd, "%d active channel%s\n", numchans, ESS(numchans));
@@ -1987,7 +1987,7 @@
* \param cmds
* \param match_type has 3 possible values:
* 0 returns if the search key is equal or longer than the entry.
- * note that trailing optional arguments are skipped.
+ * note that trailing optional arguments are skipped.
* -1 true if the mismatch is on the last word XXX not true!
* 1 true only on complete, exact match.
*
Modified: team/group/stasis_cache_usage/main/manager.c
URL: http://svnview.digium.com/svn/asterisk/team/group/stasis_cache_usage/main/manager.c?view=diff&rev=392950&r1=392949&r2=392950
==============================================================================
--- team/group/stasis_cache_usage/main/manager.c (original)
+++ team/group/stasis_cache_usage/main/manager.c Wed Jun 26 09:01:24 2013
@@ -219,21 +219,6 @@
<description>
<para>Will return the status information of each channel along with the
value for the specified channel variables.</para>
- </description>
- </manager>
- <manager name="BridgeShow" language="en_US">
- <synopsis>
- List bridge information.
- </synopsis>
- <syntax>
- <xi:include xpointer="xpointer(/docs/manager[@name='Login']/syntax/parameter[@name='ActionID'])" />
- <parameter name="Bridge" required="false">
- <para>Optional identifier of a specific bridge.</para>
- </parameter>
- </syntax>
- <description>
- <para>Will return the bridge information of each bridge, or optionally
- only information for a specific bridge.</para>
</description>
</manager>
<manager name="Setvar" language="en_US">
@@ -3708,8 +3693,6 @@
char *variables = ast_strdupa(S_OR(cvariables, ""));
RAII_VAR(struct ao2_container *, cached_channels, NULL, ao2_cleanup);
struct stasis_message *msg;
- struct timeval now = ast_tvnow();
- long elapsed_seconds = 0;
int channels = 0;
int all = ast_strlen_zero(name); /* set if we want all channels */
const char *id = astman_get_header(m, "ActionID");
@@ -3757,6 +3740,7 @@
for (; msg; msg = ao2_iterator_next(&it_chans)) {
struct ast_channel_snapshot *snapshot = stasis_message_data(msg);
struct ast_channel *c;
+ struct ast_str *built = ast_manager_build_channel_state_string_prefix(snapshot, "");
if (!ast_strlen_zero(cvariables) && (c = ast_channel_get_by_name(snapshot->name))) {
int i;
@@ -3780,77 +3764,19 @@
channels++;
- if (!ast_tvzero(snapshot->creationtime)) {
- elapsed_seconds = now.tv_sec - snapshot->creationtime.tv_sec;
- }
astman_append(s,
"Event: Status\r\n"
"Privilege: Call\r\n"
- "Channel: %s\r\n"
- "Type: %s\r\n"
- "DNID: %s\r\n"
- "CallerIDNum: %s\r\n"
- "CallerIDName: %s\r\n"
- "ConnectedLineNum: %s\r\n"
- "ConnectedLineName: %s\r\n"
- "EffectiveConnectedLineNum: %s\r\n"
- "EffectiveConnectedLineName: %s\r\n"
- "Accountcode: %s\r\n"
- "ChannelState: %d\r\n"
- "ChannelStateDesc: %s\r\n"
- "Context: %s\r\n"
- "Extension: %s\r\n"
- "Priority: %d\r\n"
- "Seconds: %ld\r\n"
- "TimetoHangup: %ld\r\n"
- "BridgeID: %s\r\n"
- "Uniqueid: %s\r\n"
- "Linkedid: %s\r\n"
- "Callid: %s\r\n"
- "Application: %s\r\n"
- "Data: %s\r\n"
- "Nativeformats: %s\r\n"
- "Readformat: %s\r\n"
- "Readtrans: %s\r\n"
- "Writeformat: %s\r\n"
- "Writetrans: %s\r\n"
- "Callgroup: %llu\r\n"
- "Pickupgroup: %llu\r\n"
+ "%s"
"%s"
"%s"
"\r\n",
- snapshot->name,
- snapshot->type,
- snapshot->caller_dnid,
- S_OR(snapshot->caller_number, "<unknown>"),
- S_OR(snapshot->caller_name, "<unknown>"),
- S_OR(snapshot->connected_number, "<unknown>"),
- S_OR(snapshot->connected_name, "<unknown>"),
- S_OR(snapshot->effective_number, "<unknown>"),
- S_OR(snapshot->effective_name, "<unknown>"),
- snapshot->accountcode,
- snapshot->state,
- ast_state2str(snapshot->state),
- snapshot->context, snapshot->exten, snapshot->priority,
- (long) elapsed_seconds,
- snapshot->hanguptime.tv_sec,
- snapshot->bridgeid,
- snapshot->uniqueid,
- snapshot->linkedid,
- snapshot->callid,
- snapshot->appl,
- snapshot->data,
- snapshot->nativeformats,
- snapshot->readformat,
- snapshot->readtrans,
- snapshot->writeformat,
- snapshot->writetrans,
- snapshot->callgroup,
- snapshot->pickupgroup,
+ ast_str_buffer(built),
ast_str_buffer(str),
idText);
ao2_ref(msg, -1);
+ ast_free(built);
if (!all) {
break;
@@ -3866,105 +3792,6 @@
"%s"
"Items: %d\r\n"
"\r\n", idText, channels);
-
- ast_free(str);
-
- return 0;
-}
-
-/*! \brief Manager "bridgeshow" command to show bridges */
-static int action_bridgeshow(struct mansession *s, const struct message *m)
-{
- const char *name = astman_get_header(m, "Bridge");
- RAII_VAR(struct ao2_container *, cached_bridges, NULL, ao2_cleanup);
- struct stasis_message *msg;
- int bridges = 0;
- int all = ast_strlen_zero(name); /* set if we want all channels */
- const char *id = astman_get_header(m, "ActionID");
- char idText[256];
- struct ast_str *str = ast_str_create(1000);
- struct ao2_iterator it_bridges;
-
- if (!ast_strlen_zero(id)) {
- snprintf(idText, sizeof(idText), "ActionID: %s\r\n", id);
- } else {
- idText[0] = '\0';
- }
-
- if (all) {
- if (!(cached_bridges = stasis_cache_dump(ast_bridge_topic_all_cached(), ast_bridge_snapshot_type()))) {
- ast_free(str);
- astman_send_error(s, m, "Memory Allocation Failure");
- return 1;
- }
- it_bridges = ao2_iterator_init(cached_bridges, 0);
- msg = ao2_iterator_next(&it_bridges);
- } else {
- if (!(msg = stasis_cache_get(ast_bridge_topic_all_cached(), ast_bridge_snapshot_type(), name))) {
- astman_send_error(s, m, "No such bridge");
- ast_free(str);
- return 0;
- }
- }
-
- astman_send_ack(s, m, "Bridge status will follow");
-
- /* if we look by name, we break after the first iteration */
- for (; msg; msg = ao2_iterator_next(&it_bridges)) {
- struct ast_bridge_snapshot *snapshot = stasis_message_data(msg);
- struct ao2_iterator it_chans;
- char *chan;
-
- bridges++;
-
- ast_str_reset(str);
- it_chans = ao2_iterator_init(snapshot->channels, 0);
- for (; (chan = ao2_iterator_next(&it_chans)); ao2_ref(chan, -1)) {
- RAII_VAR(struct stasis_message *, chan_msg, NULL, ao2_cleanup);
- struct ast_channel_snapshot *channel_snapshot;
-
- if (!(chan_msg = stasis_cache_get(ast_channel_topic_all_cached(), ast_channel_snapshot_type(), chan))) {
- continue;
- }
- channel_snapshot = stasis_message_data(chan_msg);
-
- ast_str_append(&str, 0, "Channel: %s\r\n", channel_snapshot->name);
- }
- ao2_iterator_destroy(&it_chans);
-
- astman_append(s,
- "Event: BridgeShow\r\n"
- "Privilege: Call\r\n"
- "Bridge: %s\r\n"
- "Type: %s\r\n"
- "Technology: %s\r\n"
- "Num-Channels: %d\r\n"
- "%s"
- "%s"
- "\r\n",
- snapshot->uniqueid,
- snapshot->subclass,
- snapshot->technology,
- snapshot->num_channels,
- ast_str_buffer(str),
- idText);
-
- ao2_ref(msg, -1);
-
- if (!all) {
- break;
- }
- }
-
- if (all) {
- ao2_iterator_destroy(&it_bridges);
- }
-
- astman_append(s,
- "Event: BridgeShowComplete\r\n"
- "%s"
- "Items: %d\r\n"
- "\r\n", idText, bridges);
ast_free(str);
@@ -5316,7 +5143,6 @@
const char *actionid = astman_get_header(m, "ActionID");
char idText[256];
int numchans = 0;
- int duration, durh, durm, durs;
RAII_VAR(struct ao2_container *, channels, NULL, ao2_cleanup);
struct ao2_iterator it_chans;
struct stasis_message *msg;
@@ -5337,50 +5163,19 @@
it_chans = ao2_iterator_init(channels, 0);
for (; (msg = ao2_iterator_next(&it_chans)); ao2_ref(msg, -1)) {
struct ast_channel_snapshot *cs = stasis_message_data(msg);
- char durbuf[10] = "";
-
- if (!ast_tvzero(cs->creationtime)) {
- duration = (int)(ast_tvdiff_ms(ast_tvnow(), cs->creationtime) / 1000);
- durh = duration / 3600;
- durm = (duration % 3600) / 60;
- durs = duration % 60;
- snprintf(durbuf, sizeof(durbuf), "%02d:%02d:%02d", durh, durm, durs);
- }
+ struct ast_str *built = ast_manager_build_channel_state_string_prefix(cs, "");
astman_append(s,
"Event: CoreShowChannel\r\n"
"%s"
- "Channel: %s\r\n"
- "UniqueID: %s\r\n"
- "Context: %s\r\n"
- "Extension: %s\r\n"
- "Priority: %d\r\n"
- "ChannelState: %d\r\n"
- "ChannelStateDesc: %s\r\n"
- "Application: %s\r\n"
- "ApplicationData: %s\r\n"
- "CallerIDnum: %s\r\n"
- "CallerIDname: %s\r\n"
- "ConnectedLineNum: %s\r\n"
- "ConnectedLineName: %s\r\n"
- "Duration: %s\r\n"
- "AccountCode: %s\r\n"
- "BridgedChannel: %s\r\n"
- "BridgedUniqueID: %s\r\n"
- "\r\n", idText, cs->name, cs->uniqueid, cs->context, cs->exten, cs->priority, cs->state,
- ast_state2str(cs->state),
- cs->appl,
- cs->data,
- cs->caller_number,
- cs->caller_name,
- cs->connected_number,
- cs->connected_name,
- durbuf,
- cs->accountcode,
- "",
- cs->bridgeid);
+ "%s"
+ "\r\n",
+ idText,
+ ast_str_buffer(built));
numchans++;
+
+ ast_free(built);
}
astman_append(s,
@@ -7898,7 +7693,6 @@
ast_manager_register_xml_core("Challenge", 0, action_challenge);
ast_manager_register_xml_core("Hangup", EVENT_FLAG_SYSTEM | EVENT_FLAG_CALL, action_hangup);
ast_manager_register_xml_core("Status", EVENT_FLAG_SYSTEM | EVENT_FLAG_CALL | EVENT_FLAG_REPORTING, action_status);
- ast_manager_register_xml_core("BridgeShow", EVENT_FLAG_SYSTEM | EVENT_FLAG_CALL | EVENT_FLAG_REPORTING, action_bridgeshow);
ast_manager_register_xml_core("Setvar", EVENT_FLAG_CALL, action_setvar);
ast_manager_register_xml_core("Getvar", EVENT_FLAG_CALL | EVENT_FLAG_REPORTING, action_getvar);
ast_manager_register_xml_core("GetConfig", EVENT_FLAG_SYSTEM | EVENT_FLAG_CONFIG, action_getconfig);
Modified: team/group/stasis_cache_usage/main/manager_bridging.c
URL: http://svnview.digium.com/svn/asterisk/team/group/stasis_cache_usage/main/manager_bridging.c?view=diff&rev=392950&r1=392949&r2=392950
==============================================================================
--- team/group/stasis_cache_usage/main/manager_bridging.c (original)
+++ team/group/stasis_cache_usage/main/manager_bridging.c Wed Jun 26 09:01:24 2013
@@ -119,9 +119,13 @@
}
res = ast_str_set(&out, 0,
"BridgeUniqueid%s: %s\r\n"
- "BridgeType%s: %s\r\n",
+ "BridgeType%s: %s\r\n"
+ "BridgeTechnology%s: %s\r\n"
+ "BridgeNumChannels%s: %d\r\n",
suffix, snapshot->uniqueid,
- suffix, snapshot->technology);
+ suffix, snapshot->subclass,
+ suffix, snapshot->technology,
+ suffix, snapshot->num_channels);
if (!res) {
return NULL;
Modified: team/group/stasis_cache_usage/main/manager_channels.c
URL: http://svnview.digium.com/svn/asterisk/team/group/stasis_cache_usage/main/manager_channels.c?view=diff&rev=392950&r1=392949&r2=392950
==============================================================================
--- team/group/stasis_cache_usage/main/manager_channels.c (original)
+++ team/group/stasis_cache_usage/main/manager_channels.c Wed Jun 26 09:01:24 2013
@@ -525,34 +525,78 @@
{
struct ast_str *out = ast_str_create(1024);
int res = 0;
+ struct timeval now = ast_tvnow();
+ long elapsed_seconds = 0;
+
if (!out) {
return NULL;
}
+
+ if (!ast_tvzero(snapshot->creationtime)) {
+ elapsed_seconds = now.tv_sec - snapshot->creationtime.tv_sec;
+ }
+
res = ast_str_set(&out, 0,
"%sChannel: %s\r\n"
+ "%sType: %s\r\n"
+ "%sDNID: %s\r\n"
"%sChannelState: %d\r\n"
"%sChannelStateDesc: %s\r\n"
"%sCallerIDNum: %s\r\n"
"%sCallerIDName: %s\r\n"
"%sConnectedLineNum: %s\r\n"
"%sConnectedLineName: %s\r\n"
+ "%sEffectiveConnectedLineNum: %s\r\n"
+ "%sEffectiveConnectedLineName: %s\r\n"
"%sAccountCode: %s\r\n"
"%sContext: %s\r\n"
"%sExten: %s\r\n"
"%sPriority: %d\r\n"
- "%sUniqueid: %s\r\n",
+ "%sUniqueid: %s\r\n"
+ "%sTimeToHangup: %ld\r\n"
+ "%sBridgeID: %s\r\n"
+ "%sLinkedid: %s\r\n"
+ "%sCallid: %s\r\n"
+ "%sApplication: %s\r\n"
+ "%sData: %s\r\n"
+ "%sNativeformats: %s\r\n"
+ "%sReadformat: %s\r\n"
+ "%sReadtrans: %s\r\n"
+ "%sWriteformat: %s\r\n"
+ "%sWritetrans: %s\r\n"
+ "%sCallgroup: %llu\r\n"
+ "%sPickupgroup: %llu\r\n"
+ "%sSeconds: %ld\r\n",
prefix, snapshot->name,
+ prefix, snapshot->type,
+ prefix, snapshot->caller_dnid,
prefix, snapshot->state,
prefix, ast_state2str(snapshot->state),
prefix, S_OR(snapshot->caller_number, "<unknown>"),
prefix, S_OR(snapshot->caller_name, "<unknown>"),
prefix, S_OR(snapshot->connected_number, "<unknown>"),
prefix, S_OR(snapshot->connected_name, "<unknown>"),
+ prefix, S_OR(snapshot->effective_number, "<unknown>"),
+ prefix, S_OR(snapshot->effective_name, "<unknown>"),
prefix, snapshot->accountcode,
prefix, snapshot->context,
prefix, snapshot->exten,
prefix, snapshot->priority,
- prefix, snapshot->uniqueid);
+ prefix, snapshot->uniqueid,
+ prefix, snapshot->hanguptime.tv_sec,
+ prefix, snapshot->bridgeid,
+ prefix, snapshot->linkedid,
+ prefix, snapshot->callid,
+ prefix, snapshot->appl,
+ prefix, snapshot->data,
+ prefix, snapshot->nativeformats,
+ prefix, snapshot->readformat,
+ prefix, snapshot->readtrans,
+ prefix, snapshot->writeformat,
+ prefix, snapshot->writetrans,
+ prefix, snapshot->callgroup,
+ prefix, snapshot->pickupgroup,
+ prefix, (long) elapsed_seconds);
if (!res) {
return NULL;
More information about the asterisk-commits
mailing list