Files
systemd/man/systemd-report-files@.service.xml
T
Armaan Sandhu f41defc034 report: make report-files listing and lookup agree on masked entries
The metric list is built with conf_files_list_strv(), but each metric's
value is then looked up again by walking report_files_dirs[] by hand,
and the two disagreed whenever an earlier directory had an entry that is
not a regular file:

 - conf_files_list_strv() skipped such an entry and listed the one from
   a later directory, so the metric was advertised by Describe();
 - file_metric_generate() only moved on to the next directory on
   -ENOENT, so it hit the non-regular entry, logged a warning and
   produced nothing.

The practical case is masking a vendor-supplied entry with a symlink to
/dev/null: the metric kept being described, was never listed, and every
scrape logged "Failed to open ..., skipping: File descriptor in bad
state".

Honour masks in the enumeration via CONF_FILES_FILTER_MASKED_BY_SYMLINK,
as other conf dirs do, and make the lookup skip non-regular entries the
same way the enumeration does. Document the masking in the man page and
cover both cases in TEST-74-AUX-UTILS.report.

(cherry picked from commit 08be8677539642f45c6127085283cf08b6a410b7)
2026-10-16 11:36:32 +01:00

75 lines
3.7 KiB
XML

<?xml version="1.0"?> <!--*-nxml-*-->
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
<!-- SPDX-License-Identifier: LGPL-2.1-or-later -->
<refentry id="systemd-report-files_.service" xmlns:xi="http://www.w3.org/2001/XInclude">
<refentryinfo>
<title>systemd-report-files@.service</title>
<productname>systemd</productname>
</refentryinfo>
<refmeta>
<refentrytitle>systemd-report-files@.service</refentrytitle>
<manvolnum>8</manvolnum>
</refmeta>
<refnamediv>
<refname>systemd-report-files@.service</refname>
<refname>systemd-report-files.socket</refname>
<refname>systemd-report-files</refname>
<refpurpose>Report the contents of files as system report metrics</refpurpose>
</refnamediv>
<refsynopsisdiv>
<para><filename>systemd-report-files@.service</filename></para>
<para><filename>systemd-report-files.socket</filename></para>
<para><filename>/usr/lib/systemd/systemd-report-files</filename></para>
</refsynopsisdiv>
<refsect1>
<title>Description</title>
<para><command>systemd-report-files@.service</command> is a metrics source for
<citerefentry><refentrytitle>systemd-report</refentrytitle><manvolnum>1</manvolnum></citerefentry>. It
reports the contents of a configurable set of files as metrics, by implementing the
<constant>io.systemd.Metrics</constant> Varlink interface on a socket linked into the
<filename>/run/systemd/report/</filename> directory.</para>
<para>The files to report are picked up from <filename>report.files/</filename> subdirectories of the
usual configuration directories, i.e. from
<filename>/etc/systemd/report.files/</filename>,
<filename>/run/systemd/report.files/</filename>,
<filename>/var/lib/systemd/report.files/</filename>,
<filename>/usr/local/lib/systemd/report.files/</filename> and
<filename>/usr/lib/systemd/report.files/</filename>. Typically these directories contain symlinks pointing
to the actual files in the file system whose contents shall be reported. Entries with the same name in an
earlier directory override those in a later one. An entry that is a symlink to
<filename>/dev/null</filename> masks the identically named entries in later directories, so that no
metric is reported for that name. Entries that are not regular files are ignored.</para>
<para>Each entry is reported as a metric named
<literal>io.systemd.Files.<replaceable>NAME</replaceable></literal>, where
<replaceable>NAME</replaceable> is the name of the entry (which must be a valid metric field name). The
metric value is the verbatim contents of the file. Files that cannot be read (for example because a
symlink is dangling) are skipped, as are files whose contents are not valid UTF-8 text.</para>
<para>Note that access to this service is unprivileged, but it runs privileged. This means take care when
symlinking files into the various <filename>report.files/</filename> directories: this service might
provide read access even if the client does not have the required direct access rights itself.</para>
</refsect1>
<!-- Note: we do not document the command line switches here. The systemd-report-files binary itself should
not be invoked by users, but only as a service. Use systemd-report(1) to acquire metrics. -->
<refsect1>
<title>See Also</title>
<para><simplelist type="inline">
<member><citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry></member>
<member><citerefentry><refentrytitle>systemd-report</refentrytitle><manvolnum>1</manvolnum></citerefentry></member>
</simplelist></para>
</refsect1>
</refentry>