From: Sebastien GODARD Date: Sat, 30 Apr 2016 14:43:13 +0000 (+0200) Subject: SVG: Add SVG output for UDPv4 network statistics X-Git-Tag: v11.3.4~12 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=89835f862f68df881930ee1fda4aea65e893afd5;p=sysstat SVG: Add SVG output for UDPv4 network statistics These graphs correspond to the output of "sar -n UDP". Signed-off-by: Sebastien GODARD --- diff --git a/activity.c b/activity.c index e28f7d9..0043b22 100644 --- a/activity.c +++ b/activity.c @@ -833,9 +833,10 @@ struct activity net_udp_act = { .f_render = render_net_udp_stats, .f_xml_print = xml_print_net_udp_stats, .f_json_print = json_print_net_udp_stats, + .f_svg_print = svg_print_net_udp_stats, .hdr_line = "idgm/s;odgm/s;noport/s;idgmerr/s", .name = "A_NET_UDP", - .g_nr = 0, + .g_nr = 2, #endif .nr = 1, .nr2 = 1, diff --git a/svg_stats.c b/svg_stats.c index f76372c..d361c9b 100644 --- a/svg_stats.c +++ b/svg_stats.c @@ -2145,6 +2145,76 @@ __print_funct_t svg_print_net_tcp_stats(struct activity *a, int curr, int action } } +/* + *************************************************************************** + * Display UDPv4 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 a pointer on a record header structure + * (.@record_hdr) containing the first stats sample. + * @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_udp_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_udp + *snuc = (struct stats_net_udp *) a->buf[curr], + *snup = (struct stats_net_udp *) a->buf[!curr]; + int group[] = {2, 2}; + char *title[] = {"UDPv4 network statistics (1)", "UDPv4 network statistics (2)"}; + char *g_title[] = {"idgm/s", "odgm/s", + "noport/s", "idgmerr/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(4, &outsize, &spmin, &spmax); + } + + if (action & F_MAIN) { + /* Check for min/max values */ + save_extrema(0, 4, 0, (void *) a->buf[curr], (void *) a->buf[!curr], + itv, spmin, spmax); + + /* idgm/s */ + lnappend(record_hdr->ust_time - svg_p->record_hdr->ust_time, + S_VALUE(snup->InDatagrams, snuc->InDatagrams, itv), + out, outsize, svg_p->restart); + /* odgm/s */ + lnappend(record_hdr->ust_time - svg_p->record_hdr->ust_time, + S_VALUE(snup->OutDatagrams, snuc->OutDatagrams, itv), + out + 1, outsize + 1, svg_p->restart); + /* noport/s */ + lnappend(record_hdr->ust_time - svg_p->record_hdr->ust_time, + S_VALUE(snup->NoPorts, snuc->NoPorts, itv), + out + 2, outsize + 2, svg_p->restart); + /* idgmerr/s */ + lnappend(record_hdr->ust_time - svg_p->record_hdr->ust_time, + S_VALUE(snup->InErrors, snuc->InErrors, itv), + out + 3, outsize + 3, 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 IPV6 network socket statistics in SVG. diff --git a/svg_stats.h b/svg_stats.h index 48be0c2..1e8031b 100644 --- a/svg_stats.h +++ b/svg_stats.h @@ -50,6 +50,9 @@ __print_funct_t svg_print_net_ip_stats __print_funct_t svg_print_net_tcp_stats (struct activity *, int, int, struct svg_parm *, unsigned long long, struct record_header *); +__print_funct_t svg_print_net_udp_stats + (struct activity *, int, int, struct svg_parm *, unsigned long long, + struct record_header *); __print_funct_t svg_print_net_sock6_stats (struct activity *, int, int, struct svg_parm *, unsigned long long, struct record_header *);