From 9c57daef63da9a7fadfdf84032d299423fba6062 Mon Sep 17 00:00:00 2001 From: seb Date: Sat, 8 Dec 2012 21:54:11 +0100 Subject: [PATCH] Remove heading spaces in softirq names displayed by mpstat for easier reading. Output from mpstat -I SCPU was sometimes difficult to read because of softirq names which are sometimes too long. So remove heading spaces for easier reading. Before: 09:46:05 PM CPU HI/s TIMER/s NET_TX/s NET_RX/s BLOCK/s BLOCK_IOPOLL/s TASKLET/s SCHED/s HRTIMER/s RCU/s 09:46:05 PM 0 0.00 783.63 0.17 9.09 4.52 0.00 3.25 154.86 0.02 66.59 After: 09:57:02 PM CPU HI/s TIMER/s NET_TX/s NET_RX/s BLOCK/s BLOCK_IOPOLL/s TASKLET/s SCHED/s HRTIMER/s RCU/s 09:57:02 PM 0 0.00 752.30 0.17 7.79 3.80 0.00 2.86 168.52 0.01 64.77 --- CHANGES | 2 ++ mpstat.c | 19 +++++++++++++++---- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/CHANGES b/CHANGES index 70584df..dedd0e5 100644 --- a/CHANGES +++ b/CHANGES @@ -11,6 +11,8 @@ xxxx/xx/xx: Version 10.1.3 - Sebastien Godard (sysstat orange.fr) even if $prefix/lib directory also exists. * Fixed DTD document: If computer has run all day without restart, XML output file from sadf -x has no boot elements. + * Remove heading spaces in softirq names displayed by mpstat + for easier reading. * Cosmetic fixes in configure script. * iostat manual page updated. diff --git a/mpstat.c b/mpstat.c index 3fca3b5..cbb4edd 100644 --- a/mpstat.c +++ b/mpstat.c @@ -635,7 +635,7 @@ void read_interrupts_stat(char *file, struct stats_irqcpu *st_ic[], int ic_nr, i FILE *fp; struct stats_irq *st_irq_i; struct stats_irqcpu *p; - char *line = NULL; + char *line = NULL, *li; unsigned long irq = 0; unsigned int cpu; int cpu_index[cpu_nr], index = 0, dgt, len; @@ -669,17 +669,28 @@ void read_interrupts_stat(char *file, struct stats_irqcpu *st_ic[], int ic_nr, i /* Skip over ":" */ if ((cp = strchr(line, ':')) == NULL) + /* Chr ':' not found */ continue; cp++; p = st_ic[curr] + irq; - len = strcspn(line, ":"); + + li = line; + while (*li == ' ') + li++; + + len = strcspn(li, ":"); if (len >= MAX_IRQ_LEN) { len = MAX_IRQ_LEN - 1; } - strncpy(p->irq_name, line, len); + strncpy(p->irq_name, li, len); p->irq_name[len] = '\0'; - dgt = isdigit(line[len - 1]); + if (len > 0) { + dgt = isdigit(li[len - 1]); + } + else { + dgt = FALSE; + } for (cpu = 0; cpu < index; cpu++) { p = st_ic[curr] + cpu_index[cpu] * ic_nr + irq; -- 2.40.0