X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lnet%2Futils%2Flnetctl.c;h=947e5aadf86c80e39c134e647252499310834a0a;hb=ed052504713d1db49531454a87055b2ee54399f0;hp=969faedd0c8117ce212bc82847a491952affdc18;hpb=7a36afd9df713954426472214f9f986b60d1665b;p=fs%2Flustre-release.git diff --git a/lnet/utils/lnetctl.c b/lnet/utils/lnetctl.c index 969faed..947e5aa 100644 --- a/lnet/utils/lnetctl.c +++ b/lnet/utils/lnetctl.c @@ -101,7 +101,8 @@ command_t net_cmds[] = { "\t--if: physical interface (e.g. eth0)\n"}, {"show", jt_show_net, 0, "show networks\n" "\t--net: net name (e.g. tcp0) to filter on\n" - "\t--verbose: display detailed output per network\n"}, + "\t--verbose: display detailed output per network." + "optional argument of 2 outputs more stats\n"}, { 0, 0, 0, NULL } }; @@ -154,7 +155,8 @@ command_t peer_cmds[] = { "\t peer is deleted\n"}, {"show", jt_show_peer, 0, "show peer information\n" "\t--nid: NID of peer to filter on.\n" - "\t--verbose: Include extended statistics\n"}, + "\t--verbose: display detailed output per peer." + "optional argument of 2 outputs more stats\n"}, {"list", jt_list_peer, 0, "list all peers\n"}, { 0, 0, 0, NULL } }; @@ -801,13 +803,14 @@ static int jt_show_route(int argc, char **argv) static int jt_show_net(int argc, char **argv) { char *network = NULL; - int detail = 0, rc, opt; + int rc, opt; struct cYAML *err_rc = NULL, *show_rc = NULL; + long int detail = 0; const char *const short_options = "n:vh"; static const struct option long_options[] = { { .name = "net", .has_arg = required_argument, .val = 'n' }, - { .name = "verbose", .has_arg = no_argument, .val = 'v' }, + { .name = "verbose", .has_arg = optional_argument, .val = 'v' }, { .name = "help", .has_arg = no_argument, .val = 'h' }, { .name = NULL } }; @@ -818,7 +821,13 @@ static int jt_show_net(int argc, char **argv) network = optarg; break; case 'v': - detail = 1; + if ((!optarg) && (argv[optind] != NULL) && + (argv[optind][0] != '-')) { + if (parse_long(argv[optind++], &detail) != 0) + detail = 1; + } else { + detail = 1; + } break; case 'h': print_help(net_cmds, "net", "show"); @@ -828,7 +837,7 @@ static int jt_show_net(int argc, char **argv) } } - rc = lustre_lnet_show_net(network, detail, -1, &show_rc, &err_rc); + rc = lustre_lnet_show_net(network, (int) detail, -1, &show_rc, &err_rc); if (rc != LUSTRE_CFG_RC_NO_ERR) cYAML_print_tree2file(stderr, err_rc); @@ -1130,10 +1139,11 @@ static int jt_export(int argc, char **argv) } else f = stdout; - rc = lustre_lnet_show_net(NULL, 1, -1, &show_rc, &err_rc); + rc = lustre_lnet_show_net(NULL, 2, -1, &show_rc, &err_rc); if (rc != LUSTRE_CFG_RC_NO_ERR) { cYAML_print_tree2file(stderr, err_rc); cYAML_free_tree(err_rc); + err_rc = NULL; } rc = lustre_lnet_show_route(NULL, NULL, -1, -1, 1, -1, &show_rc, @@ -1141,30 +1151,42 @@ static int jt_export(int argc, char **argv) if (rc != LUSTRE_CFG_RC_NO_ERR) { cYAML_print_tree2file(stderr, err_rc); cYAML_free_tree(err_rc); + err_rc = NULL; } rc = lustre_lnet_show_routing(-1, &show_rc, &err_rc); if (rc != LUSTRE_CFG_RC_NO_ERR) { cYAML_print_tree2file(stderr, err_rc); cYAML_free_tree(err_rc); + err_rc = NULL; } - rc = lustre_lnet_show_peer(NULL, 1, -1, &show_rc, &err_rc); + rc = lustre_lnet_show_peer(NULL, 2, -1, &show_rc, &err_rc); if (rc != LUSTRE_CFG_RC_NO_ERR) { cYAML_print_tree2file(stderr, err_rc); cYAML_free_tree(err_rc); + err_rc = NULL; } rc = lustre_lnet_show_numa_range(-1, &show_rc, &err_rc); if (rc != LUSTRE_CFG_RC_NO_ERR) { cYAML_print_tree2file(stderr, err_rc); cYAML_free_tree(err_rc); + err_rc = NULL; } rc = lustre_lnet_show_max_intf(-1, &show_rc, &err_rc); if (rc != LUSTRE_CFG_RC_NO_ERR) { cYAML_print_tree2file(stderr, err_rc); cYAML_free_tree(err_rc); + err_rc = NULL; + } + + rc = lustre_lnet_show_discovery(-1, &show_rc, &err_rc); + if (rc != LUSTRE_CFG_RC_NO_ERR) { + cYAML_print_tree2file(stderr, err_rc); + cYAML_free_tree(err_rc); + err_rc = NULL; } if (show_rc != NULL) { @@ -1299,12 +1321,12 @@ static int jt_show_peer(int argc, char **argv) char *nid = NULL; int rc, opt; struct cYAML *err_rc = NULL, *show_rc = NULL; - int detail = 0; + long int detail = 0; - const char *const short_options = "n:vh"; + const char *const short_options = "n:v::h"; const struct option long_options[] = { { "nid", 1, NULL, 'n' }, - { "verbose", 0, NULL, 'v' }, + { "verbose", 2, NULL, 'v' }, { "help", 0, NULL, 'h' }, { NULL, 0, NULL, 0 }, }; @@ -1316,7 +1338,13 @@ static int jt_show_peer(int argc, char **argv) nid = optarg; break; case 'v': - detail = 1; + if ((!optarg) && (argv[optind] != NULL) && + (argv[optind][0] != '-')) { + if (parse_long(argv[optind++], &detail) != 0) + detail = 1; + } else { + detail = 1; + } break; case 'h': print_help(peer_cmds, "peer", "show"); @@ -1326,7 +1354,7 @@ static int jt_show_peer(int argc, char **argv) } } - rc = lustre_lnet_show_peer(nid, detail, -1, &show_rc, &err_rc); + rc = lustre_lnet_show_peer(nid, (int) detail, -1, &show_rc, &err_rc); if (rc != LUSTRE_CFG_RC_NO_ERR) cYAML_print_tree2file(stderr, err_rc); @@ -1422,6 +1450,55 @@ static int jt_ping(int argc, char **argv) return rc; } +static int jt_discover(int argc, char **argv) +{ + struct cYAML *err_rc = NULL; + struct cYAML *show_rc = NULL; + int force = 0; + int rc = 0, opt; + + const char *const short_options = "fh"; + const struct option long_options[] = { + { "force", 0, NULL, 'f' }, + { "help", 0, NULL, 'h' }, + { NULL, 0, NULL, 0 }, + }; + + while ((opt = getopt_long(argc, argv, short_options, + long_options, NULL)) != -1) { + switch (opt) { + case 'f': + force = 1; + break; + case 'h': + printf("discover: nid1 nid2 .. nidN (e.g. 10.2.2.2@tcp)\n" + "\t--force\n" + "\t--help: display this help\n"); + return 0; + default: + return 0; + } + } + + if (argc < 2) + return CMD_HELP; + + for (; optind < argc; optind++) + rc = lustre_lnet_discover_nid(argv[optind], force, -1, &show_rc, + &err_rc); + + if (show_rc) + cYAML_print_tree(show_rc); + + if (err_rc) + cYAML_print_tree2file(stderr, err_rc); + + cYAML_free_tree(err_rc); + cYAML_free_tree(show_rc); + + return rc; +} + command_t list[] = { {"lnet", jt_lnet, 0, "lnet {configure | unconfigure} [--all]"}, {"route", jt_route, 0, "route {add | del | show | help}"}, @@ -1437,6 +1514,7 @@ command_t list[] = { {"global", jt_global, 0, "global {show | help}"}, {"peer", jt_peers, 0, "peer {add | del | show | help}"}, {"ping", jt_ping, 0, "ping {--help}"}, + {"discover", jt_discover, 0, "discover {--help}"}, {"help", Parser_help, 0, "help"}, {"exit", Parser_quit, 0, "quit"}, {"quit", Parser_quit, 0, "quit"},