tc : add timestamps to tc monitor
Support -timestamp and -tshort options for tc monitor like ip monitor. # tc -tshort monitor [2015-09-23T16:39:11.260555] qdisc fq 8003: dev eth0 root refcnt 2 limit 10000p flow_limit 100p buckets 1024 quantum 3028 initial_quantum 15140 refill_delay 40.0ms Signed-off-by: Eric Dumazet <edumazet@google.com>
This commit is contained in:
parent
84d30afd8a
commit
32a6fbe563
6
tc/tc.c
6
tc/tc.c
|
|
@ -36,6 +36,7 @@ int show_details = 0;
|
||||||
int show_raw = 0;
|
int show_raw = 0;
|
||||||
int show_pretty = 0;
|
int show_pretty = 0;
|
||||||
int show_graph = 0;
|
int show_graph = 0;
|
||||||
|
int timestamp;
|
||||||
|
|
||||||
int batch_mode = 0;
|
int batch_mode = 0;
|
||||||
int resolve_hosts = 0;
|
int resolve_hosts = 0;
|
||||||
|
|
@ -311,6 +312,11 @@ int main(int argc, char **argv)
|
||||||
matches(argv[1], "-conf") == 0) {
|
matches(argv[1], "-conf") == 0) {
|
||||||
NEXT_ARG();
|
NEXT_ARG();
|
||||||
conf_file = argv[1];
|
conf_file = argv[1];
|
||||||
|
} else if (matches(argv[1], "-timestamp") == 0) {
|
||||||
|
timestamp++;
|
||||||
|
} else if (matches(argv[1], "-tshort") == 0) {
|
||||||
|
++timestamp;
|
||||||
|
++timestamp_short;
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr, "Option \"%s\" is unknown, try \"tc -help\".\n", argv[1]);
|
fprintf(stderr, "Option \"%s\" is unknown, try \"tc -help\".\n", argv[1]);
|
||||||
return -1;
|
return -1;
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ static void usage(void) __attribute__((noreturn));
|
||||||
|
|
||||||
static void usage(void)
|
static void usage(void)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Usage: tc monitor\n");
|
fprintf(stderr, "Usage: tc [-timestamp [-tshort] monitor\n");
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -41,6 +41,9 @@ static int accept_tcmsg(const struct sockaddr_nl *who,
|
||||||
{
|
{
|
||||||
FILE *fp = (FILE*)arg;
|
FILE *fp = (FILE*)arg;
|
||||||
|
|
||||||
|
if (timestamp)
|
||||||
|
print_timestamp(fp);
|
||||||
|
|
||||||
if (n->nlmsg_type == RTM_NEWTFILTER || n->nlmsg_type == RTM_DELTFILTER) {
|
if (n->nlmsg_type == RTM_NEWTFILTER || n->nlmsg_type == RTM_DELTFILTER) {
|
||||||
print_filter(who, n, arg);
|
print_filter(who, n, arg);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue