Skip to content

Commit 5f48d5c

Browse files
committed
Export individual processes stats nicolargo#794
2 parents 24a3aea + f87e7d7 commit 5f48d5c

File tree

15 files changed

+400
-258
lines changed

15 files changed

+400
-258
lines changed

Diff for: conf/glances.conf

+4
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,10 @@ nice_warning=-20,-19,-18,-17,-16,-15,-14,-13,-12,-11,-10,-9,-8,-7,-6,-5,-4,-3,-2
357357
#nice_careful=1,2,3,4,5,6,7,8,9
358358
#nice_warning=10,11,12,13,14
359359
#nice_critical=15,16,17,18,19
360+
#
361+
# Define the list of processes to export using:
362+
# a comma-separated list of Glances filter
363+
#export=.*firefox.*,pid:1234
360364

361365
[ports]
362366
disable=False

Diff for: docker-compose/glances.conf

+6
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,12 @@ nice_warning=-20,-19,-18,-17,-16,-15,-14,-13,-12,-11,-10,-9,-8,-7,-6,-5,-4,-3,-2
357357
#nice_careful=1,2,3,4,5,6,7,8,9
358358
#nice_warning=10,11,12,13,14
359359
#nice_critical=15,16,17,18,19
360+
#
361+
# Define the list of processes to export using:
362+
# a comma-separated list of regular expression (apply on name and cmdline)
363+
#export=.*firefox.*
364+
# or an uniq key:value filter
365+
#export=pid:1234
360366

361367
[ports]
362368
disable=False

Diff for: docs/aoa/ps.rst

+64-1
Original file line numberDiff line numberDiff line change
@@ -199,4 +199,67 @@ Accumulated per program — key 'j'
199199
When activated ('j' hotkey or --programs option in the command line), processes are merged
200200
to display which programs are active. The columns show the accumulated cpu consumption, the
201201
accumulated virtual and resident memory consumption, the accumulated transferred data I/O.
202-
The PID columns is replaced by a NPROCS column which is the number of processes.
202+
The PID columns is replaced by a NPROCS column which is the number of processes.
203+
204+
Export process
205+
--------------
206+
207+
Glances version 4 introduces a new feature to export specifics processes. In order to use this
208+
feature, you need to use the export option in the processlist section of the Glances configuration
209+
file or the --export-process-filter option in the command line.
210+
211+
The export option is a list of Glances filters.
212+
213+
Example number one, export all processes named 'python' (or with a command line containing 'python'):
214+
215+
.. code-block:: ini
216+
217+
[processlist]
218+
export=.*python.*
219+
220+
Note: or the --export-process-filter ".*python.*" option in the command line.
221+
222+
Example number two, export all processes with the name 'python' or 'bash':
223+
224+
.. code-block:: ini
225+
226+
[processlist]
227+
export=.*python.*,.*bash.*
228+
229+
Note: or the --export-process-filter ".*python.*,.*bash.*" option in the command line.
230+
231+
Example number three, export all processes belong to 'nicolargo' user:
232+
233+
.. code-block:: ini
234+
235+
[processlist]
236+
export=username:nicolargo
237+
238+
Note: or the --export-process-filter "username:nicolargo" option in the command line.
239+
240+
The output of the export use the PID as the key (for example if you want to export firefox process
241+
to a CSV file):
242+
243+
Configuration file (glances.conf):
244+
245+
.. code-block:: ini
246+
247+
[processlist]
248+
export=.*firefox.*
249+
250+
Note: or the --export-process-filter ".*firefox.*" option in the command line.
251+
252+
Command line example:
253+
254+
.. code-block:: bash
255+
256+
glances -C ./conf/glances.conf --export csv --export-csv-file /tmp/glances.csv --disable-plugin all --enable-plugin processlist --quiet
257+
258+
the result will be:
259+
260+
.. code-block:: csv
261+
262+
timestamp,845992.memory_percent,845992.status,845992.num_threads,845992.cpu_timesuser,845992.cpu_timessystem,845992.cpu_timeschildren_user,845992.cpu_timeschildren_system,845992.cpu_timesiowait,845992.memory_inforss,845992.memory_infovms,845992.memory_infoshared,845992.memory_infotext,845992.memory_infolib,845992.memory_infodata,845992.memory_infodirty,845992.name,845992.io_counters,845992.nice,845992.cpu_percent,845992.pid,845992.gidsreal,845992.gidseffective,845992.gidssaved,845992.key,845992.time_since_update,845992.cmdline,845992.username,total,running,sleeping,thread,pid_max
263+
2024-04-03 18:39:55,3.692938041968513,S,138,1702.88,567.89,1752.79,244.18,0.0,288919552,12871561216,95182848,856064,0,984535040,0,firefox,1863281664,0,0.5,845992,1000,1000,1000,pid,2.2084147930145264,/snap/firefox/3836/usr/lib/firefox/firefox,nicolargo,403,1,333,1511,0
264+
2024-04-03 18:39:57,3.692938041968513,S,138,1702.88,567.89,1752.79,244.18,0.0,288919552,12871561216,95182848,856064,0,984535040,0,firefox,1863281664,0,0.5,845992,1000,1000,1000,pid,2.2084147930145264,/snap/firefox/3836/usr/lib/firefox/firefox,nicolargo,403,1,333,1511,0
265+

0 commit comments

Comments
 (0)