Can I find out the status of the CARP interface (BACKUP / MASTER) through a command?
-
I would like to monitor the status of the CARP interface through the Zabbix Agent, I found the idea of inserting UserParameter = pfsense.carp.state, sysctl net.inet.carp.demotion; but I didn't like it because it will only return a value other than 0 if there was a failure with the CARP interface, and that's not what I want, as you can see from the title of this post.
-
The status of the individual VHIDs is visible in the
ifconfig
output -- you can use various shell utilities to parse/cut that down to a specific status depending on your needs.For example:
ifconfig -a | grep 'carp:' carp: MASTER vhid 11 advbase 1 advskew 0 carp: MASTER vhid 15 advbase 1 advskew 0 carp: MASTER vhid 14 advbase 1 advskew 0 carp: MASTER vhid 19 advbase 1 advskew 0 carp: MASTER vhid 16 advbase 1 advskew 0 carp: MASTER vhid 13 advbase 1 advskew 0 carp: MASTER vhid 17 advbase 1 advskew 0
-
@jimp said in Can I find out the status of the CARP interface (BACKUP / MASTER) through a command?:
ifconfig -a | grep 'carp:'
This solution looks perfect, I only made one adjustment to get only the MASTER / BACKUP:
UserParameter = pfsense.carp.state, ifconfig -a | grep 'carp:' | cut -d '' -f2 | sed -n 1p
Sed is for taking only one CARP interface, it is very rare for one interface to be BACKUP while the others are MASTER, and vice versa.
PS: I don't know if I should close this post as resolved or how to do it if I should.