{
stub_print_filesystem_stats(a, 2, TRUE);
}
+
+/*
+ ***************************************************************************
+ * Display Fibre Channel HBA statistics. This function is used to
+ * display instantaneous and average statistics.
+ *
+ * IN:
+ * @a Activity structure with statistics.
+ * @curr Index in array for current sample statistics.
+ * @dispavg TRUE if displaying average statistics.
+ * @itv Interval of time in jiffies.
+ ***************************************************************************
+ */
+__print_funct_t stub_print_fc_stats(struct activity *a, int prev, int curr, int dispavg, unsigned long long itv)
+{
+ int i;
+ struct stats_fc *sfcc,*sfcp;
+
+
+ if (dis) {
+ printf("\n%-11s FCHBA hba_rxf/s hba_txf/s hba_rxw/s hba_txw/s\n",
+ (dispavg ? _("Summary:") : timestamp[curr]));
+ }
+
+ for (i = 0; i < a->nr; i++) {
+ sfcc = (struct stats_fc *) ((char *) a->buf[curr] + i * a->msize);
+ sfcp = (struct stats_fc *) ((char *) a->buf[prev] + i * a->msize);
+
+ printf("%-11s %10s %11.2f %11.2f %11.2f %11.2f\n",
+ (dispavg ? _("Average:") : timestamp[curr]),
+ sfcc->hba_name,
+ S_VALUE(sfcp->f_rxframes, sfcc->f_rxframes, itv),
+ S_VALUE(sfcp->f_txframes, sfcc->f_txframes, itv),
+ S_VALUE(sfcp->f_rxwords, sfcc->f_rxwords, itv),
+ S_VALUE(sfcp->f_txwords, sfcc->f_txwords, itv));
+ }
+ printf("\n");
+}
+
+/*
+ ***************************************************************************
+ * Display Fibre Channel HBA statistics.
+ *
+ * IN:
+ * @a Activity structure with statistics.
+ * @prev Index in array where stats used as reference are.
+ * @curr Index in array for current sample statistics.
+ * @itv Interval of time in jiffies.
+ ***************************************************************************
+ */
+__print_funct_t print_fc_stats(struct activity *a, int prev, int curr,
+ unsigned long long itv)
+{
+ stub_print_fc_stats(a, prev, curr, FALSE, itv);
+}
+
+/*
+ ***************************************************************************
+ * Display average Fibre Channel HBA statistics.
+ *
+ * IN:
+ * @a Activity structure with statistics.
+ * @prev Index in array where stats used as reference are.
+ * @curr Index in array for current sample statistics.
+ * @itv Interval of time in jiffies.
+ ***************************************************************************
+ */
+__print_funct_t print_avg_hba_stats(struct activity *a, int prev, int curr,
+ unsigned long long itv)
+{
+ stub_print_fc_stats(a, prev, curr, TRUE, itv);
+}
(struct activity *, int, int, unsigned long long);
extern __print_funct_t print_filesystem_stats
(struct activity *, int, int, unsigned long long);
+extern __print_funct_t print_fc_stats
+ (struct activity *, int, int, unsigned long long);
/* Functions used to display average statistics */
extern __print_funct_t print_avg_memory_stats
(struct activity *, int, int, unsigned long long);
extern __print_funct_t print_avg_filesystem_stats
(struct activity *, int, int, unsigned long long);
+extern __print_funct_t print_avg_hba_stats
+ (struct activity *, int, int, unsigned long long);
#endif /* _PR_STATS_H */
fclose(fp);
}
+/*
+ ***************************************************************************
+ * Read Fibre Channel HBA statistics.
+ *
+ * IN:
+ * @st_fc Structure where stats will be saved.
+ * @nbr Total number of HBAs.
+ *
+ * OUT:
+ * @st_fc Structure with statistics.
+ ***************************************************************************
+ */
+void read_hba(struct stats_fc *st_fc, int nbr)
+{
+ DIR *dir;
+ FILE *fp;
+ struct dirent *drd;
+ struct stats_fc *st_fc_i;
+ int hba = 0;
+ char fcstat_filename[MAX_FS_LEN];
+ char line[256];
+ unsigned long rx_frames,
+ tx_frames,
+ rx_words,
+ tx_words;
+
+ /* Each HBA, if present, will have its own hostX entry within SYSFS_FCHBA */
+ if ((dir = opendir(SYSFS_FCHBA)) == NULL)
+ return; /* No HBAs */
+
+ /* Read each of the counters via sysfs, where they are
+ * returned as hex values (e.g. 0x72400) */
+ while ((drd = readdir(dir)) != NULL) {
+ rx_frames = tx_frames = rx_words = tx_words = 0;
+
+ if (strncmp(drd->d_name,"host",4) == 0) {
+ sprintf(fcstat_filename,"%s/%s/statistics/rx_frames",
+ SYSFS_FCHBA,drd->d_name);
+ if ((fp = fopen(fcstat_filename, "r"))) {
+ if (fgets(line,sizeof(line),fp))
+ sscanf(line, "%lx",&rx_frames);
+ fclose(fp);
+ }
+
+ sprintf(fcstat_filename,"%s/%s/statistics/tx_frames",
+ SYSFS_FCHBA,drd->d_name);
+ if ((fp = fopen(fcstat_filename, "r"))) {
+ if (fgets(line,sizeof(line),fp))
+ sscanf(line, "%lx",&tx_frames);
+ fclose(fp);
+ }
+
+ sprintf(fcstat_filename,"%s/%s/statistics/rx_words",
+ SYSFS_FCHBA,drd->d_name);
+ if ((fp = fopen(fcstat_filename, "r"))) {
+ if (fgets(line,sizeof(line),fp))
+ sscanf(line, "%lx",&rx_words);
+ fclose(fp);
+ }
+
+ sprintf(fcstat_filename,"%s/%s/statistics/tx_words",
+ SYSFS_FCHBA,drd->d_name);
+ if ((fp = fopen(fcstat_filename, "r"))) {
+ if (fgets(line,sizeof(line),fp))
+ sscanf(line, "%lx",&tx_words);
+ fclose(fp);
+ }
+
+ st_fc_i = st_fc + hba++;
+ st_fc_i->f_rxframes = rx_frames;
+ st_fc_i->f_txframes = tx_frames;
+ st_fc_i->f_rxwords = rx_words;
+ st_fc_i->f_txwords = tx_words;
+ strcpy(st_fc_i->hba_name, drd->d_name);
+ }
+
+ }
+ closedir(dir);
+}
+
/*------------------ END: FUNCTIONS USED BY SADC ONLY ---------------------*/
#endif /* SOURCE_SADC */
#define STATS_FILESYSTEM_SIZE (sizeof(struct stats_filesystem))
+/* Structure for Fibre Channel HBA statistics */
+struct stats_fc {
+ unsigned long f_rxframes __attribute__ ((aligned (16)));
+ unsigned long f_txframes __attribute__ ((aligned (16)));
+ unsigned long f_rxwords __attribute__ ((aligned (16)));
+ unsigned long f_txwords __attribute__ ((aligned (16)));
+ char hba_name[16] __attribute__ ((aligned (16)));
+};
+
+#define STATS_FC_SIZE (sizeof(struct stats_fc))
+
/*
***************************************************************************
* Prototypes for functions used to read system statistics
read_bus_usb_dev(struct stats_pwr_usb *, int);
extern void
read_filesystem(struct stats_filesystem *, int);
+extern void
+ read_hba(struct stats_fc *, int);
#endif /* _RD_STATS_H */