Instalación y compilación del modulo de NET-SNMP de PHP para Apache

Page last edited hace 2148 días 22 horas
De Solaris-ES
Saltar a: navegación, buscar

Nota: Si se compila el PHP con la opcion --with-snmp genera un error. Por este motivo se compilara el modulo por separado del PHP.

Pre-requisitos: netsnmp 5.7 y openssl 1.0.0g
# cd /.../php-5.3.9/ext/snmp/
# phpize --clean && phpize
# ./configure --with-snmp=/usr/local
# /usr/local/bin/make
# /usr/local/bin/make install
# l /usr/local/php/lib/php/extensions/no-debug-non-zts-20090626/snmp.so
# vi /usr/local/php/lib/php.ini 
  extension=snmp.so
  • Configurar el envitonment de Apache
# vi /usr/local/apache2/bin/envvars
MIBS=
LD_LIBRARY_PATH=/usr/local/lib:/usr/local/ssl/lib:/usr/lib:/usr/openwin/lib:/opt/mysql/mysql/lib:/usr/local/lib:/usr/sfw/lib/:
PATH=/usr/sbin:/usr/bin:/usr/ccs/bin:/usr/openwin/bin:/usr/dt/bin:/usr/local/bin:/usr/local/sbin:
/usr/local/php/bin:/usr/local/mysql/bin:/usr/local/mysql/sbin:/var/adm/sun/sbin:/var/adm/sun/bin:/usr/sfw/bin:
/usr/sfw/sbin:/usr/local/rrdtool-1.2.19/bin:/opt/SUNWswasr/bin::/usr/platform/i86pc/sbin:/opt/sun/bin:/usr/bin/nsr:
/usr/sbin/nsr:/opt/SUNWexplo/bin:/opt/SUNWsneep/bin

export LD_LIBRARY_PATH PATH MIBS
Nota: Muy importante definir la variable de entorno MIBS= en NULO porque sino el net-snmp del sunfreeware genera 
      errores del tipo:

MIB search path: $HOME/.snmp/mibs:/usr/local/share/snmp/mibs
Cannot find module (SNMPv2-TC): At line 15 in /usr/local/share/snmp/mibs/UCD-DISKIO-MIB.txt
Cannot find module (SNMPv2-SMI): At line 34 in /usr/local/share/snmp/mibs/UCD-SNMP-MIB.txt
Cannot find module (UCD-SNMP-MIB): At line 17 in /usr/local/share/snmp/mibs/UCD-DISKIO-MIB.txt
Cannot find module (UCD-DISKIO-MIB): At line 0 in (none)
Cannot find module (SNMP-FRAMEWORK-MIB): At line 11 in /usr/local/share/snmp/mibs/MTA-MIB.txt
Cannot find module (NETWORK-SERVICES-MIB): At line 13 in /usr/local/share/snmp/mibs/MTA-MIB.txt
Cannot find module (MTA-MIB): At line 0 in (none)
Cannot find module (SNMPv2-MIB): At line 0 in (none)
Cannot find module (IANAifType-MIB): At line 13 in /usr/local/share/snmp/mibs/IF-MIB.txt
Cannot find module (IF-MIB): At line 0 in (none)
Cannot find module (INET-ADDRESS-MIB): At line 15 in /usr/local/share/snmp/mibs/IP-MIB.txt
Cannot find module (IP-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 (NOTIFICATION-LOG-MIB): At line 0 in (none)
Cannot find module (SNMP-TARGET-MIB): At line 14 in /usr/local/share/snmp/mibs/DISMAN-EVENT-MIB.txt
Cannot find module (DISMAN-EVENT-MIB): At line 0 in (none)
Cannot find module (DISMAN-SCHEDULE-MIB): At line 0 in (none)
Cannot find module (UCD-DEMO-MIB): At line 0 in (none)
Cannot find module (NET-SNMP-MIB): At line 12 in /usr/local/share/snmp/mibs/NET-SNMP-AGENT-MIB.txt
Cannot find module (NET-SNMP-AGENT-MIB): At line 0 in (none)
Cannot find module (HOST-RESOURCES-TYPES): 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-VIEW-BASED-ACM-MIB): At line 0 in (none)
Cannot find module (SNMP-COMMUNITY-MIB): At line 0 in (none)
Cannot find module (NET-SNMP-EXAMPLES-MIB): At line 11 in /usr/local/share/snmp/mibs/NET-SNMP-PASS-MIB.txt
Cannot find module (NET-SNMP-PASS-MIB): At line 0 in (none)
Cannot find module (NET-SNMP-EXTEND-MIB): At line 0 in (none)
Cannot find module (UCD-DLMOD-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)
Cannot find module (NET-SNMP-VACM-MIB): At line 0 in (none)
  • Configurar la misma variable a nivel de Solaris
# vi /etc/profile
MIBS=
export MIBS
  • Reiniciar Apache y comprobar si la extensión de SNMP esta activa
# svcs -a
# svcadm disable apache2
# svcadm enable apache2
# php -i |grep -i snmp
NET-SNMP Support => enabled
NET-SNMP Version => 5.7
MIBDIRS => /usr/local/share/snmp/mibs