Forum Moderators: coopster

Message Too Old, No Replies

PHP snmp functions

How do they work?

         

kronoss

2:47 pm on Jan 5, 2005 (gmt 0)

10+ Year Member



Hi guys, I've been writing a small web app that'll be used to manage some routers and switches through SNMP. I know that PHP has integrated SNMP functions (snmpget, snmpset, snmpwalk...), and I know that they're working, but when I use my own OIDs or an MIB I downloaded for a type of router, it gives me:

"Warning: snmpget() [function.snmpget]: Error in packet: (noSuchName) There is no such variable name in this MIB. in C:\SNMP\index.php on line 15"

I have no idea why since it's working fine with the default MIBs. Anyone care to help? Thanks!

jatar_k

11:11 pm on Jan 5, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld kronoss,

honestly, no clue. Have you looked around to see if there is something similar to see how they did it?

kronoss

11:39 pm on Jan 5, 2005 (gmt 0)

10+ Year Member



Yes, I've looked around, and there's nothing at all. SNMP in general is badly documented, IMHO. The only thing I've found (which would've served my purpose perfectly) is a company that sells an ODBC for SNMP, which makes it a joke to use, but it costs something like 3000$.

So no, nothing around to really help me utilize those functions.

jatar_k

11:41 pm on Jan 5, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



I asked the sysadmin here and he just said you're in a spot of trouble.

sorry I can't help more, there just really isn't anything much out there and I have never had any grand desire to do anything similar. ;)

>> SNMP in general is badly documented, IMHO

yup

kronoss

11:59 pm on Jan 5, 2005 (gmt 0)

10+ Year Member



OK... well thanks anyway for asking around :)

phdokc

4:31 am on Jan 14, 2005 (gmt 0)



kronoss

I'm guessing that you have net-snmp or ucd-snmp installed so I won't go there. Your problem is more than likely you have a call something like this

$snmp = snmpwalk('$hostname','$community','textmibvalue');

Try something like this and see if it works.

$snmp = snmpwalk('$hostname','$community','1.3.6.1.#*$!');
using the dotted notation ASN.1 value of the mib.

If the dotted notation works you will need to add the 'textmibvalue' to net-snmp / ucd-snmp using snmptranslate, otherwise you will get the results you stated above. To add mibs to net-snmp check the net-snmp site but it goes something like this off the top of my head.

Add the mib to net-snmp with this command
echo "mibs +SNMP-MIB-NAME" >> /pathtonet-snmp/snmp/snmp.conf

Then add the entity to net-snmp with this command

snmptranslate -m +SNMP-MIB-NAME -IR snmpEntityName

Here is a real life senario.
echo "mibs +CISCO-STACK-MIB" >> /usr/local/share/snmp/snmp.conf

then

snmptranslate -m +CISCO-STACK-MIB -IR portOperStatus

Hope this helps.

phdokc