From 3684b9a0efa22d64145f92335fc79ed343c07502 Mon Sep 17 00:00:00 2001 From: Sebastien GODARD Date: Sun, 24 Mar 2019 15:14:43 +0100 Subject: [PATCH] sadf: PCP: Add support for A_NET_NFSD activity Add metrics displayed by "sar -n NFSD" (NFS server statistics) to PCP archive. Signed-off-by: Sebastien GODARD --- activity.c | 1 + pcp_def_metrics.c | 54 ++++++++++++++++++++++++++++++++++++++ pcp_def_metrics.h | 1 + pcp_stats.c | 66 +++++++++++++++++++++++++++++++++++++++++++++++ pcp_stats.h | 2 ++ sadf_misc.c | 4 +++ 6 files changed, 128 insertions(+) diff --git a/activity.c b/activity.c index b2a3ef2..45a3219 100644 --- a/activity.c +++ b/activity.c @@ -740,6 +740,7 @@ struct activity net_nfsd_act = { .f_json_print = json_print_net_nfsd_stats, .f_svg_print = svg_print_net_nfsd_stats, .f_raw_print = raw_print_net_nfsd_stats, + .f_pcp_print = pcp_print_net_nfsd_stats, .f_count_new = NULL, .item_list = NULL, .desc = "NFS server statistics", diff --git a/pcp_def_metrics.c b/pcp_def_metrics.c index 9313590..3d15946 100644 --- a/pcp_def_metrics.c +++ b/pcp_def_metrics.c @@ -632,3 +632,57 @@ void pcp_def_net_nfs_metrics(void) pmiUnits(0, -1, 1, 0, PM_TIME_SEC, PM_COUNT_ONE)); #endif /* HAVE_PCP */ } + +/* + *************************************************************************** + * Define PCP metrics for NFS server statistics. + *************************************************************************** + */ +void pcp_def_net_nfsd_metrics(void) +{ +#ifdef HAVE_PCP + pmiAddMetric("network.fs.server.call", + PM_IN_NULL, PM_TYPE_FLOAT, PM_INDOM_NULL, PM_SEM_INSTANT, + pmiUnits(0, -1, 1, 0, PM_TIME_SEC, PM_COUNT_ONE)); + + pmiAddMetric("network.fs.server.badcall", + PM_IN_NULL, PM_TYPE_FLOAT, PM_INDOM_NULL, PM_SEM_INSTANT, + pmiUnits(0, -1, 1, 0, PM_TIME_SEC, PM_COUNT_ONE)); + + pmiAddMetric("network.fs.server.packets", + PM_IN_NULL, PM_TYPE_FLOAT, PM_INDOM_NULL, PM_SEM_INSTANT, + pmiUnits(0, -1, 1, 0, PM_TIME_SEC, PM_COUNT_ONE)); + + pmiAddMetric("network.fs.server.udp", + PM_IN_NULL, PM_TYPE_FLOAT, PM_INDOM_NULL, PM_SEM_INSTANT, + pmiUnits(0, -1, 1, 0, PM_TIME_SEC, PM_COUNT_ONE)); + + pmiAddMetric("network.fs.server.tcp", + PM_IN_NULL, PM_TYPE_FLOAT, PM_INDOM_NULL, PM_SEM_INSTANT, + pmiUnits(0, -1, 1, 0, PM_TIME_SEC, PM_COUNT_ONE)); + + pmiAddMetric("network.fs.server.hits", + PM_IN_NULL, PM_TYPE_FLOAT, PM_INDOM_NULL, PM_SEM_INSTANT, + pmiUnits(0, -1, 1, 0, PM_TIME_SEC, PM_COUNT_ONE)); + + pmiAddMetric("network.fs.server.misses", + PM_IN_NULL, PM_TYPE_FLOAT, PM_INDOM_NULL, PM_SEM_INSTANT, + pmiUnits(0, -1, 1, 0, PM_TIME_SEC, PM_COUNT_ONE)); + + pmiAddMetric("network.fs.server.read", + PM_IN_NULL, PM_TYPE_FLOAT, PM_INDOM_NULL, PM_SEM_INSTANT, + pmiUnits(0, -1, 1, 0, PM_TIME_SEC, PM_COUNT_ONE)); + + pmiAddMetric("network.fs.server.write", + PM_IN_NULL, PM_TYPE_FLOAT, PM_INDOM_NULL, PM_SEM_INSTANT, + pmiUnits(0, -1, 1, 0, PM_TIME_SEC, PM_COUNT_ONE)); + + pmiAddMetric("network.fs.server.access", + PM_IN_NULL, PM_TYPE_FLOAT, PM_INDOM_NULL, PM_SEM_INSTANT, + pmiUnits(0, -1, 1, 0, PM_TIME_SEC, PM_COUNT_ONE)); + + pmiAddMetric("network.fs.server.gettattr", + PM_IN_NULL, PM_TYPE_FLOAT, PM_INDOM_NULL, 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 1ec2cd1..a1a555f 100644 --- a/pcp_def_metrics.h +++ b/pcp_def_metrics.h @@ -24,6 +24,7 @@ void pcp_def_queue_metrics(void); void pcp_def_serial_metrics(struct activity *); void pcp_def_net_dev_metrics(struct activity *); void pcp_def_net_nfs_metrics(void); +void pcp_def_net_nfsd_metrics(void); /* Define domains number */ #define PM_INDOM_CPU 0 diff --git a/pcp_stats.c b/pcp_stats.c index 692f11e..8e263ef 100644 --- a/pcp_stats.c +++ b/pcp_stats.c @@ -838,3 +838,69 @@ __print_funct_t pcp_print_net_nfs_stats(struct activity *a, int curr, unsigned l pmiPutValue("network.fs.client.getatt", NULL, buf); #endif /* HAVE_PCP */ } + +/* + *************************************************************************** + * Display NFS server 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_net_nfsd_stats(struct activity *a, int curr, unsigned long long itv, + struct record_header *record_hdr) +{ +#ifdef HAVE_PCP + char buf[64]; + struct stats_net_nfsd + *snndc = (struct stats_net_nfsd *) a->buf[curr], + *snndp = (struct stats_net_nfsd *) a->buf[!curr]; + + snprintf(buf, sizeof(buf), "%f", + S_VALUE(snndp->nfsd_rpccnt, snndc->nfsd_rpccnt, itv)); + pmiPutValue("network.fs.server.call", NULL, buf); + + snprintf(buf, sizeof(buf), "%f", + S_VALUE(snndp->nfsd_rpcbad, snndc->nfsd_rpcbad, itv)); + pmiPutValue("network.fs.server.badcall", NULL, buf); + + snprintf(buf, sizeof(buf), "%f", + S_VALUE(snndp->nfsd_netcnt, snndc->nfsd_netcnt, itv)); + pmiPutValue("network.fs.server.packets", NULL, buf); + + snprintf(buf, sizeof(buf), "%f", + S_VALUE(snndp->nfsd_netudpcnt, snndc->nfsd_netudpcnt, itv)); + pmiPutValue("network.fs.server.udp", NULL, buf); + + snprintf(buf, sizeof(buf), "%f", + S_VALUE(snndp->nfsd_nettcpcnt, snndc->nfsd_nettcpcnt, itv)); + pmiPutValue("network.fs.server.tcp", NULL, buf); + + snprintf(buf, sizeof(buf), "%f", + S_VALUE(snndp->nfsd_rchits, snndc->nfsd_rchits, itv)); + pmiPutValue("network.fs.server.hits", NULL, buf); + + snprintf(buf, sizeof(buf), "%f", + S_VALUE(snndp->nfsd_rcmisses, snndc->nfsd_rcmisses, itv)); + pmiPutValue("network.fs.server.misses", NULL, buf); + + snprintf(buf, sizeof(buf), "%f", + S_VALUE(snndp->nfsd_readcnt, snndc->nfsd_readcnt, itv)); + pmiPutValue("network.fs.server.read", NULL, buf); + + snprintf(buf, sizeof(buf), "%f", + S_VALUE(snndp->nfsd_writecnt, snndc->nfsd_writecnt, itv)); + pmiPutValue("network.fs.server.write", NULL, buf); + + snprintf(buf, sizeof(buf), "%f", + S_VALUE(snndp->nfsd_accesscnt, snndc->nfsd_accesscnt, itv)); + pmiPutValue("network.fs.server.access", NULL, buf); + + snprintf(buf, sizeof(buf), "%f", + S_VALUE(snndp->nfsd_getattcnt, snndc->nfsd_getattcnt, itv)); + pmiPutValue("network.fs.server.getattr", NULL, buf); +#endif /* HAVE_PCP */ +} diff --git a/pcp_stats.h b/pcp_stats.h index 7a7f96b..60c3e36 100644 --- a/pcp_stats.h +++ b/pcp_stats.h @@ -39,5 +39,7 @@ __print_funct_t pcp_print_net_edev_stats (struct activity *, int, unsigned long long, struct record_header *); __print_funct_t pcp_print_net_nfs_stats (struct activity *, int, unsigned long long, struct record_header *); +__print_funct_t pcp_print_net_nfsd_stats + (struct activity *, int, unsigned long long, struct record_header *); #endif /* _PCP_STATS_H */ diff --git a/sadf_misc.c b/sadf_misc.c index d9153cc..799f6aa 100644 --- a/sadf_misc.c +++ b/sadf_misc.c @@ -545,6 +545,10 @@ __printf_funct_t print_pcp_statistics(int *tab, int action, struct activity *act case A_NET_NFS: pcp_def_net_nfs_metrics(); break; + + case A_NET_NFSD: + pcp_def_net_nfsd_metrics(); + break; } } } -- 2.40.0