]> granicus.if.org Git - sysstat/commitdiff
sadf: PCP: Add support for A_NET_FC activity
authorSebastien GODARD <sysstat@users.noreply.github.com>
Sat, 11 May 2019 14:47:48 +0000 (16:47 +0200)
committerSebastien GODARD <sysstat@users.noreply.github.com>
Sat, 11 May 2019 14:47:48 +0000 (16:47 +0200)
Add metrics displayed by "sar -n FC" (Fibre Channel HBA statistics) to
PCP archive.

Signed-off-by: Sebastien GODARD <sysstat@users.noreply.github.com>
activity.c
pcp_def_metrics.c
pcp_def_metrics.h
pcp_stats.c
pcp_stats.h
sadf_misc.c

index 8fc332c563bb7d31b1f35b3eb9ec85222c3cc660..6404edea3809495f05c1b761d2dea6eabde5ed4b 100644 (file)
@@ -1801,6 +1801,7 @@ struct activity fchost_act = {
        .f_json_print   = json_print_fchost_stats,
        .f_svg_print    = svg_print_fchost_stats,
        .f_raw_print    = raw_print_fchost_stats,
+       .f_pcp_print    = pcp_print_fchost_stats,
        .f_count_new    = count_new_fchost,
        .item_list      = NULL,
        .desc           = "Fibre Channel HBA statistics",
index e995a891f17069f5759bb5542ff578652876582f..43393857ff7bec1e39ec228ad6e70a5b9a24bef1 100644 (file)
@@ -1482,3 +1482,47 @@ void pcp_def_filesystem_metrics(struct activity *a)
                     pmiUnits(0, 0, 0, 0, 0, 0));
 #endif /* HAVE_PCP */
 }
+
+/*
+ ***************************************************************************
+ * Define PCP metrics for Fibre Channel HBA statistics.
+ *
+ * IN:
+ * @a          Activity structure with statistics.
+ ***************************************************************************
+ */
+void pcp_def_fchost_metrics(struct activity *a)
+{
+#ifdef HAVE_PCP
+       int inst = 0;
+       static pmInDom indom = PM_INDOM_NULL;
+       struct sa_item *list = a->item_list;
+
+       if (indom == PM_INDOM_NULL) {
+               /* Create domain */
+               indom = pmInDom_build(0, PM_INDOM_FCHOST);
+
+               /* Create instances */
+               while (list != NULL) {
+                       pmiAddInstance(indom, list->item_name, inst++);
+                       list = list->next;
+               }
+       }
+
+       pmiAddMetric("network.fchost.in.frame",
+                    PM_IN_NULL, PM_TYPE_FLOAT, indom, PM_SEM_INSTANT,
+                    pmiUnits(0, -1, 1, 0, PM_TIME_SEC, PM_COUNT_ONE));
+
+       pmiAddMetric("network.fchost.out.frame",
+                    PM_IN_NULL, PM_TYPE_FLOAT, indom, PM_SEM_INSTANT,
+                    pmiUnits(0, -1, 1, 0, PM_TIME_SEC, PM_COUNT_ONE));
+
+       pmiAddMetric("network.fchost.in.word",
+                    PM_IN_NULL, PM_TYPE_FLOAT, indom, PM_SEM_INSTANT,
+                    pmiUnits(0, -1, 1, 0, PM_TIME_SEC, PM_COUNT_ONE));
+
+       pmiAddMetric("network.fchost.out.word",
+                    PM_IN_NULL, PM_TYPE_FLOAT, indom, PM_SEM_INSTANT,
+                    pmiUnits(0, -1, 1, 0, PM_TIME_SEC, PM_COUNT_ONE));
+#endif /* HAVE_PCP */
+}
index f94cf506dce2ccd4572a8037b50812c4f3066533..981d8a126239262694aca571d5360fc85655c8ce 100644 (file)
@@ -41,6 +41,7 @@ void pcp_def_net_eicmp6_metrics(void);
 void pcp_def_net_udp6_metrics(void);
 void pcp_def_huge_metrics(void);
 void pcp_def_filesystem_metrics(struct activity *);
+void pcp_def_fchost_metrics(struct activity *);
 
 /* Define domains number */
 #define PM_INDOM_CPU           0
@@ -49,6 +50,7 @@ void pcp_def_filesystem_metrics(struct activity *);
 #define PM_INDOM_SERIAL                3
 #define PM_INDOM_INT           4
 #define PM_INDOM_FILESYSTEM    5
