Reputation: 1482
I'm looking for a Management Information Base (MIB) designed for web applications (Note: I'm working in PHP) that I can send multiple variables to my Network Management System via an SNMP Trap. Do I have to design one or is there a solution out there already?
More details:
Basically I want to send a trap to my Network Management System (Zenoss) whenever there is an error on my web application. I would like to call it in PHP like the following (note: this syntax might not be correct):
(Note: obviously, BOSSJONES-NOTIFICATION
does not exist; I'm just using it for this example. I'd like to replace it with the MIB I'm looking for, or the one that needs to be designed.)
<?php
const SNMPTRAP = '/usr/bin/snmptrap';
$host = 'zenoss.bossjones.com';
if ( some_random_error() ) {
exec( SNMPTRAP . ' -v 2c -c public -L e ' . $host .
' "" BOSSJONES-NOTIFICATION::snmpErrorNotification' .
' device s "192.168.1.121" errorType s "image upload fail"' .
' errorCode i 340 errorMessage s "Could not upload image at path' .
' /path/to/image/blah.gif" ' );
}
I understand that the MIB might not have the same parameters, of course, but I'm wondering if theres a general solution out there that I can either "make do with" or learn from, so that I can create my own that works for my purposes?
Also, is it possible to send a list of info (like an array) rather than just multiple strings via a trap?
Sorry for the long question. Wanted to provide as much details as possible.
(PS: Running on a Ubuntu 11.04 Linux box)
Upvotes: 2
Views: 640
Reputation: 20463
I wouldn't worry about a MIB at this point in your app, since what you're doing is lightweight and not public. A MIB is just a data structure/schema that tells the public who uses your SNMP product, what those Traps are, etc. If you're going to be using it only for yourself, I wouldn't worry about a MIB. I'd suggest just using the PHP SNMP module to kickoff any SNMP Traps you want to do with whatever OIDs aren't previously being used by you and then make sure that your network management software knows what those OIDs mean. When your NMS gets those SNMP traps with the OID varbinds, then you'll know what those variables are, etc. let me know how it goes.
For your second question, you can't send an array of traps at once. SNMP is so lightweight though, that this shouldn't matter for you. What I would do if you have an array of traps, is just do a foreach loop or something iterative, and just go through your array and send out the traps one at a time, where you give a unique OID for each trap so that your NMS knows what trap string is for what OID, so that it gets properly interpreted on the NMS side.
SNMP is a very wonderful protocol, but very esoteric. Be well.
Upvotes: 1