Search code examples
phpsnmpflot

how to read SNMP for bandwidth using php


I would like to get data using SNMP from a router. The data shall be used for a graph I guess using the jquery flot.

But my issue is I do not know how to get my webpage to read the data using SNMP from the router.

I normally use MRTG but I would like to learn how to handcode it if possible.

BR. Anders


Solution

  • Use phpinfo() to check if your server's PHP binary was built with SNMP support. If so, you can do this:

    <?php
    
    $snmp_values = snmpwalk("10.0.0.1", "public", null);
    
    print_r($snmp_values);
    

    Where "10.0.0.1" is your router's IP; this will give you the SNMP values returned by your router (different routers return different data), and you can write a script to process that data.