mailwatch / MailWatch

MailWatch for MailScanner is a web-based front-end to MailScanner
http://mailwatch.org/
GNU General Public License v2.0
117 stars 66 forks source link

MTA process count wrong #1036

Open dwhile opened 6 years ago

dwhile commented 6 years ago

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

Client configuration

Skywalker-11 commented 6 years ago

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