Skip to content

Commit

Permalink
sadf: PCP: Add support for A_NET_SOCK6 activity
Browse files Browse the repository at this point in the history
Add metrics displayed by "sar -n SOCK6" (IPv6 network sockets
statistics) to PCP archive.

Signed-off-by: Sebastien GODARD <sysstat@users.noreply.github.com>
  • Loading branch information
sysstat committed Apr 6, 2019
1 parent 92626df commit 14ab20b
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 0 deletions.
1 change: 1 addition & 0 deletions activity.c
Original file line number Diff line number Diff line change
Expand Up @@ -1156,6 +1156,7 @@ struct activity net_sock6_act = {
.f_json_print = json_print_net_sock6_stats,
.f_svg_print = svg_print_net_sock6_stats,
.f_raw_print = raw_print_net_sock6_stats,
.f_pcp_print = pcp_print_net_sock6_stats,
.f_count_new = NULL,
.item_list = NULL,
.desc = "IPv6 sockets statistics",
Expand Down
26 changes: 26 additions & 0 deletions pcp_def_metrics.c
Original file line number Diff line number Diff line change
Expand Up @@ -1011,6 +1011,32 @@ void pcp_def_net_udp_metrics(void)
#endif /* HAVE_PCP */
}

/*
***************************************************************************
* Define PCP metrics for IPv6 network sockets statistics.
***************************************************************************
*/
void pcp_def_net_sock6_metrics(void)
{
#ifdef HAVE_PCP
pmiAddMetric("network.socket6.tcp6_inuse",
PM_IN_NULL, PM_TYPE_U32, PM_INDOM_NULL, PM_SEM_INSTANT,
pmiUnits(0, 0, 1, 0, 0, PM_COUNT_ONE));

pmiAddMetric("network.socket6.udp6_inuse",
PM_IN_NULL, PM_TYPE_U32, PM_INDOM_NULL, PM_SEM_INSTANT,
pmiUnits(0, 0, 1, 0, 0, PM_COUNT_ONE));

pmiAddMetric("network.socket6.raw6_inuse",
PM_IN_NULL, PM_TYPE_U32, PM_INDOM_NULL, PM_SEM_INSTANT,
pmiUnits(0, 0, 1, 0, 0, PM_COUNT_ONE));

pmiAddMetric("network.socket6.frag6_inuse",
PM_IN_NULL, PM_TYPE_U32, PM_INDOM_NULL, PM_SEM_INSTANT,
pmiUnits(0, 0, 1, 0, 0, PM_COUNT_ONE));
#endif /* HAVE_PCP */
}

/*
***************************************************************************
* Define PCP metrics for IPv6 network 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 @@ -33,6 +33,7 @@ void pcp_def_net_eicmp_metrics(void);
void pcp_def_net_tcp_metrics(void);
void pcp_def_net_etcp_metrics(void);
void pcp_def_net_udp_metrics(void);
void pcp_def_net_sock6_metrics(void);
void pcp_def_net_ip6_metrics(void);
void pcp_def_net_eip6_metrics(void);
void pcp_def_net_icmp6_metrics(void);
Expand Down
33 changes: 33 additions & 0 deletions pcp_stats.c
Original file line number Diff line number Diff line change
Expand Up @@ -1319,6 +1319,39 @@ __print_funct_t pcp_print_net_udp_stats(struct activity *a, int curr, unsigned l
#endif /* HAVE_PCP */
}

/*
***************************************************************************
* Display IPv6 network sockets 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_sock6_stats(struct activity *a, int curr, unsigned long long itv,
struct record_header *record_hdr)
{
#ifdef HAVE_PCP
char buf[64];
struct stats_net_sock6
*snsc = (struct stats_net_sock6 *) a->buf[curr];

snprintf(buf, sizeof(buf), "%u", snsc->tcp6_inuse);
pmiPutValue("network.socket6.tcp6_inuse", NULL, buf);

snprintf(buf, sizeof(buf), "%u", snsc->udp6_inuse);
pmiPutValue("network.socket6.udp6_inuse", NULL, buf);

snprintf(buf, sizeof(buf), "%u", snsc->raw6_inuse);
pmiPutValue("network.socket6.raw6_inuse", NULL, buf);

snprintf(buf, sizeof(buf), "%u", snsc->frag6_inuse);
pmiPutValue("network.socket6.frag6_inuse", NULL, buf);
#endif /* HAVE_PCP */
}

/*
***************************************************************************
* Display IPv6 network 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 @@ -57,6 +57,8 @@ __print_funct_t pcp_print_net_etcp_stats
(struct activity *, int, unsigned long long, struct record_header *);
__print_funct_t pcp_print_net_udp_stats
(struct activity *, int, unsigned long long, struct record_header *);
__print_funct_t pcp_print_net_sock6_stats
(struct activity *, int, unsigned long long, struct record_header *);
__print_funct_t pcp_print_net_ip6_stats
(struct activity *, int, unsigned long long, struct record_header *);
__print_funct_t pcp_print_net_eip6_stats
Expand Down
4 changes: 4 additions & 0 deletions sadf_misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -585,6 +585,10 @@ __printf_funct_t print_pcp_statistics(int *tab, int action, struct activity *act
pcp_def_net_udp_metrics();
break;

case A_NET_SOCK6:
pcp_def_net_sock6_metrics();
break;

case A_NET_IP6:
pcp_def_net_ip6_metrics();
break;
Expand Down

0 comments on commit 14ab20b

Please sign in to comment.