From 2ef2661c2d5daf077ee1620a2877cdef0c2218b3 Mon Sep 17 00:00:00 2001 From: zhanghan2021 Date: Wed, 21 Jun 2023 16:08:50 +0800 Subject: [PATCH] Add initialization variables for the loads module --- observation/src/loads/loads.c | 42 +++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 observation/src/loads/loads.c diff --git a/observation/src/loads/loads.c b/observation/src/loads/loads.c new file mode 100644 index 00000000..d71f0bb9 --- /dev/null +++ b/observation/src/loads/loads.c @@ -0,0 +1,42 @@ +// SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) +#include "commons.h" +#include "loads.skel.h" +#include "btf_helpers.h" +#include "trace_helpers.h" +#include +#include + +static struct env +{ + int interval; + int times; + bool verbose; + bool timestamp; +} env = { + .times = 99999999, + .interval = 1, +}; + +#define MAX_NR_CPUS 1024 + +static volatile sig_atomic_t exiting; + +const char *argp_program_version = "loads 0.1"; +const char *argp_program_bug_address = "Jackie Liu "; +const char argp_program_doc[] = + "Print load averages\n" + "\n" + "USAGE: loads [-i INTERVAL] [-t times]\n" + "\n" + "EXAMPLE:\n" + " loads # print load average every 1 seconds\n" + " loads -i 10 # print load average every 10 seconds\n" + " loads -t 5 # print load average 5 times\n"; + +static const struct argp_option opts[] = { + {"interval", 'i', "INTERVAL", 0, "Output interval, in seconds (Default 1)"}, + {"times", 't', "TIMES", 0, "The number of outputs"}, + {"verbose", 'v', NULL, 0, "Verbose debug output"}, + {"timestamp", 'T', NULL, 0, "Include timestamp on output"}, + {NULL, 'h', NULL, OPTION_HIDDEN, "SHow the full help"}, + {}}; \ No newline at end of file -- Gitee