Skip to content

Commit 0d83ae4

Browse files
committed
refactor(procs): avoid token + PEB reads and repeated attribute calls per process, as this has an impact on busy Windows servers
1 parent 019a382 commit 0d83ae4

4 files changed

Lines changed: 267 additions & 194 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ Monitoring Plugins:
6969
* infomaniak-events: increase timeout from 8 to 28 secs
7070
* journald-usage: also print SystemMaxUse and SystemKeepFree
7171
* pip-updates: modernize code
72+
* procs: avoid token + PEB reads and repeated attribute calls per process, as this has an impact on busy Windows servers
7273
* rocketchat-stats: improve output and docs a little bit
7374
* statuspal: 'performance' degredation is now a WARN, not UNKNOWN
7475

check-plugins/procs/README.md

Lines changed: 17 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,9 @@
44

55
Prints the number of currently running processes and warns on metrics like process counts or process memory usage. You may filter the process list by process name, arguments and/or user name.
66

7-
In output, process states are summarized like so:
8-
9-
| Reported Proc State | Description |
10-
|---------------------|-------------|
11-
| dead | X |
12-
| paging | W |
13-
| running | R |
14-
| sleeping | I, S |
15-
| stopped | t, T |
16-
| uninterruptible | D |
17-
| zombies | Z |
18-
197
Hints:
208

21-
* RSS aka "Resident Set Size" ("Res"): This is the non-swapped physical memory a process has used. On UNIX it matches "top"'s RES column. On Windows this is an alias for wset field and it matches "Mem Usage" column of `taskmgr.exe`.
22-
* Be aware of the differences in memory counting between different tools like top, htop, glances, GNOME System Monitor etc.
23-
* Memory counting also changed between different Linux Kernel versions.
9+
* Memory: We count RSS, also known as 'Resident Set Size' or 'Res'. This is the amount of physical memory that a process has used that has not been swapped out. In UNIX, it matches the 'RES' column in 'top'. Note the differences in memory counting between tools such as 'top', 'htop', 'glances', 'GNOME System Monitor' and others. The way memory is counted also changes between different Linux kernel versions. On Windows, this is an alias for the wset field, matching the 'Mem Usage' column in taskmgr.exe.
2410

2511

2612
## Fact Sheet
@@ -54,10 +40,11 @@ options:
5440
-V, --version show program's version number and exit
5541
--always-ok Always returns OK.
5642
--argument ARGUMENT Filter: Search only for processes containing ARGUMENT
57-
in the command, for example `-s` (case-insensitive).
43+
in the command (case-insensitive), for example
44+
`--verbose`
5845
--command COMMAND Filter: Search only for processes starting with
59-
COMMAND, for example `bash` (without path, case-
60-
insensitive).
46+
COMMAND (without path, case-insensitive), for example
47+
`bash`
6148
-c, --critical CRIT Threshold for the number of processes. Type: None or
6249
Range. Default: None
6350
--critical-mem CRIT_MEM
@@ -73,9 +60,9 @@ options:
7360
Linux only). Default: False
7461
--status {dead,disk-sleep,idle,locked,parked,running,sleeping,stopped,suspended,tracing-stop,waiting,wake-kill,waking,zombie}
7562
Filter: Search only for processes that have a specific
76-
status. Default: None,
63+
status. Default: None
7764
--username USERNAME Filter: Search only for processes with specific user
78-
name, e.g. `apache` (case-insensitive).
65+
name (case-insensitive), for example `apache`
7966
-w, --warning WARN Threshold for the number of processes. Type: None or
8067
Range. Default: None
8168
--warning-mem WARN_MEM
@@ -99,7 +86,7 @@ options:
9986
Output:
10087

10188
```text
102-
356 procs using 9.5GiB RAM (62.7%), oldest proc created 7h 44m ago, 5 running (1x glances, 1x WebExtensions, 1x systemd-resolved, 1x firefox, 1x Privileged Cont), 351 sleeping
89+
564 procs using 16.9GiB RAM (54.7%), 1 uninterruptible (1x kworker/u36:0+i915_flip), 1 running (1x isolated web co), 561 sleeping, 1 zombie (1x xdg-open)
10390
```
10491

