Hello,
I would like to use php with snmp functions, i'm trying for a long time to configure php with ucd-snmp but I always get the message undefined function snmpget().
I've tryed it on redhat 7.0 and suse 7.2. with many versions of php and apache with no success.
I don't know what else to do, i would appriciate any help.

    do you mean smtp? i've never heard of snmp, so just call me dumb.

      I did mean snmp. It is a network protocol. You can actually send a command to a device (i.e. o Hub or a Router) asking him to reply with informations on his status and other valueable data.
      Php has functions like snmpget(...) and snmpset(...) that enables you to send request to agent devices.
      But unfortunatly, I have found it very difficult to enable these functions.

        actually i do remember that from my network classes from my college days... something like simple network management protocol or something.

        anyways, i would assume that the functions are defaultly enabled, so check the php.ini first, and make sure it works on your operating system...

          a year later

          Hi!Let me reply this question. 🙂
          i am a man who seldom post on net.
          i alway search other's advices online. 🙂
          I am a system adminstrator from Chinese mainland.And i also like php programing.Becanuse the majority of my current work involves router and ethernet switch management,i do a little reserch about snmp.Yes,php announces it can support snmp,but in fact for a longe time i have the same problems like yours.I ever have downloaded lots of php module codes about snmp and compile them.But I alway got some kind of compile erro messeages.Sometime i got disappoited about php snmp functions.
          But i acutually have got one time to compile it successful!And it really works!
          i once summaried my expriences about snmp support compiling and once put it somewhere. i forget where i have put it 🙁
          May it is alread missing.
          I am not kinding.But i still belive compiling snmp codes into php is a big headache.It wastes lots of time before effective works!I don't think Comiling Codes is some kind of technology.Int fact PROGRAMMING requires real techonolgies after the programming envriroment is bulit by someome or yourself.Maybe this is the real reason that i cannot remember where my summary about snmp functions is!
          But i still can tell you a exciting news, Red hat LLINUX 7.3 have alread integrated snmp function support into php RMP packes!Now you can add the snmp suport in php simply by selecting the RPM packes during the system install procedure.It is simple!
          This is another reason i donnot care my compile summary longer.Red Hat have alread done it for us!
          Compling codes successfully requires no technologies,it is only some kind of knowlwege.Perphaps programming is a woke requires technologies.

          Of course i know rehat linux below verion 7.3 donnot support snmp module in php language.
          I am not a linux expert .But i am a linux paranea.i got my first linux version of Blue point production.But finally i have choosen redhat from it's 6.0 version product.For the reason like yours,i have bought 6.2,7.1,7.2 and burning 7.0 version just for some kind of new snmp feacures.To my disappoited, i found no snmp support in these products.But when the redhat 7.3 is issued,i downloaded it's ISO images from it's ftp server and bunring them.Then I have found new snmp modules int its php suite.

          Please look the following 🙂

          [root@liaoliang.com root]# rpm -qa|grep php
          php-4.1.2-7
          php-odbc-4.1.2-7
          asp2php-gtk-0.76.2-1
          php-imap-4.1.2-7
          php-pgsql-4.1.2-7
          php-mysql-4.1.2-7
          *php-snmp-4.1.2-7****
          asp2php-0.76.2-1
          php-ldap-4.1.2-7
          php-devel-4.1.2-7

          php-dbg-4.1.2-7

          if you really want to know how to compile snmp module into php. Maybe i can recall my exprience again for you or do some reach for you for my compile summary. 🙂

          Another simple solution is: Just use PHP system() or exec() functions to invoke UCD-snmp to support your snmp programming.
          For example,you can define a function like that.This will prevent you from snmp compile headache.
          function getSnmpValue($host,$string,$OID)

          {
          $myvalue=$exec("/usr/bin/snmpget $host $string $OID");
          .....
          return $myvalue
          }
          But i want to say just directly download redhat 7.3 and enjoy it!
          btw,i am a poor english language learner.i am sorry for any possible grammer and spelling mistakes,if there is bugs,please report it to liaoliang@371.net.
          Any kind of advices is appreciated. 🙂

            apache,mysql,php,ucd-snmp£¬phpMyadmin seamless integration under linux platform
            Written by liaoliang
            Prelude:This article is originted from liaoliang,you can copy/post it freely.
            But you must keep this article untouched including this preclude and the original grammer/spelling mistakes.

            I am system administrator from Chinese mainland.I love linux and php programming.Because my current
            work often involves router and ethernet switch manegement,i do a little reserch about snmp(simple network management protocol).I am not a linux expert,but i am linux paranoia.And i love the free
            feeling of linux platform.

            As a administrator,I actually do some php programming involveing snmp.And i actually think that compile snmp
            support into php enviroment may be a big headache.During you cnfigure and make procedure,you alway get some
            kind of compile error messages which may hurt your interst of snmp programing.Once upon a time,i surfed on net for more advices,but i seldom found anything that may be useful.

            This artcle was wrriten befor redhat linux 7.3 is issued.Before redhat linux 7.3 i onwed quite a few linux versions including redhat,blue point,turbo linux.To my disappoited i found no integrated snmp module of php lamguage in those production.Yes,I know redhat 7.3 integrates snmp packet into their php enviroment.In fact ,now,you can simply install a redhat 7.3 to support your snmp programming.I acknowlege i have installed 7.3 on my hardisk.

            But i will still think this article may help you.becuase when i surf on phpbuilder.com,i still see someone
            post some article titled "How to compile snmp...."I hope my exprience will do some help.

            But i still think the ability that you can compile other's code is just some knowlege,not technology.If you want to be an expert,you need some knowlege,and more and more technology.Maybe programming under an already bulit programming enviroment requires more technology,at least i think so.

            I am not a good english language leaner.Acutally i seldom post articles on net,especially in english.If you find this article is useful,please keep it untouched like its original look,including this preclude.
            If you have any questions/advices about this tutorial.Just email to me via liaoliang@371.net.
            (This preculude was written on 8,1,2002)
            apache,mysql,php,ucd-snmp£¬phpMyadmin seamless integration under linux platform
            written by liaoliang,first completed in chinese before rh 7.3 is issued.

            I donnot guarantee my expience is fit to you.If it cuases any damages,it is your problem,not mine. 🙂

            The following procedual is tested successfully on redhat linux 6.2 platform.

            We need the following source packes.(You can test other version of those packes,but i have not tested them. But i think it ususally will works .)

            apache_1.3.20.tar.gz

            mysql-3.23.40.tar.gz

            php-4.0.5.tar.gz

            phpadmin.tar.gz

            ucd-snmp-4.2.3.tar.gz

            Step 1
            Copy those packet into a directory, for example, /home/liang,the issue tar command to extract them.

            #cd /home/liang/

            tar xvzf apache_1.3.20.tar.gz

            tar xvzf mysql-3.23.40.tar.gz

            tar xvzf php-4.0.5.tar.gz

            tar xvzf ucd-snmp-4.2.3.tar.gz

            Step 2
            In this step,our target is installing Mysql database.We will install it into /usr/local/mysql directory.(Before you install it,this directory does not exist.)

            cd mysql-3.23.40

            #./configure --prefix=/usr/local/mysql

            #make

            #make install

            After you have done it,use the fowlling shell script to initiate your Mysql database,It will initiate
            system database like db, host, user, tables_priv, columns_priv

            /home/liang/mysql-3.23.40/scripts/mysql_install_db

            Then run MYSQL server like this:

            /usr/local/mysql/bin/safe_mysqld &

            /usr/local/mysql/bin/mysqladmin -u root password "new-password" ---It will define database access password.

            Use the following command to show dabase:

            /usr/local/mysql/bin/mysqlshow ¨Cp

            +---------------+

            | Databases |

            +---------------+

            | mysql |

            +---------------+

            /usr/local/mysql/bin/mysql -u root -p

            mysql> show databases;

            +----------------+

            | Database |

            +----------------+

            | mysql |

            | test |

            +----------------+

            If you have seen that,you MYSQL server is OK.

            Step 3
            Now we will install ucd-snmp packet.It's codes comes from Carnegie-maron university.Becuase PPH will invoke
            it's APIs to support its own snmp functions,we must install ucd-snmp before installing php packet.
            We first copy those packes to /usr/local/ucd-snmp.Then do the following procedure.

            cd /home/liang/ucd-snmp-4.2.3

            ./configure ¨Cprefix=/usr/local/ucd-snmp

            make

            make install

            This step is finished.

            Now our following target is compilling php into a apache module.Then install apache server.

            Step 4
            We must first configure apache,but not install it.We will install it later.

            cd apache_1.3.20

            ./configre

            (Notice😃o not do "make" and "make install" here.After the configuration of apache,we must install php first )

            Step5

            cd /home/liang/php-4.0.5

            ./configure --with-mysql=/usr/local/mysql --with-apache=../apache_1.3.20 \

            --with-snmp=/usr/local/ucd-snmp \

            --enable-track-vars

            Using --enable-track-vars option can enable php's ability to trace http enriroment variables.
            (i of course do some web programming,but i seldom trace a http vriables.You may give me some tips about tracing a
            http variable here. 🙂 )

            Using ¡ªwith-xxxxx option enable php's ability to know the information about other soft packes.
            Then make and make install it.
            #make

            #make install

            Copy ini php to lib directory.

            cp ./php.ini-dist /usr/local/lib/php.ini

            You can also edit php.ini file to costum your own favorite.For example,define max_execution_time option.
            Notice: php3 users copy the neccessary file to php3.ini not php.ini
            cp ./php.ini-dist /usr/local/lib/php3.ini

            Step 6
            This is the time to configure,make,make install apache server.

            cd /home/liang/apache_1.3.20

            ./configure --activate-module=src/modules/php4/libphp4.a \

            --enable-module=php4 \

            --prefix=/usr/local/apache

            #make

            #make install

            The edit usr/local/apache/conf/httpd.conf
            And for PHP 4.x, use:

            ---> AddType application/x-httpd-php .php
            ---> AddType application/x-httpd-php-source .phps

            Step 7

            Test apache server:

            cd /usr/local/apache/bin

            ./apachectl configtest

            Syntax OK

            ./apachectl start

            ./apachectl start: httpd started

            then define web index file
            #

            DirectoryIndex: Name of the file or files to use as a pre-written HTML

            directory index. Separate multiple entries with spaces.

            #

            <IfModule mod_dir.c>

            DirectoryIndex index.html index.htm index.shtml index.php index.php4 index.php3 index.cgi

            </IfModule>

            At last we use phpMyAdmin to be database's client side management platform.

            cp /home/liang/phpadmin.tar.gz

            cd /usr/local/apache/htdocs

            tar xvzf phpadmin.tar.gz

            edit /usr/local/apache/htdocs/phpMyAdmin/config.inc.php3

            $cfgServers[1]['password'] = 'password of MYSQL'

            It will be ok.
            ---this is the end of this article--------

              Write a Reply...