diff options
| author | Donald Sharp <sharpd@cumulusnetworks.com> | 2018-06-16 18:12:54 -0400 |
|---|---|---|
| committer | Donald Sharp <sharpd@cumulusnetworks.com> | 2018-06-16 20:09:45 -0400 |
| commit | 8872626bb4b8f5d9d06ea2b5e513e5ecb6a541aa (patch) | |
| tree | 4f07bddb6d420f027b593cdb81dc7ba5f15f59de /lib/thread.c | |
| parent | 65c4ceac44bc08a319ae67021eec77f37fb009a7 (diff) | |
lib, vtysh: Add 'show thread poll' command
Add a 'show thread poll' command that displays the
poll information and fd's setup.
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Diffstat (limited to 'lib/thread.c')
| -rw-r--r-- | lib/thread.c | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/lib/thread.c b/lib/thread.c index 18e1c92280..1c5e838772 100644 --- a/lib/thread.c +++ b/lib/thread.c @@ -296,6 +296,47 @@ DEFUN (show_thread_cpu, return CMD_SUCCESS; } +static void show_thread_poll_helper(struct vty *vty, struct thread_master *m) +{ + const char *name = m->name ? m->name : "main"; + char underline[strlen(name) + 1]; + uint32_t i; + + memset(underline, '-', sizeof(underline)); + underline[sizeof(underline) - 1] = '\0'; + + vty_out(vty, "\nShowing poll FD's for %s\n", name); + vty_out(vty, "----------------------%s\n", underline); + vty_out(vty, "Count: %u\n", (uint32_t)m->handler.pfdcount); + for (i = 0; i < m->handler.pfdcount; i++) + vty_out(vty, "\t%6d fd:%6d events:%2d revents:%2d\n", i, + m->handler.pfds[i].fd, + m->handler.pfds[i].events, + m->handler.pfds[i].revents); +} + +DEFUN (show_thread_poll, + show_thread_poll_cmd, + "show thread poll", + SHOW_STR + "Thread information\n" + "Show poll FD's and information\n") +{ + struct listnode *node; + struct thread_master *m; + + pthread_mutex_lock(&masters_mtx); + { + for (ALL_LIST_ELEMENTS_RO(masters, node, m)) { + show_thread_poll_helper(vty, m); + } + } + pthread_mutex_unlock(&masters_mtx); + + return CMD_SUCCESS; +} + + DEFUN (clear_thread_cpu, clear_thread_cpu_cmd, "clear thread cpu [FILTER]", @@ -325,6 +366,7 @@ DEFUN (clear_thread_cpu, void thread_cmd_init(void) { install_element(VIEW_NODE, &show_thread_cpu_cmd); + install_element(VIEW_NODE, &show_thread_poll_cmd); install_element(ENABLE_NODE, &clear_thread_cpu_cmd); } /* CLI end ------------------------------------------------------------------ */ |
