License
MIT License
v1.2.4 · public · Published 3 days ago
sensu-process-ressources is a Sensu Check that watches the resource usage of
a named process and alerts when it goes over a threshold. It can alert on three
things, in any combination:
Every running process is examined, and the check reports on the first one whose
name (or full command line, with --cmdline) matches --process. If several
processes share a name, the first match wins rather than the busiest one.
The check exits 0 (OK) when nothing matched a threshold — including when no
process matched the name at all. It does not alert on a missing process; use a
dedicated process-presence check for that.
Check if process is using too much ressources (CPU/memory)
Usage:
check-process-ressources [flags]
check-process-ressources [command]
Available Commands:
completion Generate the autocompletion script for the specified shell
help Help about any command
version Print the version number of this plugin
Flags:
--cmdline Use full command line of the process
--cpu-crit float Critical if process is using more than cpu-crit (in percent) (default 75)
--cpu-warn float Warn if process is using more than cpu-warn (in percent) (default 50)
-h, --help help for check-process-ressources
--memory-crit float32 Critical if process is using more than memory-crit (in percent) (default 70)
--memory-warn float32 Warn if process is using more than memory-warn (in percent) (default 50)
--process string Process to monitor
--time-crit int Critical if process has been running for longer than time-crit (in seconds)
--time-warn int Warn if process has been running for longer than time-warn (in seconds)
Use "check-process-ressources [command] --help" for more information about a command.
Alert when nginx uses more than 60% of memory (critical) or 40% (warning),
leaving the CPU thresholds at their defaults:
sensu-process-ressources --process nginx --memory-warn 40 --memory-crit 60
Alert on a long-running backup job. The memory and CPU thresholds are raised out
of the way so that only the runtime triggers:
sensu-process-ressources --process backup.sh \
--memory-warn 95 --memory-crit 99 \
--cpu-warn 95 --cpu-crit 99 \
--time-warn 3600 --time-crit 7200
Match on the full command line instead of the process name, which is how you tell
two processes of the same binary apart:
sensu-process-ressources --cmdline --process "/usr/bin/python3 /opt/app/worker.py --queue email"
Sensu Assets are the best way to make use of this plugin. If you're not using an asset, please
consider doing so! If you're using sensuctl 5.13 with Sensu Backend 5.13 or later, you can use the
following command to add the asset:
sensuctl asset add elfranne/sensu-process-ressources
If you're using an earlier version of sensuctl, you can find the asset on the
Bonsai Asset Index.
---
type: CheckConfig
api_version: core/v2
metadata:
name: sensu-process-ressources
namespace: default
spec:
command: sensu-process-ressources --process nginx --memory-warn 40 --memory-crit 60
subscriptions:
- system
runtime_assets:
- elfranne/sensu-process-ressources
Every argument can also be set as an entity or check annotation under the
sensu.io/plugins/check-process-ressources/config keyspace, which lets you keep
one check definition and vary the thresholds per entity:
---
type: Entity
api_version: core/v2
metadata:
name: web-01
namespace: default
annotations:
sensu.io/plugins/check-process-ressources/config/process: nginx
sensu.io/plugins/check-process-ressources/config/memory-crit: "60"
| Argument | Type | Default | Description |
|---|---|---|---|
--process |
string | — | Process to match. Required. |
--cmdline |
bool | false |
Match against the full command line instead of the process name. |
--memory-warn |
float32 | 50 |
Warn above this percentage of system memory. |
--memory-crit |
float32 | 70 |
Go critical above this percentage of system memory. |
--cpu-warn |
float64 | 50 |
Warn above this CPU percentage. |
--cpu-crit |
float64 | 75 |
Go critical above this CPU percentage. |
--time-warn |
int64 | 0 |
Warn when the process has run this many seconds. 0 disables the check. |
--time-crit |
int64 | 0 |
Go critical when the process has run this many seconds. 0 disables the check. |
The preferred way of installing and deploying this plugin is to use it as an Asset. If you would
like to compile and install the plugin from source or contribute to it, download the latest version
or create an executable script from this source.
From the local path of the sensu-process-ressources repository:
go build
To run the tests:
go test ./...
100 is rejected. The check exits with a warning0, so leaving them out means the check never alerts on process age.For more information about contributing to this plugin, see Contributing.
Please describe the reason for reporting this asset. Our moderators will be notified and will disable the asset if it is found to be inappropriate.
×