diff options
| author | David Lamparter <equinox@opensourcerouting.org> | 2017-04-04 20:04:07 +0200 |
|---|---|---|
| committer | David Lamparter <equinox@opensourcerouting.org> | 2017-04-04 20:04:07 +0200 |
| commit | 422f8d0ca9745a16b1f46710c621fc9f98200bcf (patch) | |
| tree | 24e91ad38adfd824c624a4a46889e6102b913225 /lib/memory_vty.c | |
| parent | b394fc99bc4b555aa3c78521439b28f1ff8886ef (diff) | |
| parent | b3cfe637a66a5de00c72125f5fa051155ccb4a29 (diff) | |
Merge branch 'master'
Diffstat (limited to 'lib/memory_vty.c')
| -rw-r--r-- | lib/memory_vty.c | 77 |
1 files changed, 62 insertions, 15 deletions
diff --git a/lib/memory_vty.c b/lib/memory_vty.c index 149b329130..6d63bc2d53 100644 --- a/lib/memory_vty.c +++ b/lib/memory_vty.c @@ -1,23 +1,22 @@ /* - * Memory management routine - * Copyright (C) 1998 Kunihiro Ishiguro + * Memory and dynamic module VTY routine * - * This file is part of GNU Zebra. + * Copyright (C) 1998 Kunihiro Ishiguro + * Copyright (C) 2016-2017 David Lamparter for NetDEF, Inc. * - * GNU Zebra is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2, or (at your option) any - * later version. + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. * - * GNU Zebra is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. * - * You should have received a copy of the GNU General Public License - * along with GNU Zebra; see the file COPYING. If not, write to the Free - * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA - * 02111-1307, USA. + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., 59 Temple + * Place, Suite 330, Boston, MA 02111-1307 USA */ #include <zebra.h> @@ -25,9 +24,12 @@ #if (defined(GNU_LINUX) && defined(HAVE_MALLINFO)) #include <malloc.h> #endif /* HAVE_MALLINFO */ +#include <dlfcn.h> +#include <link.h> #include "log.h" #include "memory.h" +#include "module.h" #include "memory_vty.h" /* Looking up memory status from vty interface. */ @@ -110,10 +112,55 @@ DEFUN (show_memory, return CMD_SUCCESS; } +DEFUN (show_modules, + show_modules_cmd, + "show modules", + "Show running system information\n" + "Loaded modules\n") +{ + struct frrmod_runtime *plug = frrmod_list; + + vty_out (vty, "%-12s %-25s %s%s%s", + "Module Name", "Version", "Description", + VTY_NEWLINE, VTY_NEWLINE); + while (plug) + { + const struct frrmod_info *i = plug->info; + + vty_out (vty, "%-12s %-25s %s%s", i->name, i->version, i->description, + VTY_NEWLINE); + if (plug->dl_handle) + { +#ifdef HAVE_DLINFO_ORIGIN + char origin[MAXPATHLEN] = ""; + dlinfo (plug->dl_handle, RTLD_DI_ORIGIN, &origin); +# ifdef HAVE_DLINFO_LINKMAP + const char *name; + struct link_map *lm = NULL; + dlinfo (plug->dl_handle, RTLD_DI_LINKMAP, &lm); + if (lm) + { + name = strrchr(lm->l_name, '/'); + name = name ? name + 1 : lm->l_name; + vty_out (vty, "\tfrom: %s/%s%s", origin, name, VTY_NEWLINE); + } +# else + vty_out (vty, "\tfrom: %s %s", origin, plug->load_name, VTY_NEWLINE); +# endif +#else + vty_out (vty, "\tfrom: %s%s", plug->load_name, VTY_NEWLINE); +#endif + } + plug = plug->next; + } + return CMD_SUCCESS; +} + void memory_init (void) { install_element (VIEW_NODE, &show_memory_cmd); + install_element (VIEW_NODE, &show_modules_cmd); } /* Stats querying from users */ |
