]> granicus.if.org Git - sysstat/commitdiff
sar: Add softnet statistics (part 1): Basic definitions and structures
authorSebastien GODARD <sysstat@users.noreply.github.com>
Fri, 14 Oct 2016 13:35:18 +0000 (15:35 +0200)
committerSebastien GODARD <sysstat@users.noreply.github.com>
Fri, 14 Oct 2016 13:35:18 +0000 (15:35 +0200)
Add new switch (-n SOFT) to sar. This option will tell sar to parse
/proc/net/softnet_stat file and display corresponding software-based
network processing statistics.
This first patch defines the needed structures, constants and functions
prototypes.
sar's help message is also updated.

Signed-off-by: Sebastien GODARD <sysstat@users.noreply.github.com>
16 files changed:
activity.c
json_stats.c
json_stats.h
pr_stats.c
pr_stats.h
rd_stats.h
rndr_stats.c
rndr_stats.h
sa.h
sa_common.c
sa_wrap.c
sar.c
svg_stats.c
svg_stats.h
xml_stats.c
xml_stats.h

index db51517ba21977b37c24796744e9d2f15425b852..e087e8d69e70a61b3073ec513ea3e10d50131303 100644 (file)
@@ -1413,7 +1413,7 @@ struct activity filesystem_act = {
 /* Fibre Channel HBA usage activity */
 struct activity fchost_act = {
        .id             = A_NET_FC,
-       .options        = AO_CLOSE_MARKUP + AO_GRAPH_PER_ITEM,
+       .options        = AO_GRAPH_PER_ITEM,
        .magic          = ACTIVITY_MAGIC_BASE,
        .group          = G_DISK,
 #ifdef SOURCE_SADC
@@ -1446,6 +1446,42 @@ struct activity fchost_act = {
        .bitmap         = NULL
 };
 
+/* Softnet activity */
+struct activity softnet_act = {
+       .id             = A_NET_SOFT,
+       .options        = AO_CLOSE_MARKUP + AO_GRAPH_PER_ITEM,
+       .magic          = ACTIVITY_MAGIC_BASE,
+       .group          = G_DEFAULT,
+#ifdef SOURCE_SADC
+       .f_count_index  = 0,    /* wrap_get_cpu_nr() */
+       .f_count2       = NULL,
+       .f_read         = wrap_read_softnet,
+#endif
+#ifdef SOURCE_SAR
+       .f_print        = print_softnet_stats,
+       .f_print_avg    = print_softnet_stats,
+#endif
+#if defined(SOURCE_SAR) || defined(SOURCE_SADF)
+       .hdr_line       = "CPU;total/s;dropd/s;squeezd/s;rx_rps/s;flw_lim/s",
+#endif
+#ifdef SOURCE_SADF
+       .f_render       = render_softnet_stats,
+       .f_xml_print    = xml_print_softnet_stats,
+       .f_json_print   = json_print_softnet_stats,
+       .f_svg_print    = svg_print_softnet_stats,
+       .name           = "A_NET_SOFT",
+       .g_nr           = 2,
+#endif
+       .nr             = -1,
+       .nr2            = 1,
+       .nr_max         = NR_CPUS,
+       .fsize          = STATS_SOFTNET_SIZE,
+       .msize          = STATS_SOFTNET_SIZE,
+       .opt_flags      = 0,
+       .buf            = {NULL, NULL, NULL},
+       .bitmap         = NULL
+};
+
 #ifdef SOURCE_SADC
 /*
  * Array of functions used to count number of items.
@@ -1501,7 +1537,8 @@ struct activity *act[NR_ACT] = {
        &net_icmp6_act,
        &net_eicmp6_act,
        &net_udp6_act,
-       &fchost_act,            /* AO_CLOSE_MARKUP */
+       &fchost_act,
+       &softnet_act,   /* AO_CLOSE_MARKUP */
        /* </network> */
        /* <power-management> */
        &pwr_cpufreq_act,
index f45254ec0b38f31b63fefa3c495fecd7d5509211..b0ba12e17f730b8bb7a97b669daacf371dcdfeae 100644 (file)
@@ -2233,3 +2233,30 @@ close_json_markup:
                json_markup_network(tab, CLOSE_JSON_MARKUP);
        }
 }
