This adds a new top level menu to display some statistics of devices. If the adapter is an AF DASD we show the output of show-perf and if it is a RI SSD, we show the same output as ssd-report.
This depends on my last patch that adds the ssd-report command. Signed-off-by: Gabriel Krisman Bertazi <kris...@linux.vnet.ibm.com> --- iprconfig.c | 98 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ iprconfig.h | 20 +++++++++++++ 2 files changed, 118 insertions(+) diff --git a/iprconfig.c b/iprconfig.c index 1b15a82..ecb3087 100644 --- a/iprconfig.c +++ b/iprconfig.c @@ -129,6 +129,8 @@ int display_menu(ITEM **, int, int, int **); char *__print_device(struct ipr_dev *, char *, char *, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int); static char *print_path_details(struct ipr_dev *, char *); static int get_drive_phy_loc(struct ipr_ioa *ioa); +static char *print_ssd_report(struct ipr_dev *dev, char *body); +static char *af_dasd_perf (char *body, struct ipr_dev *dev); #define print_dev(i, dev, buf, fmt, type) \ for (i = 0; i < 2; i++) \ @@ -2747,6 +2749,102 @@ int device_details(i_container *i_con) return rc; } +int device_stats(i_container *i_con) +{ + int rc; + struct ipr_dev *dev; + char *body = NULL; + char *tmp; + s_node *n_screen = &n_device_stats; + struct screen_output *s_out; + + processing(); + if ((rc = device_details_get_device(i_con, &dev))) + return rc; + + if (ipr_is_af_dasd_device(dev)) { + body = af_dasd_perf(body, dev); + } + + body = print_ssd_report(dev, body); + + if (!body) + return rc; + + n_screen->body = body; + s_out = screen_driver(n_screen, 0, i_con); + free(n_screen->body); + n_screen->body = NULL; + rc = s_out->rc; + free(s_out); + return rc; +} + +int statistics_menu(i_container *i_con) +{ + int rc, k; + int len = 0; + int num_lines = 0; + struct ipr_ioa *ioa; + struct ipr_dev *dev; + struct screen_output *s_out; + int header_lines; + char *buffer[2]; + int toggle = 1; + struct ipr_dev *vset; + processing(); + + rc = RC_SUCCESS; + i_con = free_i_con(i_con); + + check_current_config(false); + body_init_status(buffer, n_device_stats.header, &header_lines); + + for_each_ioa(ioa) { + if (!ioa->ioa.scsi_dev_data) + continue; + + num_lines += print_standalone_disks(ioa, &i_con, buffer, 2); + num_lines += print_hotspare_disks(ioa, &i_con, buffer, 2); + + for_each_vset(ioa, vset) { + for_each_dev_in_vset(vset, dev) { + print_dev(k, dev, buffer, "%1", 2+k); + i_con = add_i_con(i_con, "\0", dev); + num_lines++; + } + } + } + + if (num_lines == 0) { + for (k = 0; k < 2; k++) { + len = strlen(buffer[k]); + buffer[k] = realloc(buffer[k], len + + strlen(_(no_dev_found)) + 8); + sprintf(buffer[k] + len, "\n%s", _(no_dev_found)); + } + } + + do { + n_device_stats.body = buffer[toggle&1]; + s_out = screen_driver(&n_device_stats, header_lines, + i_con); + rc = s_out->rc; + free(s_out); + toggle++; + } while (rc == TOGGLE_SCREEN); + + for (k = 0; k < 2; k++) { + free(buffer[k]); + buffer[k] = NULL; + } + n_device_stats.body = NULL; + + return rc; +} + + + #define IPR_INCLUDE 0 #define IPR_REMOVE 1 #define IPR_ADD_HOT_SPARE 0 diff --git a/iprconfig.h b/iprconfig.h index 5a40700..1fcd4a3 100644 --- a/iprconfig.h +++ b/iprconfig.h @@ -156,6 +156,9 @@ int restore_log_defaults(i_container *); int ibm_boot_log(i_container *); int exit_confirmed(i_container *); +int statistics_menu(i_container *); +int device_stats(i_container *); + static int raid_create_check_num_devs(struct ipr_array_cap_entry *, int, int); /* constant strings */ @@ -198,6 +201,7 @@ struct screen_opts main_menu_opt[] = { {ioa_config, "7", __("Work with adapter configuration")}, {ucode_screen, "8", __("Work with microcode updates")}, {log_menu, "9", __("Analyze log")}, + {statistics_menu, "a", __("Devices Statistics")} }; s_node n_main_menu = { @@ -240,6 +244,22 @@ s_node n_disk_status = { "" } }; +struct screen_opts device_stats_opt[] = { + {device_stats, "\n"} +}; + +s_node n_device_stats = { + .rc_flags = (CANCEL_FLAG), + .f_flags = (EXIT_FLAG | CANCEL_FLAG | REFRESH_FLAG | TOGGLE_FLAG | FWD_FLAG), + .num_opts = NUM_OPTS(device_stats_opt), + .options = &device_stats_opt[0], + .title = __("Display Device Statistics"), + .header = { + __("Type option, press Enter.\n"), + __(" 1=Display hardware resource information details\n\n"), + "" } +}; + s_node n_adapter_details = { .rc_flags = (CANCEL_FLAG), .f_flags = (ENTER_FLAG | EXIT_FLAG | CANCEL_FLAG | FWD_FLAG), -- 2.1.0 ------------------------------------------------------------------------------ Go from Idea to Many App Stores Faster with Intel(R) XDK Give your users amazing mobile app experiences with Intel(R) XDK. Use one codebase in this all-in-one HTML5 development environment. Design, debug & build mobile apps & 2D/3D high-impact games for multiple OSs. http://pubads.g.doubleclick.net/gampad/clk?id=254741911&iu=/4140 _______________________________________________ Iprdd-devel mailing list Iprdd-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/iprdd-devel