Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: RFC: Who wants to design a better SNMP API?

by Hercynium (Hermit)
on Nov 29, 2007 at 16:54 UTC ( #653906=note: print w/ replies, xml ) Need Help??


in reply to RFC: Who wants to design a better SNMP API?

Here's a pseudo-SQL-style example for the second one:

SELECT adMX2820M13PrvSlotTable.adMX2820M13NetFuncServState.value FROM adMX2820M13PrvSlotTable WHERE adMX2820M13PrvSlotTable.adMX2820M13NetFuncServState.index_val[ +0] IN ( SELECT adGenPortSlotMapTable.adGenSlotAddress.index_val[0] FROM adGenPortSlotMapTable WHERE adGenPortSlotMapTable.adGenSlotAddress.value IN ( SELECT adMX2820M13StatDS3Table.adMX2820M13PrvCardPairID.index_ +val[0] FROM adMX2820M13StatDS3Table WHERE adMX2820M13StatDS3Table.adMX2820M13PrvCardPairID.value + !~ /not in use/i AND adMX2820M13StatDS3Table.adMX2820M13PrvCardPairID.value ! += '' ) )
This query string could be parsed and 'compiled' into a set of SNMP queries and then a set of lookup operations on the SNMP query results to return the specific data being requested.

So, the SNMP queries generated by parsing this would probably be something like this:
my $snmp1 = $sess->gettable( adMX2820M13StatDS3Table, columns => ['adMX2820M13PrvCardPairID',], ); my $snmp2 = $sess->gettable( adGenPortSlotMapTable, columns => ['adGenSlotAddress',], ); my $snmp3 = $sess->gettable( adMX2820M13PrvSlotTable, columns => ['adMX2820M13NetFuncServState',], ); # Code to correlate indices and values and such... # I could do this in larger, combined steps, or in a more # functional fashion, but I want this code to be as clear # and linear as possible # Inner-most sub-select: my $res1 = match_by_value( $snmp1, sub { $_ !~ /not in use/i } ); my $res2 = match_by_value( $snmp1, sub { $_ != '' } ); my $res3 = and( $res1, $res2 ); my $res4 = extract_index_val( 0, $res3 ); # Next sub-select: my $res5 = match_by_value( $snmp2, sub { $_ in( @$res4 ) } ); my $res6 = extract_index_val( 0, $res5 ); # Main select: my $res7 = match_by_value( $snmp3, sub { $_ in( @$res6 ) } ); my $res8 = extract_value( $res7 ); my $result = $res8
Somehow, it didn't come out as clear as I had hoped.


Comment on Re: RFC: Who wants to design a better SNMP API?
Select or Download Code
I'm no good at obfu... or am I?
by Anonymous Monk on Nov 29, 2007 at 17:23 UTC
    Posting anonymously so people don't think I'm begging for XP

    Just for fun, Here's what the above code would look like if I eliminated all the temporary variables...
    my $snmp1 = $sess->gettable( adMX2820M13StatDS3Table, columns => ['adMX2820M13PrvCardPairID',], ); my $snmp2 = $sess->gettable( adGenPortSlotMapTable, columns => ['adGenSlotAddress',], ); my $snmp3 = $sess->gettable( adMX2820M13PrvSlotTable, columns => ['adMX2820M13NetFuncServState',], ); # wheeeeee! my $result = extract_value( match_by_value( $snmp3, sub { $_ in( extract_index_val( 0, match_by_value( $snmp2, sub { $_ in( extract_index_val( 0, and( match_by_value( $snmp1, sub { $_ !~ /not in use/i } ), match_by_value( $snmp1, sub { $_ != '' } ) ) ) ) } ) ) ) } ) );

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://653906]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (8)
As of 2014-12-22 18:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (126 votes), past polls