1MIB2C.CONF(5)                      Net-SNMP                      MIB2C.CONF(5)
2
3
4

NAME

6       mib2c.conf  - How to write mib2c.conf files to do ANYTHING based on MIB
7       input.
8

SYNOPSIS

10       % cat > mib2c.test.conf  << EOF @foreach $t table@
11         Starting table $t
12         @foreach $c column@
13           echo $t has column $c which has a syntax of $c.syntax
14         @end@
15
16       @end@ EOF
17
18       % mib2c -c mib2c.test.conf internet
19

DESCRIPTION

21       The mib2c.conf script language is a MIB-particular language designed to
22       easily  process  MIB  nodes in ways that you want.  mib2c is a misnomer
23       (for historical purposes), because you can produce anything (not just C
24       code).   Look  in the Net-SNMP "local" directory for a bunch of example
25       mib2c.*.conf files and behold the power before you.
26

COMMANDS

28       All commands within mib2c.conf files are embraced by @ signs.  Anything
29       with  an @ sign at the front and back of the line is generally supposed
30       to be a mib2c specific command.  These are detailed here:
31
32       @open FILE@
33              writes generated output to FILE note that  for  file  specifica‐
34              tions, opening '-' will print to stdout.
35
36       @append FILE@
37              appends the given FILE
38
39       @close FILE@
40              closes the given FILE
41
42       @push@ save  the  current  outputs, then clear outputs. Use with @open@
43              and @pop@ to write to a new file without interfering  with  cur‐
44              rent outputs.
45
46       @pop@  pop  up  the  process()  stack  one level. Use after a @push@ to
47              return to the previous set of open files.
48
49       @foreach $VAR scalar@
50              repeat iterate over code until @end@ setting $VAR to  all  known
51              scalars
52
53       @foreach $VAR table@
54              repeat  iterate  over code until @end@ setting $VAR to all known
55              tables
56
57       @foreach $VAR column@
58              repeat iterate over code until @end@ setting $VAR to  all  known
59              columns  within  a  given  table.  Obviously this must be called
60              within a foreach-table clause.
61
62       @foreach $VAR nonindex@
63              repeat iterate over code until @end@ setting $VAR to  all  known
64              non-index  columns within a given table.  Obviously this must be
65              called within a foreach-table clause.
66
67       @foreach $VAR internalindex@
68              repeat iterate over code until @end@ setting $VAR to  all  known
69              internal  index  columns  within  a given table.  Obviously this
70              must be called within a foreach-table clause.
71
72       @foreach $VAR externalindex@
73              repeat iterate over code until @end@ setting $VAR to  all  known
74              external  index  columns  within  a given table.  Obviously this
75              must be called within a foreach-table clause.
76
77       @foreach $VAR index@
78              repeat iterate over code until @end@ setting $VAR to  all  known
79              indexes  within  a  given  table.  Obviously this must be called
80              within a foreach-table clause.
81
82       @foreach $VAR notifications@
83              repeat iterate over code until @end@ setting $VAR to  all  known
84              notifications
85
86       @foreach $VAR varbinds@
87              repeat  iterate  over code until @end@ setting $VAR to all known
88              varbinds Obviously this must be called within a  foreach-notifi‐
89              cations clause.
90
91       @foreach $LABEL, $VALUE enum@
92              repeat  iterate  over code until @end@ setting $LABEL and $VALUE
93              to the label and values from the enum list.
94
95       @foreach $RANGE_START, $RANGE_END range NODE@
96              repeat iterate over code until @end@  setting  $RANGE_START  and
97              $RANGE_END to the legal accepted range set for a given mib NODE.
98
99       @foreach $var stuff a b c d@
100              repeat  iterate  over  values a, b, c, d as assigned generically
101              (ie, the values are taken straight from the list  with  no  mib-
102              expansion, etc).
103
104       @while expression@
105              repeat iterate over code until the expression is false
106
107       @eval $VAR = expression@
108              evaluates  expression  and assigns the results to $VAR.  This is
109              not a full perl eval, but sort of a ""psuedo"" eval  useful  for
110              simple  expressions  while keeping the same variable name space.
111              See below for a full-blown export to perl.
112
113       @perleval STUFF@
114              evaluates STUFF directly in perl.  Note that all mib2c variables
115              interpereted  within  .conf  files are in $vars{NAME} and that a
116              warning will be printed if STUFF does not return  0.  (adding  a
117              'return 0;' at the end of STUFF is a workaround.
118
119       @startperl@
120
121       @endperl@
122              treats everything between these tags as perl code, and evaluates
123              it.
124
125       @next@ restart foreach; should  only  be  used  inside  a  conditional.
126              skips  out of current conditional, then continues to skip to end
127              for the current foreach clause.
128
129       @if expression@
130              evaluates expression, and if expression is true  processes  con‐
131              tained  part until appropriate @end@ is reached.  If the expres‐
132              sion is false, the next @elsif  expression@  expression  (if  it
133              exists)  will  be  evaluated, until an expression is true. If no
134              such expression exists and an @else@ clause is found, it will be
135              evaluated.
136
137       @ifconf file@
138              If the specified file can be found in the conf file search path,
139              and if found processes contained part until an appropriate @end@
140              is  found. As with a regular @if expression@, @elsif expression@
141              and @else@ can be used.
142
143       @ifdir dir@
144              If the specified directory exists, process contained part  until
145              an  appropriate  @end@  is  found. As with a regular @if expres‐
146              sion@, @elsif expression@ and @else@ can be used.
147
148       @define NAME@
149
150       @enddefine@
151              Memorizes ""stuff"" between the define and  enddefine  tags  for
152              later calling as NAME by @calldefine NAME@.
153
154       @calldefine NAME@
155              Executes stuff previously memorized as NAME.
156
157       @printf "expression" stuff1, stuff2, ...@
158              Like all the other printf's you know and love.
159
160       @run FILE@
161              Sources  the  contents  of  FILE  as  a mib2c file, but does not
162              affect current files opened.
163
164       @include FILE@
165              Sources the contents of FILE as a mib2c  file  and  appends  its
166              output to the current output.
167
168       @prompt $var QUESTION@
169              Presents  the user with QUESTION, expects a response and puts it
170              in $var
171
172       @print STUFF@
173              Prints stuff directly to the users screen (ie, not to where nor‐
174              mal mib2c output goes)
175
176       @quit@ Bail out (silently)
177
178       @exit@ Bail out!
179

VARIABLES

181       Variables in the mib2c language look very similar to perl variables, in
182       that they start with a "$".  They can be used for  anything  you  want,
183       but  most  typically  they'll  hold  mib  node names being processed by
184       @foreach ...@ clauses.
185
186       They also have a special properties when they are a mib node, such that
187       adding  special  suffixes  to them will allow them to be interpreted in
188       some fashion.  The easiest way to understand this is through  an  exam‐
189       ple.  If the variable 'x' contained the word 'ifType' then some magical
190       things happen.  In mib2c output, anytime $x is seen it is replaced with
191       "ifType".  Additional suffixes can be used to get other aspects of that
192       mib node though.  If $x.objectID is seen, it'll be replaced by the  OID
193       for  ifType:  ".1.3.6.1.2.1.2.2.1.3".   Other  suffixes that can appear
194       after a dot are listed below.
195
196       One last thing: you can use things like $vartext immediately ending  in
197       some  other  text, you can use {}s to get proper expansion of only part
198       of the mib2c input.  IE, $xtext will  produce  "$xtext",  but  ${x}text
199       will produce "ifTypetext" instead.
200
201       $var.uc
202              all upper case version of $var
203
204       $var.objectID
205              dotted, fully-qualified, and numeric OID
206
207       $var.commaoid
208              comma separated numeric OID for array initialization
209
210       $var.oidlength
211              length of the oid
212
213       $var.subid
214              last number component of oid
215
216       $var.module
217              MIB name that the object comes from
218
219       $var.parent
220              contains the label of the parent node of $var.
221
222       $var.isscalar
223              returns 1 if var contains the name of a scalar
224
225       $var.iscolumn
226              returns 1 if var contains the name of a column
227
228       $var.children
229              returns 1 if var has children
230
231       $var.perltype
232              node's perl SYNTAX ($SNMP::MIB{node}{'syntax'})
233
234       $var.type
235              node's ASN_XXX type (Net-SNMP specific #define)
236
237       $var.decl
238              C data type (char, u_long, ...)
239
240       $var.readable
241              1 if an object is readable, 0 if not
242
243       $var.settable
244              1 if an object is writable, 0 if not
245
246       $var.creatable
247              1  if  a column object can be created as part of a new row, 0 if
248              not
249
250       $var.noaccess
251              1 if not-accessible, 0 if not
252
253       $var.accessible
254              1 if accessible, 0 if not
255
256       $var.storagetype
257              1 if an object is a StorageType object, 0 if not
258
259       $var.rowstatus
260              1 if an object is a RowStatus object, 0 if not 'settable', 'cre‐
261              atable', 'lastchange', 'storagetype' and 'rowstatus' can also be
262              used with  table  variables  to  indicate  whether  it  contains
263              writable, creatable, LastChange, StorageType or RowStatus column
264              objects
265
266       $var.hasdefval
267              returns 1 if var has a DEFVAL clause
268
269       $var.defval
270              node's DEFVAL
271
272       $var.hashint
273              returns 1 if var has a HINT clause
274
275       $var.hint
276              node's HINT
277
278       $var.ranges
279              returns 1 if var has a value range defined
280
281       $var.enums
282              returns 1 if var has enums defined for it.
283
284       $var.access
285              node's access type
286
287       $var.status
288              node's status
289
290       $var.syntax
291              node's syntax
292
293       $var.reference
294              node's reference
295
296       $var.description
297              node's description
298

SEE ALSO

300       mib2c(1)
301
302
303
304VVERSIONINFO                      28 Apr 2004                    MIB2C.CONF(5)
Impressum