From owner-svn-src-all@FreeBSD.ORG Sun Feb 14 09:48:56 2010 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 17E6910656A8; Sun, 14 Feb 2010 09:48:55 +0000 (UTC) (envelope-from gavin@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id DA3058FC1F; Sun, 14 Feb 2010 09:48:53 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o1E9mrlh031689; Sun, 14 Feb 2010 09:48:53 GMT (envelope-from gavin@svn.freebsd.org) Received: (from gavin@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o1E9mr0h031686; Sun, 14 Feb 2010 09:48:53 GMT (envelope-from gavin@svn.freebsd.org) Message-Id: <201002140948.o1E9mr0h031686@svn.freebsd.org> From: Gavin Atkinson Date: Sun, 14 Feb 2010 09:48:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r203858 - stable/8/sbin/sysctl X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 14 Feb 2010 09:49:00 -0000 Author: gavin Date: Sun Feb 14 09:48:53 2010 New Revision: 203858 URL: http://svn.freebsd.org/changeset/base/203858 Log: Merge r203310,203547,203717 from head: Implement the "-i" option to sysctl(8), to ignore failures while retrieving individual OIDs. This allows the same list of OIDs to be passed to sysctl(8) across different systems where particular OIDs may not exist, and still get as much information as possible from them. PR: bin/123644 Submitted by: dhw Modified: stable/8/sbin/sysctl/sysctl.8 stable/8/sbin/sysctl/sysctl.c Directory Properties: stable/8/sbin/sysctl/ (props changed) Modified: stable/8/sbin/sysctl/sysctl.8 ============================================================================== --- stable/8/sbin/sysctl/sysctl.8 Sun Feb 14 09:40:58 2010 (r203857) +++ stable/8/sbin/sysctl/sysctl.8 Sun Feb 14 09:48:53 2010 (r203858) @@ -28,7 +28,7 @@ .\" From: @(#)sysctl.8 8.1 (Berkeley) 6/6/93 .\" $FreeBSD$ .\" -.Dd November 28, 2007 +.Dd February 6, 2010 .Dt SYSCTL 8 .Os .Sh NAME @@ -36,7 +36,7 @@ .Nd get or set kernel state .Sh SYNOPSIS .Nm -.Op Fl bdehNnoqx +.Op Fl bdehiNnoqx .Ar name Ns Op = Ns Ar value .Ar ... .Nm @@ -82,6 +82,12 @@ or is specified, or a variable is being set. .It Fl h Format output for human, rather than machine, readability. +.It Fl i +Ignore unknown OIDs. +The purpose is to make use of +.Nm +for collecting data from a variety of machines (not all of which +are necessarily running exactly the same software) easier. .It Fl N Show only variable names, not their values. This is particularly useful with shells that offer programmable Modified: stable/8/sbin/sysctl/sysctl.c ============================================================================== --- stable/8/sbin/sysctl/sysctl.c Sun Feb 14 09:40:58 2010 (r203857) +++ stable/8/sbin/sysctl/sysctl.c Sun Feb 14 09:48:53 2010 (r203858) @@ -58,8 +58,8 @@ static const char rcsid[] = #include #include -static int aflag, bflag, dflag, eflag, hflag, Nflag, nflag, oflag; -static int qflag, xflag, warncount; +static int aflag, bflag, dflag, eflag, hflag, iflag; +static int Nflag, nflag, oflag, qflag, xflag, warncount; static int oidfmt(int *, int, char *, u_int *); static void parse(char *); @@ -75,7 +75,7 @@ usage(void) { (void)fprintf(stderr, "%s\n%s\n", - "usage: sysctl [-bdehNnoqx] name[=value] ...", + "usage: sysctl [-bdehiNnoqx] name[=value] ...", " sysctl [-bdehNnoqx] -a"); exit(1); } @@ -89,7 +89,7 @@ main(int argc, char **argv) setbuf(stdout,0); setbuf(stderr,0); - while ((ch = getopt(argc, argv, "AabdehNnoqwxX")) != -1) { + while ((ch = getopt(argc, argv, "AabdehiNnoqwxX")) != -1) { switch (ch) { case 'A': /* compatibility */ @@ -110,6 +110,9 @@ main(int argc, char **argv) case 'h': hflag = 1; break; + case 'i': + iflag = 1; + break; case 'N': Nflag = 1; break; @@ -187,6 +190,8 @@ parse(char *string) len = name2oid(bufp, mib); if (len < 0) { + if (iflag) + return; if (qflag) exit(1); else