Date: Sun, 31 Jan 2010 19:33:25 +0000 (UTC) From: Gavin Atkinson <gavin@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r203310 - head/sbin/sysctl Message-ID: <201001311933.o0VJXPku018353@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: gavin Date: Sun Jan 31 19:33:25 2010 New Revision: 203310 URL: http://svn.freebsd.org/changeset/base/203310 Log: 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 Approved by: ed (mentor) MFC after: 2 weeks Modified: head/sbin/sysctl/sysctl.8 head/sbin/sysctl/sysctl.c Modified: head/sbin/sysctl/sysctl.8 ============================================================================== --- head/sbin/sysctl/sysctl.8 Sun Jan 31 19:30:47 2010 (r203309) +++ head/sbin/sysctl/sysctl.8 Sun Jan 31 19:33:25 2010 (r203310) @@ -28,7 +28,7 @@ .\" From: @(#)sysctl.8 8.1 (Berkeley) 6/6/93 .\" $FreeBSD$ .\" -.Dd November 28, 2007 +.Dd January 31, 2010 .Dt SYSCTL 8 .Os .Sh NAME @@ -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: head/sbin/sysctl/sysctl.c ============================================================================== --- head/sbin/sysctl/sysctl.c Sun Jan 31 19:30:47 2010 (r203309) +++ head/sbin/sysctl/sysctl.c Sun Jan 31 19:33:25 2010 (r203310) @@ -58,8 +58,8 @@ static const char rcsid[] = #include <string.h> #include <unistd.h> -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 *); @@ -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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201001311933.o0VJXPku018353>