Skip to content

Commit

Permalink
sadf: PCP: Add support for A_HUGE activity
Browse files Browse the repository at this point in the history
Add metrics displayed by "sar -H" (huge pages statistics) to PCP
archive.

Signed-off-by: Sebastien GODARD <[email protected]>
  • Loading branch information
sysstat committed May 11, 2019
1 parent 8a3dc48 commit bf83e7f
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 0 deletions.
1 change: 1 addition & 0 deletions activity.c
Original file line number Diff line number Diff line change
Expand Up @@ -1618,6 +1618,7 @@ struct activity huge_act = {
.f_json_print = json_print_huge_stats,
.f_svg_print = svg_print_huge_stats,
.f_raw_print = raw_print_huge_stats,
.f_pcp_print = pcp_print_huge_stats,
.f_count_new = NULL,
.item_list = NULL,
.desc = "Huge pages utilization",
Expand Down
30 changes: 30 additions & 0 deletions pcp_def_metrics.c
Original file line number Diff line number Diff line change
Expand Up @@ -1397,6 +1397,36 @@ void pcp_def_net_udp6_metrics(void)
#endif /* HAVE_PCP */
}

/*
***************************************************************************
* Define PCP metrics for huge pages statistics.
***************************************************************************
*/
void pcp_def_huge_metrics()
{
#ifdef HAVE_PCP
pmiAddMetric("mem.huge.free",
PM_IN_NULL, PM_TYPE_U64, PM_INDOM_NULL, PM_SEM_INSTANT,
pmiUnits(1, 0, 0, PM_SPACE_KBYTE, 0, 0));

pmiAddMetric("mem.huge.used",
PM_IN_NULL, PM_TYPE_U64, PM_INDOM_NULL, PM_SEM_INSTANT,
pmiUnits(1, 0, 0, PM_SPACE_KBYTE, 0, 0));

pmiAddMetric("mem.huge.used_pct",
PM_IN_NULL, PM_TYPE_FLOAT, PM_INDOM_NULL, PM_SEM_INSTANT,
pmiUnits(0, 0, 0, 0, 0, 0));

pmiAddMetric("mem.huge.reserved",
PM_IN_NULL, PM_TYPE_U64, PM_INDOM_NULL, PM_SEM_INSTANT,
pmiUnits(1, 0, 0, PM_SPACE_KBYTE, 0, 0));

pmiAddMetric("mem.huge.surplus",
PM_IN_NULL, PM_TYPE_U64, PM_INDOM_NULL, PM_SEM_INSTANT,
pmiUnits(1, 0, 0, PM_SPACE_KBYTE, 0, 0));
#endif /* HAVE_PCP */
}

/*
***************************************************************************
* Define PCP metrics for filesystem statistics.
Expand Down
1 change: 1 addition & 0 deletions pcp_def_metrics.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ void pcp_def_net_eip6_metrics(void);
void pcp_def_net_icmp6_metrics(void);
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 *);

/* Define domains number */
Expand Down
36 changes: 36 additions & 0 deletions pcp_stats.c
Original file line number Diff line number Diff line change
Expand Up @@ -1736,6 +1736,42 @@ __print_funct_t pcp_print_pwr_cpufreq_stats(struct activity *a, int curr, unsign
#endif /* HAVE_PCP */
}

/*
***************************************************************************
* Display huge pages 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_huge_stats(struct activity *a, int curr, unsigned long long itv,
struct record_header *record_hdr)
{
#ifdef HAVE_PCP
char buf[64];
struct stats_huge
*smc = (struct stats_huge *) a->buf[curr];

snprintf(buf, sizeof(buf), "%llu", smc->frhkb);
pmiPutValue("mem.huge.free", NULL, buf);

snprintf(buf, sizeof(buf), "%llu", smc->tlhkb - smc->frhkb);
pmiPutValue("mem.huge.used", NULL, buf);

snprintf(buf, sizeof(buf), "%f", smc->tlhkb ? SP_VALUE(smc->frhkb, smc->tlhkb, smc->tlhkb) : 0.0);
pmiPutValue("mem.huge.used_pct", NULL, buf);

snprintf(buf, sizeof(buf), "%llu", smc->rsvdhkb);
pmiPutValue("mem.huge.reserved", NULL, buf);

snprintf(buf, sizeof(buf), "%llu", smc->surphkb);
pmiPutValue("mem.huge.surplus", NULL, buf);
#endif /* HAVE_PCP */
}

/*
***************************************************************************
* Display filesystem statistics in PCP format.
Expand Down
2 changes: 2 additions & 0 deletions pcp_stats.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ __print_funct_t pcp_print_net_udp6_stats
(struct activity *, int, unsigned long long, struct record_header *);
__print_funct_t pcp_print_pwr_cpufreq_stats
(struct activity *, int, unsigned long long, struct record_header *);
__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_softnet_stats
Expand Down
4 changes: 4 additions & 0 deletions sadf_misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -761,6 +761,10 @@ __printf_funct_t print_pcp_statistics(int *tab, int action, struct activity *act
pcp_def_net_udp6_metrics();
break;

case A_HUGE:
pcp_def_huge_metrics();
break;

case A_FS:
pcp_def_filesystem_metrics(act[p]);
break;
Expand Down

0 comments on commit bf83e7f

Please sign in to comment.