+#define PM_INDOM_FCHOST                6
 
 
 #endif /* _PCP_DEF_METRICS_H */
index ca9f6e23e0f0cebc4013938561312b9bae68070e..cf47962eadc466de442802e26b137fc9d8bbaee7 100644 (file)
@@ -1918,3 +1918,73 @@ __print_funct_t pcp_print_softnet_stats(struct activity *a, int curr, unsigned l
        }
 #endif /* HAVE_PCP */
 }
+
+/*
+ ***************************************************************************
+ * Display Fibre Channel HBA statistics in PCP format.
+ *
+ * IN:
+ * @a          Activity structure with statistics.
+ * @curr       Index in array for current sample statistics.
+ * @itv                Interval of time in 1/100th of a second.
+ * @record_hdr Record header for current sample.
+ ***************************************************************************
+ */
+__print_funct_t pcp_print_fchost_stats(struct activity *a, int curr, unsigned long long itv,
+                                      struct record_header *record_hdr)
+{
+#ifdef HAVE_PCP
+       int i, j, j0, found;
+       struct stats_fchost *sfcc, *sfcp;
+       char buf[64];
+
+       for (i = 0; i < a->nr[curr]; i++) {
+
+               found = FALSE;
+
+               if (a->nr[!curr] > 0) {
+                       sfcc = (struct stats_fchost *) ((char *) a->buf[curr] + i * a->msize);
+
+                       /* Look for corresponding structure in previous iteration */
+                       j = i;
+
+                       if (j >= a->nr[!curr]) {
+                               j = a->nr[!curr] - 1;
+                       }
+
+                       j0 = j;
+
+                       do {
+                               sfcp = (struct stats_fchost *) ((char *) a->buf[!curr] + j * a->msize);
+                               if (!strcmp(sfcc->fchost_name, sfcp->fchost_name)) {
+                                       found = TRUE;
+                                       break;
+                               }
+                               if (++j >= a->nr[!curr]) {
+                                       j = 0;
+                               }
+                       }
+                       while (j != j0);
+               }
+
+               if (!found)
+                       continue;
+
+               snprintf(buf, sizeof(buf), "%f",
+                        S_VALUE(sfcp->f_rxframes, sfcc->f_rxframes, itv));
+               pmiPutValue("network.fchost.in.frame", sfcc->fchost_name, buf);
+
+               snprintf(buf, sizeof(buf), "%f",
+                        S_VALUE(sfcp->f_txframes, sfcc->f_txframes, itv));
+               pmiPutValue("network.fchost.out.frame", sfcc->fchost_name, buf);
+
+               snprintf(buf, sizeof(buf), "%f",
+                        S_VALUE(sfcp->f_rxwords, sfcc->f_rxwords, itv));
+               pmiPutValue("network.fchost.in.word", sfcc->fchost_name, buf);
+
+               snprintf(buf, sizeof(buf), "%f",
+                        S_VALUE(sfcp->f_txwords, sfcc->f_txwords, itv));
+               pmiPutValue("network.fchost.out.word", sfcc->fchost_name, buf);
+       }
+#endif /* HAVE_PCP */
+}
index 37f9aa833ecf610df4893c091e2310f7726e29e0..073d111dab47629ece894eedc7c474293cb83df5 100644 (file)
@@ -75,6 +75,8 @@ __print_funct_t pcp_print_huge_stats
        (struct activity *, int, unsigned long long, struct record_header *);
 __print_funct_t pcp_print_filesystem_stats
        (struct activity *, int, unsigned long long, struct record_header *);
+__print_funct_t pcp_print_fchost_stats
+       (struct activity *, int, unsigned long long, struct record_header *);
 __print_funct_t pcp_print_softnet_stats
        (struct activity *, int, unsigned long long, struct record_header *);
 
index 9c6ad19b42865a21479ac625651862ef4768b27a..35000d570e401aebd1d70af20a94a30e4d0dd538 100644 (file)
@@ -768,6 +768,10 @@ __printf_funct_t print_pcp_statistics(int *tab, int action, struct activity *act
                                case A_FS:
                                        pcp_def_filesystem_metrics(act[p]);
                                        break;
+
+                               case A_NET_FC:
+                                       pcp_def_fchost_metrics(act[p]);
+                                       break;
                        }
                }
        }