0

When I use this code in PHP:

print_r($_SERVER);

the first index that it prints is:

[MIBDIRS] => C:/xampp/php/extras/mibs

Can somebody tell me what is MIB-Directory ? and what is used for ?

Sᴀᴍ Onᴇᴌᴀ
  • 8,218
  • 8
  • 36
  • 58
  • http://php.net/manual/en/snmp.installation.php "The Windows distribution of Net-SNMP contains support files for SNMP in the mibs directory. This directory should added to Windows' environment variables, as MIBDIRS, with the value being the full path to the mibs directory: e.g. c:\usr\mibs." – ceejayoz Apr 22 '17 at 18:19

1 Answers1

3

From my research, I have found:

A management information base (MIB) is a database used for managing the entities in a communication network. Most often associated with the Simple Network Management Protocol (SNMP), the term is also used more generically in contexts such as in OSI/ISO Network management model. While intended to refer to the complete collection of management information available on an entity, it is often used to refer to a particular subset, more correctly referred to as MIB-module.1

There is a PHP package Net-SNMP, which when enabled, will allow a user to call functions like snmp_read_mib() that will read MIB files.

snmp_read_mib

Reads and parses a MIB file into the active MIB tree

bool snmp_read_mib ( string $filename )

This function is used to load additional, e.g. vendor specific, MIBs so that human readable OIDs like VENDOR-MIB::foo.1 instead of error prone numeric OIDs can be used.

The order in which the MIBs are loaded does matter as the underlying Net-SNMP libary will print warnings if referenced objects cannot be resolved.

Note that $_SERVER contains environment variables:

$_SERVER -- $HTTP_SERVER_VARS [removed] — Server and execution environment information2

And in the User Contributed Notes for snmp_read_mib(), the top post is:

If you are trying to import mibs with dependencies on other mibs you will have to set the MIBDIRS environment variable.

Unix / Linux: export MIBDIRS=/home/<user>/MIBS:/usr/share/snmp/mibs
Window: Good luck! No really. Try this url out. It has everything that you need to know about setting environment vars in windows.

http://vlaurie.com/computers2/Articles/environment.htm
3

I just installed the latest version of (32-bit) XAMPP for Windows with PHP version 7.1.1. Looking in C:\xampp\apache\conf\extra\httpd-xampp.conf (one of the main Apache configuration files) I see on line 6:

SetEnv MIBDIRS "C:/xampp/php/extras/mibs"

So that sets the environment variable for PHP, which is why you see MIBDIRS in $_SERVER.

Perhaps the MIBDIRS from $_SERVER would be used like this:

snmp_read_mib($_SERVER['MIBDIRS'].'IPV6-TC.txt');

I was hoping to see an example in this question or its answers but didn't see any.


1https://en.wikipedia.org/wiki/Management_information_base

2http://php.net/manual/en/reserved.variables.server.php

3http://php.net/manual/en/function.snmp-read-mib.php#81586

Community
  • 1
  • 1
Sᴀᴍ Onᴇᴌᴀ
  • 8,218
  • 8
  • 36
  • 58