show cpu time and memory in processes list
Stefan Schuermans

Stefan Schuermans commited on 2020-05-24 10:44:02
Showing 2 changed files, with 49 additions and 5 deletions.

... ...
@@ -22,6 +22,10 @@
22 22
       <column type="gchararray"/>
23 23
       <!-- column-name cmdline -->
24 24
       <column type="gchararray"/>
25
+      <!-- column-name cpu_time -->
26
+      <column type="gchararray"/>
27
+      <!-- column-name max_rss_kb -->
28
+      <column type="gchararray"/>
25 29
     </columns>
26 30
   </object>
27 31
   <object class="GtkWindow" id="Application">
... ...
@@ -68,7 +72,7 @@
68 72
                         <property name="clickable">True</property>
69 73
                         <property name="reorderable">True</property>
70 74
                         <property name="sort_indicator">True</property>
71
-                        <property name="sort_column_id">0</property>
75
+                        <property name="sort_column_id">1</property>
72 76
                         <child>
73 77
                           <object class="GtkCellRendererText" id="ProcessesBeginText"/>
74 78
                           <attributes>
... ...
@@ -85,7 +89,7 @@
85 89
                         <property name="clickable">True</property>
86 90
                         <property name="reorderable">True</property>
87 91
                         <property name="sort_indicator">True</property>
88
-                        <property name="sort_column_id">1</property>
92
+                        <property name="sort_column_id">2</property>
89 93
                         <child>
90 94
                           <object class="GtkCellRendererText" id="ProcessesEndText"/>
91 95
                           <attributes>
... ...
@@ -102,7 +106,7 @@
102 106
                         <property name="clickable">True</property>
103 107
                         <property name="reorderable">True</property>
104 108
                         <property name="sort_indicator">True</property>
105
-                        <property name="sort_column_id">2</property>
109
+                        <property name="sort_column_id">3</property>
106 110
                         <child>
107 111
                           <object class="GtkCellRendererText" id="ProcessesCommandText"/>
108 112
                           <attributes>
... ...
@@ -111,6 +115,40 @@
111 115
                         </child>
112 116
                       </object>
113 117
                     </child>
118
+                    <child>
119
+                      <object class="GtkTreeViewColumn" id="ProcessesCpuTimeCol">
120
+                        <property name="resizable">True</property>
121
+                        <property name="sizing">fixed</property>
122
+                        <property name="title" translatable="yes">CPU Time</property>
123
+                        <property name="clickable">True</property>
124
+                        <property name="reorderable">True</property>
125
+                        <property name="sort_indicator">True</property>
126
+                        <property name="sort_column_id">4</property>
127
+                        <child>
128
+                          <object class="GtkCellRendererText" id="ProcessesCpuTimeText"/>
129
+                          <attributes>
130
+                            <attribute name="text">4</attribute>
131
+                          </attributes>
132
+                        </child>
133
+                      </object>
134
+                    </child>
135
+                    <child>
136
+                      <object class="GtkTreeViewColumn" id="ProcessesMemoryCol">
137
+                        <property name="resizable">True</property>
138
+                        <property name="sizing">fixed</property>
139
+                        <property name="title" translatable="yes">Memory</property>
140
+                        <property name="clickable">True</property>
141
+                        <property name="reorderable">True</property>
142
+                        <property name="sort_indicator">True</property>
143
+                        <property name="sort_column_id">5</property>
144
+                        <child>
145
+                          <object class="GtkCellRendererText" id="ProcessesMemoryText"/>
146
+                          <attributes>
147
+                            <attribute name="text">5</attribute>
148
+                          </attributes>
149
+                        </child>
150
+                      </object>
151
+                    </child>
114 152
                   </object>
115 153
                 </child>
116 154
               </object>
... ...
@@ -101,7 +101,9 @@ class UptGui:
101 101
     PROC_PROC_ID = 0
102 102
     PROC_BEGIN = 1
103 103
     PROC_END = 2
104
-    PROC_COMMAND = 3
104
+    PROC_CMDLINE = 3
105
+    PROC_CPU_TIME = 4
106
+    PROC_MAX_RSS_KB = 5
105 107
 
106 108
     def __init__(self, proto_filename):
107 109
         """
... ...
@@ -220,8 +222,12 @@ class UptGui:
220 222
                 timestamp2str(proc.begin_timestamp))
221 223
             self.widProcessesTree.set_value(proc_iter, self.PROC_END,
222 224
                                             timestamp2str(proc.end_timestamp))
223
-            self.widProcessesTree.set_value(proc_iter, self.PROC_COMMAND,
225
+            self.widProcessesTree.set_value(proc_iter, self.PROC_CMDLINE,
224 226
                                             cmdline2str(proc.cmdline))
227
+            self.widProcessesTree.set_value(proc_iter, self.PROC_CPU_TIME,
228
+                                            duration2str(proc.cpu_time))
229
+            self.widProcessesTree.set_value(proc_iter, self.PROC_MAX_RSS_KB,
230
+                                            kb2str(proc.max_rss_kb))
225 231
             to_be_output.append((proc.children, proc_iter))
226 232
         # show all processes
227 233
         self.widProcessesView.expand_all()
228 234