summaryrefslogtreecommitdiffstats
path: root/ctdb/config/events.d/10.interface
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2009-12-14 11:59:45 +0100
committerStefan Metzmacher <metze@samba.org>2010-01-20 11:11:01 +0100
commit9c89dd92104612f40caa111ea8217ef1626390a2 (patch)
treef1036e30eba754081553f1a3ce7607f2a0d34c02 /ctdb/config/events.d/10.interface
parent5fa6a51388dab11c4e9fafb62e83833974d85b03 (diff)
downloadsamba-9c89dd92104612f40caa111ea8217ef1626390a2.tar.gz
samba-9c89dd92104612f40caa111ea8217ef1626390a2.tar.xz
samba-9c89dd92104612f40caa111ea8217ef1626390a2.zip
events: splitout a monitor_interfaces function in 10.interface
metze (This used to be ctdb commit b5ba56dea57db97d6c6ba3e7582e74fe0e3041fc)
Diffstat (limited to 'ctdb/config/events.d/10.interface')
-rwxr-xr-xctdb/config/events.d/10.interface109
1 files changed, 64 insertions, 45 deletions
diff --git a/ctdb/config/events.d/10.interface b/ctdb/config/events.d/10.interface
index 89e2a2eb4b..134a0e67ae 100755
--- a/ctdb/config/events.d/10.interface
+++ b/ctdb/config/events.d/10.interface
@@ -17,6 +17,65 @@ loadconfig
exit 0
}
+monitor_interfaces()
+{
+ local INTERFACES=`cat $CTDB_PUBLIC_ADDRESSES |
+ sed -e "s/^[^\t ]*[\t ]*//" -e "s/,/ /g" -e "s/[\t ]*$//"`
+
+ [ "$CTDB_PUBLIC_INTERFACE" ] && INTERFACES="$CTDB_PUBLIC_INTERFACE $INTERFACES"
+ [ "$CTDB_NATGW_PUBLIC_IFACE" ] && INTERFACES="$CTDB_NATGW_PUBLIC_IFACE $INTERFACES"
+
+ local IFACE
+
+ INTERFACES=`for IFACE in $INTERFACES ; do echo $IFACE ; done | sort | uniq`
+
+ local fail=0
+ for IFACE in $INTERFACES ; do
+ # These interfaces are sometimes bond devices
+ # When we use VLANs for bond interfaces, there will only
+ # be an entry in /proc for the underlying real interface
+ local REALIFACE=`echo $IFACE |sed -e 's/\..*$//'`
+ [ -f /proc/net/bonding/$REALIFACE ] && {
+ grep -q 'Currently Active Slave: None' /proc/net/bonding/$REALIFACE && {
+ echo "ERROR: No active slaves for bond device $REALIFACE"
+ fail=1
+ continue;
+ }
+ grep -q '^MII Status: up' /proc/net/bonding/$REALIFACE || {
+ echo "ERROR: public network interface $REALIFACE is down"
+ fail=1
+ continue;
+ }
+ return 0;
+ }
+
+ case $IFACE in
+ ib*)
+ # we dont know how to test ib links
+ ;;
+ *)
+ [ -z "$IFACE" ] || {
+ /usr/sbin/ethtool $IFACE | grep -q 'Link detected: yes' || {
+ # On some systems, this is not successful when a
+ # cable is plugged but the interface has not been
+ # brought up previously. Bring the interface up and
+ # try again...
+ /sbin/ip link set $IFACE up
+ /usr/sbin/ethtool $IFACE | grep -q 'Link detected: yes' || {
+ echo "ERROR: No link on the public network interface $IFACE"
+ fail=1
+ continue
+ }
+ }
+ }
+ ;;
+ esac
+
+ done
+
+ return $fail;
+}
+
case "$1" in
#############################
# called when ctdbd starts up
@@ -112,52 +171,12 @@ case "$1" in
;;
monitor)
- INTERFACES=`cat $CTDB_PUBLIC_ADDRESSES |
- sed -e "s/^[^\t ]*[\t ]*//" -e "s/,/ /g" -e "s/[\t ]*$//"`
-
- [ "$CTDB_PUBLIC_INTERFACE" ] && INTERFACES="$CTDB_PUBLIC_INTERFACE $INTERFACES"
- [ "$CTDB_NATGW_PUBLIC_IFACE" ] && INTERFACES="$CTDB_NATGW_PUBLIC_IFACE $INTERFACES"
-
- INTERFACES=`for IFACE in $INTERFACES ; do echo $IFACE ; done | sort | uniq`
-
- for IFACE in $INTERFACES ; do
- # These interfaces are sometimes bond devices
- # When we use VLANs for bond interfaces, there will only
- # be an entry in /proc for the underlying real interface
- REALIFACE=`echo $IFACE |sed -e 's/\..*$//'`
- [ -f /proc/net/bonding/$REALIFACE ] && {
- grep -q 'Currently Active Slave: None' /proc/net/bonding/$REALIFACE && {
- echo "ERROR: No active slaves for bond device $REALIFACE"
- exit 1
- }
- grep -q '^MII Status: up' /proc/net/bonding/$REALIFACE || {
- echo "ERROR: public network interface $REALIFACE is down"
- exit 1
- }
- exit 0;
- }
+ monitor_interfaces
+ ret=$?
- case $IFACE in
- ib*)
- # we dont know how to test ib links
- ;;
- *)
- [ -z "$IFACE" ] || {
- /usr/sbin/ethtool $IFACE | grep -q 'Link detected: yes' || {
- # On some systems, this is not successful when a
- # cable is plugged but the interface has not been
- # brought up previously. Bring the interface up and
- # try again...
- /sbin/ip link set $IFACE up
- /usr/sbin/ethtool $IFACE | grep -q 'Link detected: yes' || {
- echo "ERROR: No link on the public network interface $IFACE"
- exit 1
- }
- }
- }
- ;;
- esac
- done
+ test x"$ret" != x"0" && {
+ exit 1;
+ }
;;
*)
ctdb_standard_event_handler "$@"