]> granicus.if.org Git - sysstat/commitdiff
pidstat displays -1 for unknown I/O statistics
authorSebastien GODARD <sysstat@orange.fr.fake>
Sat, 28 Sep 2013 14:07:41 +0000 (16:07 +0200)
committerSebastien GODARD <sysstat@orange.fr.fake>
Sat, 28 Sep 2013 14:07:41 +0000 (16:07 +0200)
pidstat -d now displays -1 for I/O statistics values when the
file containing the statistics data for the corresponding process cannot
be read (permission denied or file non existent).

Signed-off-by: Sebastien GODARD <sysstat@orange.fr.fake>
pidstat.c

index 1e208229d27edeaa43079765eed570eae9c21e06..ed0874869df553c2efcf55f33b6bb9f14c137c8c 100644 (file)
--- a/pidstat.c
+++ b/pidstat.c
@@ -1273,7 +1273,6 @@ int write_pid_task_all_stats(int prev, int curr, int dis,
                        printf("   %3d", pstc->processor);
                }
 
-
                if (DISPLAY_MEM(actflag)) {
                        printf(" %9.2f %9.2f %7lu %6lu %6.2f",
                               S_VALUE(pstp->minflt, pstc->minflt, itv),
@@ -1820,11 +1819,17 @@ int write_pid_io_stats(int prev, int curr, int dis,
                        continue;
        
                print_line_id(curr_string, pstc);
-               printf(" %9.2f %9.2f %9.2f",
-                      S_VALUE(pstp->read_bytes,  pstc->read_bytes, itv)  / 1024,
-                      S_VALUE(pstp->write_bytes, pstc->write_bytes, itv) / 1024,
-                      S_VALUE(pstp->cancelled_write_bytes,
-                              pstc->cancelled_write_bytes, itv) / 1024);
+               if (!NO_PID_IO(pstc->flags)) {
+                       printf(" %9.2f %9.2f %9.2f",
+                              S_VALUE(pstp->read_bytes,  pstc->read_bytes, itv)  / 1024,
+                              S_VALUE(pstp->write_bytes, pstc->write_bytes, itv) / 1024,
+                              S_VALUE(pstp->cancelled_write_bytes,
+                                      pstc->cancelled_write_bytes, itv) / 1024);
+               }
+               else {
+                       /* I/O file not readable (permission denied or file non existent) */
+                       printf(" %9.2f %9.2f %9.2f", -1.0, -1.0, -1.0);
+               }
                print_comm(pstc);
                again = 1;
        }