Add check: check_available_conntrack
This commit is contained in:
parent
10d065871a
commit
c0242386a1
59
conf/usr/local/bin/check_available_conntrack
Executable file
59
conf/usr/local/bin/check_available_conntrack
Executable file
@ -0,0 +1,59 @@
|
||||
#!/bin/bash
|
||||
|
||||
################################################################################
|
||||
# BSD 3-Clause License
|
||||
#
|
||||
# Copyright (c) 2019, Alban Vidal <alban.vidal@zordhak.fr>
|
||||
# All rights reserved.
|
||||
#
|
||||
# Please see license file on root of this directory
|
||||
################################################################################
|
||||
|
||||
# !! GIT FILE !!
|
||||
# https://framagit.org/zorval/scripts/check-nrpe
|
||||
|
||||
################################################################################
|
||||
|
||||
# ConnTrack files
|
||||
FILE_CONNTRACK_MAX="/proc/sys/net/netfilter/nf_conntrack_max"
|
||||
FILE_CONNTRACK_COUNT="/proc/sys/net/netfilter/nf_conntrack_count"
|
||||
|
||||
if [[ ! -f "$FILE_CONNTRACK_MAX" || ! -f "$FILE_CONNTRACK_COUNT" ]] ; then
|
||||
echo "Error, one of this files does not exists :"
|
||||
echo " - $FILE_CONNTRACK_MAX"
|
||||
echo " - $FILE_CONNTRACK_COUNT"
|
||||
exit2
|
||||
fi
|
||||
|
||||
################################################################################
|
||||
|
||||
# Initialize variables
|
||||
RESULT=""
|
||||
PERF_DATA=""
|
||||
CONNTRACK_WARN=${CONNTRACK_WARN:=80}
|
||||
CONNTRACK_CRIT=${CONNTRACK_CRIT:=90}
|
||||
EXIT_CODE=0
|
||||
|
||||
################################################################################
|
||||
|
||||
# Get conntrack values
|
||||
CONNTRACK_MAX=$(cat $FILE_CONNTRACK_MAX)
|
||||
CONNTRACK_COUNT=$(cat $FILE_CONNTRACK_COUNT)
|
||||
|
||||
WARN_COUNT=$(( CONNTRACK_MAX * CONNTRACK_WARN / 100 ))
|
||||
CRIT_COUNT=$(( CONNTRACK_MAX * CONNTRACK_CRIT / 100 ))
|
||||
|
||||
USAGE_PERCENT=$(( CONNTRACK_COUNT * 100 / CONNTRACK_MAX ))
|
||||
|
||||
# Test percent for output
|
||||
if [ $USAGE_PERCENT -ge $CONNTRACK_CRIT ] ; then
|
||||
EXIT_CODE=2
|
||||
elif [ $USAGE_PERCENT -ge $CONNTRACK_WARN ] ; then
|
||||
EXIT_CODE=1
|
||||
fi
|
||||
|
||||
RESULT="Conntrack usage: ${USAGE_PERCENT}% (${CONNTRACK_COUNT}/${CONNTRACK_MAX})"
|
||||
PERF_DATA="conntrack_table=$CONNTRACK_COUNT;$WARN_COUNT;$CRIT_COUNT;0;$CONNTRACK_MAX"
|
||||
|
||||
echo "$RESULT | $PERF_DATA"
|
||||
exit $EXIT_CODE
|
Loading…
Reference in New Issue
Block a user