Forum Discussion
Can an "after" job be referenced from a different context?
This is related to a previously un-answered question: https://devcentral.f5.com/questions/periodic-summary-logging-with-table-and-after. I'm trying to accomplish roughly the same thing, but I'm looking for a more specific answer. I'm trying to count the number of times a certain kind of request has been processed, then dump those counts every X seconds.
Is it possible to reference an "after" ID that was registered in a different thread of execution? The docs don't explicitly state one way or the other:
after info [ …]
* Returns information about currently scheduled scripts, or about a specific .
* Returns active timer ID(s) ( ...) for the current executing context (i.e., client, server).
* If called without supplying or multiple s supplied, return value is TCL list.
When I pass a after ID to "after info " that was registered in a different thread (The ID was saved to/retrieved from a session table), I get something like:
TCL error: MY_IRULE - Invalid after ID: afterbf8f674
My code looks something like this:
set count [ table incr "count_$tbl" ]
set after_id [after info [table lookup -subtable ${static::prefix} -notouch count_monitor]]
if { [ info exists after_id ]} {
do nothing, don't log right now
} else {
set after_id [after 10000 {
log local4.notice "prefix=${static::prefix} -- count=${count}"
table delete "count_$tbl"
}]
table set -subtable ${static::prefix} count_monitor ${after_id} 120000
}
When I run that code, it fails on the second line, trying to reference the "after info" by ID. If I log "[after info] by itself, it returns nothing.
After some playing around, it appears that after IDs can't be referenced outside of the original context. Is there a way that they can be registered in such a way as to be able to access them from a different context? If not, is there a different (v10-compatible) way that I could achieve some sort of asynchronous "dumping and clearing" of session table data?
- John_Alam_45640Historic F5 Account
Are you looking for something like the table record "lifetime" parameter. See this page.
- Nat_ThirasuttakornEmployee
I think after may not be shared across tmm. that probably one reason it may not work the same way as table.
is this your objective?
I'm trying to count the number of times a certain kind of request has been processed, then dump those counts every X seconds.
I think maybe you can do this way - use periodic after in RULE_INIT, only run for specific tmm - keep counter in ISTAT. I believe we can access ISTAT in RULE_INIT. someone, please correct me if I am wrong. (we cannot access table in RULE_INIT)
when RULE_INIT { if { [tmm::cmp_unit] == 0 } { after -periodic 10000 { log your iStat here, reset value, etc } } } when CLIENT_ACCEPTED { ISTATS::incr here ... }
note that the ISTATS counter is not realtime update. see good article by Colin here https://devcentral.f5.com/articles/introduction-to-istats-part-1-overview.Ut34PvL-Lkg if you want something more precise, it probably not good solution
another alternative is, you can do this using static::variable. but statistic would be per tmm.
not sure if this would answer your question though.
Nat
Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com