PHP  
downloads | documentation | faq | getting help | mailing lists | | php.net sites | links 
search for in the  
previousswf_viewportsnmp_get_quick_printnext
Last updated: Tue, 09 Jul 2002
view the printer friendly version or the printer friendly version with notes or change language to English | Brazilian Portuguese | Chinese | Czech | Dutch | Finnish | German | Hungarian | Italian | Japanese | Korean | Polish | Romanian | Russian | Spanish | Swedish | Turkish

XCV. SNMP

Afin de pouvoir utiliser les fonctions SNMP sous Unix, vous aurez besoin d'installer le package . Sous Windows ces fonctions ne sont disponibles que sous NT, et pas sous Win95/98.

Important : Afin d'utiliser le package UCD SNMP, vous devez mettre la variable NO_ZEROLENGTH_COMMUNITY � 1 avant de compiler. Apr�s avoir configur� UCD SNMP, �ditez le fichier config.h et recherchez la valeur NO_ZEROLENGTH_COMMUNITY. D�commentez la ligne avec le #define. Cela doit ressembler � ceci :

#define NO_ZEROLENGTH_COMMUNITY 1

Si vous avez des erreurs "segmentation faults", lors de l'utilisation des commandes SNMP, c'est que vous n'avez pas suivi les recommendations pr�c�dentes. Si vous ne voulez pas recompiler UCD SNMP, vous pouvez aussi recompiler PHP avec l'option --enable-ucd-snmp-hack qui �vitera cette erreur.

Table des mati�res
snmp_get_quick_print -- Lit la valeur courante de l'option quick_print de la librairie UCD.
snmp_set_quick_print -- Ecrit la valeur courante de l'option quick_print de la librairie UCD.
snmpget -- Re�oit un objet SNMP.
snmprealwalk --  Return all objects including their respective object ID within the specified one
snmpset -- Envoie un objet SNMP.
snmpwalk -- Re�oit tous les objets SNMP d'un agent.
snmpwalkoid --  Demande d'informations d'arbre sur une entit� du r�seau.
User Contributed Notes
SNMP
add a note about notes
rgroesb_garbage@triple-it_garbage.nl
11-Mar-1999 01:39

<pre>
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:
i INTEGER
s STRING
x HEX STRING
d DECIMAL STRING
n NULLOBJ
o OBJID
t TIMETICKS
a IPADDRESS

Example:
snmpset("127.0.0.1",
"private","system.SysContact.0", "s",
"Captain Iglo");
</pre>

Snmpset URL:

[email protected]
19-Mar-2000 04:27

in the <sourcedir php>/functions/snmp.c
add the line
#include <default_store.h>
before the first #include line.

[email protected]
23-Mar-2000 01: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.
[email protected]
26-Apr-2000 02:41

Regarding to Gustavo's SNMP question.
I changed the code on ext/snmp/snmp.c.

Heres how the snmp support compiles without errors. Dont forget the --enable-ucd-snmp-hack:-)

look for the following function (about line 360)


<pre>
PHP_FUNCTION(snmp_set_quick_print) {
/* jecete */
int set_val;
zval **a1;
if (ARG_COUNT(ht) != 1 || zend_get_parameters_ex(1, &a1) == FAILURE) {
WRONG_PARAM_COUNT;
}
convert_to_long_ex(a1);
/* jecete
Old value commented
int set_val = (*a1)->value.lval; */
set_val = (*a1)->value.lval;
snmp_set_quick_print(set_val);
}
</pre>

[email protected]
01-Mar-2001 03:49

If you are trying to install the following on FreeBSD 4.2-RELEASE #0:

apache_1.3.19
php-4.0.2
ucd-snmp-4.2

You will need to :
1- install the ucd-snmp
a- rm libsnmp.so
b- ln libsnmp.a libsnmp.so
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

[email protected]
17-Jun-2001 11:06

Hey people!

Have you checked ?
There are more functions available (citation):
NOTE: The first 8 snmp_* functions are new and should be used. These obsolete the "snmpget", "snmpwalk" and "snmpwalkoid".
General usage of these are: snmp_opensession(); snmp_get(); snmp_close();

Table of Contents
snmp_session � Opens an SNMP session
snmp_close � Closes an SNMP session
snmp_get � Fetches SNMP objects with an SNMP get request
snmp_getnext � Fetches SNMP objects with an SNMP getnext request
snmp_getbulk � Fetches SNMP objects with a SNMP getbulk request
snmp_walk � Fetches all SNMP objects with the SNMP getnext request
snmp_bulkwalk � Fetches all SNMP objects with the SNMP getbulk request
snmp_set � Sets the value of SNMP objects with the SNMP set request
snmp_error � Fetches SNMP protocol error of the last SNMP request.
snmpget � Fetch an SNMP object
snmpwalk � Fetch all the SNMP objects from an agent
snmpwalkoid � Query for a tree of information about a network entity
snmp_get_quick_print � Fetch 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


I've just checked source code - at least it's free of bug of non-reading UCD library configuration files (snmp.conf and etc.). I think it have to be still adopted to php4.

And about this "bug":
if you want for snmp module to read configuration files (snmp.conf) and return data in described formats - not default ones, you have to change in source file ext/snmp/snmp.c (php4-4.0.3) it should be:

PHP_MINIT_FUNCTION(snmp)
{
init_snmp("snmp"); // instead of init_mib();

return SUCCESS;
}


Regards,
Vilius Benetis
LITNET

[email protected]
20-Aug-2001 04: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.

[email protected]
22-Aug-2001 03:10

The additional functions for SNMP for PHP v3 listed above I have converted with the authors permission to work in version 4 of PHP.

Its available from:

[email protected]
14-Jan-2002 11:42

The new SNMP functions need to be modified to work properly with ucd 4.2.3 (and maybe others.) My symptom was that it looked like it wasn't read my user defined MIBS. Your milage may vary.

I had to change all read_objid() calls to snmp_parse_oid().

My diffs are a mess othewise I would post them.

[email protected]
22-Apr-2002 06: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!!!

add a note about notes
previousswf_viewportsnmp_get_quick_printnext
Last updated: Tue, 09 Jul 2002
show source | credits | stats | mirror sites
Copyright © 2001, 2002 The PHP Group
All rights reserved.
This mirror generously provided by:
Last updated: Sat Aug 31 06:19:44 2002 CEST