-
-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Small suggestion for proc name #32
Comments
Hi Simon, I hadn't considered the proc name as a conveyor of status information, but if it doesn't cause issues with anything else, I don't see why not. OTOH I don't know what is considered "acceptable" on all possible platforms. I did some searching and it seems like anything allowed in a file name would be acceptable... but this is a vague determination so far. Looking at a random proc list on a box, most of them seem to keep the name simple (but I do see at least one exception). Do you have any guidance on the subject? For example in your patch/idea (which I otherwise like), I wonder about some of the "special" chars like It does seem to work in my limited testing (on a Debian-based Linux), I just have no idea how others may react. In fact sounds like it may be a god idea to wrap the actual I've found only limited/useless information so far: Thanks, |
Hi Maxim, I'm not sure about the limitations. My idea was inspired by Zabbix which makes use of this feature on a different operating systems. On our Zabbix server it shows:
Some info they have here https://support.zabbix.com/browse/ZBXNEXT-1855 I think it can be done on most systems but it may also need support for it in with Perl on the platform. Do all the Perls have the ability to set the proctitle and how to handle the case where it doesn't work? If in doubt I could also keep it as a patch in my RPMs where I know that it works on the target platform. Apart from that, I've missed one of the important info which is the UPDATE version of the SA rules. Do you know how to read the UPDATE version? I see that there is a macro which can be used in rules but how can we use it in SpamPD:
That way one could see if SpamPD really runs with the latest updates. Thanks, |
…anks to Simon Matter for suggestion (#32 (comment)).
… for suggestion and patch. Closes #32
Hi Simon, Well... that was a bit of a rabbit hole... :) I'd love your feedback in PR #33 . Not only does a HUP reload new configs and any updated module(s) but one can even update SpamPD code itself on the fly. Pretty neat, didn't really realize that before. Great suggestion on "RULESVERSION," I didn't know about that. Found a way to get ahold of it at startup, though it's a bit "unconventional" I suppose. Don't see much of an impact on startup time. I added it to the logging as well as the proc name. I shortened "SpamAssassin" to "SA" in the proc name... Maybe "Net::Server::PreFork[Simple]" could also be shortened... or maybe they both should be spelled out... on the fence there (and maybe doesn't matter). The Zabbix stuff is interesting... actually stats came to mind right away when you brought up the child name thing. Though currently the only really interesting stat SpamPD tracks is number of processed messages per child. Which could be useful? It would have to update the child name after every message of course, so that would need to be optimized a bit. Thanks, |
Hi Max,
Just some quick thoughts, real tests may have to wait for tomorrow.
Hi Simon,
Well... that was a bit of a rabbit hole... :) I'd love your feedback in
PR #33 .
Not only does a HUP reload new configs and any updated module(s) but one
can even update SpamPD code itself on the fly. Pretty neat, didn't really
realize that before.
And that's where a config file makes more sense than options on the
command line.
Great suggestion on "RULESVERSION," I didn't know about that. Found a way
to get ahold of it at startup, though it's a bit "unconventional" I
suppose. Don't see much of an impact on startup time. I added it to the
logging as well as the proc name.
Thanks, that's really nice.
I shortened "SpamAssassin" to "SA" in the proc name... Maybe
"Net::Server::PreFork[Simple]" could also be shortened... or maybe they
both should be spelled out... on the fence there (and maybe doesn't
matter).
If we always use the same module PreFork, then why not shortening it. I
wasn't sure we never change it.
The Zabbix stuff is interesting... actually stats came to mind right away
when you brought up the child name thing. Though currently the only really
interesting stat SpamPD tracks is number of processed messages per child.
Which could be useful? It would have to update the child name after every
message of course, so that would need to be optimized a bit.
As you say, I thought it would be interesting to see how many requests a
child has already served and the maximum of requests it will do, like
34/100.
One thing that also came to my mind is if it was possible to add a custom
header to show the engine which processed the message, like
X-Spam-Filter: SpamPD 2.60/3.4.6
Maybe even as a config option so that we can define how much info we'd
like to reveal in the message.
What do you think?
Thanks,
Simon
|
Of course it would be nice to inject the X-Spam-Filter: header before SA
adds the other X-Spam-*: headers.
|
It can now be PreFork (which is new) or PreForkSimple (default). Which could be useful to know I suppose. But we could easily just grab the last part of the module name and/or shorten the whole thing to just the upper case letter (for example).
That's what I was thinking. I guess the question is if it's worth the little bit of extra overhead. Though with my other changes the net result should still be quite positive.
My practice so far has been to let the user set up their injected headers using SA configs, to keep that all centralized (with the exception of I think there's a way to do that as an SA "plugin" but I'm not really sure what's involved (I'll check). Barring that, we could of course make an option to do it in SPD itself. My initial thought on that would be maybe some kind of template the user can provide which includes the actual header name as well (maybe "X-Spam-Filter" is already used, for example). eg. |
OK well that's done, anyway. Very simple, at least once I figured out there couldn't be any separators in the macro name. c5ad090 (and added to the PR). Another 👍🏼 for the idea, thanks! |
Hi Maxim,
> If we always use the same module PreFork, then why not shortening it. I
> wasn't sure we never change it.
It can now be PreFork (which is new) or PreForkSimple (default). Which
could be useful to know I suppose. But we could easily just grab the last
part of the module name and/or shorten the whole thing to just the upper
case letter (for example).
That's exactly what I thought and I don't really care about long proc
lines. On our large systems I see lots of processes with command lines of
hundreds of chars.
> As you say, I thought it would be interesting to see how many requests a
> child has already served and the maximum of requests it will do, like
> 34/100.
That's what I was thinking. I guess the question is if it's worth the
little bit of extra overhead. Though with my other changes the net result
should still be quite positive.
I had the impression that SA takes so much time to process a message that
such things like setproctitle won't really matter :)
One more idea, do we have the absolute number of children started by the
parent? That could also be interesting to know in case of debugging leaks.
Thanks,
Simon
|
I've just tested with PR #33 and it works nicely with one small issue: On a newly installed system, before running sa-update, the rules version reported is empty, like
maybe in such case it would be better to show BTW, just in case it's possible to add the child number and request numbers, may I suggest something like this:
(remove the v after rules?) |
Attached patch fixes the unknown rules version for me by showing |
Thanks Simon, I'm working on a way to have the child name be configurable via a template. Something like this: child_name_templ => '$base_name: child [requests $req_count/$req_total] [v$spampd_ver, SA $sa_ver (rules $sa_rls_ver), NS$ns_typ_acr $ns_ver, Perl $perl_ver]', # default child name template Seems most flexible?
Do you mean a sequence number, like the first launched child will be Net::Server doesn't seems to keep any other stats. One thing we could show is if the child is currently connected/working. One other one I thought may be interesting to track would be average time to process a message (we already know the time for each message). Though this may be most interesting for all the children as a whole, so I'm not sure how useful a number that would be to see in a child proc name. OTOH there's no other easy way to get this stat right now. BTW does that header solution work for you? I mean using SA -M |
PS. I meant we could keep an avg. processing time per child and/or overall across all children. Of course for the overall counter then we get into if it's a average over all time since started, or a moving window, or.... but at least some indicator seems potentially useful. |
Hi Maxim,
Thanks Simon,
I'm working on a way to have the child name be configurable via a
template. Something like this:
```perl
child_name_templ => '$base_name: child [requests $req_count/$req_total]
[v$spampd_ver, SA $sa_ver (rules $sa_rls_ver), NS$ns_typ_acr $ns_ver, Perl
$perl_ver]', # default child name template
```
Seems most flexible?
Sure, that would be great, I like the idea.
> One more idea, do we have the absolute number of children started by the
> parent?
...
> BTW, just in case it's possible to add the child number
Do you mean a sequence number, like the first launched child will be `#1`
and incremented for each subsequent one? I don't see an existing counter
for this, but we could add one (using the child creation hook). Or
something else?
Exactly, that's what I had in mind. Since we can now reconfigure
dynamically with SIGHUP, I expect long running instances because we don't
have to restart every few days for rules update. So it's interesting to
see how many children SpamPD has already launched in total and also to see
how many requests each child has processed.
Usually such info can only be found in logfiles and it's difficult to
filter out the interesting values. Using the procnames to show these stats
helps to get a quick overview of what's going on.
Net::Server doesn't seems to keep any other stats. One thing we could
show is if the child is currently connected/working. One other one I
Oh yes, a child status would be nice.
thought may be interesting to track would be average time to process a
message (we already know the time for each message). Though this may be
most interesting for all the children as a whole, so I'm not sure how
useful a number that would be to see in a child proc name. OTOH there's no
other easy way to get this stat right now.
Maybe always show two values: the avg. at the time when the child was
started and the time the last message took?
BTW does that header solution work for you? I mean using SA `add_header`
to add SpamPD version/etc.
I've added the config to our production host which is not running 2.6x
yet. The header is being added fine but of course the _SPAMPDVERSION_ does
not show up yet. So far it looks good.
Thanks,
Simon
|
Just tested and I can now confirm that |
Another rabbit hole visited... :) Pushed a new commit to PR #33. You can now format the child name as you see fit (see new POD section for some details). I made the default somewhat of a middle ground with information most likely to change:
The "D" is for disconnected. The total child count seems to work, since we can count spawns in the parent. The other counters are only tracked per child. Unfortunately there's no (simple-ish) way to get data from a child back to the parent process. So there's currently there's no way to track overall stats like time, or
To overcome this we'd basically need a separate custom communication process between the parent/child. Net::Server actually has a sort-of hook for this, using a UNIX socket which it can open up for you. But the actual protocol is up to the user. Nor does it seem like
Great, thanks. Earlier I was also checking that this met your needs, vs. having SpamPD add the header. Now that we have a template system already, it would be easy to add (including with any of those other statistics I added for child procs). But no need for redundant functionality. Cheers, |
That's good to know, and thanks for checking, I wouldn't have thought of it. I made the default be "(unknown)", whether there's been no update like you said or SA version is too old (or the lookup fails for some other reason). I kept the round brackets just because it's consistent with a couple other places in the logging code (hope that's OK). |
And just pushed a fix (hopefully) for that when there hasn't been a rules update yet. |
Seems my older systems do not like some of the newer code style. On RHEL7 I get:
On a even older system I get this:
Any chance we can get this to work here? Thanks, |
Ah older Perl's again... sorry. Hard to tell which versions implement what (though I should have known on the latter issue). Both fixed I hope! Thanks, |
Thanks, all fixed now and it works great! There's a
Thanks, |
Thanks Simon, good eye. I'll get that fixed up along with a few documentation niggles. |
Hi Maxim, I just wanted to mention how useful the new procname stuff is where the SA rules version is shown: On a system I found that the running system didn't use the updated rules from last night. In the end I found the culprit in this script https://src.fedoraproject.org/rpms/spamassassin/raw/rawhide/f/sa-update.cronscript So, the recent changes are worth gold 👍 Thanks, |
Hi Simon, Very cool! And useful indeed, w/out combing through any logs. Thanks for letting me know. And that was some great "small suggestion"s :) you had! I think 2.61 is ready for a release, but of course let me know if anything comes up at any time (including more good ideas). Cheers! |
Hi Maxim, I agree this code is good for a 2.61 release, congratulations! In case you want to do a last minute change, maybe this:
Thanks, |
Thanks! And yes I did notice the outdated service example file and replaced it with an updated version from the But I was wondering, and perhaps you know... in this block:
Is |
Thanks! And yes I did notice the outdated service example file and
replaced it with an updated version from the `debian` branch (haven't
pushed that change yet).
But I was wondering, and perhaps you know... in this block:
```
[Service]
ExecStart=/usr/sbin/spampd --config /etc/spampd.cfg --pid
/var/run/spampd.pid
ExecReload=/bin/kill -HUP $MAINPID
PIDFile=/var/run/spampd.pid
...
```
Is `PIDFile` necessary here? Or does/can the service controller track pid
for $MAINPID some other way?
I'm a bit confused here. If the service is Type=forking, then a PIDFile is
needed. Here, the type seems to be 'simple' (the default), which means the
PIDFile is not needed. But then, Spampd has to be started with --nodetach.
To be exact, /usr/bin/kill is the binary to call, /bin is now only a
compatibility link to /usr/bin. The same applies to the pid file, it goes
into /run and /var/run is only a compat link. The systemd developers like
to change things :)
In my example systemd will send SIGQUIT only to the master, then wait 30
seconds max. for termination, otherwise terminate master and all children.
In the past we had many different init scripts, with systemd we have a lot
of different unit files :)
Regards,
Simon
|
Thanks... yea a bit confused here also. I punted and put "both" (simple and forking) versions in the example.
Understatement :) I can't keep up! Well 2.61 is official, FWIW. Thanks again for all your help, it's nice working with you. Best, |
Thank you for the new release, it's much appreciated.
Well 2.61 is official, FWIW. Thanks again for all your help, it's nice
working with you.
Glad I was able to contribute, it was a pleasure for me as well.
Thanks,
Simon
|
Hi Maxim,
I can confirm that #30 and #31 are fine now, thanks for that.
Now that we can dynamically reload using SIGHUP, I just had a small idea: why not show some useful runtime information in the proc name instead of only 'child'?
That way one should be able to see which versions are actually running by the child. At least that's how I understood it, when you SIGHUP the processes re-execute with new config and probably new modules so they should show it at runtime, right?
This patch is what I tried here: spampd-2.60-procname.patch.txt
Regards,
Simon
The text was updated successfully, but these errors were encountered: