Evening.. I ended up writing a MySQL function today to help with this..
This works for me since all the points found in MIBs (via mibble) I put
into a DB. Here's how I use the function.. Just posting it here in case
anyone else is looking to sort by OIDs
Example usage
============================
SELECT oid_value from table_of_mibs order by OID_PAD(oid_value);
OID_PAD FUNCTION
============================
DROP FUNCTION IF EXISTS OID_PAD;
DELIMITER $$
CREATE FUNCTION OID_PAD(oid TEXT)
RETURNS TEXT
BEGIN
DECLARE result TEXT;
DECLARE segment VARCHAR(50);
DECLARE oid_segments INT;
DECLARE processed INT;
#run this in mysql console before debugging is possible
#create table log ( id int AUTO_INCREMENT, timestamp int default 0 ,
name varchar(64), value varchar(255), key(id));
SET oid_segments = (LENGTH(oid) - LENGTH(REPLACE(oid, '.', ''))) +1;
SET processed = 0;
SET result = "";
oid_loop: LOOP
SET processed = processed + 1;
SET segment =
SUBSTRING_INDEX(SUBSTRING_INDEX(oid,'.',processed),'.',-1);
IF LENGTH(segment) < 3 THEN SET segment = LPAD(segment,3,"0");
END IF;
SET result = CONCAT(result,segment);
#insert into log(timestamp,name,value)
values(UNIX_TIMESTAMP(),"LOOP DEBUG",CONCAT(segment,':',processed));
IF processed = oid_segments THEN LEAVE oid_loop;
END IF;
END LOOP;
RETURN result;
END;
$$
DELIMITER ;
=======================
END FUNCTION
-Matthew
On 1/28/2014 12:16 PM, Per Cederberg wrote:
Try version 2.10.alpha2 (found at
http://www.mibble.org/download/development/index.html).
Let me know if there are any issues with the fix. Didn't have time to
run it through proper testing, but at least it compiled... ;-)
Cheers,
/Per
On Tue, Jan 28, 2014 at 5:40 PM, Matthew Walker
<[email protected] <mailto:[email protected]>> wrote:
Great to hear..
Although the problem I'm having is OID sorting in general.. I use
mibble to parse a MIB and the resulting points are stored in a DB.
Using that DB, I will occasionally add 'children' to the MIB
resulting in new OIDs which I need to bring back to the user in
order (numerically).
I was hoping that Mibble would have a utility that receives, say,
an Array of OIDs and returns an Array with each OID sorted
numerically. If Mibble doesn't have this - then my search
continues and I may have to build that sorting algorithm myself.
If I do, I'd be happy to contribute to the source.
Mysql addresses the sorting of IPV4 addresses with the INET_ATON
function:
*| INET_ATON('10.0.5.9') is evaluated as|*10×256^3 + 0×256^2 + 5×256
+ 9
which is fine with there are only 4 segments to employ this logic
towards.. Obviously the problem with OIDs is that there can an
unlimited number of segments (certainly more than 4) so this sort
of logic would quickly create numbers that exceed any of Java's
datatypes
-Matthew
On 1/28/2014 11:00 AM, Per Cederberg wrote:
Matthew,
It seems you encountered a bug (or misfeature). Now added to GitHub:
https://github.com/cederberg/mibble/issues/13
I'll try to push a fix up to 2.10.alpha2 in a few hours.
Cheers,
/Per
On Tue, Jan 28, 2014 at 3:15 PM, Matthew Walker
<[email protected] <mailto:[email protected]>> wrote:
Surely this comes up often and I apologize for not finding
other refernces.. but I'm stumped here.
Does mibble contain a utility for the numeric sorting of SNMP
ObjectIdentifiers, (OIDs)?
Current sorting (since OIDs are treated as Strings) results
in inaccuracies like this:
| 1.3.6.1.2.1.33.1.9.1.0 |
| 1.3.6.1.2.1.33.1.9.10.0 |
| 1.3.6.1.2.1.33.1.9.2.0 |
Much thanks.
-Matthew
_______________________________________________
Mibble-users mailing list
[email protected] <mailto:[email protected]>
https://lists.nongnu.org/mailman/listinfo/mibble-users
_______________________________________________
Mibble-users mailing list
[email protected] <mailto:[email protected]>
https://lists.nongnu.org/mailman/listinfo/mibble-users
_______________________________________________
Mibble-users mailing list
[email protected] <mailto:[email protected]>
https://lists.nongnu.org/mailman/listinfo/mibble-users
_______________________________________________
Mibble-users mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/mibble-users
_______________________________________________
Mibble-users mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/mibble-users