# Process monitoring


<!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->

------------------------------------------------------------------------

<a
href="https://github.com/cj-mills/cjm-fasthtml-sysmon/blob/main/cjm_fasthtml_sysmon/monitors/processes.py#L12"
target="_blank" style="float:right; font-size:smaller">source</a>

### get_process_info

>  get_process_info (top_n:int=5)

*Get top processes by CPU and memory usage.*

<table>
<colgroup>
<col style="width: 6%" />
<col style="width: 25%" />
<col style="width: 34%" />
<col style="width: 34%" />
</colgroup>
<thead>
<tr>
<th></th>
<th><strong>Type</strong></th>
<th><strong>Default</strong></th>
<th><strong>Details</strong></th>
</tr>
</thead>
<tbody>
<tr>
<td>top_n</td>
<td>int</td>
<td>5</td>
<td></td>
</tr>
<tr>
<td><strong>Returns</strong></td>
<td><strong>dict</strong></td>
<td></td>
<td><strong>Number of top processes to return for CPU and memory
categories # A dictionary containing top processes and process
statistics</strong></td>
</tr>
</tbody>
</table>

``` python
get_process_info()
```

    {'top_cpu': [{'pid': 1,
       'name': 'systemd',
       'cpu_percent': 0,
       'memory_percent': 0.014959169314795313,
       'memory_mb': 14.07421875,
       'username': 'root',
       'status': 'sleeping'},
      {'pid': 621,
       'name': 'systemd-journald',
       'cpu_percent': 0,
       'memory_percent': 0.016449688821875943,
       'memory_mb': 15.4765625,
       'username': 'root',
       'status': 'sleeping'},
      {'pid': 696,
       'name': 'systemd-udevd',
       'cpu_percent': 0,
       'memory_percent': 0.007884391487315099,
       'memory_mb': 7.41796875,
       'username': 'root',
       'status': 'sleeping'},
      {'pid': 1175,
       'name': 'systemd-oomd',
       'cpu_percent': 0,
       'memory_percent': 0.007867784027626177,
       'memory_mb': 7.40234375,
       'username': 'systemd-oom',
       'status': 'sleeping'},
      {'pid': 1191,
       'name': 'systemd-resolved',
       'cpu_percent': 0,
       'memory_percent': 0.012592606309124113,
       'memory_mb': 11.84765625,
       'username': 'systemd-resolve',
       'status': 'sleeping'}],
     'top_memory': [{'pid': 14235,
       'name': 'firefox',
       'cpu_percent': 0,
       'memory_percent': 1.9376462961503658,
       'memory_mb': 1823.01953125,
       'username': 'innom-dt',
       'status': 'sleeping'},
      {'pid': 15126,
       'name': 'Isolated Web Co',
       'cpu_percent': 0,
       'memory_percent': 0.9300717168235476,
       'memory_mb': 875.05078125,
       'username': 'innom-dt',
       'status': 'sleeping'},
      {'pid': 5452,
       'name': 'gnome-shell',
       'cpu_percent': 0,
       'memory_percent': 0.5894402630090176,
       'memory_mb': 554.5703125,
       'username': 'innom-dt',
       'status': 'sleeping'},
      {'pid': 12565,
       'name': 'code',
       'cpu_percent': 0,
       'memory_percent': 0.48500010089031764,
       'memory_mb': 456.30859375,
       'username': 'innom-dt',
       'status': 'sleeping'},
      {'pid': 65825,
       'name': 'Isolated Web Co',
       'cpu_percent': 0,
       'memory_percent': 0.4831400654051585,
       'memory_mb': 454.55859375,
       'username': 'innom-dt',
       'status': 'sleeping'}],
     'total': 199,
     'status_counts': {'sleeping': 198, 'running': 1}}
