]> git.proxmox.com Git - mirror_frr.git/commitdiff
vtysh: handle "show modules" like "show memory"
authorDavid Lamparter <equinox@opensourcerouting.org>
Tue, 4 Apr 2017 14:12:59 +0000 (16:12 +0200)
committerDavid Lamparter <equinox@opensourcerouting.org>
Tue, 4 Apr 2017 14:12:59 +0000 (16:12 +0200)
Preface with line identifying which daemon it applies to.
[Also fixes a missed "plugin" -> "module" replace.]

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
lib/memory_vty.c
vtysh/vtysh.c

index 01a41fe02e03ad60b0686e9a9d672a93672b6ea6..6d63bc2d53b3bb02c29f54200b6622f17307161d 100644 (file)
@@ -121,7 +121,7 @@ DEFUN (show_modules,
   struct frrmod_runtime *plug = frrmod_list;
 
   vty_out (vty, "%-12s %-25s %s%s%s",
-                "Plugin Name", "Version", "Description",
+                "Module Name", "Version", "Description",
                 VTY_NEWLINE, VTY_NEWLINE);
   while (plug)
     {
index 114022d199269018cf77afaaae2db313686b4c1b..1182944f8f83585f5267079f36a14907e735a4af 100644 (file)
@@ -2010,29 +2010,43 @@ DEFUNSH (VTYSH_ZEBRA,
   return CMD_SUCCESS;
 }
 
-/* Memory */
-DEFUN (vtysh_show_memory,
-       vtysh_show_memory_cmd,
-       "show memory",
-       SHOW_STR
-       "Memory statistics\n")
+static int
+show_per_daemon (const char *line, const char *headline)
 {
   unsigned int i;
   int ret = CMD_SUCCESS;
-  char line[] = "show memory\n";
-  
+
   for (i = 0; i < array_size(vtysh_client); i++)
     if ( vtysh_client[i].fd >= 0 )
       {
-        fprintf (stdout, "Memory statistics for %s:\n", 
+        fprintf (stdout, headline,
                  vtysh_client[i].name);
         ret = vtysh_client_execute (&vtysh_client[i], line, stdout);
         fprintf (stdout,"\n");
       }
-  
+
   return ret;
 }
 
+/* Memory */
+DEFUN (vtysh_show_memory,
+       vtysh_show_memory_cmd,
+       "show memory",
+       SHOW_STR
+       "Memory statistics\n")
+{
+  return show_per_daemon ("show memory\n", "Memory statistics for %s:\n");
+}
+
+DEFUN (vtysh_show_modules,
+       vtysh_show_modules_cmd,
+       "show modules",
+       SHOW_STR
+       "Loaded modules\n")
+{
+  return show_per_daemon ("show modules\n", "Module information for %s:\n");
+}
+
 /* Logging commands. */
 DEFUN (vtysh_show_logging,
        vtysh_show_logging_cmd,
@@ -3388,6 +3402,7 @@ vtysh_init_vty (void)
 #endif
 
   install_element (VIEW_NODE, &vtysh_show_memory_cmd);
+  install_element (VIEW_NODE, &vtysh_show_modules_cmd);
 
   install_element (VIEW_NODE, &vtysh_show_work_queues_cmd);
   install_element (VIEW_NODE, &vtysh_show_work_queues_daemon_cmd);