* Display current activity header line.
*
* IN:
- * @p_timestamp Timestamp for previous stat sample.
- * @a Activity structure.
- * @pos Index in @.hdr_line string, 0 being the first one (header
- * are delimited by the '|' character).
- * @iwidth First column width (generally this is the item name). A
- * negative value means that the corresponding field shall be
- * displayed at the end of the line, with no indication of width.
- * @vwidth Column width for stats values.
+ * @p_timestamp Timestamp for previous stat sample.
+ * @a Activity structure.
+ * @pos Header to display, 0 being the first header (headers
+ * are delimited by the '|' character).
+ * @iwidth First column width (generally this is the item name).
+ * A negative value means that the corresponding field
+ * shall be displayed at the end of the line, with no
+ * indication of width.
+ * @vwidth Column width for stats values.
+ * @offline_bitmap Bitmap for offline items (e.g. CPU).
***************************************************************************
*/
-void print_hdr_line(char *p_timestamp, struct activity *a, int pos, int iwidth, int vwidth)
+void print_hdr_line(char *p_timestamp, struct activity *a, int pos, int iwidth, int vwidth,
+ unsigned char *offline_bitmap)
{
char hline[HEADER_LINE_LEN] = "";
+ char cfld[16], dfld[16];
char *hl, *tk, *it = NULL;
- int i = -1, j;
+ int i = -1, j, k;
int p = pos;
strncpy(hline, a->hdr_line, sizeof(hline) - 1);
}
/* Display each field */
for (tk = strtok(hl, ";"); tk; tk = strtok(NULL, ";"), i--) {
+
+ if (strchr(tk, '*')) {
+ strncpy(cfld, tk, sizeof(cfld) - 1);
+ k = strcspn(cfld, "*");
+ if (k >= strlen(cfld))
+ continue; /* Should not happen */
+ cfld[k] = '\0';
+ for (j = 0; (j < a->nr_ini) && (j < a->bitmap->b_size + 1); j++) {
+ if (!(a->bitmap->b_array[j >> 3] & (1 << (j & 0x07))))
+ /* Don't display current item if not selected */
+ continue;
+ if (offline_bitmap && (offline_bitmap[j >> 3] & (1 << (j & 0x07))))
+ /* Don't display current item if offline */
+ continue;
+ if (j == 0) {
+ printf(" %*s", vwidth, "all");
+ }
+ else {
+ snprintf(dfld, sizeof(dfld), "%s%d%s", cfld, j - 1, cfld + k + 1);
+ dfld[sizeof(dfld) - 1] = '\0';
+ printf(" %*s", vwidth, dfld);
+ }
+ }
+ continue;
+ }
if (iwidth > 0) {
printf(" %*s", iwidth, tk);
iwidth = 0;
printf(" %*s", vwidth, tk);
}
}
+
if (it) {
printf(" %s", it);
}
unsigned char offline_cpu_bitmap[BITMAP_SIZE(NR_CPUS)] = {0};
if (dish) {
- print_hdr_line(timestamp[!curr], a, FIRST + DISPLAY_CPU_ALL(a->opt_flags), 7, 9);
+ print_hdr_line(timestamp[!curr], a, FIRST + DISPLAY_CPU_ALL(a->opt_flags), 7, 9, NULL);
}
/*
*spp = (struct stats_pcsw *) a->buf[prev];
if (dish) {
- print_hdr_line(timestamp[!curr], a, FIRST, 0, 9);
+ print_hdr_line(timestamp[!curr], a, FIRST, 0, 9, NULL);
}
printf("%-11s", timestamp[curr]);
struct stats_irq *sic, *sip;
if (dish || DISPLAY_ZERO_OMIT(flags)) {
- print_hdr_line(timestamp[!curr], a, FIRST, 0, 9);
+ print_hdr_line(timestamp[!curr], a, FIRST, 0, 9, NULL); // TODO: Check for offline CPU
}
for (i = 0; (i < a->nr[curr]) && (i < a->bitmap->b_size + 1); i++) {
*ssp = (struct stats_swap *) a->buf[prev];
if (dish) {
- print_hdr_line(timestamp[!curr], a, FIRST, 0, 9);
+ print_hdr_line(timestamp[!curr], a, FIRST, 0, 9, NULL);
}
printf("%-11s", timestamp[curr]);
*spp = (struct stats_paging *) a->buf[prev];
if (dish) {
- print_hdr_line(timestamp[!curr], a, FIRST, 0, 9);
+ print_hdr_line(timestamp[!curr], a, FIRST, 0, 9, NULL);
}
printf("%-11s", timestamp[curr]);
*sip = (struct stats_io *) a->buf[prev];
if (dish) {
- print_hdr_line(timestamp[!curr], a, FIRST, 0, 9);
+ print_hdr_line(timestamp[!curr], a, FIRST, 0, 9, NULL);
}
printf("%-11s", timestamp[curr]);
if (DISPLAY_MEMORY(a->opt_flags)) {
if (dish) {
- print_hdr_line(timestamp[!curr], a, FIRST, 0, 9);
+ print_hdr_line(timestamp[!curr], a, FIRST, 0, 9, NULL);
}
printf("%-11s", timestamp[curr]);
if (DISPLAY_SWAP(a->opt_flags)) {
if (dish) {
- print_hdr_line(timestamp[!curr], a, SECOND, 0, 9);
+ print_hdr_line(timestamp[!curr], a, SECOND, 0, 9, NULL);
}
printf("%-11s", timestamp[curr]);
if (dish) {
- print_hdr_line(timestamp[!curr], a, FIRST, 0, 9);
+ print_hdr_line(timestamp[!curr], a, FIRST, 0, 9, NULL);
}
printf("%-11s", timestamp[curr]);
avg_procs_blocked = 0;
if (dish) {
- print_hdr_line(timestamp[!curr], a, FIRST, 0, 9);
+ print_hdr_line(timestamp[!curr], a, FIRST, 0, 9, NULL);
}
printf("%-11s", timestamp[curr]);
struct stats_serial *ssc, *ssp;
if (dish || DISPLAY_ZERO_OMIT(flags)) {
- print_hdr_line(timestamp[!curr], a, FIRST, 0, 9);
+ print_hdr_line(timestamp[!curr], a, FIRST, 0, 9, NULL);
}
for (i = 0; i < a->nr[curr]; i++) {
}
if (dish || DISPLAY_ZERO_OMIT(flags)) {
- print_hdr_line(timestamp[!curr], a, FIRST, DISPLAY_PRETTY(flags) ? -1 : 0, 9);
+ print_hdr_line(timestamp[!curr], a, FIRST, DISPLAY_PRETTY(flags) ? -1 : 0, 9, NULL);
}
for (i = 0; i < a->nr[curr]; i++) {
}
if (dish || DISPLAY_ZERO_OMIT(flags)) {
- print_hdr_line(timestamp[!curr], a, FIRST, DISPLAY_PRETTY(flags) ? -1 : 0, 9);
+ print_hdr_line(timestamp[!curr], a, FIRST, DISPLAY_PRETTY(flags) ? -1 : 0, 9, NULL);
}
for (i = 0; i < a->nr[curr]; i++) {
memset(&snedzero, 0, STATS_NET_EDEV_SIZE);
if (dish || DISPLAY_ZERO_OMIT(flags)) {
- print_hdr_line(timestamp[!curr], a, FIRST, DISPLAY_PRETTY(flags) ? -1 : 0, 9);
+ print_hdr_line(timestamp[!curr], a, FIRST, DISPLAY_PRETTY(flags) ? -1 : 0, 9, NULL);
}
for (i = 0; i < a->nr[curr]; i++) {
*snnp = (struct stats_net_nfs *) a->buf[prev];
if (dish) {
- print_hdr_line(timestamp[!curr], a, FIRST, 0, 9);
+ print_hdr_line(timestamp[!curr], a, FIRST, 0, 9, NULL);
}
printf("%-11s", timestamp[curr]);
*snndp = (struct stats_net_nfsd *) a->buf[prev];
if (dish) {
- print_hdr_line(timestamp[!curr], a, FIRST, 0, 9);
+ print_hdr_line(timestamp[!curr], a, FIRST, 0, 9, NULL);
}
printf("%-11s", timestamp[curr]);
avg_tcp_tw = 0;
if (dish) {
- print_hdr_line(timestamp[!curr], a, FIRST, 0, 9);
+ print_hdr_line(timestamp[!curr], a, FIRST, 0, 9, NULL);
}
printf("%-11s", timestamp[curr]);
*snip = (struct stats_net_ip *) a->buf[prev];
if (dish) {
- print_hdr_line(timestamp[!curr], a, FIRST, 0, 9);
+ print_hdr_line(timestamp[!curr], a, FIRST, 0, 9, NULL);
}
printf("%-11s", timestamp[curr]);
*sneip = (struct stats_net_eip *) a->buf[prev];
if (dish) {
- print_hdr_line(timestamp[!curr], a, FIRST, 0, 9);
+ print_hdr_line(timestamp[!curr], a, FIRST, 0, 9, NULL);
}
printf("%-11s", timestamp[curr]);
*snip = (struct stats_net_icmp *) a->buf[prev];
if (dish) {
- print_hdr_line(timestamp[!curr], a, FIRST, 0, 9);
+ print_hdr_line(timestamp[!curr], a, FIRST, 0, 9, NULL);
}
printf("%-11s", timestamp[curr]);
*sneip = (struct stats_net_eicmp *) a->buf[prev];
if (dish) {
- print_hdr_line(timestamp[!curr], a, FIRST, 0, 9);
+ print_hdr_line(timestamp[!curr], a, FIRST, 0, 9, NULL);
}
printf("%-11s", timestamp[curr]);
*sntp = (struct stats_net_tcp *) a->buf[prev];
if (dish) {
- print_hdr_line(timestamp[!curr], a, FIRST, 0, 9);
+ print_hdr_line(timestamp[!curr], a, FIRST, 0, 9, NULL);
}
printf("%-11s", timestamp[curr]);
*snetp = (struct stats_net_etcp *) a->buf[prev];
if (dish) {
- print_hdr_line(timestamp[!curr], a, FIRST, 0, 9);
+ print_hdr_line(timestamp[!curr], a, FIRST, 0, 9, NULL);
}
printf("%-11s", timestamp[curr]);
*snup = (struct stats_net_udp *) a->buf[prev];
if (dish) {
- print_hdr_line(timestamp[!curr], a, FIRST, 0, 9);
+ print_hdr_line(timestamp[!curr], a, FIRST, 0, 9, NULL);
}
printf("%-11s", timestamp[curr]);
avg_frag6_inuse = 0;
if (dish) {
- print_hdr_line(timestamp[!curr], a, FIRST, 0, 9);
+ print_hdr_line(timestamp[!curr], a, FIRST, 0, 9, NULL);
}
printf("%-11s", timestamp[curr]);
*snip = (struct stats_net_ip6 *) a->buf[prev];
if (dish) {
- print_hdr_line(timestamp[!curr], a, FIRST, 0, 9);
+ print_hdr_line(timestamp[!curr], a, FIRST, 0, 9, NULL);
}
printf("%-11s", timestamp[curr]);
*sneip = (struct stats_net_eip6 *) a->buf[prev];
if (dish) {
- print_hdr_line(timestamp[!curr], a, FIRST, 0, 9);
+ print_hdr_line(timestamp[!curr], a, FIRST, 0, 9, NULL);
}
printf("%-11s", timestamp[curr]);
*snip = (struct stats_net_icmp6 *) a->buf[prev];
if (dish) {
- print_hdr_line(timestamp[!curr], a, FIRST, 0, 9);
+ print_hdr_line(timestamp[!curr], a, FIRST, 0, 9, NULL);
}
printf("%-11s", timestamp[curr]);
*sneip = (struct stats_net_eicmp6 *) a->buf[prev];
if (dish) {
- print_hdr_line(timestamp[!curr], a, FIRST, 0, 9);
+ print_hdr_line(timestamp[!curr], a, FIRST, 0, 9, NULL);
}
printf("%-11s", timestamp[curr]);
*snup = (struct stats_net_udp6 *) a->buf[prev];
if (dish) {
- print_hdr_line(timestamp[!curr], a, FIRST, 0, 9);
+ print_hdr_line(timestamp[!curr], a, FIRST, 0, 9, NULL);
}
printf("%-11s", timestamp[curr]);
}
if (dish) {
- print_hdr_line(timestamp[!curr], a, FIRST, 7, 9);
+ print_hdr_line(timestamp[!curr], a, FIRST, 7, 9, NULL);
}
for (i = 0; (i < a->nr[curr]) && (i < a->bitmap->b_size + 1); i++) {
}
if (dish) {
- print_hdr_line(timestamp[!curr], a, FIRST, -2, 9);
+ print_hdr_line(timestamp[!curr], a, FIRST, -2, 9, NULL);
}
for (i = 0; i < a->nr[curr]; i++) {
}
if (dish) {
- print_hdr_line(timestamp[!curr], a, FIRST, -2, 9);
+ print_hdr_line(timestamp[!curr], a, FIRST, -2, 9, NULL);
}
for (i = 0; i < a->nr[curr]; i++) {
}
if (dish) {
- print_hdr_line(timestamp[!curr], a, FIRST, -2, 9);
+ print_hdr_line(timestamp[!curr], a, FIRST, -2, 9, NULL);
}
for (i = 0; i < a->nr[curr]; i++) {
}
if (dish) {
- print_hdr_line(timestamp[!curr], a, FIRST, 0, 9);
+ print_hdr_line(timestamp[!curr], a, FIRST, 0, 9, NULL);
}
printf("%-11s", timestamp[curr]);
unsigned long long tis, tisfreq;
if (dish) {
- print_hdr_line(timestamp[!curr], a, FIRST, 7, 9);
+ print_hdr_line(timestamp[!curr], a, FIRST, 7, 9, NULL);
}
for (i = 0; (i < a->nr[curr]) && (i < a->bitmap->b_size + 1); i++) {
if (dish || DISPLAY_ZERO_OMIT(flags)) {
print_hdr_line((dispavg ? _("Summary:") : timestamp[!curr]),
- a, FIRST + DISPLAY_MOUNT(a->opt_flags), -1, 9);
+ a, FIRST + DISPLAY_MOUNT(a->opt_flags), -1, 9, NULL);
}
for (i = 0; i < a->nr[curr]; i++) {
memset(&sfczero, 0, sizeof(struct stats_fchost));
if (dish) {
- print_hdr_line(timestamp[!curr], a, FIRST, -1, 9);
+ print_hdr_line(timestamp[!curr], a, FIRST, -1, 9, NULL);
}
for (i = 0; i < a->nr[curr]; i++) {
unsigned char offline_cpu_bitmap[BITMAP_SIZE(NR_CPUS)] = {0};
if (dish || DISPLAY_ZERO_OMIT(flags)) {
- print_hdr_line(timestamp[!curr], a, FIRST, 7, 9);
+ print_hdr_line(timestamp[!curr], a, FIRST, 7, 9, NULL);
}
/*
s_avg300 = 0;
if (dish) {
- print_hdr_line(timestamp[!curr], a, FIRST, 0, 9);
+ print_hdr_line(timestamp[!curr], a, FIRST, 0, 9, NULL);
}
printf("%-11s", timestamp[curr]);
f_avg300 = 0;
if (dish) {
- print_hdr_line(timestamp[!curr], a, FIRST, 0, 9);
+ print_hdr_line(timestamp[!curr], a, FIRST, 0, 9, NULL);
}
printf("%-11s", timestamp[curr]);
f_avg300 = 0;
if (dish) {
- print_hdr_line(timestamp[!curr], a, FIRST, 0, 9);
+ print_hdr_line(timestamp[!curr], a, FIRST, 0, 9, NULL);
}
printf("%-11s", timestamp[curr]);