1SNMP_CONFIG(5) Net-SNMP SNMP_CONFIG(5)
2
3
4
6 snmp_config - handling of Net-SNMP configuration files
7
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
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 with the extension of both conf and
19 local.conf (reading the second ones last). In this manner, there are 8
20 default places a configuration file can exist for any given configura‐
21 tion file type.
22
23 Additionally, the above default search path can be overridden by set‐
24 ting the environment variable SNMPCONFPATH to a colon-separated list of
25 directories to search for. The path for the persistent data should be
26 included when running applications that use persistent storage, such as
27 snmpd.
28
29 Applications will read persistent configuration files in the following
30 order of preference:
31
32 file in SNMP_PERSISTENT_FILE environment variable
33
34 directories in SNMPCONFPATH environment variable
35
36 directory defined by persistentDir snmp.conf variable
37
38 directory in SNMP_PERSISTENT_DIR environment variable
39
40 default /var/lib/net-snmp directory
41
42 Finally, applications will write persistent configuration files in the
43 following order of preference:
44
45 file in SNMP_PERSISTENT_FILE environment variable
46
47 directory defined by persistentDir snmp.conf variable
48
49 directory in SNMP_PERSISTENT_DIR environment variable
50
51 default /var/lib/net-snmp directory
52
53 Note: When using SNMP_PERSISTENT_FILE, the filename should match the
54 application name. For example, /var/net-snmp/snmpd.conf.
55
57 Each application may use multiple configuration files, which will con‐
58 figure various different aspects of the application. For instance, the
59 SNMP agent (snmpd) knows how to understand configuration directives in
60 both the snmpd.conf and the snmp.conf files. In fact, most applica‐
61 tions understand how to read the contents of the snmp.conf files.
62 Note, however, that configuration directives understood in one file may
63 not be understood in another file. For further information, read the
64 associated manual page with each configuration file type. Also, most
65 of the applications support a -H switch on the command line that will
66 list the configuration files it will look for and the directives in
67 each one that it understands.
68
69 The snmp.conf configuration file is intended to be a application suite
70 wide configuration file that supports directives that are useful for
71 controlling the fundamental nature of all of the SNMP applications,
72 such as how they all manipulate and parse the textual SNMP MIB files.
73
75 It's possible to switch in mid-file the configuration type that the
76 parser is supposed to be reading. Since that sentence doesn't make
77 much sense, lets give you an example: say that you wanted to turn on
78 packet dumping output for the agent by default, but you didn't want to
79 do that for the rest of the applications (ie, snmpget, snmpwalk, ...).
80 Normally to enable packet dumping in the configuration file you'd need
81 to put a line like:
82
83 dumpPacket true
84
85 into the snmp.conf file. But, this would turn it on for all of the
86 applications. So, instead, you can put the same line in the snmpd.conf
87 file so that it only applies to the snmpd daemon. However, you need to
88 tell the parser to expect this line. You do this by putting a special
89 type specification token inside a [] set. In other words, inside your
90 snmpd.conf file you could put the above snmp.conf directive by adding a
91 line like so:
92
93 [snmp] dumpPacket true
94
95 This tells the parser to parse the above line as if it were inside a
96 snmp.conf file instead of an snmpd.conf file. If you want to parse a
97 bunch of lines rather than just one then you can make the context
98 switch apply to the remainder of the file or until the next context
99 switch directive by putting the special token on a line by itself:
100
101 # make this file handle snmp.conf tokens:
102 [snmp]
103 dumpPacket true
104 logTimestamp true
105 # return to our original snmpd.conf tokens:
106 [snmpd]
107 rocommunity mypublic
108
110 Any lines beginning with the character '#' in the configuration files
111 are treated as a comment and are not parsed.
112
114 Information about writing C code that makes use of this system in
115 either the agent's MIB modules or in applications can be found in the
116 read_config(3) manual page.
117
119 snmpconf(1), read_config(3), snmp.conf(5), snmpd.conf(5)
120
121
122
1234th Berkeley Distribution 5 May 2005 SNMP_CONFIG(5)