10592
Other examples:
@@ -121,15 +108,6 @@ Other examples:
121108
./procs --command='web content'
122109
```
123110

124-
## How to get process names
125-
126-
Some process names in Python's psutil do not match the ones from `ps aux`. To get a list with all processes, their names and details from a Python point of view, do:
127-
128-
```python
129-
(echo "import psutil"; echo "processes = psutil.process_iter()"; echo "for process in processes: print(process)") | python
130-
```
131-
132-
133111
## States
134112

135113
* WARN or CRIT depending on your parameters, or if no process can be found.
@@ -151,6 +129,15 @@ Some process names in Python's psutil do not match the ones from `ps aux`. To ge
151129
| procs_zombies | Number | Number of zombie processes |
152130

153131

132+
## Troubleshooting
133+
134+
How to get process names? Some process names in Python's psutil do not match the ones from `ps aux`. To get a list with all processes, their names and details from a Python point of view, do:
135+
136+
```python
137+
(echo "import psutil"; echo "processes = psutil.process_iter()"; echo "for process in processes: print(process)") | python
138+
```
139+
140+
154141
## Credits, License
155142

156143
* Authors: [Linuxfabrik GmbH, Zurich](https://www.linuxfabrik.ch)

check-plugins/procs/icingaweb2-module-director/procs.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,7 @@
569569
"2": {
570570
"varname": "procs_argument",
571571
"caption": "Procs: Argument",
572-
"description": "Filter: Search only for processes containing ARGUMENT in the command, for example `-s` (case-insensitive).",
572+
"description": "Filter: Search only for processes containing ARGUMENT in the command (case-insensitive), for example `--verbose`",
573573
"datatype": "Icinga\\Module\\Director\\DataType\\DataTypeString",
574574
"format": null,
575575
"settings": {
@@ -580,7 +580,7 @@
580580
"3": {
581581
"varname": "procs_command",
582582
"caption": "Procs: Command",
583-
"description": "Filter: Search only for processes starting with COMMAND, for example `bash` (without path, case-insensitive).",
583+
"description": "Filter: Search only for processes starting with COMMAND (without path, case-insensitive), for example `bash`",
584584
"datatype": "Icinga\\Module\\Director\\DataType\\DataTypeString",
585585
"format": null,
586586
"settings": {
@@ -657,7 +657,7 @@
657657
"10": {
658658
"varname": "procs_username",
659659
"caption": "Procs: Username",
660-
"description": "Filter: Search only for processes with specific user name, e.g. `apache` (case-insensitive).",
660+
"description": "Filter: Search only for processes with specific user name (case-insensitive), for example `apache`",
661661
"datatype": "Icinga\\Module\\Director\\DataType\\DataTypeString",
662662
"format": null,
663663
"settings": {
@@ -721,7 +721,7 @@
721721
"16": {
722722
"varname": "procs_windows_argument",
723723
"caption": "Procs: Argument",
724-
"description": "Filter: Search only for processes containing ARGUMENT in the command, for example `-s` (case-insensitive).",
724+
"description": "Filter: Search only for processes containing ARGUMENT in the command (case-insensitive), for example `--verbose`",
725725
"datatype": "Icinga\\Module\\Director\\DataType\\DataTypeString",
726726
"format": null,
727727
"settings": {
@@ -732,7 +732,7 @@
732732
"17": {
733733
"varname": "procs_windows_command",
734734
"caption": "Procs: Command",
735-
"description": "Filter: Search only for processes starting with COMMAND, for example `bash` (without path, case-insensitive).",
735+
"description": "Filter: Search only for processes starting with COMMAND (without path, case-insensitive), for example `bash`",
736736
"datatype": "Icinga\\Module\\Director\\DataType\\DataTypeString",
737737
"format": null,
738738
"settings": {
@@ -809,7 +809,7 @@
809809
"24": {
810810
"varname": "procs_windows_username",
811811
"caption": "Procs: Username",
812-
"description": "Filter: Search only for processes with specific user name, e.g. `apache` (case-insensitive).",
812+
"description": "Filter: Search only for processes with specific user name (case-insensitive), for example `apache`",
813813
"datatype": "Icinga\\Module\\Director\\DataType\\DataTypeString",
814814
"format": null,
815815
"settings": {

0 commit comments

Comments
 (0)