*) # Default case: If no more options then break out of the loop.
break
esac
shift
done
# Make sure that each given ID is given once only
all_ID=("${ID_master[@]}" "${ID_backup[@]}")
uniqueNum=$(printf '%s\n' "${all_ID[@]}"|awk '!($0 in seen){seen[$0];c++} END {print c}')
if [ "$uniqueNum" != ${#all_ID[@]} ]; then
echo "ERROR : At least one VRRP ID is given multiple times"
exit 2
fi
# Make sure --vrrpd and --uvrrpd are not both set
if [ $vrrpd_option = "set" ] && [ $uvrrpd_option = "set" ]; then
echo "ERROR : You cannot set both parameters --vrrpd and --uvrrpd"
exit 2
fi
# Make sure no sysclt parameter "rp_filter" is set to 1
if grep -q 1 /proc/sys/net/ipv4/conf/*/rp_filter; then
critical_output="${critical_output}CRITICAL - rp_filter is set to 1 at least for one interface\n"
critical_state="set"
fi
vrrpd_processes_number=$((${#ID_master[@]}+${#ID_backup[@]})) # Number of vrrpd processes that should be running = length of arrays ID_master + ID_backup
ID_running_vrrpd=($(for i in ${vrrpd_processes}; do echo "$i" | grep -Eo -- "-v [0-9]+" | awk '{print $2}'; done))
# Check the number of running vrrpd processes in comparison to the number of ID given
if ! sudo /usr/lib/nagios/plugins/check_procs -C "$used_daemon" -c $vrrpd_processes_number:$vrrpd_processes_number >/dev/null; then
critical_output="${critical_output}CRITICAL : $vrrpd_processes_number VRRP ID are given but $(ps auwx | grep "$used_daemon" | grep -v -e grep -e check -c) $used_daemon processes are running\n"
if pgrep uvrrp >/dev/null && [ $uvrrpd_option = "unset" ]; then
critical_output="${critical_output}It seems that uvrrpd is running. Use parameter --uvrrpd\n"
fi
critical_state="set"
fi
IFS=" "
# For each ID_master, make sure a process exist
if [ ${#ID_master[@]} -ne 0 ]; then
for i in "${ID_master[@]}"; do
# If array contains the current ID, then a process exist, and we have to make sure the corresponding interface exists
if [[ " ${ID_running_vrrpd[*]} " =~ " $i " ]]; then