diff --git a/extra/resources/ifspeed b/extra/resources/ifspeed new file mode 100644 index 0000000000..520db65b51 --- /dev/null +++ b/extra/resources/ifspeed @@ -0,0 +1,457 @@ +#!/bin/bash +# +# OCF resource agent which monitors state of network interface and records it +# as a value in CIB based on summ of speeds of its active (up, link detected, +# not blocked) underlying interfaces. +# +# Copyright (c) 2011 Vladislav Bogdanov +# Partially based on 'ping' RA by Andrew Beekhof +# +# OCF instance parameters: +# OCF_RESKEY_name: name of attribute to set in CIB +# OCF_RESKEY_iface: network interface to monitor +# OCF_RESKEY_bridge_ports: if not null and OCF_RESKEY_iface is a bridge, list of +# bridge ports to consider. +# Default is all ports which have designated_bridge=root_id +# OCF_RESKEY_weight_base: Relative weight of 1Gbps. This can be used to tune +# value of resulting CIB attribute. +# +# Initialization: + +: ${OCF_FUNCTIONS_DIR=${OCF_ROOT}/lib/heartbeat} +. ${OCF_FUNCTIONS_DIR}/ocf-shellfuncs + +# Defaults +OCF_RESKEY_name_default="ifspeed" +OCF_RESKEY_bridge_ports_default="detect" +OCF_RESKEY_weight_base_default=1000 +OCF_RESKEY_dampen_default=5 + +: ${OCF_RESKEY_name=${OCF_RESKEY_name_default}} +: ${OCF_RESKEY_bridge_ports=${OCF_RESKEY_bridge_ports_default}} +: ${OCF_RESKEY_weight_base=${OCF_RESKEY_weight_base_default}} +: ${OCF_RESKEY_dampen=${OCF_RESKEY_dampen_default}} + +meta_data() { + cat < + + +1.0 + + +Every time the monitor action is run, this resource agent records (in the CIB) +(relative) speed of network interface it monitors. + +This RA can monitor physical interfaces, bonds, bridges, vlans and (hopefully) +any combination of them. + +Examples: +*) Bridge on top of one 10Gbps interface (eth2) and 802.3ad bonding (bond0) built + on two 1Gbps interfaces (eth0 and eth1). +*) Active-backup bonding built on top of one physical interface and one vlan on + another interface. + +For STP-enabled bridges this RA tries to some-how guess network topology and by +default looks only on ports which are connected to upstream switch. This can be +overriden by 'bridge_ports' parameter. Active interfaces in this case are those +in "forwarding" state. + +For balancing bonds this RA summs speeds of underlying "up" slave interfaces +(and applies coefficient 0.8 to result). + +For non-balancing bonds ('active-backup' and probably 'brodcast') only speed of +now active slave is used. + +Network interface speed monitor + + + + + +The name of the attribute to set. This is the name to be used in the constraints. + +Attribute name + + + + + +Network interface to monitor. + +Network interface + + + + + +If not null and OCF_RESKEY_iface is a bridge, list of bridge ports to consider. +Default is all ports which have designated_bridge=root_id. + +Bridge ports + + + + + +Relative weight of 1Gbps in interface speed. +Can be used to tune how big attribute value will be. + +Weight of 1Gbps + + + + + +The time to wait (dampening) for further changes to occur. + +Dampening interval + + + + + +Log what have been done more verbosely. + +Verbose logging + + + + + + + + + + + + + + +END +} + +usage() { + cat <