ifstated check commands behavior
Alexandre Biancalana
biancalana at gmail.com
Thu Mar 15 12:42:39 UTC 2007
On 3/14/07, Alexandre Biancalana <biancalana at gmail.com> wrote:
>
> Hi list,
>
> I'm trying to setup ifstated to check two links and if some go down, do
> some actions like change pf rules and machine's route.
>
> My doubt is about the execution order/repetition of the states body of
> ifstated.conf, in all configs that I tried just the last check is executed
> always, follow and example:
>
> ifstated.conf:
> ==============================
> loglevel debug
>
> ping1 = '( "ping -q -c 1 -t 3 www.site1.com > /dev/null" every 10 ) '
> ping2 = '( "ping -q -c 1 -t 3 www.site2.com > /dev/null" every 10 ) '
>
> state one {
> if ! ( $ping1 && $ping2 ) {
> set-state two
> }
> }
>
> state two {
>
> init {
> run "logger -p console.notice -t ifstated 'Restarting
> network !'"
> }
>
> if ( $ping && $ping2 ) {
> set-state one
> }
> }
>
> ==============================
>
> # ifstated -dv
> ping1 = "( "ping -q -c 1 -t 3 www.site1.com > /dev/null" every 10 ) "
> ping2 = "( "ping -q -c 1 -t 3 www.site2.com > /dev/null" every 10 ) "
> ifstated: initial state: one
> ifstated: changing state to one
> ifstated: running ping -q -c 1 -t 3 www.site1.com > /dev/null
> ifstated: running ping -q -c 1 -t 3 www.site2.com > /dev/null
> ifstated: started
> ifstated: changing state to two
> ifstated: running ping -q -c 1 -t 3 www.site1.com > /dev/null
> ifstated: running ping -q -c 1 -t 3 www.site2.com > /dev/null
> ifstated: running ping -q -c 1 -t 3 www.site2.com > /dev/null
> ifstated: running ping -q -c 1 -t 3 www.site2.com > /dev/null
>
>
> As you can see, after change state ifstated execute only the *last* check
> command of the statement (ping2) forever....
>
> This is the expected behavior ?
This shouldn't execute all state body until state change ??
Thanks for any help.
Alexandre
More information about the freebsd-questions
mailing list