This diff adds a new set of ometric sets to show the protocol used to sync the repository. Possible values are "rrdp", "rsync", "https".
This adds for example rpki_client_repository_protos{rpki_client_repository_protos="rrdp",name="ripe",carepo="rsync://chloe.sobornost.net/rpki",notify="https://chloe.sobornost.net/rpki/news.xml"} 1 rpki_client_repository_protos{rpki_client_repository_protos="rsync",name="ripe",carepo="rsync://chloe.sobornost.net/rpki",notify="https://chloe.sobornost.net/rpki/news.xml"} 0 -- :wq Claudio Index: extern.h =================================================================== RCS file: /cvs/src/usr.sbin/rpki-client/extern.h,v retrieving revision 1.175 diff -u -p -r1.175 extern.h --- extern.h 13 Mar 2023 19:51:49 -0000 1.175 +++ extern.h 30 Mar 2023 07:50:02 -0000 @@ -756,6 +756,7 @@ const char *repo_uri(const struct repo * 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 *); Index: output-ometric.c =================================================================== RCS file: /cvs/src/usr.sbin/rpki-client/output-ometric.c,v retrieving revision 1.1 diff -u -p -r1.1 output-ometric.c --- output-ometric.c 15 Dec 2022 12:02:29 -0000 1.1 +++ output-ometric.c 30 Mar 2023 07:49:37 -0000 @@ -26,11 +26,13 @@ #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, @@ -118,6 +120,8 @@ repo_stats(const struct repo *rp, const 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); } @@ -158,6 +162,10 @@ output_ometric(FILE *out, struct vrp_tre 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 Index: repo.c =================================================================== RCS file: /cvs/src/usr.sbin/rpki-client/repo.c,v retrieving revision 1.42 diff -u -p -r1.42 repo.c --- repo.c 29 Mar 2023 17:03:29 -0000 1.42 +++ repo.c 30 Mar 2023 07:56:38 -0000 @@ -1206,6 +1206,27 @@ repo_synced(const struct repo *rp) } /* + * 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. */ int