mirror of
https://github.com/monitoring-plugins/monitoring-plugins.git
synced 2026-06-09 00:32:05 -04:00
Merge pull request #2101 from RincewindsHat/refactor/check_procs
Refactor/check procs
This commit is contained in:
commit
e63acdb83d
4 changed files with 626 additions and 571 deletions
|
|
@ -796,7 +796,7 @@ elif ps axwo 'stat comm vsz rss user uid pid ppid etime args' 2>/dev/null | \
|
|||
then
|
||||
ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procetime,procprog,&pos]"
|
||||
ac_cv_ps_command="$PATH_TO_PS axwo 'stat uid pid ppid vsz rss pcpu etime comm args'"
|
||||
ac_cv_ps_format="%s %d %d %d %d %d %f %s %s %n"
|
||||
ac_cv_ps_format="%s %u %d %d %d %d %f %s %s %n"
|
||||
ac_cv_ps_cols=10
|
||||
AC_MSG_RESULT([$ac_cv_ps_command])
|
||||
|
||||
|
|
|
|||
|
|
@ -72,6 +72,7 @@ EXTRA_DIST = t \
|
|||
check_ntp_peer.d \
|
||||
check_apt.d \
|
||||
check_pgsql.d \
|
||||
check_procs.d \
|
||||
check_ping.d \
|
||||
check_by_ssh.d \
|
||||
check_smtp.d \
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
75
plugins/check_procs.d/config.h
Normal file
75
plugins/check_procs.d/config.h
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
#pragma once
|
||||
|
||||
#include "../../config.h"
|
||||
#include "regex.h"
|
||||
#include "thresholds.h"
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
enum metric {
|
||||
METRIC_PROCS,
|
||||
METRIC_VSZ,
|
||||
METRIC_RSS,
|
||||
METRIC_CPU,
|
||||
METRIC_ELAPSED
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
int options; /* bitmask of filter criteria to test against */
|
||||
enum metric metric;
|
||||
char *metric_name;
|
||||
char *input_filename;
|
||||
char *prog;
|
||||
char *args;
|
||||
char *fmt;
|
||||
char *fails;
|
||||
char *exclude_progs;
|
||||
char **exclude_progs_arr;
|
||||
char exclude_progs_counter;
|
||||
regex_t re_args;
|
||||
|
||||
bool kthread_filter;
|
||||
bool usepid; /* whether to test for pid or /proc/pid/exe */
|
||||
uid_t uid;
|
||||
pid_t ppid;
|
||||
int vsz;
|
||||
int rss;
|
||||
float pcpu;
|
||||
char *statopts;
|
||||
|
||||
char *warning_range;
|
||||
char *critical_range;
|
||||
thresholds *procs_thresholds;
|
||||
} check_procs_config;
|
||||
|
||||
check_procs_config check_procs_config_init() {
|
||||
check_procs_config tmp = {
|
||||
.options = 0,
|
||||
.metric = METRIC_PROCS,
|
||||
.metric_name = strdup("PROCS"),
|
||||
.input_filename = NULL,
|
||||
.prog = NULL,
|
||||
.args = NULL,
|
||||
.fmt = NULL,
|
||||
.fails = NULL,
|
||||
.exclude_progs = NULL,
|
||||
.exclude_progs_arr = NULL,
|
||||
.exclude_progs_counter = 0,
|
||||
.re_args = {0},
|
||||
|
||||
.kthread_filter = false,
|
||||
.usepid = false,
|
||||
.uid = 0,
|
||||
.ppid = 0,
|
||||
.vsz = 0,
|
||||
.rss = 0,
|
||||
.pcpu = 0,
|
||||
.statopts = NULL,
|
||||
|
||||
.warning_range = NULL,
|
||||
.critical_range = NULL,
|
||||
.procs_thresholds = NULL,
|
||||
};
|
||||
return tmp;
|
||||
}
|
||||
Loading…
Reference in a new issue