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]",
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 ------------------------------------------------------------------ */
return vtysh_exit_interface(self, vty, argc, argv);
}
+DEFUN (vtysh_show_poll,
+ vtysh_show_poll_cmd,
+ "show thread poll",
+ SHOW_STR
+ "Thread information\n"
+ "Thread Poll Information\n")
+{
+ unsigned int i;
+ int idx = 0;
+ int ret = CMD_SUCCESS;
+ char line[100];
+
+ snprintf(line, sizeof(line), "do show thread poll\n");
+ for (i = 0; i < array_size(vtysh_client); i++)
+ if (vtysh_client[i].fd >= 0) {
+ vty_out(vty, "Thread statistics for %s:\n",
+ vtysh_client[i].name);
+ ret = vtysh_client_execute(&vtysh_client[i], line);
+ vty_out(vty, "\n");
+ }
+ return ret;
+}
+
DEFUN (vtysh_show_thread,
vtysh_show_thread_cmd,
"show thread cpu [FILTER]",
install_element(VIEW_NODE, &vtysh_show_work_queues_cmd);
install_element(VIEW_NODE, &vtysh_show_work_queues_daemon_cmd);
install_element(VIEW_NODE, &vtysh_show_thread_cmd);
+ install_element(VIEW_NODE, &vtysh_show_poll_cmd);
/* Logging */
install_element(VIEW_NODE, &vtysh_show_logging_cmd);