Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Compiling PHP with SNMP - SNMP sanity check failed

Options
  • 30-03-2010 2:50pm
    #1
    Registered Users Posts: 1,127 ✭✭✭


    Hi,

    Iv been trying to compile php with snmp support for the past week and its driving me nuts.

    I am on a linux machine and after seeing some guides around I installed net-snmp, open-ssl, apache with no problems and now when i go to try and compile php with snmp, i get snmp sanity check failed error.

    Here is my configure script for php:
    cd /usr/local/src/php-5.3.2/
    
    ./configure --prefix=/usr/local/php --with-snmp=/usr/local/include/net-snmp --with-apxs2=/usr/local/apache2/bin/apxs --with-openssl=/usr/local/ssl --enable-ucd-snmp-hack  
    
    
    

    Can anyone help me on this one? Im already after spending too much time on it but I need it working for my college FYP. Any help much appreciated.

    Thanks


Comments

  • Registered Users Posts: 6,762 ✭✭✭WizZard


    What flavour of Linux? Can you post the error message?


  • Registered Users Posts: 1,127 ✭✭✭mossy464


    Using openSuse 11.1

    Here is the final few lines showing the error.
    checking for SNMP support... yes
    checking OpenSSL dir for SNMP... no
    checking whether to enable UCD SNMP hack... yes
    checking for default_store.h... no
    
    checking for kstat_read in -lkstat... no
    checking for snmp_parse_oid in -lsnmp... no
    checking for init_snmp in -lsnmp... no
    configure: error: SNMP sanity check failed. Please check config.log for more information.
    


  • Registered Users Posts: 6,762 ✭✭✭WizZard


    And what does config.log show???


  • Registered Users Posts: 6,762 ✭✭✭WizZard


    Is there any reason you want to compile yourself as opposed to using pre-built packages for OpenSUSE? e.g. php5-snmp


  • Registered Users Posts: 1,127 ✭✭✭mossy464


    Config.log shows:
    configure:82107: checking for SNMP support
    configure:82154: checking OpenSSL dir for SNMP
    configure:82180: checking whether to enable UCD SNMP hack
    configure:82409: checking for default_store.h
    configure:82419: gcc -E -I/usr/local/include/net-snmp/include conftest.c >/dev/null 2>conftest.out
    configure:82415:27: error: default_store.h: No such file or directory
    

    And further down the file.
    configure:83464: checking for snmp_parse_oid in -lsnmp
    configure:83483: gcc -o conftest -I/usr/include -g -O2 -fvisibility=hidden  -L/usr/lib  -Wl,-rpath,/usr/local/ssl/lib -L/usr/local/ssl/lib -Wl,-rpath,/usr/local/include/net-snmp/lib -L/usr/local/include/net-snmp/lib conftest.c -lsnmp  -lsnmp -lrt -lssl -lcrypto -lrt -lm -ldl -lnsl  -lxml2 -lz -lm -lxml2 -lz -lm -lxml2 -lz -lm 1>&5
    /usr/lib/gcc/i586-suse-linux/4.3/../../../../i586-suse-linux/bin/ld: cannot find -lsnmp
    collect2: ld returned 1 exit status
    configure: failed program was:
    #line 83472 "configure"
    #include "confdefs.h"
    /* Override any gcc2 internal prototype to avoid an error.  */
    /* We use char because int might match the return type of a gcc2
        builtin and then its argument prototype would still apply.  */
    char snmp_parse_oid();
    
    int main() {
    snmp_parse_oid()
    ; return 0; }
    configure:83617: checking for init_snmp in -lsnmp
    configure:83636: gcc -o conftest -I/usr/include -g -O2 -fvisibility=hidden  -L/usr/lib  -Wl,-rpath,/usr/local/ssl/lib -L/usr/local/ssl/lib -Wl,-rpath,/usr/local/include/net-snmp/lib -L/usr/local/include/net-snmp/lib conftest.c -lsnmp  -lsnmp -lrt -lssl -lcrypto -lrt -lm -ldl -lnsl  -lxml2 -lz -lm -lxml2 -lz -lm -lxml2 -lz -lm 1>&5
    /usr/lib/gcc/i586-suse-linux/4.3/../../../../i586-suse-linux/bin/ld: cannot find -lsnmp
    collect2: ld returned 1 exit status
    configure: failed program was:
    #line 83625 "configure"
    #include "confdefs.h"
    /* Override any gcc2 internal prototype to avoid an error.  */
    /* We use char because int might match the return type of a gcc2
        builtin and then its argument prototype would still apply.  */
    char init_snmp();
    
    int main() {
    init_snmp()
    ; return 0; }
    
    


  • Advertisement
  • Registered Users Posts: 6,762 ✭✭✭WizZard


    Have you installed the devel (headers) for net-snmp? I'm not familiar with OpenSUSE so not sure what it's called. It's often/usually net-snmp-devel


  • Registered Users Posts: 1,127 ✭✭✭mossy464


    That could be it. I'll check there. Thanks


  • Registered Users Posts: 1,127 ✭✭✭mossy464


    It turns out i didnt have the devel headers installed for net-snmp. I installed them and the configure worked but then when i did a make I got a series of errors. See below. There was more besides these. Just giving u the last few
    /usr/local/src/php-5.3.2/ext/snmp/snmp.c:1179: error: ‘SNMP_DEFAULT_TIMEOUT’ undeclared (first use in this function)
    /usr/local/src/php-5.3.2/ext/snmp/snmp.c:1180: error: ‘SNMP_DEFAULT_RETRIES’ undeclared (first use in this function)
    /usr/local/src/php-5.3.2/ext/snmp/snmp.c:1184: error: ‘MAX_NAME_LEN’ undeclared (first use in this function)
    /usr/local/src/php-5.3.2/ext/snmp/snmp.c:1208: error: ‘SNMP_VERSION_3’ undeclared (first use in this function)
    make: *** [ext/snmp/snmp.lo] Error 1
    
    


  • Registered Users Posts: 6,762 ✭✭✭WizZard


    You'll also need snmp-libs and snmp-devel.

    Again, is there a specific reason you want to compile yourself vs using pre-built packages for your OS?


  • Registered Users Posts: 1,127 ✭✭✭mossy464


    Well I was told that net-snmp would be the best to use. I'll check if I have the snmp-libs and snmp-devel and try that.

    If all comes to all I will just install the php-snmp module


  • Advertisement
  • Registered Users Posts: 6,762 ✭✭✭WizZard


    Do you have net-snmp-libs installed? Are you sure it's in /usr/local/include/net-snmp ?


  • Registered Users Posts: 1,127 ✭✭✭mossy464


    Yes, I have net-snmp-libs installed as far as i know. In the software manager i have installed every available net-snmp component. There isnt one called net-snmp-libs but one called libsnmp15 and its described as shared libraries from net-snmp.

    As far as /usr/local/include/net-snmp is concerned im not sure about this, i just put this in as this is the dir where there are a lot of net-snmp header files and stuff.


  • Registered Users Posts: 1,127 ✭✭✭mossy464


    Ok iv given up on using net-snmp but now having problems with php5-snmp.

    I have installed the lamp package and the php5-snmp module using the package manager in opensuse then in the htdocs folder for apache i put in a little php script i wrote with snmp commands in it and i named it index.php but its just giving me a blank page .


  • Registered Users Posts: 6,762 ✭✭✭WizZard


    What's appearing in the PHP logs (error_log)?
    Is snmp appearing in phpinfo()?


  • Registered Users Posts: 1,127 ✭✭✭mossy464


    WizZard wrote: »
    What's appearing in the PHP logs (error_log)?
    Is snmp appearing in phpinfo()?

    Iv removed it again. Im starting from scratch installing everything.

    Any way you can guide me through it please? I must be making a mistake somewhere.

    Its so frustrating, the amount of time iv been trying to sort this out.

    Iv moved onto my ubuntu virtual machine now.


  • Registered Users Posts: 6,762 ✭✭✭WizZard


    Follow this guide to install LAMP on Ubuntu https://help.ubuntu.com/community/ApacheMySQLPHP

    Also install the php5-snmp package.

    That should work ok (assuming your Ubuntu install is clean)


  • Registered Users Posts: 1,127 ✭✭✭mossy464


    Cheers, i'll try this. So follow the lamp install guide.

    Then install php5-snmp through synaptic package manager?


  • Registered Users Posts: 6,762 ✭✭✭WizZard


    Yes. The guide will give you a fully working LAMP install (assuming you need the M[ySQL] also), and then
    sudo apt-get install php5-snmp
    
    will install the snmp module for PHP.

    Verify it's installed correctly by checking phpinfo - create a new file in your web-root with the following content:
    <?
    phpinfo();
    ?>
    
    Save as phpinfo.php and navigate to http://localhost/phpinfo.php to view it. You should see an snmp section like in the attached (partial) screenshot.


  • Registered Users Posts: 1,127 ✭✭✭mossy464


    WizZard wrote: »
    Yes. The guide will give you a fully working LAMP install (assuming you need the M[ySQL] also), and then
    sudo apt-get install php5-snmp
    
    will install the snmp module for PHP.

    Verify it's installed correctly by checking phpinfo - create a new file in your web-root with the following content:
    <?
    phpinfo();
    ?>
    
    Save as phpinfo.php and navigate to http://localhost/phpinfo.php to view it. You should see an snmp section like in the attached (partial) screenshot.

    Thank you very much for this. I will post how i get on


  • Registered Users Posts: 1,127 ✭✭✭mossy464


    Thank you so much. Its working. Finally.

    Many thanks for your help and patience wizZard.


  • Advertisement
  • Registered Users Posts: 6,762 ✭✭✭WizZard


    You're welcome. Glad to be of some help.


Advertisement