+
+/*
+ ***************************************************************************
+ * Display softnet statistics in JSON.
+ *
+ * IN:
+ * @a          Activity structure with statistics.
+ * @curr       Index in array for current sample statistics.
+ * @tab                Indentation in output.
+ * @itv                Interval of time in jiffies.
+ ***************************************************************************
+ */
+__print_funct_t json_print_softnet_stats(struct activity *a, int curr, int tab,
+                                        unsigned long long itv)
+{
+       if (!IS_SELECTED(a->options) || (a->nr <= 0))
+               goto close_json_markup;
+
+       json_markup_network(tab, OPEN_JSON_MARKUP);
+
+       /* FIXME */
+
+close_json_markup:
+       if (CLOSE_MARKUP(a->options)) {
+               json_markup_network(tab, CLOSE_JSON_MARKUP);
+       }
+}
index 086ee7bfec29ac944202bf819ab2a0a046be9979..c5eed2b5d2e25322f67d48490e93f85a0e2a63e0 100644 (file)
@@ -91,5 +91,7 @@ __print_funct_t json_print_filesystem_stats
        (struct activity *, int, int, unsigned long long);
 __print_funct_t json_print_fchost_stats
        (struct activity *, int, int, unsigned long long);
+__print_funct_t json_print_softnet_stats
+       (struct activity *, int, int, unsigned long long);
 
 #endif /* _XML_STATS_H */
index ed2761c1148df47dc98514dac2406c14a7db8c9c..c09c9c6184d02996febf8db2e10a14d1a52d543e 100644 (file)
@@ -2725,3 +2725,20 @@ __print_funct_t print_fchost_stats(struct activity *a, int prev, int curr,
                cprintf_in(IS_STR, " %s\n", sfcc->fchost_name, 0);
        }
 }
+
+/*
+ ***************************************************************************
+ * Display softnet statistics.
+ *
+ * IN:
+ * @a          Activity structure with statistics.
+ * @prev       Index in array where stats used as reference are.
+ * @curr       Index in array for current sample statistics.
+ * @itv                Interval of time in jiffies.
+ ***************************************************************************
+ */
+__print_funct_t print_softnet_stats(struct activity *a, int prev, int curr,
+                                   unsigned long long itv)
+{
+       /* FIXME */
+}
index d695d4358a1cbb2b593c70c6afec6eb6b5ba78e9..b90b253936c8c37abe618b6a309aa090d73f1177 100644 (file)
@@ -92,6 +92,8 @@ __print_funct_t print_filesystem_stats
        (struct activity *, int, int, unsigned long long);
 __print_funct_t print_fchost_stats
        (struct activity *, int, int, unsigned long long);
+__print_funct_t print_softnet_stats
+       (struct activity *, int, int, unsigned long long);
 
 /* Functions used to display average statistics */
 __print_funct_t print_avg_memory_stats
index a57e6c5811c25f9418dcb5cb165d1429257a0f67..57d1bdba256f74cbc39fabaa4128fafd3cf1a4d0 100644 (file)
@@ -58,6 +58,7 @@
 #define NET_SOCKSTAT6  "/proc/net/sockstat6"
 #define NET_RPC_NFS    "/proc/net/rpc/nfs"
 #define NET_RPC_NFSD   "/proc/net/rpc/nfsd"
+#define NET_SOFTNET    "/proc/net/softnet_stat"
 #define LOADAVG                "/proc/loadavg"
 #define VMSTAT         "/proc/vmstat"
 #define NET_SNMP       "/proc/net/snmp"
