1SNMP_CONFIG(5)                     Net-SNMP                     SNMP_CONFIG(5)
2
3
4

NAME

6       snmp_config - handling of Net-SNMP configuration files
7

DESCRIPTION

9       The  Net-SNMP package uses various configuration files to configure its
10       applications.  This manual page merely describes the overall nature  of
11       them, so that the other manual pages don't have to.
12

DIRECTORIES SEARCHED

14       First  off,  there  are numerous places that configuration files can be
15       found and read from.  By default, the applications look for  configura‐
16       tion  files  in  the  following  4  directories,  in  order: /etc/snmp,
17       /usr/share/snmp, /usr/lib(64)/snmp, and $HOME/.snmp.  In each of  these
18       directories,   it   looks   for   files  snmp.conf,  snmpd.conf  and/or
19       snmptrapd.conf, as well  as  snmp.local.conf,  snmpd.local.conf  and/or
20       snmptrapd.local.conf.  *.local.conf  are always read last. In this man‐
21       ner, there are 8 default places a configuration file can exist for  any
22       given configuration file type.
23
24       Additionally,  the  above default search path can be overridden by set‐
25       ting the environment variable SNMPCONFPATH to a colon-separated list of
26       directories  to search for.  The path for the persistent data should be
27       included when running applications that use persistent storage, such as
28       snmpd.
29
30       Applications  will read persistent configuration files in the following
31       order of preference:
32
33              file in SNMP_PERSISTENT_FILE environment variable
34              directories in SNMPCONFPATH environment variable
35              directory defined by persistentDir snmp.conf variable
36              directory in SNMP_PERSISTENT_DIR environment variable
37              default /var/lib/net-snmp directory
38
39       Finally, applications will write persistent configuration files in  the
40       following order of preference:
41
42              file in SNMP_PERSISTENT_FILE environment variable
43              directory defined by persistentDir snmp.conf variable
44              directory in SNMP_PERSISTENT_DIR environment variable
45              default /var/lib/net-snmp directory
46
47       Note:   When  using SNMP_PERSISTENT_FILE, the filename should match the
48       application name.  For example, /var/net-snmp/snmpd.conf.
49

CONFIGURATION FILE TYPES

51       Each application may use multiple configuration files, which will  con‐
52       figure various different aspects of the application.  For instance, the
53       SNMP agent (snmpd) knows how to understand configuration directives  in
54       both  the  snmpd.conf  and the snmp.conf files.  In fact, most applica‐
55       tions understand how to read  the  contents  of  the  snmp.conf  files.
56       Note, however, that configuration directives understood in one file may
57       not be understood in another file.  For further information,  read  the
58       associated  manual  page with each configuration file type.  Also, most
59       of the applications support a -H switch on the command line  that  will
60       list  the  configuration  files  it will look for and the directives in
61       each one that it understands.
62
63       The snmp.conf configuration file is intended to be a application  suite
64       wide  configuration  file  that supports directives that are useful for
65       controlling the fundamental nature of all  of  the  SNMP  applications,
66       such as how they all manipulate and parse the textual SNMP MIB files.
67

SWITCHING CONFIGURATION TYPES IN MID-FILE

69       It's  possible  to  switch  in mid-file the configuration type that the
70       parser is supposed to be reading.  Since  that  sentence  doesn't  make
71       much  sense,  lets  give you an example: say that you wanted to turn on
72       packet dumping output for the agent by default, but you didn't want  to
73       do  that for the rest of the applications (ie, snmpget, snmpwalk, ...).
74       Normally to enable packet dumping in the configuration file you'd  need
75       to put a line like:
76
77              dumpPacket true
78
79       into  the  snmp.conf  file.   But, this would turn it on for all of the
80       applications.  So, instead, you can put the same line in the snmpd.conf
81       file so that it only applies to the snmpd daemon.  However, you need to
82       tell the parser to expect this line.  You do this by putting a  special
83       type  specification token inside a [] set.  In other words, inside your
84       snmpd.conf file you could put the above snmp.conf directive by adding a
85       line like so:
86
87              [snmp] dumpPacket true
88
89       This  tells  the  parser to parse the above line as if it were inside a
90       snmp.conf file instead of an snmpd.conf file.  If you want to  parse  a
91       bunch  of  lines  rather  than  just  one then you can make the context
92       switch apply to the remainder of the file or  until  the  next  context
93       switch directive by putting the special token on a line by itself:
94
95              # make this file handle snmp.conf tokens:
96              [snmp]
97              dumpPacket true
98              logTimestamp true
99              # return to our original snmpd.conf tokens:
100              [snmpd]
101              rocommunity mypublic
102
103       The  same  approach  can  be used to set configuration directives for a
104       particular client application (or group of applications).  For example,
105       any  program  that uses the 'snmp_parse_args()' call to handle command-
106       line arguments (including the standard command-line  tools  shipped  as
107       part  of the Net-SNMP distributions) will automatically read the config
108       file 'snmpapp.conf'.  To set library-level settings for these  applica‐
109       tions  (but  not  other more-specific tools), use configuration such as
110       the following:
111
112              [snmp] defCommunity myCommunity
113
114       for a single directive, or
115
116              # make this file handle snmp.conf tokens:
117              [snmp]
118              defCommunity myCommunity
119              defVersion   2c
120              # return to our original snmpapp.conf tokens:
121              [snmpapp]
122
123       for multiple settings.  Similarly for any other application  token  (as
124       passed to init_snmp()).
125

COMMENTS

127       Any  lines  beginning with the character '#' in the configuration files
128       are treated as a comment and are not parsed.
129

INCLUDING OTHER CONFIGURATION FILES

131       It is possible to include other configuration files for processing dur‐
132       ing normal configuration file processing.:
133
134              # include site specific config
135              includeFile site.conf
136
137       This will load the specified configuration file. The
138       path to file must be either absolute, starting with '/',
139       or relative. The relative path is then relative to the directory
140       where the parent file with 'includeFile' directive resides.
141
142       The included file name does not need to have '.conf' suffix.
143
144              # include a all *.conf files in a directory
145              includeDir /etc/snmp/config.d
146
147       This will search specified directory for all files with '.conf'
148       suffix and process them as if they were included using includeFile
149       directive. The configuration files are not processed in any particular
150       order.
151
152       The specified directory must be absolute directory path.
153

API INTERFACE

155       Information  about  writing  C  code  that  makes use of this system in
156       either the agent's MIB modules or in applications can be found  in  the
157       netsnmp_config_api(3) manual page.
158

SEE ALSO

160       snmpconf(1), netsnmp_config_api(3), snmp.conf(5), snmpd.conf(5)
161
162
163
164V5.8                              08 Mar 2010                   SNMP_CONFIG(5)
Impressum