net-mail/mailgraph-1.14-r2 does not contain systemd-relevant files. (a) suggested service-file: [Unit] Description=mailgraph mail log file analyzer After=syslog.target [Service] EnvironmentFile=/etc/conf.d/mailgraph Nice=19 Type=forking ExecStart=/usr/bin/mailgraph -d -l /var/log/messages \ --daemon-rrd=/var/lib/mailgraph \ --daemon-pid=/var/run/mailgraph/mailgraph.pid \ –-ignore-localhost [Install] WantedBy=multi-user.target (b) needed entry in tmpfiles.d # mailgraph.conf D /run/mailgraph 0750 root root
BUMP bug is old, pls do something ;-)
Please take a look to guidelines about how to make better unit files :) https://wiki.gentoo.org/wiki/Project:Systemd/Ebuild_policy In summary: 1. Does this really need to run in daemon mode and then using Type=forking + needing to take care of the pid file? Would it cause problems to run it instead in foreground? 2. EnvironmentFile is usually discouraged... and also, in this case it looks to be even not needed, I would drop that line then.
thanks for the pointer, I will try to rewrite my file and test that asap. It works for me so far but I agree to get it right (the suggested service file is from late 2014 ...).
improved and working service file: # cat mailgraph.service [Unit] Description=mailgraph mail log file analyzer After=syslog.target [Service] Nice=19 Type=simple # User=mgraph ExecStart=/usr/bin/mailgraph -l /var/log/messages \ --daemon-rrd=/var/lib/mailgraph --daemon-pid=/var/run/mailgraph/mailgraph.pid \ –-ignore-localhost [Install] WantedBy=multi-user.target -> Type=simple, no "--daemon", no Environmentfile What I dislike (and need advice/help for): it runs as root right now to be able to read from /var/log/messages. Which leads to the fact that mailgraph isn't yet able (AFAIK) to read directly from the systemd journal. With "User=mgraph" it fails to read /var/log/messages with perms 600.
In Fedora the logs for mailgraph are on a separate /var/log/maillog file... maybe it could help
(In reply to Pacho Ramos from comment #5) > In Fedora the logs for mailgraph are on a separate /var/log/maillog file... > maybe it could help To have a dedicated /var/log/maillog with systemd-journal one would need to pipe the journald-msgs to something like syslog-ng etc (just checked a fedora server, they run rsyslogd for that) ... not really to be solved inside this one ebuild, right? I am unsure how to effectively solve that without much overhead.
Maybe the ArchLinux approach could be used... I don't like it so much but it looks like the only alternative :/ https://projects.archlinux.org/svntogit/community.git/plain/trunk/mailgraph.service?h=packages/mailgraph
I try that right now ... it works as root but not as User=mgraph. As that user it doesn't get in log lines either. Oct 04 11:05:21 postler.lichtfels.com systemd[1]: Started mailgraph mail log file analyzer. Oct 04 11:05:21 postler.lichtfels.com bash[2928]: No journal files were found. as root: Oct 04 11:22:07 postler.lichtfels.com systemd[1]: Started mailgraph mail log file analyzer. Oct 04 11:22:07 postler.lichtfels.com bash[3502]: WARNING: line not in syslog format: -- Logs begin at Wed 2015-09-23 06:38:50 CEST. -- but then data gets displayed in the cgi. But if I add that user to the systemd-journal group # gpasswd -a mgraph systemd-journal the mailgraph.service is working as non-root-user mgraph as well. Do you think that is a good-enough solution for now?
Created attachment 413668 [details] current draft
Do we really need to run it as a separate user? It looks like Fedora and Arch are running it as root (and, then, not having this problem dealing with logs)
I just wanted to try and follow the principle of least privileges. Even as root we would need the more or less ugly construction for ExecStart= ... I tend to prefer the solution with "gpasswd -a mgraph systemd-journal" then. You decide.