Procmatch PID column show five digits only

Issue #872 resolved
Lutz Mader created an issue

Hello Tildeslash,
based on Monit 5.26.0 I get the following (useless) procmatch list.

monit -B procmatch "/bin/ksh ./loop.*"

List of processes matching pattern "/bin/ksh ./loop.*":
    PID    PPID   Command
    10...      1  /bin/ksh ./loop.sh
    10...      1  /bin/ksh ./loopim24dca.sh
    10...      1  /bin/ksh ./looptrdca.sh
    11...      1  /bin/ksh ./loopdigidca.sh
    12...      1  /bin/ksh ./loopscddca.sh
    17...      1  /bin/ksh ./loopiflogserver.sh
    17...      1  /bin/ksh ./loopifdca.sh
*   19...      1  /bin/ksh ./loop.sh
    65915      1  /bin/ksh ./loopposdca.sh
Total matches: 9

WARNING:
Multiple processes match the pattern. Monit will select the process with the
highest uptime, the one highlighted.

Everything is well, but the column for the PID/PPID is to small, only five digits are shown, but my Linux use six digits.

www       65915      1  0  2019 ?        00:00:00 /bin/ksh ./loopposdca.sh
www      101756      1  0  2019 ?        00:00:00 /bin/ksh ./loop.sh
www      103995      1  0  2019 ?        00:00:00 /bin/ksh ./loopim24dca.sh
www      104246      1  0  2019 ?        00:00:00 /bin/ksh ./looptrdca.sh
www      113313      1  0  2019 ?        00:00:00 /bin/ksh ./loopdigidca.sh
www      126074      1  0  2019 ?        00:00:00 /bin/ksh ./loopscddca.sh
www      176187      1  0 15:19 ?        00:00:00 /bin/ksh ./loopiflogserver.sh
www      176245      1  0 15:19 ?        00:00:00 /bin/ksh ./loopifdca.sh
www      197642      1  0  2019 ?        00:00:00 /bin/ksh ./loop.sh

From my point of view it is a mistake in general for several Unix systems, PIDs are greater than 32767 since several years, for Linux a popular value is 262143 and the max PID is 4194303.

For Linux the max PID size is 5 to 7 digits.
For AIX the max PID size is 7 or 8 digits.
And for MacOS X the max PID size is 5 digits.

Unfortunately, I can not find a place, the include file, where the max PID is defined for all supported systems.

With regards,
Lutz

p.s.
https://unix.stackexchange.com/questions/16883/what-is-the-maximum-value-of-the-process-id

Comments (4)

  1. Lutz Mader reporter

    Hello,
    thanks for your help. Without the fix I get truncated PIDs only.

    monit -B procmatch "/bin/ksh ./loop.*"
    List of processes matching pattern "/bin/ksh ./loop.*":
        PID    PPID   Command
     *  16...      1  /bin/ksh ./loopiflogserver.sh
        16...      1  /bin/ksh ./loopifdca.sh
        17...      1  /bin/ksh ./loopim24dca.sh
        17...      1  /bin/ksh ./loopdigidca.sh
        18...      1  /bin/ksh ./loopposdca.sh
    Total matches: 5
    
    WARNING:
    Multiple processes match the pattern. Monit will select the process with the
    highest uptime, the one highlighted.
    

    With your fix I get the right PIDs.

    monit -B procmatch "/bin/ksh ./loop.*"
    List of processes matching pattern "/bin/ksh ./loop.*":
        PID       PPID      Command
     *    165151         1  /bin/ksh ./loopiflogserver.sh
          165202         1  /bin/ksh ./loopifdca.sh
          172864         1  /bin/ksh ./loopim24dca.sh
          178000         1  /bin/ksh ./loopdigidca.sh
          181074         1  /bin/ksh ./loopposdca.sh
    Total matches: 5
    
    WARNING:
    Multiple processes match the pattern. Monit will select the process with the
    highest uptime, the one highlighted.
    

    I do some more tests, but your fix will probably not cause any other problems, I think.

    Thanks for your help.

    With regards,
    Lutz

  2. Log in to comment