On Sun, 5 Sep 2021 16:51:46 +1000 Nathan Scott <nath...@redhat.com> wrote:
Hi Petter,

On Sun, Sep 5, 2021 at 4:45 PM Petter Reinholdtsen <p...@hungry.com> wrote:
> [...] This approach is known as multilevel configuration.
>
> I recommend it over modifying conffiles in /etc/.

I'll discuss with other upstream folks and see if we can transition
to this style of solution & for all distros.  It's a fairly major change,
so it won't happen overnight, but I agree it is a good way to tackle
this.


There is a simpler solution. The configuration option in question is an environment variable. This can be passed to the daemon by shipping a systemd service configuration file in pmlogger packaging.

$ cat /usr/lib/systemd/system/pmlogger.service.d/pcp-zeroconf.conf
[Service]

Environment=PMLOGGER_INTERVAL=10


When the package pcp-zeroconf is removed, the configuration will be restored to previous state and this is often desirable. This, however, works only on systemd systems.

Handling Dynamic Values:

Alternatively, if the file needs to contain dynamically calculated options, pmlogger.postint can generate the file /etc/systemd/system/pmlogger.service.d/pcp-zeroconf.conf . This file will need to be removed by pmlogger.postrm (for purge).

Test:

I have tested this solution as follows:

(comment out PMLOGGER_INTERVAL in /etc/default/pmlogger)
# systemctl daemon-reload
# systemctl show pmlogger.service | grep Environment
Environment=PMLOGGER_INTERVAL=10

# systemctl restart pmlogger.service
# systemctl status pmlogger.service
(pickup main PID from output)
# cat /proc/{pid}/environ | tr '\0' '\n' | grep PMLOGGER_INTERVAL
PMLOGGER_INTERVAL=10

Non-systemd systems:

In addition to this solution the change in pmlogger.postinst can be confined to non-systemd systems:



# increase default pmlogger recording frequency


if [ ! -e /run/systemd ]; then

sed -i 's/^\#\ PMLOGGER_INTERVAL.*/PMLOGGER_INTERVAL=10/g' /etc/default/pmlogger


fi


If better approach for non-systemd systems is desired, then we canpatch the /etc/init.d/pmlogger (src: src/pmlogger/rc_pmlogger) to read more environment files from, say, /etc/pmlogger/*.conf and /usr/share/pmlogger/*.conf. Then pcp-zeoconf can install the file /etc/pmlogger/pcp-zeroconf.conf.


Severity:

Currently, this bug is threatening to remove all of pcp, cockpit and freedombox from Debian on October 10th. Please consider adopting some solution to avoid this.

Thanks you for pcp!

--
Sunil

Reply via email to