return CMD_SUCCESS;
}
-DEFPY (debug_uid_backtrace,
- debug_uid_backtrace_cmd,
- "[no] debug unique-id UID backtrace",
- NO_STR
- DEBUG_STR
- "Options per individual log message, by unique ID\n"
- "Log message unique ID (XXXXX-XXXXX)\n"
- "Add backtrace to log when message is printed\n")
+DEFPY_NOSH (debug_uid_backtrace,
+ debug_uid_backtrace_cmd,
+ "[no] debug unique-id UID backtrace",
+ NO_STR
+ DEBUG_STR
+ "Options per individual log message, by unique ID\n"
+ "Log message unique ID (XXXXX-XXXXX)\n"
+ "Add backtrace to log when message is printed\n")
{
struct xrefdata search, *xrd;
struct xrefdata_logmsg *xrdl;
strlcpy(search.uid, uid, sizeof(search.uid));
xrd = xrefdata_uid_find(&xrefdata_uid, &search);
- if (!xrd) {
- vty_out(vty, "%% no log message with ID \"%s\" found\n", uid);
- return CMD_WARNING;
- }
+ if (!xrd)
+ return CMD_ERR_NOTHING_TODO;
+
if (xrd->xref->type != XREFT_LOGMSG) {
vty_out(vty, "%% ID \"%s\" is not a log message\n", uid);
return CMD_WARNING;
return CMD_SUCCESS;
}
+DEFUN(vtysh_debug_uid_backtrace,
+ vtysh_debug_uid_backtrace_cmd,
+ "[no] debug unique-id UID backtrace",
+ NO_STR
+ DEBUG_STR
+ "Options per individual log message, by unique ID\n"
+ "Log message unique ID (XXXXX-XXXXX)\n"
+ "Add backtrace to log when message is printed\n")
+{
+ unsigned int i, ok = 0;
+ int err = CMD_SUCCESS, ret;
+ const char *uid;
+ char line[64];
+
+ if (!strcmp(argv[0]->text, "no")) {
+ uid = argv[3]->arg;
+ snprintfrr(line, sizeof(line),
+ "no debug unique-id %s backtrace", uid);
+ } else {
+ uid = argv[2]->arg;
+ snprintfrr(line, sizeof(line), "debug unique-id %s backtrace",
+ uid);
+ }
+
+ for (i = 0; i < array_size(vtysh_client); i++)
+ if (vtysh_client[i].fd >= 0 || vtysh_client[i].next) {
+ ret = vtysh_client_execute(&vtysh_client[i], line);
+ switch (ret) {
+ case CMD_SUCCESS:
+ ok++;
+ break;
+ case CMD_ERR_NOTHING_TODO:
+ /* ignore this daemon
+ *
+ * note this doesn't need to handle instances
+ * of the same daemon individually because
+ * the same daemon will have the same UIDs
+ */
+ break;
+ default:
+ if (err == CMD_SUCCESS)
+ err = ret;
+ break;
+ }
+ }
+
+ if (err == CMD_SUCCESS && !ok) {
+ vty_out(vty, "%% no running daemon recognizes unique-ID %s\n",
+ uid);
+ err = CMD_WARNING;
+ }
+ return err;
+}
+
DEFUNSH(VTYSH_ALL, vtysh_service_password_encrypt,
vtysh_service_password_encrypt_cmd, "service password-encryption",
"Set up miscellaneous service\n"
install_element(CONFIG_NODE, &vtysh_debug_all_cmd);
install_element(ENABLE_NODE, &vtysh_debug_memstats_cmd);
install_element(CONFIG_NODE, &vtysh_debug_memstats_cmd);
+ install_element(ENABLE_NODE, &vtysh_debug_uid_backtrace_cmd);
+ install_element(CONFIG_NODE, &vtysh_debug_uid_backtrace_cmd);
/* northbound */
install_element(ENABLE_NODE, &show_config_running_cmd);