Skip to content

Commit

Permalink
sadf: PCP: Add support for A_NET_ICMP and A_NET_EICMP activities
Browse files Browse the repository at this point in the history
Add metrics displayed by "sar -n ICMP" and "sar -n EICMP" (network ICMP
statistics) to PCP archive.

Signed-off-by: Sebastien GODARD <[email protected]>
  • Loading branch information
sysstat committed Mar 31, 2019
1 parent 9207540 commit 4e2b842
Show file tree
Hide file tree
Showing 6 changed files with 289 additions and 0 deletions.
2 changes: 2 additions & 0 deletions activity.c
Original file line number Diff line number Diff line change
Expand Up @@ -924,6 +924,7 @@ struct activity net_icmp_act = {
.f_json_print = json_print_net_icmp_stats,
.f_svg_print = svg_print_net_icmp_stats,
.f_raw_print = raw_print_net_icmp_stats,
.f_pcp_print = pcp_print_net_icmp_stats,
.f_count_new = NULL,
.item_list = NULL,
.desc = "ICMPv4 traffic statistics",
Expand Down Expand Up @@ -970,6 +971,7 @@ struct activity net_eicmp_act = {
.f_json_print = json_print_net_eicmp_stats,
.f_svg_print = svg_print_net_eicmp_stats,
.f_raw_print = raw_print_net_eicmp_stats,
.f_pcp_print = pcp_print_net_eicmp_stats,
.f_count_new = NULL,
.item_list = NULL,
.desc = "ICMPv4 traffic errors statistics",
Expand Down
124 changes: 124 additions & 0 deletions pcp_def_metrics.c
Original file line number Diff line number Diff line change
Expand Up @@ -770,3 +770,127 @@ void pcp_def_net_eip_metrics(void)
pmiUnits(0, -1, 1, 0, PM_TIME_SEC, PM_COUNT_ONE));
#endif /* HAVE_PCP */
}

