tags:

views:

712

answers:

3

Hi,

I'm trying to make a PHP website send information through SNMP. I've been reading allot about SNMP, but I'm still a bit clueless about where to start.

I believe I need to create an MIB with all the OIDs my website will use to send the info. Is this correct? How and where can I define those variables (OIDs)? Can someone point me in the right direction?

I'm using FreeBSD on the server.

Thanks in advance.

A: 

What i know is that SNMP is a protocol where an host send request for value of a particular OID to a device and then receive a response.

I'm not sure you can have a php website that answer to this packets.

The only information I have found is that PHP have an SNMP client class PHP SNMP

And wikipedia gives you detailed info about SNMP link text

But I'm still sure that a website can't act as an SNMP server.

Mauro Destro
PHP has socket functions, so it can be used to listen for SNMP requests by creating a UDP socket with socket_create.
derobert
I know that PHP has socket functions ... but a "website" as asked in the question cannot create a wait loop to receive UDP packet.. If the question was about a php program that runs in a box .. ok!
Mauro Destro
+1  A: 

There are a couple of issues:

  • To get your own top level identifier I think you actually have to request it somewhere (and probably pay money?) however there is an experimental range that you can use to test. (this is not a php issue, it is an snmp issue/feature)

  • As far as I know the protocol assumes a process to listen on a port that is totally different from the http port, and also not using TCP but UDP. Just creating a php page the usual way is not going to work.

A possible solution might be to use a snmp module in apache (or whatever webserver you are using) that allows you to program the response logic in php. My feeling is that most of the snmp php stuff that you encounter on the web is not about the agent part but about the manager part.

Simon Groenewolt
Yes, I'm already using the snmp module on Apache. I just need to be able to write an OID value everytime a page is requested. But for this I believe I have to create "the structure" in MIB.
rogeriopvl
+4  A: 

What you are trying to do is send an "SNMP trap". You don't need to define a MIB necessarily. A MIB just translates a "semi human friendly" name into an OID, such as SNMPv2-MIB::sysContact.0 into .1.3.6.1.2.1.1.4.0 . For a private application, you could theoretically use any OID you want, just as you could theoretically use any IP address you want for a private network that's not connected to others. I am not sure if there is a preferred "private" OID branch. There is some good info to get you started at http://www.paessler.com/support/kb/questions/49/ . It looks like PHP does not directly support sending SNMP traps though, but you could invoke the "snmptrap" command.

Your answer gave me valuable info to get on the right path. Thanks.
rogeriopvl