#!@BASH_PATH@ # # ocf:pacemaker:ifspeed resource agent # # Copyright 2011-2023 the Pacemaker project contributors # # The version control history for this file may have further details. # # This source code is licensed under the GNU General Public License version 2 # or later (GPLv2+) WITHOUT ANY WARRANTY. # # # Record speed of a network interface as a node attribute, based on the sum of # speeds of its active (up, link detected, not blocked) underlying interfaces. # # Originally based on ocf:pacemaker:ping agent # : ${OCF_FUNCTIONS:="${OCF_ROOT}/resource.d/heartbeat/.ocf-shellfuncs"} # If these aren't available, we can still show help, # which is all that is needed to build the man pages. [ -r "${OCF_FUNCTIONS}" ] && . "${OCF_FUNCTIONS}" [ -r "${OCF_FUNCTIONS_DIR}/findif.sh" ] && . "${OCF_FUNCTIONS_DIR}/findif.sh" : ${OCF_SUCCESS:=0} : ${__OCF_ACTION:=$1} FINDIF=findif # Defaults OCF_RESKEY_name_default="ifspeed" OCF_RESKEY_bridge_ports_default="detect" OCF_RESKEY_weight_base_default=1000 OCF_RESKEY_dampen_default=5 # Explicitly list all environment variables used, to make static analysis happy : ${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}} : ${OCF_RESKEY_iface:=""} : ${OCF_RESKEY_ip:=""} : ${OCF_RESKEY_debug:="false"} meta_data() { cat < 1.1 This agent's monitor action records the speed of a specified network interface as a node attribute. The attribute can be used in rules to prefer nodes based on network speeds. This agent can monitor physical interfaces, bonded interfaces, bridges, VLANs, or any combination thereof. For example: *) 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 agent tries to determine the network topology, and by default looks only on ports which are connected to an upstream switch. This can be overridden by 'bridge_ports' parameter. Active interfaces in this case are those in "forwarding" state. For balancing bonded interfaces, this agent uses 80% of the sum of the speeds of underlying "up" ports. For non-balancing bonded interfaces ("active-backup" and probably "broadcast"), only the speed of the currently active port is considered. Network interface speed monitor Name of the node attribute to set Attribute name If this is set, monitor this network interface. One of iface or ip must be set. Network interface If this is set instead of iface, monitor the interface that holds this IP address. The address may be specified in dotted-quad notation for IPv4 (for example, 192.168.1.1) or hexadecimal notation for IPv6 (for example, 2001:db8:DC28:0:0:FC57:D4C8:1FFF). One of iface or ip must be set. IPv4 or IPv6 address If set and iface is a bridge, consider these bridge ports (by default, 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 more verbosely. Verbose logging END } usage() { cat <