From nobody Sat Aug 20 02:58:35 2022 X-Original-To: dev-commits-src-branches@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 4M8jxR41pFz4Z0N2; Sat, 20 Aug 2022 02:58:35 +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 4M8jxR3Xtzz3SN0; Sat, 20 Aug 2022 02:58:35 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1660964315; 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=yjf1pcRX6JgeFikmkpu78glEC8ZrgMeO22GK7cHTMVw=; b=Ytmr68EBMF9TjfYzekZuKTlWPgDIUWWYZnu1Y8Iccv1sxdrOQVOn8TQZVYguwgQNevFwqG 2yvSl6G3qx93CVb9zotqn8VOSQ1Kr+5oyTfNXccE5sD6PhH34y0gTSInXlALdRLxirT9s0 NvIjFFYdgaK64rFNceB8tDLS3k3KWqAU24O5cjxwhi9/QmUlgHEO+ipTWV0khUdQHmnq2o DfneJCirgRSQ7Ke7Ih313m8Z7Ly+c/A/awY1Zv0TpQ1iHap94hC4xIl8lt9eF6Y/eIHC/c Hjj1Ti4/ZU04ooJbFqghhPU3oK9ccTUMqjFdybCB6Lh4z1ybu7syqKTWZt9LwA== 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 4M8jxR2YhTzGw0; Sat, 20 Aug 2022 02:58:35 +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 27K2wZut052154; Sat, 20 Aug 2022 02:58:35 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 27K2wZTC052153; Sat, 20 Aug 2022 02:58:35 GMT (envelope-from git) Date: Sat, 20 Aug 2022 02:58:35 GMT Message-Id: <202208200258.27K2wZTC052153@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: 5c155bab48c0 - stable/12 - prometheus_sysctl_exporter: ignore ENOENT for mibs specified on the CLI List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@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/12 X-Git-Reftype: branch X-Git-Commit: 5c155bab48c09e7a34bec8fb6a16164d26c1629c Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1660964315; 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=yjf1pcRX6JgeFikmkpu78glEC8ZrgMeO22GK7cHTMVw=; b=WK7PQiPMPL1Sfj1jD0j6AYx7ZQDKoaODS5HjZHBxZsqNZ0YhKWbBfJpf7fcdcJzGSvGm7E UCyPMIXU6dpbOOzqfwx/8DLbN/WfgNwn9EOOIjkvWoK0dfvbmswCVYzLcHpwWcs/MbOFF4 1oh7QgsttgQJpON3fUwyc0me2Z/wygKFpjb1tvNGmsBk3IN/xS1jmnXsqaL464nIdy+hKD tS3Ak6f8q2TpzO5zzmSQDE7lYRFanSP7GwvNiLIhxIgJf4yC/NUJ/GABQfwpDhkEeFxnnX zdY42fUGBpSJXUcKlZkwhkQHbX4qwqLU/Yyia8YGrQng7VRhT10swXN43MYafQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1660964315; a=rsa-sha256; cv=none; b=XVnq+UcX7ewNSPxyO5860U+YHt8YRt/cHw8mcu0hfHcOIO6dl3xjUK9MC5NR33SLVY2YbR 2LKihj0lBlddpH2Oj7T+Gjpm8zd99o2+IjF/QLIY79WxgFVL/41ov7v10icZeCAtySpycu StAHgVPybH7r2kBOTV2C8tAiq6qOIwlx4bSfhhAdXSpqBCXysRpNy3D1MWQRDDgFqpsHBs 4bpEq3ImW3//AwqPCFN7V+mOwhf5A34zBTKc7lr2lnOs7Hb8awaBLA0BQPOsPLTt8hi4fD xhPsXkgbY16WThb4anLL+3QR6SBs/kBuX4ON6gVAWcAPXOLDlVWo2sgNXdLWMQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/12 has been updated by asomers: URL: https://cgit.FreeBSD.org/src/commit/?id=5c155bab48c09e7a34bec8fb6a16164d26c1629c commit 5c155bab48c09e7a34bec8fb6a16164d26c1629c Author: Alan Somers AuthorDate: 2022-06-21 18:51:14 +0000 Commit: Alan Somers CommitDate: 2022-08-20 02:58:12 +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);