zpcimon: Allow setting output format and use JSON Lines in systemd unit

Introduce separate '--format' option to set output format. Use the new
JSON Lines format explicitly in the systemd unit. Since JSON Lines
format only uses printable characters this removes the need for passing
'-a' to systemctl status. At the same time JSON-SEQ is more easily
parsable using 'jq --seq' so keep it the default for easier scripting.

Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Niklas Schnelle <schnelle@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
This commit is contained in:
Niklas Schnelle
2026-06-17 21:48:47 +02:00
committed by Jan Höppner
parent 8a4a4e0557
commit 2c63c69af4
4 changed files with 59 additions and 3 deletions
+9
View File
@@ -7,9 +7,11 @@
#ifndef OPTICSMON_CLI_H
#define OPTICSMON_CLI_H
#include "lib/util_fmt.h"
#include "lib/util_opt.h"
#define OPT_DUMP 128
#define OPT_FORMAT 129
static struct util_opt opt_vec[] = {
UTIL_OPT_SECTION("OPERATION OPTIONS"),
@@ -41,6 +43,13 @@ static struct util_opt opt_vec[] = {
"in the absence of link state changes. A value larger than "
"24 hours (86400 seconds) is clamped down to 24 hours.",
},
UTIL_OPT_SECTION("OUTPUT FORMAT OPTIONS"),
{
.option = { "format", required_argument, NULL, OPT_FORMAT },
.argument = "FORMAT",
.flags = UTIL_OPT_FLAG_NOSHORT,
.desc = "Output format (" FMT_TYPE_NAMES ")",
},
UTIL_OPT_SECTION("GENERAL OPTIONS"),
UTIL_OPT_HELP,
UTIL_OPT_VERSION,