]> granicus.if.org Git - sysstat/blob - pidstat.h
Remove unused constants from header files
[sysstat] / pidstat.h
1 /*
2  * pidstat: Display per-process statistics.
3  * (C) 2007-2013 by Sebastien Godard (sysstat <at> orange.fr)
4  */
5
6 #ifndef _PIDSTAT_H
7 #define _PIDSTAT_H
8
9
10 #define K_SELF          "SELF"
11
12 #define K_P_TASK        "TASK"
13 #define K_P_CHILD       "CHILD"
14 #define K_P_ALL         "ALL"
15
16 #define NR_PID_PREALLOC 10
17
18 #define MAX_COMM_LEN    128
19 #define MAX_CMDLINE_LEN 128
20 #define MAX_USER_LEN    32
21
22 /* Activities */
23 #define P_A_CPU         0x01
24 #define P_A_MEM         0x02
25 #define P_A_IO          0x04
26 #define P_A_CTXSW       0x08
27 #define P_A_STACK       0x10
28
29 #define DISPLAY_CPU(m)          (((m) & P_A_CPU) == P_A_CPU)
30 #define DISPLAY_MEM(m)          (((m) & P_A_MEM) == P_A_MEM)
31 #define DISPLAY_IO(m)           (((m) & P_A_IO) == P_A_IO)
32 #define DISPLAY_CTXSW(m)        (((m) & P_A_CTXSW) == P_A_CTXSW)
33 #define DISPLAY_STACK(m)        (((m) & P_A_STACK) == P_A_STACK)
34
35 /* TASK/CHILD */
36 #define P_NULL          0x00
37 #define P_TASK          0x01
38 #define P_CHILD         0x02
39
40 #define DISPLAY_TASK_STATS(m)   (((m) & P_TASK) == P_TASK)
41 #define DISPLAY_CHILD_STATS(m)  (((m) & P_CHILD) == P_CHILD)
42
43 #define P_D_PID         0x001
44 #define P_D_ALL_PID     0x002
45 #define P_F_IRIX_MODE   0x004
46 #define P_F_COMMSTR     0x008
47 #define P_D_ACTIVE_PID  0x010
48 #define P_D_TID         0x020
49 #define P_D_ONELINE     0x040
50 #define P_D_CMDLINE     0x080
51 #define P_D_USERNAME    0x100
52 #define P_F_USERSTR     0x200
53
54 #define DISPLAY_PID(m)          (((m) & P_D_PID) == P_D_PID)
55 #define DISPLAY_ALL_PID(m)      (((m) & P_D_ALL_PID) == P_D_ALL_PID)
56 #define IRIX_MODE_OFF(m)        (((m) & P_F_IRIX_MODE) == P_F_IRIX_MODE)
57 #define COMMAND_STRING(m)       (((m) & P_F_COMMSTR) == P_F_COMMSTR)
58 #define DISPLAY_ACTIVE_PID(m)   (((m) & P_D_ACTIVE_PID) == P_D_ACTIVE_PID)
59 #define DISPLAY_TID(m)          (((m) & P_D_TID) == P_D_TID)
60 #define DISPLAY_ONELINE(m)      (((m) & P_D_ONELINE) == P_D_ONELINE)
61 #define DISPLAY_CMDLINE(m)      (((m) & P_D_CMDLINE) == P_D_CMDLINE)
62 #define DISPLAY_USERNAME(m)     (((m) & P_D_USERNAME) == P_D_USERNAME)
63 #define USER_STRING(m)          (((m) & P_F_USERSTR) == P_F_USERSTR)
64
65 #define F_NO_PID_IO     0x01
66
67 #define NO_PID_IO(m)            (((m) & F_NO_PID_IO) == F_NO_PID_IO)
68
69 #define PROC            "/proc"
70
71 #define PID_STAT        "/proc/%u/stat"
72 #define PID_STATUS      "/proc/%u/status"
73 #define PID_IO          "/proc/%u/io"
74 #define PID_CMDLINE     "/proc/%u/cmdline"
75 #define PID_SMAP        "/proc/%u/smaps"
76
77 #define PROC_TASK       "/proc/%u/task"
78 #define TASK_STAT       "/proc/%u/task/%u/stat"
79 #define TASK_STATUS     "/proc/%u/task/%u/status"
80 #define TASK_IO         "/proc/%u/task/%u/io"
81 #define TASK_CMDLINE    "/proc/%u/task/%u/cmdline"
82 #define TASK_SMAP       "/proc/%u/task/%u/smaps"
83
84 #define PRINT_ID_HDR(_timestamp_, _flag_)       do {                                            \
85                                                         printf("\n%-11s", _timestamp_); \
86                                                         if (DISPLAY_USERNAME(_flag_)) {         \
87                                                                 printf("     USER");            \
88                                                         }                                       \
89                                                         else {                                  \
90                                                                 printf("   UID");               \
91                                                         }                                       \
92                                                         if (DISPLAY_TID(_flag_)) {              \
93                                                                 printf("      TGID       TID"); \
94                                                         }                                       \
95                                                         else {                                  \
96                                                                 printf("       PID");           \
97                                                         }                                       \
98                                                 } while (0)
99
100 struct pid_stats {
101         unsigned long long read_bytes                   __attribute__ ((aligned (8)));
102         unsigned long long write_bytes                  __attribute__ ((packed));
103         unsigned long long cancelled_write_bytes        __attribute__ ((packed));
104         unsigned long long total_vsz                    __attribute__ ((packed));
105         unsigned long long total_rss                    __attribute__ ((packed));
106         unsigned long long total_stack_size             __attribute__ ((packed));
107         unsigned long long total_stack_ref              __attribute__ ((packed));
108         unsigned long      minflt                       __attribute__ ((packed));
109         unsigned long      cminflt                      __attribute__ ((packed));
110         unsigned long      majflt                       __attribute__ ((packed));
111         unsigned long      cmajflt                      __attribute__ ((packed));
112         unsigned long      utime                        __attribute__ ((packed));
113         unsigned long      cutime                       __attribute__ ((packed));
114         unsigned long      stime                        __attribute__ ((packed));
115         unsigned long      cstime                       __attribute__ ((packed));
116         unsigned long      gtime                        __attribute__ ((packed));
117         unsigned long      cgtime                       __attribute__ ((packed));
118         unsigned long      vsz                          __attribute__ ((packed));
119         unsigned long      rss                          __attribute__ ((packed));
120         unsigned long      nvcsw                        __attribute__ ((packed));
121         unsigned long      nivcsw                       __attribute__ ((packed));
122         unsigned long      stack_size                   __attribute__ ((packed));
123         unsigned long      stack_ref                    __attribute__ ((packed));
124         /* If pid is null, the process has terminated */
125         unsigned int       pid                          __attribute__ ((packed));
126         /* If tgid is not null, then this PID is in fact a TID */
127         unsigned int       tgid                         __attribute__ ((packed));
128         unsigned int       rt_asum_count                __attribute__ ((packed));
129         unsigned int       rc_asum_count                __attribute__ ((packed));
130         unsigned int       uc_asum_count                __attribute__ ((packed));
131         unsigned int       processor                    __attribute__ ((packed));
132         unsigned int       flags                        __attribute__ ((packed));
133         unsigned int       uid                          __attribute__ ((packed));
134         char               comm[MAX_COMM_LEN];
135         char               cmdline[MAX_CMDLINE_LEN];
136 };
137
138 #define PID_STATS_SIZE  (sizeof(struct pid_stats))
139
140 #endif  /* _PIDSTAT_H */