#708945 amavisd-new: amavis unfriendly against process list tools

#708945#5
Date:
2013-05-19 15:08:55 UTC
From:
To:
Dear Maintainer,
after upgrading from squeeze to wheezy, any tools which refer to the process
details of amavisd-new, refer the process name not by the name of the
invoked binary (amavisd-new), but by the fully qualified path of this binary
(/usr/sbin/amavi). This reference is limited to 15 characters
(as in /proc/<pid>/stat), so the process name is  severly crippled.

Of course, I could blame ps or pgrep or pkill for this behaviour - but I
think, they are the wrong addressees. This tools refer on /proc/<pid>/stat,
and if they find wrong data there, it's not their fault.

On the other hand, one could wonder, what amavis has to do with
/proc/<pid>/stat? But on a number of very different servers and client
computers, with very different purposes, different installation details and
hundreds or thousands of different installed packages, I found only two
processes, which show this strange behaviour: amavis and postgrey.

#708945#10
Date:
2014-09-09 22:51:31 UTC
From:
To:
Hi,

I crashed into this today too, so here's some more information :)

The underlying cause of this change appears to be the same thing
that resulted in #652026 (also in amavis).  There's a pretty
complete description of it there, so I won't repeat it here.

On the bright side, it should be quite easy to fix, and is trivial
to workaround.

amavisd-new does:

 $myprogram_name = $0;

Followed by later calls to do (essentially):

 $0 = $myprogram_name . $something

for its various sub-processes.  So it could be fixed in the amavis
code by just stripping the path components off the initial assignment
to $myprogram_name in the BEGIN {} section.


In the meantime, people who need to can set $myprogram_name to whatever
they want in the amavis config, and that will also be respected.


FWIW, I hit this trying to use the munin 'proc' plugin to monitor
amavis, and it initially choked on the '/' characters in the process
name.  Unfortunately there's a synergy of sadness there which means
it still doesn't play nice with $myprogram_name = 'amavisd-new',
because that then means /proc/$pid/stat ends up with something like
'amavisd-new (ma' in it, and there's no prizes for guessing how happy
it is with the space and the paren ...

But I can set it to something like 'amavisd_process' which is 15
characters long, doesn't look totally stupid as a graph label, and
pushes the nasties out of the /stat entry too, to work around two
bugs with one kludge :)

  Cheers,
  Ron