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.

Signed-off-by: Gabriel Krisman Bertazi <kris...@linux.vnet.ibm.com>
---
 iprconfig.c | 98 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 iprconfig.h | 22 +++++++++++++-
 2 files changed, 119 insertions(+), 1 deletion(-)

diff --git a/iprconfig.c b/iprconfig.c
index 771ec23..29e7a52 100644
--- a/iprconfig.c
+++ b/iprconfig.c
@@ -131,6 +131,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++) \
@@ -2756,6 +2758,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;
+
+       body = print_ssd_report(dev, body);
+
+       if (ipr_is_af_dasd_device(dev)) {
+               body = af_dasd_perf(body, dev);
+       }
+
+       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", 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 54309d4..5796eee 100644
--- a/iprconfig.h
+++ b/iprconfig.h
@@ -157,6 +157,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 */
@@ -195,7 +198,8 @@ struct screen_opts main_menu_opt[] = {
        {disk_unit_recovery, "3", __("Work with disk unit recovery")},
        {config_menu,        "4", __("Work with configuration options")},
        {ucode_screen,       "5", __("Work with microcode updates")},
-       {log_menu,           "6", __("Analyze log")},
+       {statistics_menu,    "6", __("Devices Statistics")},
+       {log_menu,           "7", __("Analyze log")}
 };
 
 s_node n_main_menu = {
@@ -237,6 +241,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


------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=267308311&iu=/4140
_______________________________________________
Iprdd-devel mailing list
Iprdd-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/iprdd-devel

Reply via email to