274 lines
10 KiB
HTML
274 lines
10 KiB
HTML
|
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
<HTML><HEAD><TITLE>Man page of MIB2C.CONF</TITLE>
|
|
</HEAD><BODY>
|
|
<H1>MIB2C.CONF</H1>
|
|
Section: Net-SNMP (5)<BR>Updated: 28 Apr 2004<BR><A HREF="#index">Index</A>
|
|
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
|
|
|
|
<A NAME="lbAB"> </A>
|
|
<H2>NAME</H2>
|
|
|
|
mib2c.conf - How to write mib2c.conf files to do ANYTHING based on MIB input.
|
|
<A NAME="lbAC"> </A>
|
|
<H2>SYNOPSIS</H2>
|
|
|
|
% cat > mib2c.test.conf << EOF
|
|
@foreach $t table@
|
|
<BR> Starting table $t
|
|
<BR> @foreach $c column@
|
|
<BR> echo $t has column $c which has a syntax of $c.syntax
|
|
<BR> @end@
|
|
<P>
|
|
@end@
|
|
EOF
|
|
<P>
|
|
% mib2c -c mib2c.test.conf internet
|
|
<A NAME="lbAD"> </A>
|
|
<H2>DESCRIPTION</H2>
|
|
|
|
The mib2c.conf script language is a MIB-particular language designed
|
|
to easily process MIB nodes in ways that you want. mib2c is a
|
|
misnomer (for historical purposes), because you can produce anything
|
|
(not just C code). Look in the Net-SNMP "local" directory for a bunch
|
|
of example mib2c.*.conf files and behold the power before you.
|
|
<A NAME="lbAE"> </A>
|
|
<H2>COMMANDS</H2>
|
|
|
|
<P>
|
|
|
|
All commands within mib2c.conf files are embraced by @ signs.
|
|
Anything with an @ sign at the front and back of the line is generally
|
|
supposed to be a mib2c specific command. These are detailed here:
|
|
<DL COMPACT>
|
|
<DT id="1">@open FILE@<DD>
|
|
writes generated output to FILE
|
|
note that for file specifications, opening '-' will print to stdout.
|
|
<DT id="2">@append FILE@<DD>
|
|
appends the given FILE
|
|
<DT id="3">@close FILE@<DD>
|
|
closes the given FILE
|
|
<DT id="4">@push@<DD>
|
|
save the current outputs, then clear outputs. Use with @open@
|
|
and @pop@ to write to a new file without interfering with current
|
|
outputs.
|
|
<DT id="5">@pop@<DD>
|
|
pop up the process() stack one level. Use after a @push@ to return to
|
|
the previous set of open files.
|
|
<DT id="6">@foreach $VAR scalar@<DD>
|
|
repeat iterate over code until @end@ setting $VAR to all known scalars
|
|
<DT id="7">@foreach $VAR table@<DD>
|
|
repeat iterate over code until @end@ setting $VAR to all known tables
|
|
<DT id="8">@foreach $VAR column@<DD>
|
|
repeat iterate over code until @end@ setting $VAR to all known
|
|
columns within a given table. Obviously this must be called
|
|
within a foreach-table clause.
|
|
<DT id="9">@foreach $VAR nonindex@<DD>
|
|
repeat iterate over code until @end@ setting $VAR to all known
|
|
non-index columns within a given table. Obviously this must be called
|
|
within a foreach-table clause.
|
|
<DT id="10">@foreach $VAR internalindex@<DD>
|
|
repeat iterate over code until @end@ setting $VAR to all known internal
|
|
index columns within a given table. Obviously this must be called
|
|
within a foreach-table clause.
|
|
<DT id="11">@foreach $VAR externalindex@<DD>
|
|
repeat iterate over code until @end@ setting $VAR to all known external
|
|
index columns within a given table. Obviously this must be called
|
|
within a foreach-table clause.
|
|
<DT id="12">@foreach $VAR index@<DD>
|
|
repeat iterate over code until @end@ setting $VAR to all known
|
|
indexes within a given table. Obviously this must be called
|
|
within a foreach-table clause.
|
|
<DT id="13">@foreach $VAR notifications@<DD>
|
|
repeat iterate over code until @end@ setting $VAR to all known notifications
|
|
<DT id="14">@foreach $VAR varbinds@<DD>
|
|
repeat iterate over code until @end@ setting $VAR to all known varbinds
|
|
Obviously this must be called within a foreach-notifications clause.
|
|
<DT id="15">@foreach $LABEL, $VALUE enum@<DD>
|
|
repeat iterate over code until @end@ setting $LABEL and $VALUE
|
|
to the label and values from the enum list.
|
|
<DT id="16">@foreach $RANGE_START, $RANGE_END range NODE@<DD>
|
|
repeat iterate over code until @end@ setting $RANGE_START and $RANGE_END
|
|
to the legal accepted range set for a given mib NODE.
|
|
<DT id="17">@foreach $var stuff a b c d@<DD>
|
|
repeat iterate over values a, b, c, d as assigned generically
|
|
(ie, the values are taken straight from the list with no
|
|
mib-expansion, etc).
|
|
<DT id="18">@while expression@<DD>
|
|
repeat iterate over code until the expression is false
|
|
<DT id="19">@eval $VAR = expression@<DD>
|
|
evaluates expression and assigns the results to $VAR. This is
|
|
not a full perl eval, but sort of a ""psuedo"" eval useful for
|
|
simple expressions while keeping the same variable name space.
|
|
See below for a full-blown export to perl.
|
|
<DT id="20">@perleval STUFF@<DD>
|
|
evaluates STUFF directly in perl. Note that all mib2c variables
|
|
interpereted within .conf files are in $vars{NAME} and that
|
|
a warning will be printed if STUFF does not return 0. (adding a
|
|
'return 0;' at the end of STUFF is a workaround.
|
|
<DT id="21">@startperl@<DD>
|
|
<DT id="22">@endperl@<DD>
|
|
treats everything between these tags as perl code, and evaluates it.
|
|
<DT id="23">@next@<DD>
|
|
restart foreach; should only be used inside a conditional.
|
|
skips out of current conditional, then continues to skip to
|
|
end for the current foreach clause.
|
|
<DT id="24">@if expression@<DD>
|
|
evaluates expression, and if expression is true processes
|
|
contained part until appropriate @end@ is reached. If the
|
|
expression is false, the next @elsif expression@ expression
|
|
(if it exists) will be evaluated, until an expression is
|
|
true. If no such expression exists and an @else@
|
|
clause is found, it will be evaluated.
|
|
<DT id="25">@ifconf file@<DD>
|
|
If the specified file can be found in the conf file search path,
|
|
and if found processes contained part until an appropriate @end@ is
|
|
found. As with a regular @if expression@, @elsif expression@ and
|
|
@else@ can be used.
|
|
<DT id="26">@ifdir dir@<DD>
|
|
If the specified directory exists, process contained part until an
|
|
appropriate @end@ is found. As with a regular @if expression@,
|
|
@elsif expression@ and @else@ can be used.
|
|
<DT id="27">@define NAME@<DD>
|
|
<DT id="28">@enddefine@<DD>
|
|
Memorizes ""stuff"" between the define and enddefine tags for
|
|
later calling as NAME by @calldefine NAME@.
|
|
<DT id="29">@calldefine NAME@<DD>
|
|
Executes stuff previously memorized as NAME.
|
|
<DT id="30">@printf "expression" stuff1, stuff2, ...@<DD>
|
|
Like all the other printf's you know and love.
|
|
<DT id="31">@run FILE@<DD>
|
|
Sources the contents of FILE as a mib2c file,
|
|
but does not affect current files opened.
|
|
<DT id="32">@include FILE@<DD>
|
|
Sources the contents of FILE as a mib2c file and appends its
|
|
output to the current output.
|
|
<DT id="33">@prompt $var QUESTION@<DD>
|
|
Presents the user with QUESTION, expects a response and puts it in $var
|
|
<DT id="34">@print STUFF@<DD>
|
|
Prints stuff directly to the users screen (ie, not to where
|
|
normal mib2c output goes)
|
|
<DT id="35">@quit@<DD>
|
|
Bail out (silently)
|
|
<DT id="36">@exit@<DD>
|
|
Bail out!
|
|
</DL>
|
|
<A NAME="lbAF"> </A>
|
|
<H2>VARIABLES</H2>
|
|
|
|
<P>
|
|
|
|
Variables in the mib2c language look very similar to perl variables,
|
|
in that they start with a "$". They can be used for anything you
|
|
want, but most typically they'll hold mib node names being processed
|
|
by @foreach ...@ clauses.
|
|
<P>
|
|
|
|
They also have a special properties when they are a mib node, such that
|
|
adding special suffixes to them will allow them to be interpreted in
|
|
some fashion. The easiest way to understand this is through an
|
|
example. If the variable 'x' contained the word 'ifType' then some
|
|
magical things happen. In mib2c output, anytime $x is seen it is
|
|
replaced with "ifType". Additional suffixes can be used to get other
|
|
aspects of that mib node though. If $x.objectID is seen, it'll be
|
|
replaced by the OID for ifType: ".1.3.6.1.2.1.2.2.1.3". Other
|
|
suffixes that can appear after a dot are listed below.
|
|
<P>
|
|
|
|
One last thing: you can use things like $vartext immediately ending in
|
|
some other text, you can use {}s to get proper expansion of only part
|
|
of the mib2c input. IE, $xtext will produce "$xtext", but ${x}text
|
|
will produce "ifTypetext" instead.
|
|
<DL COMPACT>
|
|
<DT id="37">$var.uc<DD>
|
|
all upper case version of $var
|
|
<DT id="38">$var.objectID<DD>
|
|
dotted, fully-qualified, and numeric OID
|
|
<DT id="39">$var.commaoid<DD>
|
|
comma separated numeric OID for array initialization
|
|
<DT id="40">$var.oidlength<DD>
|
|
length of the oid
|
|
<DT id="41">$var.subid<DD>
|
|
last number component of oid
|
|
<DT id="42">$var.module<DD>
|
|
MIB name that the object comes from
|
|
<DT id="43">$var.parent<DD>
|
|
contains the label of the parent node of $var.
|
|
<DT id="44">$var.isscalar<DD>
|
|
returns 1 if var contains the name of a scalar
|
|
<DT id="45">$var.iscolumn<DD>
|
|
returns 1 if var contains the name of a column
|
|
<DT id="46">$var.children<DD>
|
|
returns 1 if var has children
|
|
<DT id="47">$var.perltype<DD>
|
|
node's perl SYNTAX ($SNMP::MIB{node}{'syntax'})
|
|
<DT id="48">$var.type<DD>
|
|
node's ASN_XXX type (Net-SNMP specific #define)
|
|
<DT id="49">$var.decl<DD>
|
|
C data type (char, u_long, ...)
|
|
<DT id="50">$var.readable<DD>
|
|
1 if an object is readable, 0 if not
|
|
<DT id="51">$var.settable<DD>
|
|
1 if an object is writable, 0 if not
|
|
<DT id="52">$var.creatable<DD>
|
|
1 if a column object can be created as part of a new row, 0 if not
|
|
<DT id="53">$var.noaccess<DD>
|
|
1 if not-accessible, 0 if not
|
|
<DT id="54">$var.accessible<DD>
|
|
1 if accessible, 0 if not
|
|
<DT id="55">$var.storagetype<DD>
|
|
1 if an object is a StorageType object, 0 if not
|
|
<DT id="56">$var.rowstatus<DD>
|
|
1 if an object is a RowStatus object, 0 if not
|
|
'settable', 'creatable', 'lastchange', 'storagetype' and 'rowstatus' can
|
|
also be used with table variables to indicate whether it contains
|
|
writable, creatable, LastChange, StorageType or RowStatus column objects
|
|
<DT id="57">$var.hasdefval<DD>
|
|
returns 1 if var has a DEFVAL clause
|
|
<DT id="58">$var.defval<DD>
|
|
node's DEFVAL
|
|
<DT id="59">$var.hashint<DD>
|
|
returns 1 if var has a HINT clause
|
|
<DT id="60">$var.hint<DD>
|
|
node's HINT
|
|
<DT id="61">$var.ranges<DD>
|
|
returns 1 if var has a value range defined
|
|
<DT id="62">$var.enums<DD>
|
|
returns 1 if var has enums defined for it.
|
|
<DT id="63">$var.access<DD>
|
|
node's access type
|
|
<DT id="64">$var.status<DD>
|
|
node's status
|
|
<DT id="65">$var.syntax<DD>
|
|
node's syntax
|
|
<DT id="66">$var.reference<DD>
|
|
node's reference
|
|
<DT id="67">$var.description<DD>
|
|
node's description
|
|
</DL>
|
|
<A NAME="lbAG"> </A>
|
|
<H2>SEE ALSO</H2>
|
|
|
|
<P>
|
|
|
|
<A HREF="/cgi-bin/man/man2html?1+mib2c">mib2c</A>(1)
|
|
<P>
|
|
|
|
<HR>
|
|
<A NAME="index"> </A><H2>Index</H2>
|
|
<DL>
|
|
<DT id="68"><A HREF="#lbAB">NAME</A><DD>
|
|
<DT id="69"><A HREF="#lbAC">SYNOPSIS</A><DD>
|
|
<DT id="70"><A HREF="#lbAD">DESCRIPTION</A><DD>
|
|
<DT id="71"><A HREF="#lbAE">COMMANDS</A><DD>
|
|
<DT id="72"><A HREF="#lbAF">VARIABLES</A><DD>
|
|
<DT id="73"><A HREF="#lbAG">SEE ALSO</A><DD>
|
|
</DL>
|
|
<HR>
|
|
This document was created by
|
|
<A HREF="/cgi-bin/man/man2html">man2html</A>,
|
|
using the manual pages.<BR>
|
|
Time: 00:06:03 GMT, March 31, 2021
|
|
</BODY>
|
|
</HTML>
|