From nobody Sat Aug 20 03:01:58 2022 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4M8k1L39j0z4Z0jx; Sat, 20 Aug 2022 03:01:58 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4M8k1L29zfz3TQw; Sat, 20 Aug 2022 03:01:58 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1660964518; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=+VA7AwmMbx6RRXE8DhLATNi4oOBkUakfcFkH6QaGtMQ=; b=roeuL+VAiagXIgjNMJZtNPYDukpsJPmpjpgq1LhJfetVZkyhLCdf98oGdhI4EubWJh6VzM 1fWZMFnsf+8a4Pnfes2dZc6TZNi1OhIYKVYqWrcJ9U0ecdX3HEQTnksVu25qT1SGnn3hxT cuD0bNWAEsxn+WE8YIPpMn2jEieSPr7oiBZXIU9xkxayureSvmAMB3vPPVJ7Ci2R0/hpA4 IxTed+8t7UEs8aLeKOXHzSoxMGsAv6elxcjHEgVG7RcELrvM5QRlEt6Se7jR1kOMzfPo8X FIGaV65BNMVX9O8a5nlM8T505WqgFjXjHQ7zivpi1/Mi7Du3GC4fNRSSbUH6+g== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4M8k1L1GSxzGjy; Sat, 20 Aug 2022 03:01:58 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 27K31wWu066504; Sat, 20 Aug 2022 03:01:58 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 27K31wBC066503; Sat, 20 Aug 2022 03:01:58 GMT (envelope-from git) Date: Sat, 20 Aug 2022 03:01:58 GMT Message-Id: <202208200301.27K31wBC066503@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Alan Somers Subject: git: d58ced88d39f - stable/13 - prometheus_sysctl_exporter: ignore ENOENT for mibs specified on the CLI List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: asomers X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: d58ced88d39f0169a3fa08e8e626870131cee90f Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1660964518; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=+VA7AwmMbx6RRXE8DhLATNi4oOBkUakfcFkH6QaGtMQ=; b=Sv9sPnasbDw+Y+0zUJ7fhwyxu8bAGoXYQRQ1n+xihCA33FZSJb4dpVLfv/S6RVrb6V2shi EkOVE3CAXQhkr6tePxrk39n5N7sAWe+6eUlX0SSJlc7P05E8nKZu/lKL4/3zv/ZJ/On5Ag og0GAjU7FSF0V6ETGqAOuK0EKN8SAxwbb0tWOvpEOXx+0mCyEmnjTeYrrNXyELqvwFkzSE fghoT/u66BoIXVOm3S9YoQS8xu7PL6zEzX8eyQ3J1V3e/JpFWjjNGjC3+QwwywuiJ6BhwL fN9dr3dTSHORabfWEr5gGEhhZQ8z0V4zylcCV5GDh6cEAg8g4bZVZvbXMq4NxQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1660964518; a=rsa-sha256; cv=none; b=nao+NTcsQrAATEP3OO5JfkcsUykjIaPwF20fJjE5our6OZRPqODeQsx1dlsrlbhmw/1em+ HX2r/NC05XRWBl81z86pSDApO1/A3gGZ3tfd0KPWCZOr6lx39IrDGo1jWfaJnXhifsq2Zs AbGjYLqz4qpvP7Eothst1fBkk5JlF0XpdGrecPcIEqPIJ/alNX58GvttAEo3NlzxI78XYJ VhQnxY+Z1Wt9G4QiHQWwpudhMmCyQysbLNwt0/OZhizqI5ckeD4yoHOukZ7kPdixGtKnn8 QjtYZyaGlxezYr5BgZGz1OgtARahrsxWni/rKQxwAbn4/noV+GOJGqkPrOow0w== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by asomers: URL: https://cgit.FreeBSD.org/src/commit/?id=d58ced88d39f0169a3fa08e8e626870131cee90f commit d58ced88d39f0169a3fa08e8e626870131cee90f Author: Alan Somers AuthorDate: 2022-06-21 18:51:14 +0000 Commit: Alan Somers CommitDate: 2022-08-20 03:01:43 +0000 prometheus_sysctl_exporter: ignore ENOENT for mibs specified on the CLI They might belong to kernel modules not currently loaded, or to other kernel versions. Ignoring them allows the configuration to be shared between multiple hosts. Sponsored by: Axcient Reviewed by: rew Differential Revision: https://reviews.freebsd.org/D35540 (cherry picked from commit 982f980b86d6bab4d55452d17bf3f5eb04e5f01e) --- .../prometheus_sysctl_exporter.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/usr.sbin/prometheus_sysctl_exporter/prometheus_sysctl_exporter.c b/usr.sbin/prometheus_sysctl_exporter/prometheus_sysctl_exporter.c index e452e305d2bf..931d8e965d00 100644 --- a/usr.sbin/prometheus_sysctl_exporter/prometheus_sysctl_exporter.c +++ b/usr.sbin/prometheus_sysctl_exporter/prometheus_sysctl_exporter.c @@ -67,13 +67,12 @@ oid_get_root(struct oid *o) } /* Obtains the OID for a sysctl by name. */ -static void +static bool oid_get_by_name(struct oid *o, const char *name) { o->len = nitems(o->id); - if (sysctlnametomib(name, o->id, &o->len) != 0) - err(1, "sysctl(%s)", name); + return (sysctlnametomib(name, o->id, &o->len) == 0); } /* Returns whether an OID is placed below another OID. */ @@ -644,7 +643,15 @@ main(int argc, char *argv[]) for (i = 0; i < argc; ++i) { struct oid o, root; - oid_get_by_name(&root, argv[i]); + if (!oid_get_by_name(&root, argv[i])) { + /* + * Ignore trees provided as arguments that + * can't be found. They might belong, for + * example, to kernel modules not currently + * loaded. + */ + continue; + } o = root; do { oid_print(&o, &on, print_descriptions, exclude, include, fp);