Commit Graph
31 Commits
Author SHA1 Message Date
Mike Yuan 18d1f2dced tree-wide: make private hash ops static 2026-03-04 14:32:15 +01:00
Lennart Poettering 9277393d7b report: install systemd-report binary to /usr/lib/systemd/ for now
The tool should not be considered stable, and those things we usually
place in /usr/lib/systemd, and not in $PATH.

We can move that to $PATH once we are confident it's gonna stay the way
it is.
2026-02-20 08:25:12 +01:00
Lennart Poettering cd961ea209 report: use JSON-SEQ when outputing a series of json objects
We do this in our other tools that output a large number of JSON objects
in a potentially streamable way, hence do so here too.
2026-02-20 08:25:12 +01:00
Lennart Poettering fc5537635d report: fix log level of connection log messages
Let's also rename the "metric_prefix" to "name", because it's actually
the servce name, and by giving it this generic name we can use it
reasonably in log messages.
2026-02-20 08:25:12 +01:00
Lennart Poettering bbb151da78 report: add --no-legend
Like most of our other tools, add a --no-legend switch.
2026-02-20 08:25:12 +01:00
Lennart Poettering e83cbc9372 report: implement filtering for metrics 2026-02-20 08:25:12 +01:00
Lennart Poettering ec2cd403f4 report: tighten rules on metrics names
Let's stay close to Varlink's naming rules and insist that metrics
prefixes must be valid varlink interface names, and suffixes are valid
varlink field names.

The former rule is clear: because a metric <x>.<y> can only be provided
by a varlink service <x>, it is obvious we should validate them the
same way. Validating the suffix via varlink field rules is not that
obvious, but I think it makes sense to stay close to Varlink naming
rules if we already started out at one place.
2026-02-20 08:25:12 +01:00
Lennart Poettering 5617ebb096 report: we don't use inline in .c files, the compiler can figure this out better on its own 2026-02-20 08:25:12 +01:00
Lennart Poettering 442040e716 report: add -j shortcut
json output is going to be used very frequently, hence provide a
shortcut for it, like many our tools do it.
2026-02-20 08:25:12 +01:00
Lennart Poettering 39225c9904 report: also dump metrics in tabular output
JSON output is great, but let's show the metrics by default in a more
human readable fashion.
2026-02-20 08:25:12 +01:00
Lennart Poettering e1f7f33713 report: add 'list-sources' verb for enumerating metrics sources 2026-02-20 08:25:12 +01:00
Lennart Poettering 0e05a03577 report: split out service enumeration logic
We want to reuse it later to list all services, hence make it generic.

(Also, allow symlinked services too)
2026-02-20 08:23:11 +01:00
Lennart Poettering 5046a12fbc report: switch to "verbs" command line interface, and add 'describe-metrics'
Let's prepare for a future where the "systemd-report" tool can do more
than enumerate metrics: let's introduce our usual "verbs" style
interface.

Let's also add a second command right-away: "describe-metrics" shows the
description of the metrics.
2026-02-20 08:23:11 +01:00
Lennart Poettering 5344bede1e report: adjust indentation to our usual style 2026-02-20 08:15:30 +01:00
Lennart Poettering b01dfa2c83 report: add comment explaining that metric_startswith_prefix() does a true prefix match 2026-02-20 08:15:30 +01:00
Ivan Kruglov cc14f78c02 report: validate metric name by socket 2026-02-16 05:46:24 -08:00
Ivan Kruglov b465e848f3 report: rearrange handling connection drop when skipping metrics 2026-02-16 02:34:11 -08:00
Zbigniew Jędrzejewski-Szmek 3604664638 report: simplify error propagation
Returning EXIT_* from an inner function is unusual and better
avoided. Let's just return a negative value and let the caller
do the conversion.
2026-02-11 15:31:37 +01:00
Zbigniew Jędrzejewski-Szmek 4f78e5fa86 report: fix hang when we start skipping metrics
Fixup for 0ec663a41f.
2026-02-11 12:47:02 +01:00
Lennart Poettering 9b09b11d21 report: rework limits logic
Let's count how many sources we skip, and output that as a summary, and
return an error exit code in this case.

Let's also put a limit on the metrics collected, not just the sources.

Also, our macros that put limits on things are usually called XYZ_MAX,
follow the same scheme here.
2026-02-07 23:30:00 +01:00
Lennart Poettering a7aebb2250 report: don't claim no reporting sockets were found, when it's no metrics that were found
Let's add a proper message about missing sources, and call them
"sources", i.e. take a more high-level view on things.
2026-02-07 23:28:51 +01:00
Lennart Poettering 1b9506601f report: keep track of varlink connections inside of Context object
Let's also move the Varlink connection management into the Context
object. Let's also switch to Set* for it, so that we get get
auto-expanding behaviour.
2026-02-07 23:28:51 +01:00
Lennart Poettering 6c051e84c7 report: move event loop object into Context
It's one of the primary objects that make up the program "context"
conceptually, hence it also should be part of the Context object. This
allows us to just have it available if the Context object is seen.
2026-02-07 23:13:16 +01:00
Lennart Poettering 3317ea84bc report: pass Context as first argument to metrics_call()
Typically the context object should be the first one. And the return
parameters should be the last ones.
2026-02-07 23:13:16 +01:00
Lennart Poettering 9fa9f10088 report: -p is not defined 2026-02-07 23:13:16 +01:00
Lennart Poettering 0ec663a41f report: do not treat an empty report dir as an issue
We should permit that the report varlink dir is created on the fly when
the first socket is bound there. Hence, let's treat a non-existant dir
equivalent to an empty one.

We usually do this in our tree like this, do it here too.
2026-02-07 23:13:16 +01:00
Lennart Poettering 1f8b09dfc6 report: use sd_json_variant_unref_many() 2026-02-07 23:13:16 +01:00
Lennart Poettering 75e1963df1 report: add the usual --json= argument 2026-02-07 23:13:16 +01:00
Zbigniew Jędrzejewski-Szmek dffcb61f7f metrics/report: add log messages, do not hang if no metrics are found
If the directory existed but was empty, we'd hang in the event loop.
2026-02-04 18:20:11 +01:00
Zbigniew Jędrzejewski-Szmek ab4028c47a metrics/report: use _cleanup_, avoid goto 2026-02-04 17:57:24 +01:00
Yaping Li c498f3790f [metrics] Add a basic CLI
systemd-report will list all the metrics.
2026-02-02 08:03:56 -08:00