Project

General

Profile

Feature #7895

Add a script for CARP monitoring to NRPE

Added by Stéphane Lapie over 1 year ago. Updated over 1 year ago.

Status:
New
Priority:
Normal
Assignee:
-
Category:
NRPE
Target version:
-
Start date:
09/27/2017
Due date:
% Done:

0%

Estimated time:

Description

I have deployed several CARP clusters at work, but I realized there is no real good way to monitor CARP status :
  • SNMP does not provide MIBs for checking on CARP, and IF-MIB do not provide enough information to infer whether an interface is "MASTER but should be BACKUP" or the opposite.
  • Default NRPE plugins do not provide any good information
  • ifconfig is the only reliable source of information

Therefore, I decided to use NRPEv2 and to create a custom script to check the NIC CARP status.
I don't mind contributing it to pfSense, but I was not sure how to integrate it in the new package repository.

I wanted first to make a system patch that would create the file in /usr/local/libexec/nagios, but the patching system is not appropriate for "adding new files", since it will view the diff as always both applicable/removable.

check_carp_freebsd.sh (3.88 KB) check_carp_freebsd.sh Stéphane Lapie, 09/27/2017 05:14 AM
check_carp_freebsd.sh (3.5 KB) check_carp_freebsd.sh Added "exit $1" command after reporting error Stéphane Lapie, 10/02/2017 03:53 AM
check_carp_freebsd.sh (4.51 KB) check_carp_freebsd.sh Added support for multiple VHIDs per NIC Stéphane Lapie, 10/17/2017 11:10 AM

History

#1 Updated by Stéphane Lapie over 1 year ago

Little fix, the current plugin did not set the return code upon exiting.

#2 Updated by Phillip Hernandez over 1 year ago

I agree that it would be very helpful if there was a way to monitor carp status via SNMP.

I ran your script on my pfsense box that is 2.4... this was the output... Is the formatting correct?

I would love to use this script to integrate with my zabbix monitoring.

/root: sh check_carp_freebsd.sh
[: 0
0
0: bad number
UNKNOWN - CARP Status : vmx0 is MASTER
MASTER
MASTER (UNKNOWN); vmx1 is MASTER (OK); vmx3_vlan300 is MASTER (OK);

This is the output of ifconfig...
vmx0: flags=8943<UP,BROADCAST,RUNNING,PROMISC,SIMPLEX,MULTICAST> metric 0 mtu 1500
options=60009b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM,RXCSUM_IPV6,TXCSUM_IPV6>
ether 00:50:56:84:2e:e6
hwaddr 00:50:56:84:2e:e6
inet6 fe80::250:56ff:fe84:2ee6%vmx0 prefixlen 64 scopeid 0x1
inet x.x.x.218 netmask 0xfffffff8 broadcast x.x.x.x
inet x.x.x.217 netmask 0xfffffff8 broadcast x.x.x.x vhid 5
inet x.x.x.220 netmask 0xfffffff8 broadcast x.x.x.x vhid 6
inet x.x.x.221 netmask 0xfffffff8 broadcast x.x.x.x vhid 7
nd6 options=21<PERFORMNUD,AUTO_LINKLOCAL>
media: Ethernet autoselect
status: active
carp: MASTER vhid 5 advbase 1 advskew 0
carp: MASTER vhid 6 advbase 1 advskew 0
carp: MASTER vhid 7 advbase 1 advskew 0
vmx1: flags=8943<UP,BROADCAST,RUNNING,PROMISC,SIMPLEX,MULTICAST> metric 0 mtu 9000
options=60009b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM,RXCSUM_IPV6,TXCSUM_IPV6>
ether 00:50:56:84:28:84
hwaddr 00:50:56:84:28:84
inet6 fe80::250:56ff:fe84:2884%vmx1 prefixlen 64 scopeid 0x2
inet x.x.20.2 netmask 0xffffff00 broadcast x.x.20.255
inet x.x.20.1 netmask 0xffffff00 broadcast x.x.20.255 vhid 10
nd6 options=21<PERFORMNUD,AUTO_LINKLOCAL>
media: Ethernet autoselect
status: active
carp: MASTER vhid 10 advbase 1 advskew 0
vmx2: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
options=60009b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM,RXCSUM_IPV6,TXCSUM_IPV6>
ether 00:50:56:84:a1:ca
hwaddr 00:50:56:84:a1:ca
inet6 fe80::250:56ff:fe84:a1ca%vmx2 prefixlen 64 scopeid 0x3
inet x.x.50.2 netmask 0xffffff00 broadcast x.x.50.255
nd6 options=21<PERFORMNUD,AUTO_LINKLOCAL>
media: Ethernet autoselect
status: active
vmx3: flags=8943<UP,BROADCAST,RUNNING,PROMISC,SIMPLEX,MULTICAST> metric 0 mtu 1500
options=61009b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM,VLAN_HWFILTER,RXCSUM_IPV6,TXCSUM_IPV6>
ether 00:50:56:84:5a:ee
hwaddr 00:50:56:84:5a:ee
inet6 fe80::250:56ff:fe84:5aee%vmx3 prefixlen 64 scopeid 0x4
nd6 options=21<PERFORMNUD,AUTO_LINKLOCAL>
media: Ethernet autoselect
status: active

#3 Updated by Stéphane Lapie over 1 year ago

Ah, I think I see. I did not handle the case of multiple VHIDs on one interface, I will fix it right now.

#4 Updated by Stéphane Lapie over 1 year ago

Here is a fixed version, I tested it based on your above output.

It now gives the following result :

OK - CARP Status : vmx0 (vhid 5) is MASTER (OK) vmx0 (vhid 6) is MASTER (OK) vmx0 (vhid 7) is MASTER (OK); vmx1 (vhid 10) is MASTER (OK);

Also available in: Atom PDF