Skip to content

Commit

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

Signed-off-by: Sebastien GODARD <[email protected]>
  • Loading branch information
sysstat committed Mar 29, 2019
1 parent 1f94de0 commit dcf740a
Show file tree
Hide file tree
Showing 6 changed files with 208 additions and 0 deletions.
2 changes: 2 additions & 0 deletions activity.c
Original file line number Diff line number Diff line change
Expand Up @@ -831,6 +831,7 @@ struct activity net_ip_act = {
.f_json_print = json_print_net_ip_stats,
.f_svg_print = svg_print_net_ip_stats,
.f_raw_print = raw_print_net_ip_stats,
.f_pcp_print = pcp_print_net_ip_stats,
.f_count_new = NULL,
.item_list = NULL,
.desc = "IPv4 traffic statistics",
Expand Down Expand Up @@ -876,6 +877,7 @@ struct activity net_eip_act = {
.f_json_print = json_print_net_eip_stats,
.f_svg_print = svg_print_net_eip_stats,
.f_raw_print = raw_print_net_eip_stats,
.f_pcp_print = pcp_print_net_eip_stats,
.f_count_new = NULL,
.item_list = NULL,
.desc = "IPv4 traffic errors statistics",
Expand Down
84 changes: 84 additions & 0 deletions pcp_def_metrics.c
Original file line number Diff line number Diff line change
Expand Up @@ -686,3 +686,87 @@ void pcp_def_net_nfsd_metrics(void)
pmiUnits(0, -1, 1, 0, PM_TIME_SEC, PM_COUNT_ONE));
#endif /* HAVE_PCP */
}

/*
***************************************************************************
* Define PCP metrics for IP network statistics.
***************************************************************************
*/
void pcp_def_net_ip_metrics(void)
{
#ifdef HAVE_PCP
pmiAddMetric("network.snmp.ip.ipInReceives",
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.ip.ipForwDatagrams",
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.ip.ipInDelivers",
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.ip.ipOutRequests",
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.ip.ipReasmReqds",
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.ip.ipReasmOKs",
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.ip.ipFragOKs",
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.ip.ipFragCreates",
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 IP network errors statistics.
***************************************************************************
*/
void pcp_def_net_eip_metrics(void)
{
#ifdef HAVE_PCP
pmiAddMetric("network.snmp.ip.ipInHdrErrors",
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.ip.ipInAddrErrors",
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.ip.ipInUnknownProtos",
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.ip.ipInDiscards",
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.ip.ipOutDiscards",
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.ip.ipOutNoRoutes",
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.ip.ipReasmFails",
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.ip.ipFragFails",
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 @@ -25,6 +25,8 @@ 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);
void pcp_def_net_ip_metrics(void);
void pcp_def_net_eip_metrics(void);

/* Define domains number */
#define PM_INDOM_CPU 0
Expand Down
108 changes: 108 additions & 0 deletions pcp_stats.c
Original file line number Diff line number Diff line change
Expand Up @@ -904,3 +904,111 @@ __print_funct_t pcp_print_net_nfsd_stats(struct activity *a, int curr, unsigned
pmiPutValue("network.fs.server.getattr", NULL, buf);
#endif /* HAVE_PCP */
}

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

snprintf(buf, sizeof(buf), "%f",
S_VALUE(snip->InReceives, snic->InReceives, itv));
pmiPutValue("network.snmp.ip.ipInReceives", NULL, buf);

snprintf(buf, sizeof(buf), "%f",
S_VALUE(snip->ForwDatagrams, snic->ForwDatagrams, itv));
pmiPutValue("network.snmp.ip.ipForwDatagrams", NULL, buf);

snprintf(buf, sizeof(buf), "%f",
S_VALUE(snip->InDelivers, snic->InDelivers, itv));
pmiPutValue("network.snmp.ip.ipInDelivers", NULL, buf);

snprintf(buf, sizeof(buf), "%f",
S_VALUE(snip->OutRequests, snic->OutRequests, itv));
pmiPutValue("network.snmp.ip.ipOutRequests", NULL, buf);

snprintf(buf, sizeof(buf), "%f",
S_VALUE(snip->ReasmReqds, snic->ReasmReqds, itv));
pmiPutValue("network.snmp.ip.ipReasmReqds", NULL, buf);

snprintf(buf, sizeof(buf), "%f",
S_VALUE(snip->ReasmOKs, snic->ReasmOKs, itv));
pmiPutValue("network.snmp.ip.ipReasmOKs", NULL, buf);

snprintf(buf, sizeof(buf), "%f",
S_VALUE(snip->FragOKs, snic->FragOKs, itv));
pmiPutValue("network.snmp.ip.ipFragOKs", NULL, buf);

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

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

snprintf(buf, sizeof(buf), "%f",
S_VALUE(sneip->InHdrErrors, sneic->InHdrErrors, itv));
pmiPutValue("network.snmp.ip.ipInHdrErrors", NULL, buf);

snprintf(buf, sizeof(buf), "%f",
S_VALUE(sneip->InAddrErrors, sneic->InAddrErrors, itv));
pmiPutValue("network.snmp.ip.ipInAddrErrors", NULL, buf);

snprintf(buf, sizeof(buf), "%f",
S_VALUE(sneip->InUnknownProtos, sneic->InUnknownProtos, itv));
pmiPutValue("network.snmp.ip.ipInUnknownProtos", NULL, buf);

snprintf(buf, sizeof(buf), "%f",
S_VALUE(sneip->InDiscards, sneic->InDiscards, itv));
pmiPutValue("network.snmp.ip.ipInDiscards", NULL, buf);

snprintf(buf, sizeof(buf), "%f",
S_VALUE(sneip->OutDiscards, sneic->OutDiscards, itv));
pmiPutValue("network.snmp.ip.ipOutDiscards", NULL, buf);

snprintf(buf, sizeof(buf), "%f",
S_VALUE(sneip->OutNoRoutes, sneic->OutNoRoutes, itv));
pmiPutValue("network.snmp.ip.ipOutNoRoutes", NULL, buf);

snprintf(buf, sizeof(buf), "%f",
S_VALUE(sneip->ReasmFails, sneic->ReasmFails, itv));
pmiPutValue("network.snmp.ip.ipReasmFails", NULL, buf);

snprintf(buf, sizeof(buf), "%f",
S_VALUE(sneip->FragFails, sneic->FragFails, itv));
pmiPutValue("network.snmp.ip.ipFragFails", 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 @@ -41,5 +41,9 @@ __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 *);
__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 *);

#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 @@ -549,6 +549,14 @@ __printf_funct_t print_pcp_statistics(int *tab, int action, struct activity *act
case A_NET_NFSD:
pcp_def_net_nfsd_metrics();
break;

case A_NET_IP:
pcp_def_net_ip_metrics();
break;

case A_NET_EIP:
pcp_def_net_eip_metrics();
break;
}
}
}
Expand Down

0 comments on commit dcf740a

Please sign in to comment.