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.
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.