From: Sebastien Godard Date: Fri, 17 Dec 2010 20:19:53 +0000 (+0100) Subject: Added a new field (blocked) to sar -q. X-Git-Tag: v9.1.7~3 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1554a7ddf9dafdca6155eb1083fa947c7b1c9f14;p=sysstat Added a new field (blocked) to sar -q. This patch adds a new metric (blocked - number of tasks currently blocked, waiting for I/O to complete) to sar -q. Also update sar manual page, and DTD/XSD documents. Note that this breaks stats_queue structure format. --- diff --git a/CHANGES b/CHANGES index c3aadac..bc7cc87 100644 --- a/CHANGES +++ b/CHANGES @@ -1,8 +1,12 @@ Changes: xxxx/xx/xx: Version 9.1.7 - Sebastien Godard (sysstat orange.fr) + INFO: stats_queue structure format has changed and is *not* + compatible with the previous one [+1] * sar now tells sadc to read only the necessary groups of activities. + * Added a new metric (number of tasks waiting for I/O) to + sar -q. * [Ivana Varekova]: Fix segfaults on bogus localtime input. * Fixed bogus CPU statistics output, which happened when CPU user value from /proc/stat wasn't incremented whereas @@ -13,6 +17,7 @@ xxxx/xx/xx: Version 9.1.7 - Sebastien Godard (sysstat orange.fr) expressed in blocks/s). * No longer assume that device-mapper major number is 253. Get the real number from /proc/devices file. + * DTD and XSD documents updated. * [Kenichi Okuyama]: Small change to sar manual page. * sar manual page updated. * Code cleaned. diff --git a/activity.c b/activity.c index 8d3ce25..ac4d0b1 100644 --- a/activity.c +++ b/activity.c @@ -311,7 +311,7 @@ struct activity ktables_act = { struct activity queue_act = { .id = A_QUEUE, .options = AO_COLLECTED, - .magic = ACTIVITY_MAGIC_BASE, + .magic = ACTIVITY_MAGIC_BASE + 1, .group = G_DEFAULT, #ifdef SOURCE_SADC .f_count = NULL, @@ -325,7 +325,7 @@ struct activity queue_act = { #ifdef SOURCE_SADF .f_render = render_queue_stats, .f_xml_print = xml_print_queue_stats, - .hdr_line = "runq-sz;plist-sz;ldavg-1;ldavg-5;ldavg-15", + .hdr_line = "runq-sz;plist-sz;ldavg-1;ldavg-5;ldavg-15;blocked", .name = "A_QUEUE", #endif .nr = 1, diff --git a/man/sar.in b/man/sar.in index 7826f95..08e23a9 100644 --- a/man/sar.in +++ b/man/sar.in @@ -1,4 +1,4 @@ -.TH SAR 1 "NOVEMBER 2010" Linux "Linux User's Manual" -*- nroff -*- +.TH SAR 1 "DECEMBER 2010" Linux "Linux User's Manual" -*- nroff -*- .SH NAME sar \- Collect, report, or save system activity information. .SH SYNOPSIS @@ -1641,6 +1641,11 @@ System load average for the past 5 minutes. .RS System load average for the past 15 minutes. .RE + +.B blocked +.RS +Number of tasks currently blocked, waiting for I/O to complete. +.RE .RE .IP -r Report memory utilization statistics. diff --git a/pr_stats.c b/pr_stats.c index 6fc7fad..73f7085 100644 --- a/pr_stats.c +++ b/pr_stats.c @@ -660,45 +660,50 @@ void stub_print_queue_stats(struct activity *a, int prev, int curr, int dispavg) struct stats_queue *sqc = (struct stats_queue *) a->buf[curr]; static unsigned long long - avg_nr_running = 0, - avg_nr_threads = 0, - avg_load_avg_1 = 0, - avg_load_avg_5 = 0, - avg_load_avg_15 = 0; + avg_nr_running = 0, + avg_nr_threads = 0, + avg_load_avg_1 = 0, + avg_load_avg_5 = 0, + avg_load_avg_15 = 0, + avg_procs_blocked = 0; if (dis) { - printf("\n%-11s runq-sz plist-sz ldavg-1 ldavg-5 ldavg-15\n", + printf("\n%-11s runq-sz plist-sz ldavg-1 ldavg-5 ldavg-15 blocked\n", timestamp[!curr]); } if (!dispavg) { /* Display instantaneous values */ - printf("%-11s %9lu %9u %9.2f %9.2f %9.2f\n", timestamp[curr], + printf("%-11s %9lu %9u %9.2f %9.2f %9.2f %9lu\n", timestamp[curr], sqc->nr_running, sqc->nr_threads, (double) sqc->load_avg_1 / 100, (double) sqc->load_avg_5 / 100, - (double) sqc->load_avg_15 / 100); + (double) sqc->load_avg_15 / 100, + sqc->procs_blocked); /* Will be used to compute the average */ - avg_nr_running += sqc->nr_running; - avg_nr_threads += sqc->nr_threads; - avg_load_avg_1 += sqc->load_avg_1; - avg_load_avg_5 += sqc->load_avg_5; - avg_load_avg_15 += sqc->load_avg_15; + avg_nr_running += sqc->nr_running; + avg_nr_threads += sqc->nr_threads; + avg_load_avg_1 += sqc->load_avg_1; + avg_load_avg_5 += sqc->load_avg_5; + avg_load_avg_15 += sqc->load_avg_15; + avg_procs_blocked += sqc->procs_blocked; } else { /* Display average values */ - printf("%-11s %9.0f %9.0f %9.2f %9.2f %9.2f\n", timestamp[curr], - (double) avg_nr_running / avg_count, - (double) avg_nr_threads / avg_count, - (double) avg_load_avg_1 / (avg_count * 100), - (double) avg_load_avg_5 / (avg_count * 100), - (double) avg_load_avg_15 / (avg_count * 100)); + printf("%-11s %9.0f %9.0f %9.2f %9.2f %9.2f %9.0f\n", timestamp[curr], + (double) avg_nr_running / avg_count, + (double) avg_nr_threads / avg_count, + (double) avg_load_avg_1 / (avg_count * 100), + (double) avg_load_avg_5 / (avg_count * 100), + (double) avg_load_avg_15 / (avg_count * 100), + (double) avg_procs_blocked / avg_count); /* Reset average counters */ avg_nr_running = avg_nr_threads = 0; avg_load_avg_1 = avg_load_avg_5 = avg_load_avg_15 = 0; + avg_procs_blocked = 0; } } diff --git a/rd_stats.c b/rd_stats.c index 8762f0c..9d78c63 100644 --- a/rd_stats.c +++ b/rd_stats.c @@ -164,8 +164,8 @@ void read_stat_cpu(struct stats_cpu *st_cpu, int nbr, /* *************************************************************************** - * Read processes (tasks) creation and context switches statistics from - * /proc/stat + * Read processes (tasks) creation and context switches statistics + * from /proc/stat. * * IN: * @st_pcsw Structure where stats will be saved. @@ -241,7 +241,7 @@ void read_stat_irq(struct stats_irq *st_irq, int nbr) /* *************************************************************************** - * Read queue and load statistics from /proc/loadavg. + * Read queue and load statistics from /proc/loadavg and /proc/stat. * * IN: * @st_queue Structure where stats will be saved. @@ -253,6 +253,7 @@ void read_stat_irq(struct stats_irq *st_irq, int nbr) void read_loadavg(struct stats_queue *st_queue) { FILE *fp; + char line[8192]; int load_tmp[3]; if ((fp = fopen(LOADAVG, "r")) == NULL) @@ -276,6 +277,21 @@ void read_loadavg(struct stats_queue *st_queue) /* Do not take current process into account */ st_queue->nr_running--; } + + /* Read nr of tasks blocked from /proc/stat */ + if ((fp = fopen(STAT, "r")) == NULL) + return; + + while (fgets(line, 8192, fp) != NULL) { + + if (!strncmp(line, "procs_blocked ", 14)) { + /* Read number of processes blocked */ + sscanf(line + 14, "%lu", &st_queue->procs_blocked); + break; + } + } + + fclose(fp); } /* diff --git a/rd_stats.h b/rd_stats.h index c358572..90c224a 100644 --- a/rd_stats.h +++ b/rd_stats.h @@ -169,6 +169,7 @@ struct stats_ktables { /* Structure for queue and load statistics */ struct stats_queue { unsigned long nr_running __attribute__ ((aligned (8))); + unsigned long procs_blocked __attribute__ ((aligned (8))); unsigned int load_avg_1 __attribute__ ((aligned (8))); unsigned int load_avg_5 __attribute__ ((packed)); unsigned int load_avg_15 __attribute__ ((packed)); diff --git a/rndr_stats.c b/rndr_stats.c index 58172fa..33e8e58 100644 --- a/rndr_stats.c +++ b/rndr_stats.c @@ -798,10 +798,14 @@ __print_funct_t render_queue_stats(struct activity *a, int isdb, char *pre, NOVAL, (double) sqc->load_avg_5 / 100); - render(isdb, pre, pt_newlin, + render(isdb, pre, PT_NOFLAG, "-\tldavg-15", NULL, NULL, NOVAL, (double) sqc->load_avg_15 / 100); + + render(isdb, pre, PT_USEINT | pt_newlin, + "-\tblocked", NULL, NULL, + sqc->procs_blocked, DNOVAL); } /* diff --git a/sadf.h b/sadf.h index 5e1eb1e..d5b7afa 100644 --- a/sadf.h +++ b/sadf.h @@ -14,6 +14,6 @@ #define S_O_DBD_OPTION 5 /* DTD version for XML output */ -#define XML_DTD_VERSION "2.9" +#define XML_DTD_VERSION "2.10" #endif /* _SADF_H */ diff --git a/xml/sysstat.dtd b/xml/sysstat.dtd index 58130f5..ad21c56 100644 --- a/xml/sysstat.dtd +++ b/xml/sysstat.dtd @@ -1,5 +1,5 @@ - + diff --git a/xml/sysstat.xsd b/xml/sysstat.xsd index 201c79e..60e40fc 100644 --- a/xml/sysstat.xsd +++ b/xml/sysstat.xsd @@ -1,6 +1,6 @@ --- XML Schema v2.9 for sysstat. See sadf.h -- +-- XML Schema v2.10 for sysstat. See sadf.h -- @@ -11,6 +11,7 @@ + diff --git a/xml_stats.c b/xml_stats.c index 096a997..2b6dc9b 100644 --- a/xml_stats.c +++ b/xml_stats.c @@ -603,12 +603,14 @@ __print_funct_t xml_print_queue_stats(struct activity *a, int curr, int tab, "plist-sz=\"%u\" " "ldavg-1=\"%.2f\" " "ldavg-5=\"%.2f\" " - "ldavg-15=\"%.2f\"/>", + "ldavg-15=\"%.2f\" " + "blocked=\"%lu\"/>", sqc->nr_running, sqc->nr_threads, (double) sqc->load_avg_1 / 100, (double) sqc->load_avg_5 / 100, - (double) sqc->load_avg_15 / 100); + (double) sqc->load_avg_15 / 100, + sqc->procs_blocked); } /*