summaryrefslogtreecommitdiffstats
path: root/usr.sbin/rpki-client
diff options
context:
space:
mode:
authorderaadt <deraadt@openbsd.org>2020-04-30 13:46:39 +0000
committerderaadt <deraadt@openbsd.org>2020-04-30 13:46:39 +0000
commitb0404f1fdb0bd98ff9efd0e6f80e5b37c27206a3 (patch)
tree1e45cf10c8c4e28b5d557519f072a50b567e9722 /usr.sbin/rpki-client
parentDo not remove the automatic-rename option from the global set, only from (diff)
downloadwireguard-openbsd-b0404f1fdb0bd98ff9efd0e6f80e5b37c27206a3.tar.xz
wireguard-openbsd-b0404f1fdb0bd98ff9efd0e6f80e5b37c27206a3.zip
Place elapsed, user, and system time for processing in the comment headers.
ok job benno claudio
Diffstat (limited to 'usr.sbin/rpki-client')
-rw-r--r--usr.sbin/rpki-client/extern.h6
-rw-r--r--usr.sbin/rpki-client/main.c35
-rw-r--r--usr.sbin/rpki-client/output-json.c8
-rw-r--r--usr.sbin/rpki-client/output.c6
4 files changed, 39 insertions, 16 deletions
diff --git a/usr.sbin/rpki-client/extern.h b/usr.sbin/rpki-client/extern.h
index 7e312c1105b..cfbc5a1dfb9 100644
--- a/usr.sbin/rpki-client/extern.h
+++ b/usr.sbin/rpki-client/extern.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: extern.h,v 1.28 2020/04/28 13:41:35 deraadt Exp $ */
+/* $OpenBSD: extern.h,v 1.29 2020/04/30 13:46:39 deraadt Exp $ */
/*
* Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -18,6 +18,7 @@
#define EXTERN_H
#include <sys/tree.h>
+#include <sys/time.h>
enum cert_as_type {
CERT_AS_ID, /* single identifier */
@@ -263,6 +264,9 @@ struct stats {
size_t vrps; /* total number of vrps */
size_t uniqs; /* number of unique vrps */
char *talnames;
+ struct timeval elapsed_time;
+ struct timeval user_time;
+ struct timeval system_time;
};
/* global variables */
diff --git a/usr.sbin/rpki-client/main.c b/usr.sbin/rpki-client/main.c
index d88e1281e44..a431a431b78 100644
--- a/usr.sbin/rpki-client/main.c
+++ b/usr.sbin/rpki-client/main.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: main.c,v 1.66 2020/04/28 13:41:35 deraadt Exp $ */
+/* $OpenBSD: main.c,v 1.67 2020/04/30 13:46:39 deraadt Exp $ */
/*
* Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -44,6 +44,7 @@
#include <sys/queue.h>
#include <sys/socket.h>
+#include <sys/resource.h>
#include <sys/stat.h>
#include <sys/tree.h>
#include <sys/types.h>
@@ -140,6 +141,8 @@ const char *bird_tablename = "ROAS";
int verbose;
+struct stats stats;
+
/*
* Log a message to stderr if and only if "verbose" is non-zero.
* This uses the err(3) functionality.
@@ -459,8 +462,6 @@ queue_add_from_mft_set(int fd, struct entityq *q, const struct mft *mft,
}
}
-char *talnames;
-
/*
* Add a local TAL file (RFC 7730) to the queue of files to fetch.
*/
@@ -474,13 +475,13 @@ queue_add_tal(int fd, struct entityq *q, const char *file, size_t *eid)
buf = tal_read_file(file);
/* Record tal for later reporting */
- if (talnames == NULL)
- talnames = strdup(file);
+ if (stats.talnames == NULL)
+ stats.talnames = strdup(file);
else {
char *tmp;
- asprintf(&tmp, "%s %s", talnames, file);
- free(talnames);
- talnames = tmp;
+ asprintf(&tmp, "%s %s", stats.talnames, file);
+ free(stats.talnames);
+ stats.talnames = tmp;
}
/* Not in a repository, so directly add to queue. */
@@ -1376,13 +1377,16 @@ main(int argc, char *argv[])
struct entity *ent;
struct pollfd pfd[2];
struct repotab rt;
- struct stats stats;
struct roa **out = NULL;
char *rsync_prog = "openrsync";
char *bind_addr = NULL;
const char *cachedir = NULL;
const char *tals[TALSZ_MAX];
struct vrp_tree v = RB_INITIALIZER(&v);
+ struct rusage ru;
+ struct timeval start_time, now_time;
+
+ gettimeofday(&start_time, NULL);
/* If started as root, priv-drop to _rpki-client */
if (getuid() == 0) {
@@ -1473,7 +1477,6 @@ main(int argc, char *argv[])
err(1, "no TAL files found in %s", "/etc/rpki");
memset(&rt, 0, sizeof(struct repotab));
- memset(&stats, 0, sizeof(struct stats));
TAILQ_INIT(&q);
/*
@@ -1648,7 +1651,17 @@ main(int argc, char *argv[])
rc = 1;
}
- stats.talnames = talnames;
+ gettimeofday(&now_time, NULL);
+ timersub(&now_time, &start_time, &stats.elapsed_time);
+ if (getrusage(RUSAGE_SELF, &ru) == 0) {
+ stats.user_time = ru.ru_utime;
+ stats.system_time = ru.ru_stime;
+ }
+ if (getrusage(RUSAGE_CHILDREN, &ru) == 0) {
+ timeradd(&stats.user_time, &ru.ru_utime, &stats.user_time);
+ timeradd(&stats.system_time, &ru.ru_stime, &stats.system_time);
+ }
+
if (outputfiles(&v, &stats))
rc = 1;
diff --git a/usr.sbin/rpki-client/output-json.c b/usr.sbin/rpki-client/output-json.c
index 2bbb9fb00f6..135fc310461 100644
--- a/usr.sbin/rpki-client/output-json.c
+++ b/usr.sbin/rpki-client/output-json.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: output-json.c,v 1.9 2020/04/29 04:29:40 deraadt Exp $ */
+/* $OpenBSD: output-json.c,v 1.10 2020/04/30 13:46:39 deraadt Exp $ */
/*
* Copyright (c) 2019 Claudio Jeker <claudio@openbsd.org>
*
@@ -39,6 +39,9 @@ outputheader_json(FILE *out, struct stats *st)
"{\n\t\"metadata\": {\n"
"\t\t\"buildmachine\": \"%s\",\n"
"\t\t\"buildtime\": \"%s\",\n"
+ "\t\t\"elapsedtime\": \"%lld\",\n"
+ "\t\t\"usertime\": \"%lld\",\n"
+ "\t\t\"systemtime\": \"%lld\",\n"
"\t\t\"roas\": %zu,\n"
"\t\t\"failedroas\": %zu,\n"
"\t\t\"invalidroas\": %zu,\n"
@@ -55,7 +58,8 @@ outputheader_json(FILE *out, struct stats *st)
"\t\t\"vrps\": %zu,\n"
"\t\t\"uniquevrps\": %zu\n"
"\t},\n\n",
- hn, tbuf,
+ hn, tbuf, (long long)st->elapsed_time.tv_sec,
+ (long long)st->user_time.tv_sec, (long long)st->system_time.tv_sec,
st->roas, st->roas_fail, st->roas_invalid,
st->certs, st->certs_fail, st->certs_invalid,
st->tals, st->talnames,
diff --git a/usr.sbin/rpki-client/output.c b/usr.sbin/rpki-client/output.c
index 92db14a560e..86a2e3dc839 100644
--- a/usr.sbin/rpki-client/output.c
+++ b/usr.sbin/rpki-client/output.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: output.c,v 1.12 2020/04/28 15:04:05 deraadt Exp $ */
+/* $OpenBSD: output.c,v 1.13 2020/04/30 13:46:39 deraadt Exp $ */
/*
* Copyright (c) 2019 Theo de Raadt <deraadt@openbsd.org>
*
@@ -185,6 +185,7 @@ outputheader(FILE *out, struct stats *st)
if (fprintf(out,
"# Generated on host %s at %s\n"
+ "# Processing time %lld seconds (%lld seconds user, %lld seconds system)\n"
"# Route Origin Authorizations: %zu (%zu failed parse, %zu invalid)\n"
"# Certificates: %zu (%zu failed parse, %zu invalid)\n"
"# Trust Anchor Locators: %zu (%s)\n"
@@ -192,7 +193,8 @@ outputheader(FILE *out, struct stats *st)
"# Certificate revocation lists: %zu\n"
"# Repositories: %zu\n"
"# VRP Entries: %zu (%zu unique)\n",
- hn, tbuf,
+ hn, tbuf, (long long)st->elapsed_time.tv_sec,
+ (long long)st->user_time.tv_sec, (long long)st->system_time.tv_sec,
st->roas, st->roas_fail, st->roas_invalid,
st->certs, st->certs_fail, st->certs_invalid,
st->tals, st->talnames,