Skip to main content

Under the command type F5_LTM_POOL_STATE for F5 devices, the pool and pool members are in the following format:

---------------------------------------------------------------------------------------
Ltm::Pool: XXX
---------------------------------------------------------------------------------------
Status
Availability : XXX
State : XXX

...

--------------------------------------------------------------
| Ltm::Pool Member: XXX
--------------------------------------------------------------
| Status
| Availability : XXX
| State : XXX

...

--------------------------------------------------------------
| Ltm::Pool Member: XXX
--------------------------------------------------------------
| Status
| Availability : XXX
| State : XXX

I am trying to match the pattern to get the pool name and the members under that pool name. I am a little confused as there are multiple pool members under a single pool. Any help is appreciated!

@pjptsujit This can be a little tricky because of the non alphanumeric characters. One thing to keep in mind is the hierarchy as the parser we use is highly sensitive to indentation.
 

/**
* @intent Parse out F5 Pools and Members
* @description Report on all F5 Pools and their members
*/

pattern = ```
Ltm::Pool: {pool: string}
Connection Queue
Average queue entry age (ms)
Ltm::Pool Member: {poolmember: string}
```;

// This is used to clean some of the characters so we can parse effectively
cleanMembers(config) = replace(cleanCharacters(config), "|", "");
cleanCharacters(config) = replace(config, "-", "");

foreach device in network.devices
where device.platform.vendor == Vendor.F5
let outputs = device.outputs
foreach command in outputs.commands
where command.commandType == CommandType.F5_LTM_POOL_STATE
let modified = cleanMembers(command.response)
let configlines = parseConfigBlocks(OS.UNKNOWN, modified)
let matches = blockMatches(configlines, pattern)
foreach match in matches

select {deviceName: device.name, Pool: match.data.pool, PoolMember: match.data.poolmember}


Depending on how you want the report, you can clean up the IP strings on the pool members or group these differently.


Reply