talsa
Dec 20, 2022Nimbostratus
Solved
BIG IP F5 IRule with data group to check if date has passed
Hello, I have a datagroup of kind string/external file, which has hosts on the first field, and dates with format YYYY-MM-DD on the second field. I want to create an irule that will do something whe...
- Dec 21, 2022
So, this code will return the value of the date you've mapped to every host
when HTTP_REQUEST { set host [string tolower [HTTP::host]] set now [clock seconds] ; log local0. "now is $now" set expire_date "1991-01-01" if { [class match $host eq test-string] }{ set expire_date [class match -value "$host" equals test-string] } else { log local0. "$host does not have a value in datagroup"} log local0. "expire date is $expire_date" set exp_clock [clock scan $expire_date]; log local0. "exp_clock is $exp_clock" }
Here's what variables look like
Dec 21 12:39:47 bigip info tmm4[11336]: Rule /Common/iRule_DC <HTTP_REQUEST>: now is 1603535987 Dec 21 12:39:47 bigip info tmm4[11336]: Rule /Common/iRule_DC <HTTP_REQUEST>: expire date is 2024-04-16 Dec 21 12:39:47 bigip info tmm4[11336]: Rule /Common/iRule_DC <HTTP_REQUEST>: exp_clock is 1713218400 Dec 21 12:40:53 bigip info tmm1[11336]: Rule /Common/iRule_DC <HTTP_REQUEST>: now is 1603536053 Dec 21 12:40:53 bigip info tmm1[11336]: Rule /Common/iRule_DC <HTTP_REQUEST>: www.random.com does not have a value in datagroup Dec 21 12:40:53 bigip info tmm1[11336]: Rule /Common/iRule_DC <HTTP_REQUEST>: expire date is 1991-01-01 Dec 21 12:40:53 bigip info tmm1[11336]: Rule /Common/iRule_DC <HTTP_REQUEST>: exp_clock is 662684400