downloads | documentation | faq | getting help | mailing lists | reporting bugs | sites | links | my 
search for in the  
view the version of this page
Last updated: Thu, 21 Aug 2003

XCVIII. SNMP functions



In order to use the SNMP functions on Unix you need to install the UCD SNMP or NET-SNMP package. On Windows these functions are only available on NT and not on Win95/98.


Important: In order to use the UCD SNMP package, you need to define NO_ZEROLENGTH_COMMUNITY to 1 before compiling it. After configuring UCD SNMP, edit config.h and search for NO_ZEROLENGTH_COMMUNITY. Uncomment the #define line. It should look like this afterwards:
Now compile PHP --with-snmp[=DIR].

If you see strange segmentation faults in combination with SNMP commands, you did not follow the above instructions. If you do not want to recompile UCD SNMP, you can compile PHP with the --enable-ucd-snmp-hack switch which will work around the misfeature.

The Windows distribution 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.

Runtime Configuration

This extension has no configuration directives defined in php.ini.

Resource Types

Predefined Constants

This extension has no constants defined.

Table of Contents
snmp_get_quick_print --  Fetches the current value of the UCD library's quick_print setting
snmp_set_quick_print -- Set the value of quick_print within the UCD SNMP library
snmpget -- Fetch an SNMP object
snmprealwalk --  Return all objects including their respective object ID within the specified one
snmpset -- Set an SNMP object
snmpwalk -- Fetch all the SNMP objects from an agent
snmpwalkoid -- Query for a tree of information about a network entity

add a note add a note User Contributed Notes
SNMP functions
thug at wolf359 dot cjb dot net
23-Apr-2002 02:06
Just a quick note on PHP SNMP instalation on Windows machines (IIS 5.x / Win2k SP2 etc...)
I had installed PHP into C:\PHP.. (standard stuff eh?)

Whilst I had followed the instructions for the installation of SNMP (put php_snmp.dll in extension_dir, uncomment entry in php.ini and all mib files located on the same drive where php was installed  (in this case c:\usr\mibs right?) I still ran into trouble like "Cannot find module (IP-MIB): At line 0 in (none)..." appearing on the bottom of every php that page I was viewing which existed on a drive other than C:\ drive...

It seams that the mibs dir (and content thereof) have to be located on every volume where a php file will be executed from.

For example :-
If you have a php file as "C:\INETPUB\WWWROOT\snmp1.php" then the coresponding "C:\USR\MIBS\*.*" has to be present (as mentioned in the install.txt).

Now here comes the catch...

If you have a "D:\INETPUB\PHPROOT\snmp1.php" file, then a copy of the mib files have to be in "D:\USR\MIBS\*.*" as well (the same mib files that are on the C:\ drive and same basic location <drive>:\USR\MIBS).

(Or in short : Copy the C:\USR dir (inc mibs dir) to *every* drive you intend to have .php files accessed from.  Done!)

Hope this helps other PHParians.

Keep up the *Great* work!!!
admin at Nospamplzkthx dot networkessence dot net
20-Aug-2001 12:54
If you are having problems getting snmp compiled with php, try these steps:

compile snmp
[root ucd-snmp-4.2.1] ./configure --with-openssl=/path/to/openssl-vers
[root ucd-snmp-4.2.1] make | make install
then compile php
[root php-4.0.6] ./configure --with-snmp=/usr/local --with-openssl --enable-ucd-snmp-hack

I found that compiling ucd-snmp without openssl leaves out crypto, leaving behind undefine symbol references, and if  you specify a directory for --with-openssl with php, it breaks the crypto library compilation.
zaid at mci dot net
01-Mar-2001 01:49
If you are trying to install the following on FreeBSD 4.2-RELEASE #0:


You will need to :
1- install the ucd-snmp
  a- rm
  b- ln libsnmp.a
2- make, and make install
3- follow the instructions in the INSTALL file under PHP directory.
  a- I used the following options to get
the ability to make snmp calls within PHP :
./configure --with-mysql --with-apache=../apache_1.3.19 --enable-track-vars --with-snmp=/usr/local --enable-ucd-snmp-hack
bira at tech dot telepac dot pt
26-Apr-2000 10:41
Regarding to Gustavo's SNMP question.
I changed the code on ext/snmp/snmp.c.<br>
Heres how the snmp support compiles without errors. Dont forget the --enable-ucd-snmp-hack:-)<br>
look for the following function (about line 360)<p>
PHP_FUNCTION(snmp_set_quick_print) {
        /* jecete */
        int set_val;
        zval **a1;
        if (ARG_COUNT(ht) != 1 || zend_get_parameters_ex(1, &a1) == FAILURE) {
        /* jecete     
           Old value commented
           int set_val = (*a1)->value.lval; */
        set_val = (*a1)->value.lval;
jclark at NOSPAM dot xnet dot com
23-Mar-2000 11:20
Usually when PHP spits back a message referring to call undefined function, it really means that the command you are attempting to use is not compiled into PHP.   To verify, use the phpinfo function.
Thor2001 at gmx dot net
19-Mar-2000 02:27
in the <sourcedir php>/functions/snmp.c
add the line 
#include <default_store.h>
before the first #include line.
rgroesb_garbage at triple-it_garbage dot nl
11-Mar-1999 11:39
snmpset -- Set an SNMP object

int snmpset(string hostname, string community,  string object_id,  string type, string vallue);

The snmpset() function is used to set the value of
an SNMP object.

The type should be a single character, one of:
    s STRING
    o OBJID

        "private","system.SysContact.0", "s",
                                               "Captain Iglo");

Snmpset URL:

 Last updated: Thu, 21 Aug 2003
show source | credits | sitemap | mirror sites 
Copyright © 2001-2003 The PHP Group
All rights reserved.
This mirror generously provided by:
Last updated: Sat 01 Nov 2003 04:13:36 EST EST