collect active processes limit feature v2 (#9843)
* Add VARIABLE of pid_max to active_processes chart to use on alarms * use function for pid_max and use a single alarm * fix in alarm
Fotis Voutsas committed
Sep 1, 2020 at 17:43 UTC
586424c4dfe8e74d33607d752adb15dc49ec20f4
2 files changed
+13
-20
collectors/proc.plugin/proc_loadavg.c
+7
@@ -46,6 +46,10 @@ int do_proc_loadavg(int update_every, usec_t dt) {
46
47
//unsigned long long running_processes = str2ull(procfile_lineword(ff, 0, 3));
48
unsigned long long active_processes = str2ull(procfile_lineword(ff, 0, 4));
49
+
50
+ //get system pid_max
51
+ unsigned long long max_processes = get_system_pid_max();
52
+ //
53
//unsigned long long next_pid = str2ull(procfile_lineword(ff, 0, 5));
54
55
@@ -95,6 +99,7 @@ int do_proc_loadavg(int update_every, usec_t dt) {
99
if(likely(do_all_processes)) {
100
static RRDSET *processes_chart = NULL;
101
static RRDDIM *rd_active = NULL;
102
+ static RRDSETVAR *rd_pidmax;
103
104
if(unlikely(!processes_chart)) {
105
processes_chart = rrdset_create_localhost(
@@ -113,10 +118,12 @@ int do_proc_loadavg(int update_every, usec_t dt) {
118
);
119
120
rd_active = rrddim_add(processes_chart, "active", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
121
+ rd_pidmax = rrdsetvar_custom_chart_variable_create(processes_chart, "pidmax");
122
}
123
else rrdset_next(processes_chart);
124
125
rrddim_set_by_pointer(processes_chart, rd_active, active_processes);
126
+ rrdsetvar_custom_chart_variable_set(rd_pidmax, max_processes);
127
rrdset_done(processes_chart);
128
}
129
health/health.d/processes.conf
+6
-20
@@ -1,27 +1,13 @@
1
# you can disable an alarm notification by setting the 'to' line to: silent
2
3
- alarm: active_processes_limit_freebsd
3
+ alarm: active_processes
4
on: system.active_processes
5
- os: freebsd
5
hosts: *
7
- calc: $active
8
- units: processes
6
+ calc: $active * 100 / $pidmax
7
+ units: %
8
every: 5s
10
- warn: $this > (($status >= $WARNING) ? (75000) : (80000))
11
- crit: $this > (($status == $CRITICAL) ? (85000) : (90000))
9
+ warn: $this > (($status >= $WARNING) ? (75) : (80))
10
+ crit: $this > (($status == $CRITICAL) ? (85) : (90))
11
delay: down 5m multiplier 1.5 max 1h
13
- info: the number of active processes
14
- to: sysadmin
15
-
16
- alarm: active_processes_limit
17
- on: system.active_processes
18
- os: linux
19
- hosts: *
20
- calc: $active
21
- units: processes
22
- every: 5s
23
- warn: $this > (($status >= $WARNING) ? (25000) : (26000))
24
- crit: $this > (($status == $CRITICAL) ? (28000) : (30000))
25
- delay: down 5m multiplier 1.5 max 1h
26
- info: number of active processes
12
+ info: the percentage of active processes
13
to: sysadmin