mirror of
https://github.com/samba-team/samba.git
synced 2025-03-29 02:50:28 +03:00
config: 10.interfaces call ctdb ifaces and ctdb setifacelink for monitoring
metze (This used to be ctdb commit c465f63585c419ba59a6b04cbbf78ae615a7259d)
This commit is contained in:
parent
9c89dd9210
commit
94e7101070
@ -25,12 +25,28 @@ monitor_interfaces()
|
||||
[ "$CTDB_PUBLIC_INTERFACE" ] && INTERFACES="$CTDB_PUBLIC_INTERFACE $INTERFACES"
|
||||
[ "$CTDB_NATGW_PUBLIC_IFACE" ] && INTERFACES="$CTDB_NATGW_PUBLIC_IFACE $INTERFACES"
|
||||
|
||||
local IFACES=`ctdb ifaces -Y | grep -v '^:Name:LinkStatus:References:'`
|
||||
|
||||
local I
|
||||
local IFACE
|
||||
|
||||
for I in $IFACES; do
|
||||
IFACE=`echo -n "$I" | cut -d ':' -f2`
|
||||
INTERFACES="$IFACE $INTERFACES"
|
||||
done
|
||||
|
||||
INTERFACES=`for IFACE in $INTERFACES ; do echo $IFACE ; done | sort | uniq`
|
||||
|
||||
local fail=0
|
||||
local force_fail=0
|
||||
local ok=0
|
||||
for IFACE in $INTERFACES ; do
|
||||
|
||||
local OLDLINK=`echo -n "$IFACES" | grep "^:$IFACE:" | cut -d ':' -f3 | xargs`
|
||||
test -z "$OLDLINK" && {
|
||||
force_fail=1
|
||||
}
|
||||
|
||||
# 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
|
||||
@ -39,13 +55,23 @@ monitor_interfaces()
|
||||
grep -q 'Currently Active Slave: None' /proc/net/bonding/$REALIFACE && {
|
||||
echo "ERROR: No active slaves for bond device $REALIFACE"
|
||||
fail=1
|
||||
test -n "$OLDLINK" && {
|
||||
ctdb setifacelink $IFACE down
|
||||
}
|
||||
continue;
|
||||
}
|
||||
grep -q '^MII Status: up' /proc/net/bonding/$REALIFACE || {
|
||||
echo "ERROR: public network interface $REALIFACE is down"
|
||||
fail=1
|
||||
test -n "$OLDLINK" && {
|
||||
ctdb setifacelink $IFACE down
|
||||
}
|
||||
continue;
|
||||
}
|
||||
test -n "$OLDLINK" && {
|
||||
ok=1 # we only set ok for interfaces known to ctdbd
|
||||
ctdb setifacelink $IFACE up
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -64,16 +90,35 @@ monitor_interfaces()
|
||||
/usr/sbin/ethtool $IFACE | grep -q 'Link detected: yes' || {
|
||||
echo "ERROR: No link on the public network interface $IFACE"
|
||||
fail=1
|
||||
test -n "$OLDLINK" && {
|
||||
ctdb setifacelink $IFACE down
|
||||
}
|
||||
continue
|
||||
}
|
||||
}
|
||||
test -n "$OLDLINK" && {
|
||||
ok=1 # we only set ok for interfaces known to ctdbd
|
||||
ctdb setifacelink $IFACE up
|
||||
}
|
||||
}
|
||||
;;
|
||||
esac
|
||||
|
||||
done
|
||||
|
||||
return $fail;
|
||||
test x"$fail" = x"0" && {
|
||||
return 0;
|
||||
}
|
||||
|
||||
test x"$force_fail" != x"0" && {
|
||||
return 1;
|
||||
}
|
||||
|
||||
test x"$ok" = x"1" && {
|
||||
return 2;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
|
Loading…
x
Reference in New Issue
Block a user