snmp_init_mib

Reset the MIB tree

Description

void snmp_init_mib(stringnull $mibdirs)

Unloads the whole MIB tree of the Net-SNMP library, including the MIB files read with snmp_read_mib, sets the list of directories in which MIB files are searched, and then loads the MIB tree again.

When the tree is loaded again, the MIB modules listed in the MIBS environment variable, or else the default modules, are read from these directories, as well as the files listed in the MIBFILES environment variable. The MIB directories are also searched when an OID such as IF-MIB::ifDescr names a module that is not loaded yet.

This is useful to load a different set of MIB modules, for instance when two vendor MIBs define conflicting objects for the same OID.

At the end of the request, the default MIB directories and tree are restored.

Parameters

mibdirs
The directories in which MIB files are searched, separated by a colon (:), or by a semicolon (;) on Windows. If null, the directories are taken from the MIBDIRS environment variable, from the mibdirs token of the Net-SNMP configuration file, or are the default directories of the Net-SNMP library, in that order.

Return Values

No value is returned.

Examples

Example #1 Loading MIB files from other directories

<?php

// Search for MIB files in these directories only
snmp_init_mib('/opt/vendor/mibs:/usr/share/snmp/mibs');
$descriptions = snmp2_real_walk('localhost', 'public', 'VENDOR-MIB::vendorDescr');

?>

See Also

  • snmp_read_mib
  • snmp_set_mib_option