ast_mutex_unlock(&qlock);
}
-static int __queues_show(int fd, int argc, char **argv, int queue_show)
+static int __queues_show(int manager, int fd, int argc, char **argv, int queue_show)
{
struct ast_call_queue *q;
struct queue_ent *qe;
char *max;
size_t max_left;
float sl = 0;
+ char *term = manager ? "\r\n" : "\n";
time(&now);
if ((!queue_show && argc != 2) || (queue_show && argc != 3))
if (!q) {
ast_mutex_unlock(&qlock);
if (queue_show)
- ast_cli(fd, "No such queue: %s.\n",argv[2]);
+ ast_cli(fd, "No such queue: %s.%s",argv[2], term);
else
- ast_cli(fd, "No queues.\n");
+ ast_cli(fd, "No queues.%s", term);
return RESULT_SUCCESS;
}
while (q) {
ast_mutex_unlock(&q->lock);
q = q->next;
if (!q) {
- ast_cli(fd, "No such queue: %s.\n",argv[2]);
+ ast_cli(fd, "No such queue: %s.%s",argv[2], term);
break;
}
continue;
sl = 0;
if(q->callscompleted > 0)
sl = 100*((float)q->callscompletedinsl/(float)q->callscompleted);
- ast_cli(fd, "%-12.12s has %d calls (max %s) in '%s' strategy (%ds holdtime), W:%d, C:%d, A:%d, SL:%2.1f%% within %ds\n",
- q->name, q->count, max_buf, int2strat(q->strategy), q->holdtime, q->weight, q->callscompleted, q->callsabandoned,sl,q->servicelevel);
+ ast_cli(fd, "%-12.12s has %d calls (max %s) in '%s' strategy (%ds holdtime), W:%d, C:%d, A:%d, SL:%2.1f%% within %ds%s",
+ q->name, q->count, max_buf, int2strat(q->strategy), q->holdtime, q->weight, q->callscompleted, q->callsabandoned,sl,q->servicelevel, term);
if (q->members) {
- ast_cli(fd, " Members: \n");
+ ast_cli(fd, " Members: %s", term);
for (mem = q->members; mem; mem = mem->next) {
max_buf[0] = '\0';
max = max_buf;
mem->calls, (long)(time(NULL) - mem->lastcall));
} else
ast_build_string(&max, &max_left, " has taken no calls yet");
- ast_cli(fd, " %s%s\n", mem->interface, max_buf);
+ ast_cli(fd, " %s%s%s", mem->interface, max_buf, term);
}
} else
- ast_cli(fd, " No Members\n");
+ ast_cli(fd, " No Members%s", term);
if (q->head) {
pos = 1;
- ast_cli(fd, " Callers: \n");
+ ast_cli(fd, " Callers: %s", term);
for (qe = q->head; qe; qe = qe->next)
- ast_cli(fd, " %d. %s (wait: %ld:%2.2ld, prio: %d)\n", pos++, qe->chan->name,
- (long)(now - qe->start) / 60, (long)(now - qe->start) % 60, qe->prio);
+ ast_cli(fd, " %d. %s (wait: %ld:%2.2ld, prio: %d)%s", pos++, qe->chan->name,
+ (long)(now - qe->start) / 60, (long)(now - qe->start) % 60, qe->prio, term);
} else
- ast_cli(fd, " No Callers\n");
- ast_cli(fd, "\n");
+ ast_cli(fd, " No Callers%s", term);
+ ast_cli(fd, "%s", term);
ast_mutex_unlock(&q->lock);
q = q->next;
if (queue_show)
static int queues_show(int fd, int argc, char **argv)
{
- return __queues_show(fd, argc, argv, 0);
+ return __queues_show(0, fd, argc, argv, 0);
}
static int queue_show(int fd, int argc, char **argv)
{
- return __queues_show(fd, argc, argv, 1);
+ return __queues_show(0, fd, argc, argv, 1);
}
static char *complete_queue(char *line, char *word, int pos, int state)
static int manager_queues_show( struct mansession *s, struct message *m )
{
char *a[] = { "show", "queues" };
- queues_show(s->fd, 2, a);
+ __queues_show(1, s->fd, 2, a, 0);
ast_cli(s->fd, "\r\n\r\n"); /* Properly terminate Manager output */
return RESULT_SUCCESS;
#undef FORMAT2
}
-static int iax2_show_peers(int fd, int argc, char *argv[])
+static int __iax2_show_peers(int manager, int fd, int argc, char *argv[])
{
regex_t regexbuf;
int havepattern = 0;
int offline_peers = 0;
int unmonitored_peers = 0;
-#define FORMAT2 "%-15.15s %-15.15s %s %-15.15s %-8s %s %-10s\n"
-#define FORMAT "%-15.15s %-15.15s %s %-15.15s %-5d%s %s %-10s\n"
+#define FORMAT2 "%-15.15s %-15.15s %s %-15.15s %-8s %s %-10s%s"
+#define FORMAT "%-15.15s %-15.15s %s %-15.15s %-5d%s %s %-10s%s"
struct iax2_peer *peer;
char name[256];
char iabuf[INET_ADDRSTRLEN];
int registeredonly=0;
+ char *term = manager ? "\r\n" : "\n";
switch (argc) {
case 6:
}
ast_mutex_lock(&peerl.lock);
- ast_cli(fd, FORMAT2, "Name/Username", "Host", " ", "Mask", "Port", " ", "Status");
+ ast_cli(fd, FORMAT2, "Name/Username", "Host", " ", "Mask", "Port", " ", "Status", term);
for (peer = peerl.peers;peer;peer = peer->next) {
char nm[20];
char status[20];
ast_test_flag(peer, IAX_DYNAMIC) ? "(D)" : "(S)",
nm,
ntohs(peer->addr.sin_port), ast_test_flag(peer, IAX_TRUNK) ? "(T)" : " ",
- peer->encmethods ? "(E)" : " ", status);
+ peer->encmethods ? "(E)" : " ", status, term);
ast_cli(fd, FORMAT, name,
peer->addr.sin_addr.s_addr ? ast_inet_ntoa(iabuf, sizeof(iabuf), peer->addr.sin_addr) : "(Unspecified)",
ast_test_flag(peer, IAX_DYNAMIC) ? "(D)" : "(S)",
nm,
ntohs(peer->addr.sin_port), ast_test_flag(peer, IAX_TRUNK) ? "(T)" : " ",
- peer->encmethods ? "(E)" : " ", status);
+ peer->encmethods ? "(E)" : " ", status, term);
total_peers++;
}
ast_mutex_unlock(&peerl.lock);
- ast_cli(fd,"%d iax2 peers [%d online, %d offline, %d unmonitored]\n", total_peers, online_peers, offline_peers, unmonitored_peers);
+ ast_cli(fd,"%d iax2 peers [%d online, %d offline, %d unmonitored]%s", total_peers, online_peers, offline_peers, unmonitored_peers, term);
if (havepattern)
regfree(®exbuf);
#undef FORMAT2
}
+static int iax2_show_peers(int fd, int argc, char *argv[])
+{
+ return __iax2_show_peers(0, fd, argc, argv);
+}
static int manager_iax2_show_netstats( struct mansession *s, struct message *m )
{
ast_cli_netstats(s->fd, 0);
{
char *a[] = { "iax2", "show", "users" };
int ret;
- ret = iax2_show_peers( s->fd, 3, a );
- ast_cli( s->fd, "\r\n\r\n" );
+ char *id;
+ id = astman_get_header(m,"ActionID");
+ if (id && !ast_strlen_zero(id))
+ ast_cli(s->fd, "ActionID: %s\r\n",id);
+ ret = __iax2_show_peers(1, s->fd, 3, a );
+ ast_cli(s->fd, "\r\n\r\n" );
return ret;
} /* /JDG */
return RESULT_SUCCESS;
}
/*--- print_group: Print call group and pickup group ---*/
-static void print_group(int fd, unsigned int group)
+static void print_group(int fd, unsigned int group, int crlf)
{
char buf[256];
- ast_cli(fd, "%s\n", ast_print_group(buf, sizeof(buf), group) );
+ ast_cli(fd, crlf ? "%s\r\n" : "%s\n", ast_print_group(buf, sizeof(buf), group) );
}
/*--- dtmfmode2str: Convert DTMF mode to printable string ---*/
if (!ast_strlen_zero(peer->fromdomain))
ast_cli(fd, " FromDomain : %s\n", peer->fromdomain);
ast_cli(fd, " Callgroup : ");
- print_group(fd, peer->callgroup);
+ print_group(fd, peer->callgroup, 0);
ast_cli(fd, " Pickupgroup : ");
- print_group(fd, peer->pickupgroup);
+ print_group(fd, peer->pickupgroup, 0);
ast_cli(fd, " Mailbox : %s\n", peer->mailbox);
ast_cli(fd, " VM Extension : %s\n", peer->vmexten);
ast_cli(fd, " LastMsgsSent : %d\n", peer->lastmsgssent);
if (!ast_strlen_zero(peer->fromdomain))
ast_cli(fd, "SIP-FromDomain: %s\r\n", peer->fromdomain);
ast_cli(fd, "Callgroup: ");
- print_group(fd, peer->callgroup);
+ print_group(fd, peer->callgroup, 1);
ast_cli(fd, "Pickupgroup: ");
- print_group(fd, peer->pickupgroup);
+ print_group(fd, peer->pickupgroup, 1);
ast_cli(fd, "VoiceMailbox: %s\r\n", peer->mailbox);
ast_cli(fd, "LastMsgsSent: %d\r\n", peer->lastmsgssent);
ast_cli(fd, "Call limit: %d\r\n", peer->call_limit);
ast_cli(fd, " CallingPres : %s\n", ast_describe_caller_presentation(user->callingpres));
ast_cli(fd, " Call limit : %d\n", user->call_limit);
ast_cli(fd, " Callgroup : ");
- print_group(fd, user->callgroup);
+ print_group(fd, user->callgroup, 0);
ast_cli(fd, " Pickupgroup : ");
- print_group(fd, user->pickupgroup);
+ print_group(fd, user->pickupgroup, 0);
ast_cli(fd, " Callerid : %s\n", ast_callerid_merge(cbuf, sizeof(cbuf), user->cid_name, user->cid_num, "<unspecified>"));
ast_cli(fd, " ACL : %s\n", (user->ha?"Yes":"No"));
ast_cli(fd, " Codec Order : (");