From: Sebastien GODARD Date: Fri, 3 Jun 2016 08:11:39 +0000 (+0200) Subject: SVG: Add SVG output for ICMPv4 network statistics X-Git-Tag: v11.3.5~23 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0c5ba1399985f230a3172131c57ec90ac613724a;p=sysstat SVG: Add SVG output for ICMPv4 network statistics These graphs correspond to the output of "sar -n ICMP". Signed-off-by: Sebastien GODARD --- diff --git a/activity.c b/activity.c index dfb8617..b2a25b4 100644 --- a/activity.c +++ b/activity.c @@ -698,10 +698,11 @@ struct activity net_icmp_act = { .f_render = render_net_icmp_stats, .f_xml_print = xml_print_net_icmp_stats, .f_json_print = json_print_net_icmp_stats, + .f_svg_print = svg_print_net_icmp_stats, .hdr_line = "imsg/s;omsg/s;iech/s;iechr/s;oech/s;oechr/s;itm/s;itmr/s;otm/s;" "otmr/s;iadrmk/s;iadrmkr/s;oadrmk/s;oadrmkr/s", .name = "A_NET_ICMP", - .g_nr = 0, + .g_nr = 4, #endif .nr = 1, .nr2 = 1, diff --git a/svg_stats.c b/svg_stats.c index c1ff5de..488b940 100644 --- a/svg_stats.c +++ b/svg_stats.c @@ -2149,6 +2149,119 @@ __print_funct_t svg_print_net_ip_stats(struct activity *a, int curr, int action, } } +/* + *************************************************************************** + * Display ICMPv4 network statistics in SVG. + * + * IN: + * @a Activity structure with statistics. + * @curr Index in array for current sample statistics. + * @action Action expected from current function. + * @svg_p SVG specific parameters: Current graph number (.@graph_no), + * flag indicating that a restart record has been previously + * found (.@restart) and time used for the X axis origin + * (@ust_time_ref). + * @itv Interval of time in jiffies (only with F_MAIN action). + * @record_hdr Pointer on record header of current stats sample. + *************************************************************************** + */ +__print_funct_t svg_print_net_icmp_stats(struct activity *a, int curr, int action, struct svg_parm *svg_p, + unsigned long long itv, struct record_header *record_hdr) +{ + struct stats_net_icmp + *snic = (struct stats_net_icmp *) a->buf[curr], + *snip = (struct stats_net_icmp *) a->buf[!curr]; + int group[] = {2, 4, 4, 4}; + char *title[] = {"ICMPv4 network statistics (1)", "ICMPv4 network statistics (2)", + "ICMPv4 network statistics (3)", "ICMPv4 network statistics (4)"}; + char *g_title[] = {"imsg/s", "omsg/s", + "iech/s", "iechr/s", "oech/s", "oechr/s", + "itm/s", "itmr/s", "otm/s", "otmr/s", + "iadrmk/s", "iadrmkr/s", "oadrmk/s", "oadrmkr/s"}; + static double *spmin, *spmax; + static char **out; + static int *outsize; + + if (action & F_BEGIN) { + /* + * Allocate arrays that will contain the graphs data + * and the min/max values. + */ + out = allocate_graph_lines(14, &outsize, &spmin, &spmax); + } + + if (action & F_MAIN) { + /* Check for min/max values */ + save_extrema(0, 14, 0, (void *) a->buf[curr], (void *) a->buf[!curr], + itv, spmin, spmax); + + /* imsg/s */ + lnappend(record_hdr->ust_time - svg_p->ust_time_ref, + S_VALUE(snip->InMsgs, snic->InMsgs, itv), + out, outsize, svg_p->restart); + /* omsg/s */ + lnappend(record_hdr->ust_time - svg_p->ust_time_ref, + S_VALUE(snip->OutMsgs, snic->OutMsgs, itv), + out + 1, outsize + 1, svg_p->restart); + /* iech/s */ + lnappend(record_hdr->ust_time - svg_p->ust_time_ref, + S_VALUE(snip->InEchos, snic->InEchos, itv), + out + 2, outsize + 2, svg_p->restart); + /* iechr/s */ + lnappend(record_hdr->ust_time - svg_p->ust_time_ref, + S_VALUE(snip->InEchoReps, snic->InEchoReps, itv), + out + 3, outsize + 3, svg_p->restart); + /* oech/s */ + lnappend(record_hdr->ust_time - svg_p->ust_time_ref, + S_VALUE(snip->OutEchos, snic->OutEchos, itv), + out + 4, outsize + 4, svg_p->restart); + /* oechr/s */ + lnappend(record_hdr->ust_time - svg_p->ust_time_ref, + S_VALUE(snip->OutEchoReps, snic->OutEchoReps, itv), + out + 5, outsize + 5, svg_p->restart); + /* itm/s */ + lnappend(record_hdr->ust_time - svg_p->ust_time_ref, + S_VALUE(snip->InTimestamps, snic->InTimestamps, itv), + out + 6, outsize + 6, svg_p->restart); + /* itmr/s */ + lnappend(record_hdr->ust_time - svg_p->ust_time_ref, + S_VALUE(snip->InTimestampReps, snic->InTimestampReps, itv), + out + 7, outsize + 7, svg_p->restart); + /* otm/s */ + lnappend(record_hdr->ust_time - svg_p->ust_time_ref, + S_VALUE(snip->OutTimestamps, snic->OutTimestamps, itv), + out + 8, outsize + 8, svg_p->restart); + /* otmr/s */ + lnappend(record_hdr->ust_time - svg_p->ust_time_ref, + S_VALUE(snip->OutTimestampReps, snic->OutTimestampReps, itv), + out + 9, outsize + 9, svg_p->restart); + /* iadrmk/s */ + lnappend(record_hdr->ust_time - svg_p->ust_time_ref, + S_VALUE(snip->InAddrMasks, snic->InAddrMasks, itv), + out + 10, outsize + 10, svg_p->restart); + /* iadrmkr/s */ + lnappend(record_hdr->ust_time - svg_p->ust_time_ref, + S_VALUE(snip->InAddrMaskReps, snic->InAddrMaskReps, itv), + out + 11, outsize + 11, svg_p->restart); + /* oadrmk/s */ + lnappend(record_hdr->ust_time - svg_p->ust_time_ref, + S_VALUE(snip->OutAddrMasks, snic->OutAddrMasks, itv), + out + 12, outsize + 12, svg_p->restart); + /* oadrmkr/s */ + lnappend(record_hdr->ust_time - svg_p->ust_time_ref, + S_VALUE(snip->OutAddrMaskReps, snic->OutAddrMaskReps, itv), + out + 13, outsize + 13, svg_p->restart); + } + + if (action & F_END) { + draw_activity_graphs(a->g_nr, SVG_LINE_GRAPH, title, g_title, NULL, group, + spmin, spmax, out, outsize, svg_p, record_hdr); + + /* Free remaining structures */ + free_graphs(out, outsize, spmin, spmax); + } +} + /* *************************************************************************** * Display TCPv4 network statistics in SVG. diff --git a/svg_stats.h b/svg_stats.h index 1e8031b..2191aa3 100644 --- a/svg_stats.h +++ b/svg_stats.h @@ -47,6 +47,9 @@ __print_funct_t svg_print_net_sock_stats __print_funct_t svg_print_net_ip_stats (struct activity *, int, int, struct svg_parm *, unsigned long long, struct record_header *); +__print_funct_t svg_print_net_icmp_stats + (struct activity *, int, int, struct svg_parm *, unsigned long long, + struct record_header *); __print_funct_t svg_print_net_tcp_stats (struct activity *, int, int, struct svg_parm *, unsigned long long, struct record_header *);