On 12/01/2015 01:47 PM, Gabriel Krisman Bertazi wrote:
> 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);

This looks to be broken for HDDs since print_ssd_report returns NULL here.

Also, I'd suggest we display the ssd_report data before the af_dasd_perf data,
since it seems like that might be more interesting to people.


> +
> +     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);

Since we aren't displaying the actual disk array device on this screen, let's 
not indent
the Description column for array members. 

> +                             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")}

We've been trying to keep the menus to nine entries at most, since I think its
cleanest that way. In order to do that here, I suggest we modify the main menu
to be:

    1. Display hardware status
    2. Work with disk arrays
    3. Work with disk unit recovery
    4. Work with configuration options
    5. Work with microcode updates
    6. Devices Statistics
    7. Analyze log

Then the "Work with configuration options" menu would look like:


    1. Work with driver configuration
    2. Work with adapter configuration
    3. Work with disk configuration
    4. Work with SCSI bus configuration


>  };
> 
>  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),
> 


-- 
Brian King
Power Linux I/O
IBM Linux Technology Center


------------------------------------------------------------------------------
_______________________________________________
Iprdd-devel mailing list
Iprdd-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/iprdd-devel

Reply via email to