Forum Discussion

gerald_wegener_'s avatar
gerald_wegener_
Icon for Nimbostratus rankNimbostratus
Aug 23, 2006

Method for reading variables needed

 

I looking for a way to read varibles (integers) into an iRule. The variables must be able to be modified on the fly via the command line. So far the best I can come up with is to use data group lists defined as integers for each variable. Each DGL has a single integer entry in it (e.g. 5). I can modify these on the fly via the command line using the bigpipe command.

 

 

My question is if a DGList has a single integet in it can it be read directly into a variable? For example if I have a DGList named "percent" with a single value of integer 5 in it is there someway I can read that into a variable e.g.

 

 

set a [matchclass::percent] (so I get the value of a = 5)

 

 

 

How can I do this? Can I use DGLists or is the a better/simplier way to do it?

 

 

Thank you.

5 Replies

  • Data Groups can be treated as TCL lists, so you can use all of the TCL list commands to extract values from them. If you have a data group and you want to extract the first element, you can use the lindex command:

    set a [lindex $::percent 0]

    This will extract the 1st element (zero based) from the data group named "percent".

    Hope this helps...

    -Joe
  • unRuleY_95363's avatar
    unRuleY_95363
    Historic F5 Account
    If the list only has one element, you don't even need to use lindex. In that case, you can just use $::percent

     

     

    However, be careful, there have been bugs with accessing datagroups as lists, so depending on your version you may have some ill-effects.
  • Thanks for the heads up.

     

     

    If there are potenial bugs using data groups as lists is there a better way for me to store and be able to read in an integer values which be chanaged on the fly? Thats why I tried using data groups since they can be easily changed via the command line (b class name value) and are immediatey updated in the iRule.

     

     

    Note that I would not be implementing this for a while and it would be implemented on at that time on the lastest stable code version. Is the bug associated with using data groups as list only in prior versions?
  • That's probably your best bet at this point. We are working at alternate ways to query external data but at this point data groups are your only option (outside of internal rule data).

     

     

    -Joe
  • unRuleY_95363's avatar
    unRuleY_95363
    Historic F5 Account
    I can't think of a better way at the moment...

     

     

    And Yes, I would hope all the bugs have been worked out in the latest stable release... he he he... famous last words... for a software developer...