added support in 'process.pm' for systems with different PID max value defined in '/proc/sys/kernel/pid_max'

This commit is contained in:
Jordi Sanfeliu 2021-04-22 07:52:05 +02:00
parent 9134aebfb7
commit cbcf2557b3
1 changed files with 4 additions and 2 deletions

View File

@ -1,7 +1,7 @@
# #
# Monitorix - A lightweight system monitoring tool. # Monitorix - A lightweight system monitoring tool.
# #
# Copyright (C) 2005-2020 by Jordi Sanfeliu <jordi@fibranet.cat> # Copyright (C) 2005-2021 by Jordi Sanfeliu <jordi@fibranet.cat>
# #
# This program is free software; you can redistribute it and/or modify # This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by
@ -169,6 +169,8 @@ sub process_update {
# check if that process is running # check if that process is running
if(open(IN, "ps -eo pid,comm,command |")) { if(open(IN, "ps -eo pid,comm,command |")) {
my $pidwidth = length(`cat /proc/sys/kernel/pid_max`);
while(<IN>) { while(<IN>) {
if(m/^\s*(\d+)\s+(\S+)\s+(.*?)$/) { if(m/^\s*(\d+)\s+(\S+)\s+(.*?)$/) {
if($p eq trim($2)) { if($p eq trim($2)) {
@ -187,7 +189,7 @@ sub process_update {
next; next;
} }
} }
if(substr($p, 0, 15) eq substr($_, 6, 15)) { if(substr($p, 0, 15) eq substr($_, $pidwidth, 15)) {
push(@pids, $1); push(@pids, $1);
$pro++; $pro++;
next; next;