From: Sebastien GODARD Date: Sat, 11 May 2019 14:47:48 +0000 (+0200) Subject: sadf: PCP: Add support for A_NET_FC activity X-Git-Tag: v12.1.5~7 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7d2edd650f95bdc444207094aa299c708bb3766e;p=sysstat sadf: PCP: Add support for A_NET_FC activity Add metrics displayed by "sar -n FC" (Fibre Channel HBA statistics) to PCP archive. Signed-off-by: Sebastien GODARD --- diff --git a/activity.c b/activity.c index 8fc332c..6404ede 100644 --- a/activity.c +++ b/activity.c @@ -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", diff --git a/pcp_def_metrics.c b/pcp_def_metrics.c index e995a89..4339385 100644 --- a/pcp_def_metrics.c +++ b/pcp_def_metrics.c @@ -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 */ +} diff --git a/pcp_def_metrics.h b/pcp_def_metrics.h index f94cf50..981d8a1 100644 --- a/pcp_def_metrics.h +++ b/pcp_def_metrics.h @@ -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 */ diff --git a/pcp_stats.c b/pcp_stats.c index ca9f6e2..cf47962 100644 --- a/pcp_stats.c +++ b/pcp_stats.c @@ -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 */ +} diff --git a/pcp_stats.h b/pcp_stats.h index 37f9aa8..073d111 100644 --- a/pcp_stats.h +++ b/pcp_stats.h @@ -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 *); diff --git a/sadf_misc.c b/sadf_misc.c index 9c6ad19..35000d5 100644 --- a/sadf_misc.c +++ b/sadf_misc.c @@ -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; } } }