@@ -568,6 +569,17 @@ struct stats_fchost {
 
 #define STATS_FCHOST_SIZE      (sizeof(struct stats_fchost))
 
+/* Structure for softnet statistics */
+struct stats_softnet {
+       unsigned long long processed    __attribute__ ((aligned (16)));
+       unsigned long long dropped      __attribute__ ((aligned (16)));
+       unsigned long long time_squeeze __attribute__ ((aligned (16)));
+       unsigned long long received_rps __attribute__ ((aligned (16)));
+       unsigned long long flow_limit   __attribute__ ((aligned (16)));
+};
+
+#define STATS_SOFTNET_SIZE     (sizeof(struct stats_softnet))
+
 /*
  ***************************************************************************
  * Prototypes for functions used to read system statistics
index f30b668631d2bc59cefd960f66872b1204ad9279..501b31ab1dc19299714d02d0eb0e24e354c790af 100644 (file)
@@ -2984,3 +2984,21 @@ __print_funct_t render_fchost_stats(struct activity *a, int isdb, char *pre,
                       NULL);
        }
 }
+
+/*
+ ***************************************************************************
+ * Display softnet statistics in selected format.
+ *
+ * IN:
+ * @a          Activity structure with statistics.
+ * @isdb       Flag, true if db printing, false if ppc printing.
+ * @pre                Prefix string for output entries
+ * @curr       Index in array for current sample statistics.
+ * @itv                Interval of time in jiffies.
+ ***************************************************************************
+ */
+__print_funct_t render_softnet_stats(struct activity *a, int isdb, char *pre,
+                                    int curr, unsigned long long itv)
+{
+       /* FIXME */
+}
index 12f271485d0aaab4c9e1db352dcc83ed449b8796..a8cf1c22c8c239fdeb5d72faaf33659a64b14506 100644 (file)
@@ -122,5 +122,7 @@ __print_funct_t render_filesystem_stats
        (struct activity *, int, char *, int, unsigned long long);
 __print_funct_t render_fchost_stats
        (struct activity *, int, char *, int, unsigned long long);
+__print_funct_t render_softnet_stats
+       (struct activity *, int, char *, int, unsigned long long);
 
 #endif /* _RNDR_STATS_H */
diff --git a/sa.h b/sa.h
index 2cfb4b58e862f68603133051e049eb3939ad958a..591cf856b059ce33fee79fb296f0959bb3821e83 100644 (file)
--- a/sa.h
+++ b/sa.h
@@ -20,7 +20,7 @@
  */
 
 /* Number of activities */
-#define NR_ACT         38
+#define NR_ACT         39
 /* The value below is used for sanity check */
 #define MAX_NR_ACT     256
 
@@ -66,6 +66,7 @@
 #define A_PWR_USB      36
 #define A_FILESYSTEM   37
 #define A_NET_FC       38
+#define A_NET_SOFT     39
 
 
 /* Macro used to flag an activity that should be collected */
 #define K_FREQ         "FREQ"
 #define K_MOUNT                "MOUNT"
 #define K_FC           "FC"
+#define K_SOFT         "SOFT"
 
 #define K_INT          "INT"
 #define K_DISK         "DISK"
@@ -1068,6 +1070,8 @@ __read_funct_t wrap_read_filesystem
        (struct activity *);
 __read_funct_t wrap_read_fchost
        (struct activity *);
+__read_funct_t wrap_read_softnet
+       (struct activity *);
 
 /* Other functions */
 void allocate_bitmaps
index d8bc089068a76cb6fb94c7dfeb42b9c43b941ab6..e58f0a1fd9ad5925b7718d4bf83997eb14723555 100644 (file)
@@ -1878,6 +1878,9 @@ int parse_sar_n_opt(char *argv[], int *opt, struct activity *act[])
                else if (!strcmp(t, K_FC)) {
                        SELECT_ACTIVITY(A_NET_FC);
                }
+               else if (!strcmp(t, K_SOFT)) {
+                       SELECT_ACTIVITY(A_NET_SOFT);
+               }
                else if (!strcmp(t, K_ALL)) {
                        SELECT_ACTIVITY(A_NET_DEV);
                        SELECT_ACTIVITY(A_NET_EDEV);
@@ -1898,6 +1901,7 @@ int parse_sar_n_opt(char *argv[], int *opt, struct activity *act[])
                        SELECT_ACTIVITY(A_NET_EICMP6);
                        SELECT_ACTIVITY(A_NET_UDP6);
                        SELECT_ACTIVITY(A_NET_FC);
+                       SELECT_ACTIVITY(A_NET_SOFT);
                }
                else
                        return 1;
index 140c5c05f58588d53dae71fd7c79851fbd707493..dc5b6cfa425526771e9cc9356124337d46e8a89d 100644 (file)
--- a/sa_wrap.c
+++ b/sa_wrap.c
@@ -901,6 +901,27 @@ __read_funct_t wrap_read_fchost(struct activity *a)
        return;
 }
 
