Project

General

Profile

Actions

Feature #7895

closed

Add a script for CARP monitoring to NRPE

Added by Stéphane Lapie about 4 years ago. Updated almost 2 years ago.

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

100%

Estimated time:
Plus Target Version:

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.


Files

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
Actions #1

Updated by Stéphane Lapie about 4 years ago

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

Actions #2

Updated by Phillip Hernandez about 4 years 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

Actions #3

Updated by Stéphane Lapie about 4 years ago

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

Actions #4

Updated by Stéphane Lapie about 4 years 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);

Actions #6

Updated by Jim Pingle almost 2 years ago

  • Status changed from New to Pull Request Review
Actions #7

Updated by Ronald Schellberg almost 2 years ago

I'm getting a build error with the addition of the script:

===>  Staging for Test_Build-pkg-nrpe-3.1_1
===>   Generating temporary packing list
/bin/mkdir -p /wrkdirs/usr/ports/net-mgmt/Test_Build-pkg-nrpe/work/stage/usr/local/pkg
/bin/mkdir -p /wrkdirs/usr/ports/net-mgmt/Test_Build-pkg-nrpe/work/stage/etc/inc/priv
/bin/mkdir -p /wrkdirs/usr/ports/net-mgmt/Test_Build-pkg-nrpe/work/stage/usr/local/share/Test_Build-pkg-nrpe
install  -m 0644 -m 0644 /usr/ports/net-mgmt/Test_Build-pkg-nrpe/files/usr/local/pkg/nrpe.xml  /wrkdirs/usr/ports/net-mgmt/Test_Build-pkg-nrpe/work/stage/usr/local/pkg
install  -m 0644 /usr/ports/net-mgmt/Test_Build-pkg-nrpe/files/usr/local/pkg/nrpe.inc  /wrkdirs/usr/ports/net-mgmt/Test_Build-pkg-nrpe/work/stage/usr/local/pkg
install  -m 0644 /usr/ports/net-mgmt/Test_Build-pkg-nrpe/files/etc/inc/priv/nrpe.priv.inc  /wrkdirs/usr/ports/net-mgmt/Test_Build-pkg-nrpe/work/stage/etc/inc/priv
install  -m 0644 /usr/ports/net-mgmt/Test_Build-pkg-nrpe/files/usr/local/share/Test_Build-pkg-nrpe/info.xml  /wrkdirs/usr/ports/net-mgmt/Test_Build-pkg-nrpe/work/stage/usr/local/share/Test_Build-pkg-nrpe
install  -m 555 /usr/ports/net-mgmt/Test_Build-pkg-nrpe/files/usr/local/libexec/nagios/check_carp_freebsd.sh  /usr/local/libexec/nagios/
install: /usr/local/libexec/nagios/check_carp_freebsd.sh: Permission denied
*** Error code 71

Missing the Libexec directory?

Actions #8

Updated by Viktor Gurov almost 2 years ago

fix that adds ${MKDIR} ${STAGEDIR}${PREFIX}/libexec/nagios line to Makefile:
https://github.com/pfsense/FreeBSD-ports/pull/766

Actions #9

Updated by Renato Botelho almost 2 years ago

  • Status changed from Pull Request Review to Feedback
  • Assignee set to Renato Botelho
  • % Done changed from 0 to 100

Fixed on version 3.1_2

Actions #10

Updated by Viktor Gurov almost 2 years ago

  • Status changed from Feedback to Resolved

tested on pfSense 2.5.0.a.20200211.1811 with nrpe 3.1_2

ok now

Actions

Also available in: Atom PDF