Add "show module status"
authorAlan T. DeKok <aland@freeradius.org>
Wed, 21 May 2014 14:28:46 +0000 (10:28 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Wed, 21 May 2014 14:29:53 +0000 (10:29 -0400)
src/main/command.c

index ffd3ac9..d83e0ba 100644 (file)
@@ -586,6 +586,38 @@ static int command_show_module_flags(rad_listen_t *listener, int argc, char *arg
        return 1;               /* success */
 }
 
+extern const FR_NAME_NUMBER mod_rcode_table[];
+
+
+static int command_show_module_status(rad_listen_t *listener, int argc, char *argv[])
+{
+       CONF_SECTION *cs;
+       const module_instance_t *mi;
+
+       if (argc != 1) {
+               cprintf(listener, "ERROR: No module name was given\n");
+               return 0;
+       }
+
+       cs = cf_section_find("modules");
+       if (!cs) return 0;
+
+       mi = find_module_instance(cs, argv[0], 0);
+       if (!mi) {
+               cprintf(listener, "ERROR: No such module \"%s\"\n", argv[0]);
+               return 0;
+       }
+
+       if (!mi->force) {
+               cprintf(listener, "alive\n");
+       } else {
+               cprintf(listener, "%s\n", fr_int2str(mod_rcode_table, mi->code, "<invalid>"));
+       }
+
+       
+       return 1;               /* success */
+}
+
 
 /*
  *     Show all loaded modules
@@ -1400,6 +1432,9 @@ static fr_command_table_t command_table_show_module[] = {
        { "methods", FR_READ,
          "show module methods <module> - show sections where <module> may be used",
          command_show_module_methods, NULL },
+       { "status", FR_READ,
+         "show module status <module> - show the module status",
+         command_show_module_status, NULL },
 
        { NULL, 0, NULL, NULL, NULL }
 };