SNMP_CONFIG(5)
๐ snmp_config(5) โ Net-SNMP config files, bestie edition โจ
๐ NAME ๐
okay so snmp_config is literally the manual page for handling Net-SNMP configuration files. That's the whole vibe: it explains how Net-SNMP config files work in general. ๐ซถ
๐ธ DESCRIPTION ๐ธ
The Net-SNMP package uses various configuration files to configure its applications. This manual page merely describes the overall nature of them, so that the other manual pages don't have to. iconic delegation, honestly ๐
๐ DIRECTORIES SEARCHED ๐
First off, there are numerous places that configuration files can be found and read from. By default, the applications look for configuration files in these 4 directories, in this exact order:
/etc/snmp/usr/share/snmp/usr/lib/snmp$HOME/.snmp
In each of these directories, it looks for files snmp.conf, snmpd.conf and/or snmptrapd.conf, as well as snmp.local.conf, snmpd.local.conf and/or snmptrapd.local.conf. The *.local.conf files are always read last โ periodt ๐
So in this manner, there are 8 default places a configuration file can exist for any given configuration file type. math is mathing โจ
Additionally, the above default search path can be overridden by setting the environment variable SNMPCONFPATH to a colon-separated list of directories to search for. The path for the persistent data should be included when running applications that use persistent storage, such as snmpd. no cap, include it ๐ซก
Applications will read persistent configuration files in this order of preference:
- file in
SNMP_PERSISTENT_FILEenvironment variable - directories in
SNMPCONFPATHenvironment variable - directory defined by
persistentDirsnmp.confvariable - directory in
SNMP_PERSISTENT_DIRenvironment variable - default
/var/lib/net-snmpdirectory
Finally, applications will write persistent configuration files in this order of preference:
- file in
SNMP_PERSISTENT_FILEenvironment variable - directory defined by
persistentDirsnmp.confvariable - directory in
SNMP_PERSISTENT_DIRenvironment variable - default
/var/lib/net-snmpdirectory
Note: when usingSNMP_PERSISTENT_FILE, the filename should match the application name. Example:/var/net-snmp/snmpd.conf. bestie, match the name ๐ญ
๐ฆ CONFIGURATION FILE TYPES ๐ฆ
Each application may use multiple configuration files, which will configure various different aspects of the application. For instance, the SNMP agent (snmpd) knows how to understand configuration directives in both the snmpd.conf and the snmp.conf files. In fact, most applications understand how to read the contents of the snmp.conf files. main character energy for snmp.conf, honestly ๐
Note, however, that configuration directives understood in one file may not be understood in another file. For further information, read the associated manual page with each configuration file type. Also, most of the applications support a -H switch on the command line that will list the configuration files it will look for and the directives in each one that it understands. -H is giving built-in cheat sheet ๐ฅ
The snmp.conf configuration file is intended to be a application suite wide configuration file that supports directives that are useful for controlling the fundamental nature of all of the SNMP applications, such as how they all manipulate and parse the textual SNMP MIB files. it's the shared group-chat settings of config files, iykyk ๐ฌ
๐ SWITCHING CONFIGURATION TYPES IN MID-FILE ๐
It's possible to switch in mid-file the configuration type that the parser is supposed to be reading. Since that sentence doesn't make much sense, lets give you an example: say that you wanted to turn on packet dumping output for the agent by default, but you didn't want to do that for the rest of the applications (ie, snmpget, snmpwalk, ...). Normally to enable packet dumping in the configuration file you'd need to put a line like:
dumpPacket true
into the snmp.conf file. But, this would turn it on for all of the applications. So, instead, you can put the same line in the snmpd.conf file so that it only applies to the snmpd daemon. However, you need to tell the parser to expect this line. You do this by putting a special type specification token inside a [] set. In other words, inside your snmpd.conf file you could put the above snmp.conf directive by adding a line like so:
[snmp] dumpPacket true
This tells the parser to parse the above line as if it were inside a snmp.conf file instead of an snmpd.conf file. If you want to parse a bunch of lines rather than just one then you can make the context switch apply to the remainder of the file or until the next context switch directive by putting the special token on a line by itself:
# make this file handle snmp.conf tokens:
[snmp]
dumpPacket true
logTimestamp true
# return to our original snmpd.conf tokens:
[snmpd]
rocommunity mypublic
The same approach can be used to set configuration directives for a particular client application (or group of applications). For example, any program that uses the snmp_parse_args() call to handle command-line arguments (including the standard command-line tools shipped as part of the Net-SNMP distributions) will automatically read the config file snmpapp.conf. To set library-level settings for these applications (but not other more-specific tools), use configuration such as the following:
[snmp] defCommunity myCommunity
for a single directive, or
# make this file handle snmp.conf tokens:
[snmp]
defCommunity myCommunity
defVersion 2c
# return to our original snmpapp.conf tokens:
[snmpapp]
for multiple settings. Similarly for any other application token (as passed to init_snmp()). slay the context-switch moment ๐
๐ COMMENTS ๐
Any lines beginning with the character # in the configuration files are treated as a comment and are not parsed. so if it starts with #, it's giving commentary, not config ๐
๐ง INCLUDING OTHER CONFIGURATION FILES ๐ง
It is possible to include other configuration files for processing during normal configuration file processing.:
# include site specific config
includeFile site.conf
This will load the specified configuration file. The path to file must be either absolute, starting with /, or relative. The relative path is then relative to the directory where the parent file with includeFile directive resides. no guessing the path, bestie โ absolute or relative, that's the rule ๐
The included file name does not need to have .conf suffix.
# include a all *.conf files in a directory
includeDir /etc/snmp/config.d
This will search specified directory for all files with .conf suffix and process them as if they were included using includeFile directive. The configuration files are not processed in any particular order. lowkey chaotic, but that's the vibe ๐ญ
The specified directory must be absolute directory path. periodt.
๐ API INTERFACE ๐
Information about writing C code that makes use of this system in either the agent's MIB modules or in applications can be found in the netsnmp_config_api(3) manual page. C girlies, this one's for you ๐
๐ซ SEE ALSO ๐ซ
mwah ๐ this iconic little page is from Net-SNMP version V5.9.5.2, dated 08 Mar 2010 โ and yes, she ate ๐ซถโจ
๐ฆ where this page comes from
- alpine 3.23: net-snmp-doc 5.9.5.2-r0 ยท Net-SNMP
- alpine 3.24: net-snmp-doc 5.9.5.2-r0 ยท Net-SNMP
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms