Forum Discussion

Matt_Breedlove_'s avatar
Matt_Breedlove_
Icon for Nimbostratus rankNimbostratus
Jun 25, 2014

Simple RULE_INIT log irule. Only 1 log, but 4 shown every time?

Testing some logic in an irule that has only the RULE_INIT event declared. There is only one log command, but I see 4 duplicate logs in the LTM log? How can this be?

irule


when RULE_INIT {
   set httphost "ie-ng-services-ConFiguRation.acme.com"
   log local0. "bomb [string tolower [lindex [split [lindex [split $httphost "-"] end] "."] end-2]]"
}

logs resulting


Wed Jun 25 12:21:31 PDT 2014 info bip7003 tmm3[9363]   Rule /Common/_irule-proto : bomb configuration
Wed Jun 25 12:21:31 PDT 2014 info bip7003 tmm2[9363]   Rule /Common/_irule-proto : bomb configuration
Wed Jun 25 12:21:31 PDT 2014 info bip7003 tmm1[9363]   Rule /Common/_irule-proto : bomb configuration
Wed Jun 25 12:21:31 PDT 2014 info bip7003 tmm[9363]   Rule /Common/_irule-proto : bomb configuration

Why is this happening? RULE_INIT should only fire once, but it seems to be firing 4 times? tmm tmm1 tmm2 tmm3

  • Clustered Multiprocessing (CMP) is the answer.

     

    http://support.f5.com/kb/en-us/solutions/public/14000/200/sol14248.html

     

    The rule is initialized by all TMM processes, and you have four.

     

  • Clustered Multiprocessing (CMP) is the answer.

     

    http://support.f5.com/kb/en-us/solutions/public/14000/200/sol14248.html

     

    The rule is initialized by all TMM processes, and you have four.

     

  • RULE_INIT is triggered for every CPU, so 4 tmm's = 4 RULE_INITs. You can get around this by "pinning" your code to a single tmm:

     

    when RULE_INIT {
        if { [TMM::cmp_unit] == 0 } {
            set httphost "ie-ng-services-ConFiguRation.acme.com"
            log local0. "bomb [string tolower [lindex [split [lindex [split $httphost "-"] end] "."] end-2]]"
        }
    }

    I'd caution not to do this for anything other than local testing. The fact that RULE_INIT is triggered for every tmm means that any (global) variables assigned therein will be accessible to every tmm.