MailWatch icon indicating copy to clipboard operation
MailWatch copied to clipboard

MTA process count wrong

Open dwhile opened this issue 6 years ago • 1 comments

Issue summary

The process count for the MTA is wrong on the home page. The process count for the MTA is actually the process count for the MTA PLUS MailScanner.

This is caused by the use of the exec function. By using the optional output argument the manual states that if the output array contains any data then the output of the exec command is appended.

This can be fixed by using an unset($output) between the exec calls.

Steps to reproduce

  1. Load the mailwatch web page
  2. Check the process count against a ps from the command line

Expected result

The count of processes should reflect the number of MTA processes

Actual result

The count of MTA processes is equal to the MTA processes PLUS MailSCanner processes

Installation

Mailwatch V1.2.7 upgraded via zip from older version.

Server configuration

  • Operating System: Fedora 26
  • PHP Version: 7.1.13
  • Database: MariaDB V5.5.56
  • Mail Server: Sendmail
  • Used web server: Apache 2.4.29

Client configuration

  • Operating System: Windows 10
  • Browser: Chrome Version 63.0.3239.132 (Official Build) (64-bit)

dwhile avatar Feb 02 '18 11:02 dwhile

Confirmed. exec only adds the values to the $output variable and does not overwrite it. Also for postfix only the master process is counted. Various processes for the queues aren't detected like smtpd, smtp, cleanup etc. because they don't have postfix in their name. Also there can be other processes that do get parameters containing postfix that will be counted as well.

Better would probably be to filter for the mta user, which seems to be at least a bit more accurate for postfix:

# ps -U postfix -u postfix | grep -v MailScanner | grep -v "MailWatch SQL"
   PID TTY          TIME CMD
  2039 ?        00:00:00 qmgr
  2043 ?        00:00:01 tlsmgr
 58085 ?        00:00:00 pickup
 58369 ?        00:00:00 anvil
 58371 ?        00:00:00 spawn
 58692 ?        00:00:00 smtpd
 58694 ?        00:00:00 trivial-rewrite
 58695 ?        00:00:00 cleanup
 58763 ?        00:00:00 smtp
 58962 ?        00:00:00 smtp
 58993 ?        00:00:00 bounce
```

Skywalker-11 avatar Feb 02 '18 16:02 Skywalker-11