This patch read softnet statistics from the /proc/net/softnet_stat file.
Softnet stats will be collected by default by sadc: So set AO_COLLECTED
flag in corresponding activity structure.
Also metrics' type is unsigned int (%x) and not unsigned long long.
Signed-off-by: Sebastien GODARD <sysstat@users.noreply.github.com>
/* Softnet activity */
struct activity softnet_act = {
.id = A_NET_SOFT,
- .options = AO_CLOSE_MARKUP + AO_GRAPH_PER_ITEM,
+ .options = AO_COLLECTED + AO_CLOSE_MARKUP + AO_GRAPH_PER_ITEM,
.magic = ACTIVITY_MAGIC_BASE,
.group = G_DEFAULT,
#ifdef SOURCE_SADC
#endif
.nr = -1,
.nr2 = 1,
- .nr_max = NR_CPUS,
+ .nr_max = NR_CPUS + 1,
.fsize = STATS_SOFTNET_SIZE,
.msize = STATS_SOFTNET_SIZE,
.opt_flags = 0,
closedir(dir);
}
+/*
+ ***************************************************************************
+ * Read softnet statistics.
+ *
+ * IN:
+ * @st_softnet Structure where stats will be saved.
+ * @nbr Total number of CPU (including cpu "all").
+ *
+ * OUT:
+ * @st_softnet Structure with statistics.
+ ***************************************************************************
+ */
+void read_softnet(struct stats_softnet *st_softnet, int nbr)
+{
+ FILE *fp;
+ struct stats_softnet *st_softnet_i;
+ char line[1024];
+ unsigned int proc_nb = 0;
+
+ if ((fp = fopen(NET_SOFTNET, "r")) == NULL)
+ return;
+
+ while ((fgets(line, sizeof(line), fp) != NULL) && (proc_nb < (nbr - 1))) {
+
+ st_softnet_i = st_softnet + proc_nb++;
+ sscanf(line, "%x %x %x %*x %*x %*x %*x %*x %*x %x %x",
+ &st_softnet_i->processed,
+ &st_softnet_i->dropped,
+ &st_softnet_i->time_squeeze,
+ &st_softnet_i->received_rps,
+ &st_softnet_i->flow_limit);
+ }
+
+ fclose(fp);
+}
+
/*------------------ END: FUNCTIONS USED BY SADC ONLY ---------------------*/
#endif /* SOURCE_SADC */
/* 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)));
+ unsigned int processed __attribute__ ((aligned (4)));
+ unsigned int dropped __attribute__ ((packed));
+ unsigned int time_squeeze __attribute__ ((packed));
+ unsigned int received_rps __attribute__ ((packed));
+ unsigned int flow_limit __attribute__ ((packed));
};
#define STATS_SOFTNET_SIZE (sizeof(struct stats_softnet))
(struct stats_filesystem *, int);
void read_fchost
(struct stats_fchost *, int);
+void read_softnet
+ (struct stats_softnet *, int);
#endif /* _RD_STATS_H */
= (struct stats_softnet *) a->_buf0;
/* Read softnet stats */
- /* FIXME */
+ read_softnet(st_softnet, a->nr);
return;
}