Adding MIBs to PHP

Post general support questions here that do not specifically fall into the Linux or Windows categories.

Moderators: Moderators, Developers

Post Reply
Author
Message
Tybio
Cacti User
Posts: 79
Joined: Thu Feb 16, 2006 8:14 am

Adding MIBs to PHP

#1 Post by Tybio » Wed Jan 30, 2008 8:48 am

Greetings all,

Due to limitations on Juniper routers, some OIDs /require/ the mib to be loaded before they will be processed properly. I have been forced to modify snmp.php to only use the binary snmp utilitys and add the -m option in order to get these working.

As I use spine to poll, I'm not amazingly worried about this, however...it will impact the ability to update Cacti. I was wondering if there was anywhere to modify the php $_ENV['MIBS'] variable so the small subest of people who do need external mibs could get them loaded?

If not, is there an option in the Settings to disable php SNMP?

I've looked for both of these things and can't find ether...forgive me if I missed the obvious.

User avatar
gandalf
Developer
Posts: 22375
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

#2 Post by gandalf » Wed Jan 30, 2008 11:27 am

Disabling php-snmp is done by uninstalling it. There's currently no configuration option for this, unless you consider changing the code.
I'm quite wondering about this, though. Enabling a MIB on the poller machine is only enabling kind of a "OID to text translation", that's all. I do not understand why this should have an effect on the ability of the polled target to answer such requests. And spine definitively does not use MIBs in any way.
You may ask user "Vlad" for his experience. He was joining our CCC.eu meetings and thus I know he's working on juniper devices as well
Reinhard

Tybio
Cacti User
Posts: 79
Joined: Thu Feb 16, 2006 8:14 am

#3 Post by Tybio » Wed Jan 30, 2008 12:04 pm

I'll explain then, as I've been fighting with this forever:

Juniper uses their enterprise MPLS MIB to turn hex returns into "Names". The output of an OID in the index I am using for my query:

Test1: snmpwalk -v2c -c <STRING> router1.isp enterprise
Result1: SNMPv2-SMI::enterprises.2636.3.2.3.1.1.109.112.114.49.46.100.99.97.50.46.117.115.45.116.111.45.99.114.49.46.108.103.97.50.46.117.115.0.0.0.0.0 = Hex-STRING: 6D 70 72 31 2E 64 63 61 32 2E 75 73 2D 74 6F 2D

Test2: snmpwalk -m ALL -v2c -c <STRING> router1.isp enterprise
Result2: MPLS-MIB::mplsLspName.'router1.isp-to-router2.isp.....' = STRING: router1.isp-to-router2.isp

So yes, spine works fine...as it is only passed the OID that is pulled out of that by the regex in the xml file. However, getting a list of LSPs named "6D 70 72 31 2E 64 63 61 32 2E 75 73 2D 74 6F 2D" in the output of the data query is just unusable. Not to mention that there is no way for the user to associate the final graph with the actual item being graphed. In a network with ~90 routers and a N*(N-1) build of LSPs...not being able to identify them means that there is no use to the graphs.

Therefor, I need the mib imported when doing a reindex, or first adding a the query to a router...however, spine is passed the OIDs and functions just perfectly.

My answer at this point is to modify snmp.php:
$temp_array = exec_into_array($path_snmpbulkwalk . " -O Qn $snmp_auth -v $version -t $timeout -r $retries -Cr50 $hostname:$port $oid");

To:

$temp_array = exec_into_array($path_snmpbulkwalk . " -m ALL -O Qn $snmp_auth -v $version -t $timeout -r $retries -Cr50 $hostname:$port $oid");

And:


function snmp_get_method($version = 1) {
if ((function_exists("snmpget")) && ($version == 1)) {
....

To:


function snmp_get_method($version = 1) {
return SNMP_METHOD_BINARY;
if ((function_exists("snmpget")) && ($version == 1)) {
....

This bypasses php_snmp and loads the MIBs...as I am using spine to poll, it does not impact performance unless I am adding a new router or reindexing existing routers.

However, there has to be a better answer.

User avatar
gandalf
Developer
Posts: 22375
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

#4 Post by gandalf » Wed Jan 30, 2008 12:15 pm

Tybio wrote:Therefor, I need the mib imported when doing a reindex, or first adding a the query to a router...however, spine is passed the OIDs and functions just perfectly.
Ah, that's very resonable. You want this to be done for re-indexing only. Well, loading MIBs as a default is a performance issue as you've already well recognized ...
I will have to dig into snmp output options to hopefully find some solution to this. This will at least have to wait 'til weekend, though.
Reinhard

Post Reply