]> granicus.if.org Git - sysstat/commitdiff
pidstat now displays task's UID.
authorseb <seb@kluane.home>
Fri, 1 Mar 2013 14:26:53 +0000 (15:26 +0100)
committerseb <seb@kluane.home>
Fri, 1 Mar 2013 14:26:53 +0000 (15:26 +0100)
pidstat now displays the real user ID of every task being monitored.
Its manual page has also been updated.

CHANGES
man/pidstat.1
pidstat.c
pidstat.h

diff --git a/CHANGES b/CHANGES
index 23a90758d7c4e602a085643cc102e0b9c87e21e4..07af58752a18781cc5a53b804b6b067c65d70f44 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -7,6 +7,8 @@ xxxx/xx/xx: Version 10.1.4 - Sebastien Godard (sysstat <at> orange.fr)
          receives SIGINT (crtl/c).
        * sar now stops and displays its average stats when it receives
          SIGINT (crtl/c).
+       * pidstat now displays task's UID for all tasks.
+       * pidstat manual page updated.
        * FAQ updated.
 
 2012/12/23: Version 10.1.3 - Sebastien Godard (sysstat <at> orange.fr)
index f8c8d9c0b6e5fcb993e9928f054f50e47824e504..f93f67e092f58854a6c7f615ce3a3a4fd9884d6f 100644 (file)
@@ -1,4 +1,4 @@
-.TH PIDSTAT 1 "JULY 2012" Linux "Linux User's Manual" -*- nroff -*-
+.TH PIDSTAT 1 "MARCH 2013" Linux "Linux User's Manual" -*- nroff -*-
 .SH NAME
 pidstat \- Report statistics for Linux tasks.
 .SH SYNOPSIS
@@ -66,8 +66,13 @@ This string can be a regular expression.
 Report I/O statistics (kernels 2.6.20 and later only).
 The following values are displayed:
 
-.B PID
+.B UID
+.RS
 .RS
+The real user identification number of the task being monitored.
+.RE
+
+.B PID
 .RS
 The identification number of the task being monitored.
 .RE
@@ -124,9 +129,14 @@ Report page faults and memory utilization.
 When reporting statistics for individual tasks,
 the following values are displayed:
 
-.B PID
+.B UID
 .RS
 .RS
+The real user identification number of the task being monitored.
+.RE
+
+.B PID
+.RS
 The identification number of the task being monitored.
 .RE
 
@@ -166,6 +176,12 @@ The command name of the task.
 When reporting global statistics for tasks and all their children,
 the following values are displayed:
 
+.B UID
+.RS
+The real user identification number of the task which is being monitored
+together with its children.
+.RE
+
 .B PID
 .RS
 The identification number of the task which is being monitored
@@ -194,9 +210,14 @@ together with its children.
 Report stack utilization.
 The following values are displayed:
 
-.B PID
+.B UID
 .RS
 .RS
+The real user identification number of the task being monitored.
+.RE
+
+.B PID
+.RS
 The identification number of the task being monitored.
 .RE
 
@@ -259,8 +280,13 @@ Report CPU utilization.
 When reporting statistics for individual tasks,
 the following values are displayed:
 
-.B PID
+.B UID
+.RS
 .RS
+The real user identification number of the task being monitored.
+.RE
+
+.B PID
 .RS
 The identification number of the task being monitored.
 .RE
@@ -306,6 +332,12 @@ The command name of the task.
 When reporting global statistics for tasks and all their children,
 the following values are displayed:
 
+.B UID
+.RS
+The real user identification number of the task which is being monitored
+together with its children.
+.RE
+
 .B PID
 .RS
 The identification number of the task which is being monitored
@@ -347,9 +379,14 @@ Print version number then exit.
 Report task switching activity (kernels 2.6.23 and later only).
 The following values are displayed:
 
-.B PID
+.B UID
 .RS
 .RS
+The real user identification number of the task being monitored.
+.RE
+
+.B PID
+.RS
 The identification number of the task being monitored.
 .RE
 
index 8c2fa9c88496b5400d59ea7f14eb26763d37c87a..0e0855838b0221b23b4e82ef9d8b192e3771883c 100644 (file)
--- a/pidstat.c
+++ b/pidstat.c
@@ -385,7 +385,10 @@ int read_proc_pid_status(unsigned int pid, struct pid_stats *pst,
 
        while (fgets(line, 256, fp) != NULL) {
 
-               if (!strncmp(line, "voluntary_ctxt_switches:", 24)) {
+               if (!strncmp(line, "Uid:", 4)) {
+                       sscanf(line + 5, "%d", &pst->uid);
+               }
+               else if (!strncmp(line, "voluntary_ctxt_switches:", 24)) {
                        sscanf(line + 25, "%lu", &pst->nvcsw);
                }
                else if (!strncmp(line, "nonvoluntary_ctxt_switches:", 27)) {
@@ -1090,7 +1093,7 @@ void __print_line_id(struct pid_stats *pst, char c)
  */
 void print_line_id(char *timestamp, struct pid_stats *pst)
 {
-       printf("%-11s", timestamp);
+       printf("%-11s %5d", timestamp, pst->uid);
        
        __print_line_id(pst, '-');
 }
@@ -1146,7 +1149,7 @@ int write_pid_task_all_stats(int prev, int curr, int dis,
                                       &pstc, &pstp) <= 0)
                        continue;
 
-               printf("%11ld", (long) time(NULL));
+               printf("%11ld %5d", (long) time(NULL), pstc->uid);
                __print_line_id(pstc, '0');
 
                if (DISPLAY_CPU(actflag)) {
@@ -1251,7 +1254,7 @@ int write_pid_child_all_stats(int prev, int curr, int dis,
                                       &pstc, &pstp) <= 0)
                        continue;
 
-               printf("%11ld", (long) time(NULL));
+               printf("%11ld %5d", (long) time(NULL), pstc->uid);
                __print_line_id(pstc, '0');
 
                if (DISPLAY_CPU(actflag)) {
index c99cf7a6f6ea85fea458efd55ddc95343230cd80..dd090a10c97c9e67dcb4cbbf1919c5f4a85459fe 100644 (file)
--- a/pidstat.h
+++ b/pidstat.h
@@ -1,6 +1,6 @@
 /*
  * pidstat: Display per-process statistics.
- * (C) 2007-2011 by Sebastien Godard (sysstat <at> orange.fr)
+ * (C) 2007-2013 by Sebastien Godard (sysstat <at> orange.fr)
  */
 
 #ifndef _PIDSTAT_H
@@ -78,7 +78,7 @@
 #define TASK_SMAP      "/proc/%u/task/%u/smaps"
 
 #define PRINT_ID_HDR(_timestamp_, _flag_)      do {                                            \
-                                                       printf("\n%-11s", _timestamp_);         \
+                                                       printf("\n%-11s   UID", _timestamp_);   \
                                                        if (DISPLAY_TID(_flag_)) {              \
                                                                printf("      TGID       TID"); \
                                                        }                                       \
@@ -120,6 +120,7 @@ struct pid_stats {
        unsigned int       uc_asum_count                __attribute__ ((packed));
        unsigned int       processor                    __attribute__ ((packed));
        unsigned int       flags                        __attribute__ ((packed));
+       unsigned int       uid                          __attribute__ ((packed));
        char               comm[MAX_COMM_LEN];
        char               cmdline[MAX_CMDLINE_LEN];
 };