struct stats_softnet *ssnc, *ssnp;
int sep = FALSE;
char cpuno[8];
+ unsigned char offline_cpu_bitmap[BITMAP_SIZE(NR_CPUS)] = {0};
if (!IS_SELECTED(a->options) || (a->nr[curr] <= 0))
goto close_json_markup;
xprintf(tab++, "\"softnet\": [");
- for (i = 0; (i < a->nr[curr]) && (i < a->bitmap->b_size + 1); i++) {
+ /* @nr[curr] cannot normally be greater than @nr_ini */
+ if (a->nr[curr] > a->nr_ini) {
+ a->nr_ini = a->nr[curr];
+ }
- /*
- * The size of a->buf[...] CPU structure may be different from the default
- * sizeof(struct stats_pwr_cpufreq) value if data have been read from a file!
- * That's why we don't use a syntax like:
- * ssnc = (struct stats_softnet *) a->buf[...] + i;
- */
- ssnc = (struct stats_softnet *) ((char *) a->buf[curr] + i * a->msize);
- ssnp = (struct stats_softnet *) ((char *) a->buf[!curr] + i * a->msize);
+ /* Compute statistics for CPU "all" */
+ get_global_soft_statistics(a, !curr, curr, flags, offline_cpu_bitmap);
+
+ for (i = 0; (i < a->nr_ini) && (i < a->bitmap->b_size + 1); i++) {
/*
+ * Should current CPU (including CPU "all") be displayed?
* Note: a->nr is in [1, NR_CPUS + 1].
* Bitmap size is provided for (NR_CPUS + 1) CPUs.
* Anyway, NR_CPUS may vary between the version of sysstat
* used by sadc to create a file, and the version of sysstat
* used by sar to read it...
*/
-
- /* Should current CPU (including CPU "all") be displayed? */
- if (!(a->bitmap->b_array[i >> 3] & (1 << (i & 0x07))))
+ if (!(a->bitmap->b_array[i >> 3] & (1 << (i & 0x07))) ||
+ offline_cpu_bitmap[i >> 3] & (1 << (i & 0x07)))
/* No */
continue;
- /* Yes: Display current CPU stats */
+ /*
+ * The size of a->buf[...] CPU structure may be different from the default
+ * sizeof(struct stats_pwr_cpufreq) value if data have been read from a file!
+ * That's why we don't use a syntax like:
+ * ssnc = (struct stats_softnet *) a->buf[...] + i;
+ */
+ ssnc = (struct stats_softnet *) ((char *) a->buf[curr] + i * a->msize);
+ ssnp = (struct stats_softnet *) ((char *) a->buf[!curr] + i * a->msize);
if (sep) {
printf(",\n");
int i;
struct stats_softnet *ssnc, *ssnp;
- for (i = 0; (i < a->nr[curr]) && (i < a->bitmap->b_size + 1); i++) {
+ /* @nr[curr] cannot normally be greater than @nr_ini */
+ if (a->nr[curr] > a->nr_ini) {
+ a->nr_ini = a->nr[curr];
+ }
+
+ /* Don't display CPU "all" which doesn't exist in file */
+ for (i = 1; (i < a->nr_ini) && (i < a->bitmap->b_size + 1); i++) {
/*
* The size of a->buf[...] CPU structure may be different from the default
continue;
/* Yes: Display current CPU stats */
- printf("%s; %s; %d;", timestr, pfield(a->hdr_line, FIRST), i - 1);
+ printf("%s; %s", timestr, pfield(a->hdr_line, FIRST));
+ if (DISPLAY_DEBUG_MODE(flags) && i) {
+ if (ssnc->processed + ssnc->dropped + ssnc->time_squeeze +
+ ssnc->received_rps + ssnc->flow_limit == 0) {
+ /* CPU is considered offline */
+ printf(" [OFF]");
+ }
+ }
+ printf("; %d;", i - 1);
+
printf(" %s", pfield(NULL, 0));
pval((unsigned long long) ssnp->processed, (unsigned long long) ssnc->processed);
printf(" %s", pfield(NULL, 0));
{
int i;
struct stats_softnet *ssnc, *ssnp;
+ unsigned char offline_cpu_bitmap[BITMAP_SIZE(NR_CPUS)] = {0};
int pt_newlin
= (DISPLAY_HORIZONTALLY(flags) ? PT_NOFLAG : PT_NEWLIN);
- for (i = 0; (i < a->nr[curr]) && (i < a->bitmap->b_size + 1); i++) {
+ /* @nr[curr] cannot normally be greater than @nr_ini */
+ if (a->nr[curr] > a->nr_ini) {
+ a->nr_ini = a->nr[curr];
+ }
- /*
- * The size of a->buf[...] CPU structure may be different from the default
- * sizeof(struct stats_pwr_cpufreq) value if data have been read from a file!
- * That's why we don't use a syntax like:
- * ssnc = (struct stats_softnet *) a->buf[...] + i;
- */
- ssnc = (struct stats_softnet *) ((char *) a->buf[curr] + i * a->msize);
- ssnp = (struct stats_softnet *) ((char *) a->buf[!curr] + i * a->msize);
+ /* Compute statistics for CPU "all" */
+ get_global_soft_statistics(a, !curr, curr, flags, offline_cpu_bitmap);
+
+ for (i = 0; (i < a->nr_ini) && (i < a->bitmap->b_size + 1); i++) {
/*
* Note: a->nr is in [1, NR_CPUS + 1].
* used by sadc to create a file, and the version of sysstat
* used by sar to read it...
*/
-
- /* Should current CPU (including CPU "all") be displayed? */
- if (!(a->bitmap->b_array[i >> 3] & (1 << (i & 0x07))))
+ if (!(a->bitmap->b_array[i >> 3] & (1 << (i & 0x07))) ||
+ offline_cpu_bitmap[i >> 3] & (1 << (i & 0x07)))
/* No */
continue;
+ /*
+ * The size of a->buf[...] CPU structure may be different from the default
+ * sizeof(struct stats_pwr_cpufreq) value if data have been read from a file!
+ * That's why we don't use a syntax like:
+ * ssnc = (struct stats_softnet *) a->buf[...] + i;
+ */
+ ssnc = (struct stats_softnet *) ((char *) a->buf[curr] + i * a->msize);
+ ssnp = (struct stats_softnet *) ((char *) a->buf[!curr] + i * a->msize);
+
if (!i) {
/* This is CPU "all" */
render(isdb, pre, PT_NOFLAG,
static char **out;
static int *outsize;
char item_name[8];
+ unsigned char offline_cpu_bitmap[BITMAP_SIZE(NR_CPUS)] = {0};
int i, pos;
if (action & F_BEGIN) {
}
if (action & F_MAIN) {
- /* For each CPU */
- for (i = 0; (i < a->nr[curr]) && (i < a->bitmap->b_size + 1); i++) {
+ /* @nr[curr] cannot normally be greater than @nr_ini */
+ if (a->nr[curr] > a->nr_ini) {
+ a->nr_ini = a->nr[curr];
+ }
- ssnc = (struct stats_softnet *) ((char *) a->buf[curr] + i * a->msize);
- ssnp = (struct stats_softnet *) ((char *) a->buf[!curr] + i * a->msize);
+ /* Compute statistics for CPU "all" */
+ get_global_soft_statistics(a, !curr, curr, flags, offline_cpu_bitmap);
+
+ /* For each CPU */
+ for (i = 0; (i < a->nr_ini) && (i < a->bitmap->b_size + 1); i++) {
/* Should current CPU (including CPU "all") be displayed? */
- if (!(a->bitmap->b_array[i >> 3] & (1 << (i & 0x07))))
+ if (!(a->bitmap->b_array[i >> 3] & (1 << (i & 0x07))) ||
+ offline_cpu_bitmap[i >> 3] & (1 << (i & 0x07)))
/* No */
continue;
+ ssnc = (struct stats_softnet *) ((char *) a->buf[curr] + i * a->msize);
+ ssnp = (struct stats_softnet *) ((char *) a->buf[!curr] + i * a->msize);
+
pos = i * 5;
/* Check for min/max values */
int i;
struct stats_softnet *ssnc, *ssnp;
char cpuno[8];
+ unsigned char offline_cpu_bitmap[BITMAP_SIZE(NR_CPUS)] = {0};
if (!IS_SELECTED(a->options) || (a->nr[curr] <= 0))
goto close_xml_markup;
xml_markup_network(tab, OPEN_XML_MARKUP);
tab++;
- for (i = 0; (i < a->nr[curr]) && (i < a->bitmap->b_size + 1); i++) {
+ /* @nr[curr] cannot normally be greater than @nr_ini */
+ if (a->nr[curr] > a->nr_ini) {
+ a->nr_ini = a->nr[curr];
+ }
- ssnc = (struct stats_softnet *) ((char *) a->buf[curr] + i * a->msize);
- ssnp = (struct stats_softnet *) ((char *) a->buf[!curr] + i * a->msize);
+ /* Compute statistics for CPU "all" */
+ get_global_soft_statistics(a, !curr, curr, flags, offline_cpu_bitmap);
+
+ for (i = 0; (i < a->nr_ini) && (i < a->bitmap->b_size + 1); i++) {
/* Should current CPU (including CPU "all") be displayed? */
- if (!(a->bitmap->b_array[i >> 3] & (1 << (i & 0x07))))
+ if (!(a->bitmap->b_array[i >> 3] & (1 << (i & 0x07))) ||
+ offline_cpu_bitmap[i >> 3] & (1 << (i & 0x07)))
/* No */
continue;
+ ssnc = (struct stats_softnet *) ((char *) a->buf[curr] + i * a->msize);
+ ssnp = (struct stats_softnet *) ((char *) a->buf[!curr] + i * a->msize);
+
/* Yes: Display it */
if (!i) {
/* This is CPU "all" */