From owner-freebsd-questions@FreeBSD.ORG Thu Feb 2 10:46:22 2012 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6D1F51065675 for ; Thu, 2 Feb 2012 10:46:22 +0000 (UTC) (envelope-from ml@my.gd) Received: from mail-bk0-f54.google.com (mail-bk0-f54.google.com [209.85.214.54]) by mx1.freebsd.org (Postfix) with ESMTP id F07AF8FC18 for ; Thu, 2 Feb 2012 10:46:21 +0000 (UTC) Received: by bkbzx1 with SMTP id zx1so2642774bkb.13 for ; Thu, 02 Feb 2012 02:46:20 -0800 (PST) Received: by 10.205.139.76 with SMTP id iv12mr1111776bkc.126.1328179580239; Thu, 02 Feb 2012 02:46:20 -0800 (PST) Received: from dfleuriot-at-hi-media.com ([83.167.62.196]) by mx.google.com with ESMTPS id t17sm5850751bke.6.2012.02.02.02.46.18 (version=SSLv3 cipher=OTHER); Thu, 02 Feb 2012 02:46:19 -0800 (PST) Message-ID: <4F2A6979.9090403@my.gd> Date: Thu, 02 Feb 2012 11:46:17 +0100 From: Damien Fleuriot User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:9.0) Gecko/20111222 Thunderbird/9.0.1 MIME-Version: 1.0 To: peter knezel References: <4F292596.2090000@my.gd> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Cc: freebsd-questions@freebsd.org Subject: Re: carp+devd+ifstated on master problem X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 02 Feb 2012 10:46:22 -0000 We're using ifstated to send nagios passive alerts in case a lagg or carp's interface's state should become degraded. Find below the config we're using: carp_up = "carp410.link.up && carp13.link.up" carp_down = "carp410.link.down && carp13.link.down" carp_unknown = "carp410.link.unknown || carp13.link.unknown" init-state auto state auto { set-state inconnu if $carp_up { set-state primary } if $carp_down { set-state backup } if $carp_unknown { set-state inconnu } } state primary { init { run "echo \"pf1-gs.hipay;carp;0;carp Master\"| send_nsca_2.7 -H monit1.hipay.eqx -d \";\" -c /usr/local/etc/send_nsca.cfg" run "echo \"pf1-gs.hipay;carp;0;carp Master\"| send_nsca_2.7 -H monit1.hipay -d \";\" -c /usr/local/etc/send_nsca.cfg" } if $carp_down { set-state backup } if $carp_unknown { set-state inconnu } if bce0.link.up && bce1.link.up { run "echo \"pf1-gs.hipay;bond;0;BONDING OK\"| send_nsca_2.7 -H monit1.hipay.eqx -d \";\" -c /usr/local/etc/send_nsca.cfg" run "echo \"pf1-gs.hipay;bond;0;BONDING OK\"| send_nsca_2.7 -H monit1.hipay -d \";\" -c /usr/local/etc/send_nsca.cfg" } if bce0.link.down || bce1.link.down { run "echo \"pf1-gs.hipay;bond;2;BONDING DEGRADED\"| send_nsca_2.7 -H monit1.hipay.eqx -d \";\" -c /usr/local/etc/send_nsca.cfg" run "echo \"pf1-gs.hipay;bond;2;BONDING DEGRADED\"| send_nsca_2.7 -H monit1.hipay -d \";\" -c /usr/local/etc/send_nsca.cfg" } } state backup { init { run "echo \"pf1-gs.hipay;carp;2;carp Backup\"| send_nsca_2.7 -H monit1.hipay.eqx -d \";\" -c /usr/local/etc/send_nsca.cfg" run "echo \"pf1-gs.hipay;carp;2;carp Backup\"| send_nsca_2.7 -H monit1.hipay -d \";\" -c /usr/local/etc/send_nsca.cfg" } if $carp_up { set-state primary } if $carp_unknown { set-state inconnu } if bce0.link.up && bce1.link.up { run "echo \"pf1-gs.hipay;bond;0;BONDING OK\"| send_nsca_2.7 -H monit1.hipay.eqx -d \";\" -c /usr/local/etc/send_nsca.cfg" run "echo \"pf1-gs.hipay;bond;0;BONDING OK\"| send_nsca_2.7 -H monit1.hipay -d \";\" -c /usr/local/etc/send_nsca.cfg" } if bce0.link.down || bce1.link.down { run "echo \"pf1-gs.hipay;bond;2;BONDING DEGRADED\"| send_nsca_2.7 -H monit1.hipay.eqx -d \";\" -c /usr/local/etc/send_nsca.cfg" run "echo \"pf1-gs.hipay;bond;2;BONDING DEGRADED\"| send_nsca_2.7 -H monit1.hipay -d \";\" -c /usr/local/etc/send_nsca.cfg" } } state inconnu { init { run "echo \"pf1-gs.hipay;carp;2;carp INIT\"| send_nsca_2.7 -H monit1.hipay.eqx -d \";\" -c /usr/local/etc/send_nsca.cfg" run "echo \"pf1-gs.hipay;carp;2;carp INIT\"| send_nsca_2.7 -H monit1.hipay -d \";\" -c /usr/local/etc/send_nsca.cfg" } if $carp_up { set-state primary } if $carp_down { set-state backup } if bce0.link.up && bce1.link.up { run "echo \"pf1-gs.hipay;bond;0;BONDING OK\"| send_nsca_2.7 -H monit1.hipay.eqx -d \";\" -c /usr/local/etc/send_nsca.cfg" run "echo \"pf1-gs.hipay;bond;0;BONDING OK\"| send_nsca_2.7 -H monit1.hipay -d \";\" -c /usr/local/etc/send_nsca.cfg" } if bce0.link.down || bce1.link.down { run "echo \"pf1-gs.hipay;bond;2;BONDING DEGRADED\"| send_nsca_2.7 -H monit1.hipay.eqx -d \";\" -c /usr/local/etc/send_nsca.cfg" run "echo \"pf1-gs.hipay;bond;2;BONDING DEGRADED\"| send_nsca_2.7 -H monit1.hipay -d \";\" -c /usr/local/etc/send_nsca.cfg" } } On 2/2/12 11:25 AM, peter knezel wrote: > Hello Damien, > > of course, the tnewpass was my copy error - newpass is OK and is in > config files everywhere. > And the carp interfaces' advskew, vhid and > pass are already in /etc/rc.conf.local. > > What I simply would like to try is run scripts if carp interfaces change. > Actually my real aim is to synchronize file from slave server to > master if master reboots or slave becomes master due to carp problems > on the master. > Regards, > Peter > > > On 01/02/2012, Damien Fleuriot wrote: >> >> >> On 2/1/12 12:12 PM, peter knezel wrote: >>> Hello all, >>> >>> I have configured devd and ifstated on a master FreeBSD server (slave >>> not changed so far) on which carp was configured with three >>> carp0,carp1 and carp2 virtual addresses. >>> >>> When I as root do ifconfig carp0 down and up, the corresponding >>> testdown.sh and testup.sh >>> scripts are run (defined in ifstated.conf). >>> The status of carp0 interface changes to INIT then to MASTER (after >>> ifconfig carp0 up). >>> >>> However this is not valid when doing the same with carp1 or carp2. >>> It goes to INIT+testdown.sh executed but then immediately afterwards >>> it goes to MASTER+testup.sh executed. >>> >>> What can be the problem? >>> >>> cd /usr/local/etc >>> cat ifstated.conf >>> init-state one >>> >>> net = '( "ifconfig -a -u |grep carp0 > /dev/null" every 3 && "ifconfig -a >>> -u >>> |grep carp1 > /dev/null" every 3 && "ifconfig -a -u |grep carp2 > >>> /dev/null" >>> every 3)' >>> >>> state one { >>> if ( ! $net ) { >>> run "/sbin/ifconfig_carp0 vhid 1 pass newpass >>> 192.xx.xx.1/24" >>> run "/sbin/ifconfig carp1 vhid 2 pass newpass >>> 192.xx.xx.2/24" >>> run "/sbin/ifconfig carp2 vhid 3 pass newpass >>> 192.xx.xx.3/24" >>> run "/usr/local/testdown.sh" >>> set-state two >>> } >>> } >>> >>> state two { >>> if ( $net ) { >>> run "/sbin/ifconfig carp0 vhid 1 advskew 100 pass >>> tnewpass 192.xx.xx.1/24" >>> run "/sbin/ifconfig carp1 vhid 2 advskew 100 pass >>> newpass 192.xx.xx.2/24" >>> run "/sbin/ifconfig carp2 vhid 3 advskew 100 pass >>> newpass 192.xx.xx.3/24" >>> run "/usr/local/testup.sh" >>> set-state one >>> } >>> } >>> >>> In addition I had to configure devd.conf to have ifdown.sh and ifup.sh >>> scripts executed when reboot is done on the master. >>> >>> notify 30 { >>> match "system" "IFNET"; >>> match "subsystem" "carp0"; >>> match "type" "LINK_UP"; >>> action "/usr/local/etc/rc.d/ifdown.sh"; >>> }; >>> >>> notify 30 { >>> match "system" "IFNET"; >>> match "subsystem" "carp0"; >>> match "type" "LINK_DOWN"; >>> action "/usr/local/etc/rc.d/ifup.sh"; >>> >>> Thanks for any suggestion in advance. >>> >>> Ardi >> >> I'm not sure I get what you're trying to do here. >> >> Is there a reason you do not set your carp interfaces' advskew, vhid and >> pass in /etc/rc.conf ? >> >> Also, I notice in state 2 your password for carp0 is tnewpass, while the >> other ones are newpass. >> >> _______________________________________________ >> freebsd-questions@freebsd.org mailing list >> http://lists.freebsd.org/mailman/listinfo/freebsd-questions >> To unsubscribe, send any mail to "freebsd-questions-unsubscribe@freebsd.org" >>