8

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.

Ilmari Karonen
  • 49,047
  • 9
  • 93
  • 153
rogeriopvl
  • 51,659
  • 8
  • 55
  • 58
  • Are you trying to have your PHP process listen for SNMP object-get requests, or are you trying to have it send out SNMP traps? – derobert Sep 08 '09 at 21:16
  • Actually I'm trying to set values and send traps. For instance I would like to take the execution time of the requested page and set it in a SNMP OID, and send the trap. Then the network manager app would get the trap and be aware that a page request was made and it took n seconds to load. – rogeriopvl Sep 08 '09 at 21:25

3 Answers3

4

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.

1

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
  • 10,607
  • 1
  • 36
  • 64
  • 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 Sep 08 '09 at 21:19
0

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
  • 746
  • 12
  • 34
  • PHP has socket functions, so it can be used to listen for SNMP requests by creating a UDP socket with socket_create. – derobert Sep 08 '09 at 21:16
  • 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 Sep 10 '09 at 07:33