summaryrefslogtreecommitdiffstats
path: root/sbin
diff options
context:
space:
mode:
authorgavin <gavin@FreeBSD.org>2010-02-14 09:48:53 +0000
committergavin <gavin@FreeBSD.org>2010-02-14 09:48:53 +0000
commit6d9379bb908605afa451bf6f4d53ad385b854150 (patch)
tree27b21c970ecc29d19867b193f558a9defddf38a3 /sbin
parent6ae12e4cb3474e8d8a76c51efd709b5cc6cc8da1 (diff)
downloadFreeBSD-src-6d9379bb908605afa451bf6f4d53ad385b854150.zip
FreeBSD-src-6d9379bb908605afa451bf6f4d53ad385b854150.tar.gz
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
Diffstat (limited to 'sbin')
-rw-r--r--sbin/sysctl/sysctl.810
-rw-r--r--sbin/sysctl/sysctl.c13
2 files changed, 17 insertions, 6 deletions
diff --git a/sbin/sysctl/sysctl.8 b/sbin/sysctl/sysctl.8
index 4084290..1f5c8e6 100644
--- a/sbin/sysctl/sysctl.8
+++ b/sbin/sysctl/sysctl.8
@@ -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
diff --git a/sbin/sysctl/sysctl.c b/sbin/sysctl/sysctl.c
index 4140fb3..3c1f364 100644
--- a/sbin/sysctl/sysctl.c
+++ b/sbin/sysctl/sysctl.c
@@ -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 *);
@@ -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
OpenPOWER on IntegriCloud