I have compiled php with snmp support, and when I perform an strace on php, I get a lot of the following, showing that it is trying to parse through every MIB file. Is it possible to compile php with the snmp3_get/snmp3_set methods enabled, but so that it won't output all of this?
$> strace php -v
...
open("/usr/local/share/snmp/mibs/SNMPv2-TM.txt", O_RDONLY|O_LARGEFILE) = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=5775, ...}) = 0
mmap2(NULL, 4096, PROT_READ|PR开发者_StackOverflowOT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7645000
read(3, "SNMPv2-TM DEFINITIONS ::= BEGIN\n"..., 4096) = 4096
read(3, "'n' as an unsigned integer\n "..., 4096) = 1679
read(3, "", 4096) = 0
close(3) = 0
munmap(0xb7645000, 4096) = 0
open("/usr/local/share/snmp/mibs/NET-SNMP-VACM-MIB.txt", O_RDONLY|O_LARGEFILE) = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=5039, ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7645000
read(3, "NET-SNMP-VACM-MIB DEFINITIONS ::"..., 4096) = 4096
read(3, "across\n all nsVa"..., 4096) = 943
read(3, "", 4096) = 0
close(3) = 0
...
All of the SNMP calls I will be making will be made by calling the full OID directly, and so it is not necessary to parse these files
Typically net-snmp applications will read the MIB files from either a hard-coded list of directories, or from a list of directories contained in the MIBDIRS environment variable.
A very simple, quick hack, way of ensuring that no MIB files are parsed is to override the MIBDIRS environment variable to point to a directory that doesn't exist, prior to calling the functions to initialise net-snmp in your application.
精彩评论