-/* $OpenBSD: extern.h,v 1.175 2023/03/13 19:51:49 job Exp $ */
+/* $OpenBSD: extern.h,v 1.176 2023/03/30 15:29:15 claudio Exp $ */
/*
* Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv>
*
void repo_fetch_uris(const struct repo *, const char **,
const char **);
int repo_synced(const struct repo *);
+const char *repo_proto(const struct repo *);
int repo_talid(const struct repo *);
struct repo *ta_lookup(int, struct tal *);
struct repo *repo_lookup(int, const char *, const char *);
-/* $OpenBSD: output-ometric.c,v 1.1 2022/12/15 12:02:29 claudio Exp $ */
+/* $OpenBSD: output-ometric.c,v 1.2 2023/03/30 15:29:15 claudio Exp $ */
/*
* Copyright (c) 2022 Claudio Jeker <claudio@openbsd.org>
*
#include "ometric.h"
#include "version.h"
-struct ometric *rpki_info, *rpki_completion_time, *rpki_duration;
-struct ometric *rpki_repo, *rpki_obj, *rpki_ta_obj;
-struct ometric *rpki_repo_obj, *rpki_repo_duration, *rpki_repo_state;
+static struct ometric *rpki_info, *rpki_completion_time, *rpki_duration;
+static struct ometric *rpki_repo, *rpki_obj, *rpki_ta_obj;
+static struct ometric *rpki_repo_obj, *rpki_repo_duration;
+static struct ometric *rpki_repo_state, *rpki_repo_proto;
static const char * const repo_states[2] = { "failed", "synced" };
+static const char * const repo_protos[3] = { "rrdp", "rsync", "https" };
static void
set_common_stats(const struct repostats *in, struct ometric *metric,
set_common_stats(in, rpki_repo_obj, ol);
ometric_set_timespec(rpki_repo_duration, &in->sync_time, ol);
ometric_set_state(rpki_repo_state, repo_states[repo_synced(rp)], ol);
+ if (repo_synced(rp))
+ ometric_set_state(rpki_repo_proto, repo_proto(rp), ol);
olabels_free(ol);
}
sizeof(repo_states) / sizeof(repo_states[0]),
"rpki_client_repository_state",
"repository state");
+ rpki_repo_proto = ometric_new_state(repo_protos,
+ sizeof(repo_protos) / sizeof(repo_protos[0]),
+ "rpki_client_repository_protos",
+ "used protocol to sync repository");
/*
* Dump statistics
-/* $OpenBSD: repo.c,v 1.42 2023/03/29 17:03:29 claudio Exp $ */
+/* $OpenBSD: repo.c,v 1.43 2023/03/30 15:29:15 claudio Exp $ */
/*
* Copyright (c) 2021 Claudio Jeker <claudio@openbsd.org>
* Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv>
return 0;
}
+/*
+ * Return the protocol string "rrdp", "rsync", "https" which was used to sync.
+ * Result is only correct if repository was properly synced.
+ */
+const char *
+repo_proto(const struct repo *rp)
+{
+
+ if (rp->ta != NULL) {
+ const struct tarepo *tr = rp->ta;
+ if (tr->uriidx < tr->urisz &&
+ strncasecmp(tr->uri[tr->uriidx], "rsync://", 8) == 0)
+ return "rsync";
+ else
+ return "https";
+ }
+ if (rp->rrdp != NULL)
+ return "rrdp";
+ return "rsync";
+}
+
/*
* Return the repository tal ID.
*/