+/*
+ ***************************************************************************
+ * Read softnet statistics.
+ *
+ * IN:
+ * @a  Activity structure.
+ *
+ * OUT:
+ * @a  Activity structure with statistics.
+ ***************************************************************************
+ */
+__read_funct_t wrap_read_softnet(struct activity *a)
+{
+       struct stats_softnet *st_softnet
+               = (struct stats_softnet *) a->_buf0;
+
+       /* Read softnet stats */
+       /* FIXME */
+
+       return;
+}
 
 /*
  ***************************************************************************
diff --git a/sar.c b/sar.c
index 9c4e7e2f195a2219727dd027ea3eab0f28e0abe7..978460f3ff777c9d33e04944b28b6eb23fa3ca85 100644 (file)
--- a/sar.c
+++ b/sar.c
@@ -170,7 +170,8 @@ void display_help(char *progname)
                 "\t\tICMP6\tICMP traffic\t(v6)\n"
                 "\t\tEICMP6\tICMP traffic\t(v6) (errors)\n"
                 "\t\tUDP6\tUDP traffic\t(v6)\n"
-                "\t\tFC\tFibre channel HBAs\n"));
+                "\t\tFC\tFibre channel HBAs\n"
+                "\t\tSOFT\tSoftware-based network processing\n"));
        printf(_("\t-q\tQueue length and load average statistics\n"));
        printf(_("\t-R\tMemory statistics\n"));
        printf(_("\t-r [ ALL ]\n"
index bcbd83c64b7b53c1f6ba2d88ea1bf81990648ddf..939edb4b86112c4a036e9ab6bed9696e3c185b3b 100644 (file)
@@ -4744,3 +4744,25 @@ __print_funct_t svg_print_fchost_stats(struct activity *a, int curr, int action,
                free_graphs(out, outsize, spmin, spmax);
        }
 }
+
+/*
+ ***************************************************************************
+ * Display softnet 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 (unused here).
+ * @record_hdr Pointer on record header of current stats sample.
+ ***************************************************************************
+ */
+__print_funct_t svg_print_softnet_stats(struct activity *a, int curr, int action, struct svg_parm *svg_p,
+                                       unsigned long long itv, struct record_header *record_hdr)
+{
+       /* FIXME */
+}
index e92749af7c55a7735b51f6391d9164ceadd967cc..0cdbf7649c5360cc0fdd54f1d8f02653e167dd4c 100644 (file)
@@ -116,5 +116,8 @@ __print_funct_t svg_print_filesystem_stats
 __print_funct_t svg_print_fchost_stats
        (struct activity *, int, int, struct svg_parm *, unsigned long long,
         struct record_header *);
+__print_funct_t svg_print_softnet_stats
+       (struct activity *, int, int, struct svg_parm *, unsigned long long,
+        struct record_header *);
        
 #endif /* _SVG_STATS_H */
index 7b57c6de06f47ea9941920f195727022b492fcc1..f18d41b7e45da5762510582a3c7e730e7ed137b1 100644 (file)
@@ -2118,3 +2118,30 @@ close_xml_markup:
                xml_markup_network(tab, CLOSE_XML_MARKUP);
        }
 }
+
+/*
+ ***************************************************************************
+ * Display softnet statistics in XML.
+ *
+ * IN:
+ * @a          Activity structure with statistics.
+ * @curr       Index in array for current sample statistics.
+ * @tab                Indentation in XML output.
+ * @itv                Interval of time in jiffies.
+ ***************************************************************************
+ */
+__print_funct_t xml_print_softnet_stats(struct activity *a, int curr, int tab,
+                                       unsigned long long itv)
+{
+       if (!IS_SELECTED(a->options) || (a->nr <= 0))
+               goto close_xml_markup;
+
+       xml_markup_network(tab, OPEN_XML_MARKUP);
+
+       /* FIXME */
+
+close_xml_markup:
+       if (CLOSE_MARKUP(a->options)) {
+               xml_markup_network(tab, CLOSE_XML_MARKUP);
+       }
+}
index 6ac7deac47d5ce70109839b0ef6ac28ce4748c27..56421954557d4ad3901a862805df5b42520a56b9 100644 (file)
@@ -91,5 +91,7 @@ __print_funct_t xml_print_filesystem_stats
        (struct activity *, int, int, unsigned long long);
 __print_funct_t xml_print_fchost_stats
        (struct activity *, int, int, unsigned long long);
+__print_funct_t xml_print_softnet_stats
+       (struct activity *, int, int, unsigned long long);
 
 #endif /* _XML_STATS_H */