Open pbiering opened 2 years ago
Excellent, i came here looking for a fix for this issue. This patch has an issue with an uninitialized value for process_state but i hope this can be resolved. Perhaps like this?
diff --git a/src/processmon.c b/src/processmon.c
index 754d732..1727bdd 100644
--- a/src/processmon.c
+++ b/src/processmon.c
@@ -233,6 +233,12 @@ static int pm_read_stat(process_data_t *pd, char *process_state) {
// read the proc stat file for pid.
snprintf(fname, sizeof(fname), "/proc/%s/stat", pd->pid);
+ // check in advance whether or not it still exists
+ if (access(fname, F_OK) != 0) {
+ WARNING("processmon plugin: Disappeared before reading %s", fname);
+ return 0;
+ }
+
ssize_t status = read_file_contents(fname, buf, sizeof(buf) - 1);
if (status <= 0) {
ERROR("processmon plugin: Error reading %s", fname);
@@ -510,7 +516,7 @@ static int pm_read(void) {
int total_count = 0;
// variables to keep counts of process states
- char process_state;
+ char process_state = '-';
int state_R = 0;
int state_S = 0;
int state_D = 0;
Sorry for the delay. We're looking into it.
Should processmon still be used? Your own documentation no longer mentions it.
Looks like shortliving processes are not proper catched by processmon
See log:
A patch which catch this case is like following:
afterwards following appears in log, processmon is no longer suspended:
Dec 07 13:57:36 *** collectd[1847744]: processmon plugin: File disappeared before reading reading /proc/1847741/stat