]> granicus.if.org Git - sysstat/commitdiff
Added a new field (blocked) to sar -q.
authorSebastien Godard <sysstat@orange.fr>
Fri, 17 Dec 2010 20:19:53 +0000 (21:19 +0100)
committerSebastien Godard <sysstat@orange.fr>
Fri, 17 Dec 2010 20:19:53 +0000 (21:19 +0100)
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.

CHANGES
activity.c
man/sar.in
pr_stats.c
rd_stats.c
rd_stats.h
rndr_stats.c
sadf.h
xml/sysstat.dtd
xml/sysstat.xsd
xml_stats.c

diff --git a/CHANGES b/CHANGES
index c3aadac1ac59c2ab116317702bac6512e81379f0..bc7cc872c6ff21b315b4c9bf78d83bbcbeb3c220 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,8 +1,12 @@
 Changes:
 
 xxxx/xx/xx: Version 9.1.7 - Sebastien Godard (sysstat <at> 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 <at> 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.
index 8d3ce25385c170c22523182bd476f8348ee45403..ac4d0b104b06730c7e091b597e74a9084b7412c5 100644 (file)
@@ -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,
index 7826f9504f47c00882121f11becb80952dc886cf..08e23a9ed12bff09e3be23cc14684c195b0f5fbe 100644 (file)
@@ -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.
index 6fc7fad5ad794676410e83044a1b3a6db525c473..73f708542ce53d79a77f49e2b306612478dddf60 100644 (file)
@@ -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;
        }
 }
 
index 8762f0c9568236f9f0461945e5c610e7917a1fdc..9d78c631359748e14fbbb425ef2a37f4fb58c933 100644 (file)
@@ -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);
 }
 
 /*
index c3585722e767b78a91886116804eb9f21cb4b86b..90c224a8fc5a9593577fe3052eeb45f3e73e52f8 100644 (file)
@@ -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));
index 58172faf9d7dcc9250388e8995d0eac6527bf639..33e8e585901b3aba30b2415018512ed91e620c2a 100644 (file)
@@ -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 5e1eb1e873c86877301d34c8ccfb8e58e689852d..d5b7afafb675253dc48d1a5b4dc660292c22627a 100644 (file)
--- 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 */
index 58130f523ff4225d79725aaed80683bd218a77d5..ad21c5683f114aa81141cff881ae25374a139c07 100644 (file)
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!--DTD v2.9 for sysstat. See sadf.h -->
+<!--DTD v2.10 for sysstat. See sadf.h -->
 <!ELEMENT boot EMPTY>
 <!ATTLIST boot
        date CDATA #REQUIRED
        ldavg-1 CDATA #REQUIRED
        ldavg-5 CDATA #REQUIRED
        ldavg-15 CDATA #REQUIRED
+       blocked CDATA #REQUIRED
 >
 <!ELEMENT restarts (boot+)>
 <!ELEMENT comments (comment+)>
index 201c79e805491da8b0d5b75083cb882e5a0e394f..60e40fc92c17ed586028fcaa83bb088586b5d844 100644 (file)
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://pagesperso-orange.fr/sebastien.godard/sysstat" targetNamespace="http://pagesperso-orange.fr/sebastien.godard/sysstat" elementFormDefault="qualified">
-<xs:annotation><xs:appinfo>-- XML Schema v2.9 for sysstat. See sadf.h --</xs:appinfo></xs:annotation>
+<xs:annotation><xs:appinfo>-- XML Schema v2.10 for sysstat. See sadf.h --</xs:appinfo></xs:annotation>
 
     <xs:element name="queue" type="queue-type"></xs:element>
 
@@ -11,6 +11,7 @@
        <xs:attribute name="ldavg-1" type="hundredth-type"></xs:attribute>
        <xs:attribute name="ldavg-5" type="hundredth-type"></xs:attribute>
        <xs:attribute name="ldavg-15" type="hundredth-type"></xs:attribute>
+       <xs:attribute name="blocked" type="xs:nonNegativeInteger"></xs:attribute>
     </xs:complexType>
 
     <xs:element name="kernel" type="kernel-type"></xs:element>
index 096a9973584f5f82148f648118db0c8bd95549a0..2b6dc9b3fc39efff08f0d9995464bb1e9b31cf47 100644 (file)
@@ -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);
 }
 
 /*