1

I've enabled the SNMP module was trying to the functions in the module. I have set the MIBDIRS environment variable to where I have my mibs but I'm still getting these "Cannot find module" warnings:

Cannot find module (IP-MIB): At line 0 in (none)
Cannot find module (IF-MIB): At line 0 in (none)
Cannot find module (TCP-MIB): At line 0 in (none)
Cannot find module (UDP-MIB): At line 0 in (none)
Cannot find module (HOST-RESOURCES-MIB): At line 0 in (none)
Cannot find module (SNMPv2-MIB): At line 0 in (none)
Cannot find module (SNMPv2-SMI): At line 0 in (none)
Cannot find module (NOTIFICATION-LOG-MIB): At line 0 in (none)
Cannot find module (UCD-SNMP-MIB): At line 0 in (none)
Cannot find module (UCD-DEMO-MIB): At line 0 in (none)
Cannot find module (SNMP-TARGET-MIB): At line 0 in (none)
Cannot find module (NET-SNMP-AGENT-MIB): At line 0 in (none)
Cannot find module (DISMAN-EVENT-MIB): At line 0 in (none)
Cannot find module (SNMP-VIEW-BASED-ACM-MIB): At line 0 in (none)
Cannot find module (SNMP-COMMUNITY-MIB): At line 0 in (none)
Cannot find module (UCD-DLMOD-MIB): At line 0 in (none)
Cannot find module (SNMP-FRAMEWORK-MIB): At line 0 in (none)
Cannot find module (SNMP-MPD-MIB): At line 0 in (none)
Cannot find module (SNMP-USER-BASED-SM-MIB): At line 0 in (none)
Cannot find module (SNMP-NOTIFICATION-MIB): At line 0 in (none)
Cannot find module (SNMPv2-TM): At line 0 in (none)

My php.ini settings are:

mibdir=C:\\Users\username\Downloads\Applications\Dev\PHP\5.4\net-snmp-mibs\net-snmp-5.7.2.1\mibs
mibs=all
extension=php_snmp.dll

I'm on Windows.

And it still gives those errors...

Any insights please?

Sᴀᴍ Onᴇᴌᴀ
  • 8,218
  • 8
  • 36
  • 58
Carmageddon
  • 2,627
  • 4
  • 36
  • 56

4 Answers4

3

The PHP docs is misleading for Windows; In order to get rid of the errors and have SNMP module working properly, you MUST add an environment variable in the System, called MIBDIRS and pointing to the location of your mib files.

On Windows 7 for example, that would be System Properties > Environment Variables > User variables section, click New and add MIBDIRS, with value of C:\usr\mibs (or wherever you put the mibs folder).

The files should be extracted using a Net-SNMP package, tested with version net-snmp-5.7.2.1 on PHP 5.4.7 using CLI mode.

Carmageddon
  • 2,627
  • 4
  • 36
  • 56
2

The php package doesn't include a mibs folder, what you have to do is download the source file of net-snmp and copy the folder into your php directory

download link https://sourceforge.net/projects/net-snmp/files/net-snmp/5.7.3/

after that, unzip the zip file and copy the mibs folder to your php directory

for example,copy it to C:\PHP\Extras\mibs Then add a new system variable called MIBDIRS. Its value should be: C:\PHP\Extras\mibs

Finally, you can run php -m

and you issue will be resoved

I attach a screenshot for your reference.enter image description here

Professor Abronsius
  • 33,063
  • 5
  • 32
  • 46
buqing
  • 925
  • 8
  • 25
1

Copied from another post:

Apparently there are 2 environment variables you can set. One is MIBDIRS which is where all the MIB files are. Another is MIBS, which I believe is which SNMP modules you want to load. By setting MIBS to ALL, I was able to get rid of the errors

Vigneshwaran
  • 387
  • 1
  • 2
  • 14
  • For your reference, http://stackoverflow.com/questions/16467712/php-snmp-cannot-find-module – Vigneshwaran Jul 10 '14 at 13:03
  • 1
    I am aware of that post, did you fully read my question? in the second half, I stated my php.ini settings: My php.ini settings are: mibdir=C:\Users\username\Downloads\Applications\Dev\PHP\5.4\net-snmp-mibs\net-snmp-5.7.2.1\mibs mibs=all extension=php_snmp.dll – Carmageddon Jul 10 '14 at 13:27
  • Can i know which web server you are using? Xamp or Wamp? – Vigneshwaran Jul 10 '14 at 13:33
  • I am not using any in fact. I have PHP extracted to C:\Users\username\Downloads\Applications\Dev\PHP\5.4\, and added to my path, so I just use it from command line using php scriptname.php I currently do not require a web server for my development needs. – Carmageddon Jul 12 '14 at 23:27
1

Acording to PHP SNMP Instllation page:

The Windows distribution of Net-SNMP contains support files for SNMP in the mibs directory. This directory should be moved to DRIVE:\usr\mibs, where DRIVE must be replaced with the driveletter where PHP is installed on, e.g.c:\usr\mibs. Alternatively you may set MIBDIRS environment variable pointed to your MIBs folder.

http://php.net/manual/en/snmp.installation.php

torrentalle
  • 643
  • 4
  • 10
  • Thanks, I've already been using mibdir setting in php.ini, but I've tried to give this a try, including adjusting the setting to C:\usr\mibs - still no change, php still gives me those "Cannot find module.." errors when calling php from command line. – Carmageddon Jul 15 '14 at 05:23
  • Actually, after further reading of the manual you linked to, I realized I misunderstood and confused **php.ini** setting for mibdir=, and the **ENVIRONMENT VARIABLE** called **MIBDIRS**!! Once I attempted and added the environment variable MIBDIRS in windows (although guide says its for 32bit windows) and re-opened the command line window - no warnings anymore, it works!!! You sir, earned the 100 bounty points, but I will post a new answer to emphsize the root issue - MIBDIRS environment variable is a MUST, not optional as the docs say... – Carmageddon Jul 15 '14 at 05:48