/*
***************************************************************************
* Define PCP metrics for ICMP network statistics.
***************************************************************************
*/
void pcp_def_net_icmp_metrics(void)
{
#ifdef HAVE_PCP
pmiAddMetric("network.snmp.icmp.icmpInMsgs",
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.snmp.icmp.icmpOutMsgs",
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.snmp.icmp.icmpInEchos",
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.snmp.icmp.icmpInEchoReps",
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.snmp.icmp.icmpOutEchos",
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.snmp.icmp.icmpOutEchoReps",
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.snmp.icmp.icmpInTimestamps",
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.snmp.icmp.icmpInTimestampReps",
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.snmp.icmp.icmpOutTimestamps",
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.snmp.icmp.icmpOutTimestampReps",
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.snmp.icmp.icmpInAddrMasks",
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.snmp.icmp.icmpInAddrMaskReps",
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.snmp.icmp.icmpOutAddrMasks",
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.snmp.icmp.icmpOutAddrMaskReps",
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 */
}

/*
***************************************************************************
* Define PCP metrics for ICMP network errors statistics.
***************************************************************************
*/
void pcp_def_net_eicmp_metrics(void)
{
#ifdef HAVE_PCP
pmiAddMetric("network.snmp.icmp.icmpInErrors",
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.snmp.icmp.icmpOutErrors",
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.snmp.icmp.icmpInDestUnreachs",
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.snmp.icmp.icmpOutDestUnreachs",
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.snmp.icmp.icmpInTimeExcds",
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.snmp.icmp.icmpOutTimeExcds",
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.snmp.icmp.icmpInParmProbs",
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.snmp.icmp.icmpOutParmProbs",
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.snmp.icmp.icmpInSrcQuenchs",
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.snmp.icmp.icmpOutSrcQuenchs",
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.snmp.icmp.icmpInRedirects",
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.snmp.icmp.icmpOutRedirects",
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 */
}
2 changes: 2 additions & 0 deletions pcp_def_metrics.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ void pcp_def_net_nfs_metrics(void);
void pcp_def_net_nfsd_metrics(void);
void pcp_def_net_ip_metrics(void);
void pcp_def_net_eip_metrics(void);
void pcp_def_net_icmp_metrics(void);
void pcp_def_net_eicmp_metrics(void);

/* Define domains number */
#define PM_INDOM_CPU 0
Expand Down
149 changes: 149 additions & 0 deletions pcp_stats.c
Original file line number Diff line number Diff line change
Expand Up @@ -1012,3 +1012,152 @@ __print_funct_t pcp_print_net_eip_stats(struct activity *a, int curr, unsigned l
pmiPutValue("network.snmp.ip.ipFragFails", NULL, buf);
#endif /* HAVE_PCP */
}

/*
***************************************************************************
* Display ICMP network 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_icmp_stats(struct activity *a, int curr, unsigned long long itv,
struct record_header *record_hdr)
{
#ifdef HAVE_PCP
char buf[64];
struct stats_net_icmp
*snic = (struct stats_net_icmp *) a->buf[curr],
*snip = (struct stats_net_icmp *) a->buf[!curr];

snprintf(buf, sizeof(buf), "%f",
S_VALUE(snip->InMsgs, snic->InMsgs, itv));
pmiPutValue("network.snmp.icmp.icmpInMsgs", NULL, buf);

snprintf(buf, sizeof(buf), "%f",
S_VALUE(snip->OutMsgs, snic->OutMsgs, itv));
pmiPutValue("network.snmp.icmp.icmpOutMsgs", NULL, buf);

snprintf(buf, sizeof(buf), "%f",
S_VALUE(snip->InEchos, snic->InEchos, itv));
pmiPutValue("network.snmp.icmp.icmpInEchos", NULL, buf);

snprintf(buf, sizeof(buf), "%f",
S_VALUE(snip->InEchoReps, snic->InEchoReps, itv));
pmiPutValue("network.snmp.icmp.icmpInEchoReps", NULL, buf);

snprintf(buf, sizeof(buf), "%f",
S_VALUE(snip->OutEchos, snic->OutEchos, itv));
pmiPutValue("network.snmp.icmp.icmpOutEchos", NULL, buf);

snprintf(buf, sizeof(buf), "%f",
S_VALUE(snip->OutEchoReps, snic->OutEchoReps, itv));
pmiPutValue("network.snmp.icmp.icmpOutEchoReps", NULL, buf);

snprintf(buf, sizeof(buf), "%f",
S_VALUE(snip->InTimestamps, snic->InTimestamps, itv));
pmiPutValue("network.snmp.icmp.icmpInTimestamps", NULL, buf);

snprintf(buf, sizeof(buf), "%f",
S_VALUE(snip->InTimestampReps, snic->InTimestampReps, itv));
pmiPutValue("network.snmp.icmp.icmpInTimestampReps", NULL, buf);

snprintf(buf, sizeof(buf), "%f",
S_VALUE(snip->OutTimestamps, snic->OutTimestamps, itv));
pmiPutValue("network.snmp.icmp.icmpOutTimestamps", NULL, buf);

snprintf(buf, sizeof(buf), "%f",
S_VALUE(snip->OutTimestampReps, snic->OutTimestampReps, itv));
pmiPutValue("network.snmp.icmp.icmpOutTimestampReps", NULL, buf);

snprintf(buf, sizeof(buf), "%f",
S_VALUE(snip->InAddrMasks, snic->InAddrMasks, itv));
pmiPutValue("network.snmp.icmp.icmpInAddrMasks", NULL, buf);

snprintf(buf, sizeof(buf), "%f",
S_VALUE(snip->InAddrMaskReps, snic->InAddrMaskReps, itv));
pmiPutValue("network.snmp.icmp.icmpInAddrMaskReps", NULL, buf);

snprintf(buf, sizeof(buf), "%f",
S_VALUE(snip->OutAddrMasks, snic->OutAddrMasks, itv));
pmiPutValue("network.snmp.icmp.icmpOutAddrMasks", NULL, buf);

snprintf(buf, sizeof(buf), "%f",
S_VALUE(snip->OutAddrMaskReps, snic->OutAddrMaskReps, itv));
pmiPutValue("network.snmp.icmp.icmpOutAddrMaskReps", NULL, buf);
#endif /* HAVE_PCP */
}


/*
***************************************************************************
* Display ICMP network errors 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_eicmp_stats(struct activity *a, int curr, unsigned long long itv,
struct record_header *record_hdr)
{
#ifdef HAVE_PCP
char buf[64];
struct stats_net_eicmp
*sneic = (struct stats_net_eicmp *) a->buf[curr],
*sneip = (struct stats_net_eicmp *) a->buf[!curr];

snprintf(buf, sizeof(buf), "%f",
S_VALUE(sneip->InErrors, sneic->InErrors, itv));
pmiPutValue("network.snmp.icmp.icmpInErrors", NULL, buf);

snprintf(buf, sizeof(buf), "%f",
S_VALUE(sneip->OutErrors, sneic->OutErrors, itv));
pmiPutValue("network.snmp.icmp.icmpOutErrors", NULL, buf);

snprintf(buf, sizeof(buf), "%f",
S_VALUE(sneip->InDestUnreachs, sneic->InDestUnreachs, itv));
pmiPutValue("network.snmp.icmp.icmpInDestUnreachs", NULL, buf);

snprintf(buf, sizeof(buf), "%f",
S_VALUE(sneip->OutDestUnreachs, sneic->OutDestUnreachs, itv));
pmiPutValue("network.snmp.icmp.icmpOutDestUnreachs", NULL, buf);

snprintf(buf, sizeof(buf), "%f",
S_VALUE(sneip->InTimeExcds, sneic->InTimeExcds, itv));
pmiPutValue("network.snmp.icmp.icmpInTimeExcds", NULL, buf);

snprintf(buf, sizeof(buf), "%f",
S_VALUE(sneip->OutTimeExcds, sneic->OutTimeExcds, itv));
pmiPutValue("network.snmp.icmp.icmpOutTimeExcds", NULL, buf);

snprintf(buf, sizeof(buf), "%f",
S_VALUE(sneip->InParmProbs, sneic->InParmProbs, itv));
pmiPutValue("network.snmp.icmp.icmpInParmProbs", NULL, buf);

snprintf(buf, sizeof(buf), "%f",
S_VALUE(sneip->OutParmProbs, sneic->OutParmProbs, itv));
pmiPutValue("network.snmp.icmp.icmpOutParmProbs", NULL, buf);

snprintf(buf, sizeof(buf), "%f",
S_VALUE(sneip->InSrcQuenchs, sneic->InSrcQuenchs, itv));
pmiPutValue("network.snmp.icmp.icmpInSrcQuenchs", NULL, buf);

snprintf(buf, sizeof(buf), "%f",
S_VALUE(sneip->OutSrcQuenchs, sneic->OutSrcQuenchs, itv));
pmiPutValue("network.snmp.icmp.icmpOutSrcQuenchs", NULL, buf);

snprintf(buf, sizeof(buf), "%f",
S_VALUE(sneip->InRedirects, sneic->InRedirects, itv));
pmiPutValue("network.snmp.icmp.icmpInRedirects", NULL, buf);

snprintf(buf, sizeof(buf), "%f",
S_VALUE(sneip->OutRedirects, sneic->OutRedirects, itv));
pmiPutValue("network.snmp.icmp.icmpOutRedirects", NULL, buf);
#endif /* HAVE_PCP */
}
4 changes: 4 additions & 0 deletions pcp_stats.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,9 @@ __print_funct_t pcp_print_net_ip_stats
(struct activity *, int, unsigned long long, struct record_header *);
__print_funct_t pcp_print_net_eip_stats
(struct activity *, int, unsigned long long, struct record_header *);
__print_funct_t pcp_print_net_icmp_stats
(struct activity *, int, unsigned long long, struct record_header *);
__print_funct_t pcp_print_net_eicmp_stats
(struct activity *, int, unsigned long long, struct record_header *);

#endif /* _PCP_STATS_H */
8 changes: 8 additions & 0 deletions sadf_misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,14 @@ __printf_funct_t print_pcp_statistics(int *tab, int action, struct activity *act
case A_NET_EIP:
pcp_def_net_eip_metrics();
break;

case A_NET_ICMP:
pcp_def_net_icmp_metrics();
break;

case A_NET_EICMP:
pcp_def_net_eicmp_metrics();
break;
}
}
}
Expand Down

0 comments on commit 4e2b842

Please sign in to comment.