Merge lp:~brad-marshall/charms/trusty/nrpe-external-master/add-conntrack-check into lp:charms/nrpe-external-master

Proposed by Brad Marshall
Status: Needs review
Proposed branch: lp:~brad-marshall/charms/trusty/nrpe-external-master/add-conntrack-check
Merge into: lp:charms/nrpe-external-master
Diff against target: 107 lines (+74/-0)
3 files modified
config.yaml (+4/-0)
files/check_conntrack.sh (+66/-0)
hooks/config-changed (+4/-0)
To merge this branch: bzr merge lp:~brad-marshall/charms/trusty/nrpe-external-master/add-conntrack-check
Reviewer Review Type Date Requested Status
charmers Pending
Review via email: mp+321412@code.launchpad.net

Description of the change

Add iptables conntrack nrpe check

To post a comment you must log in.

Unmerged revisions

43. By Brad Marshall

Added conntrack nrpe check

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'config.yaml'
--- config.yaml 2015-05-01 13:23:24 +0000
+++ config.yaml 2017-03-30 07:26:20 +0000
@@ -64,6 +64,10 @@
64 default: "-w 90% -c 75%"64 default: "-w 90% -c 75%"
65 type: string65 type: string
66 description: Swap check66 description: Swap check
67 conntrack:
68 default: "-w 80 -c 90"
69 type: string
70 description: conntrack table check
67 hostgroups:71 hostgroups:
68 default: ""72 default: ""
69 type: string73 type: string
7074
=== added file 'files/check_conntrack.sh'
--- files/check_conntrack.sh 1970-01-01 00:00:00 +0000
+++ files/check_conntrack.sh 2017-03-30 07:26:20 +0000
@@ -0,0 +1,66 @@
1#!/bin/sh
2# This file is managed by juju. Do not make local changes.
3
4# Copyright (C) 2013, 2016 Canonical Ltd.
5# Author: Haw Loeung <haw.loeung@canonical.com>
6# Paul Gear <paul.gear@canonical.com>
7
8# Alert when current conntrack entries exceeds certain percentage of max. to
9# detect when we're about to fill it up and start dropping packets.
10
11set -eu
12
13STATE_OK=0
14STATE_WARNING=1
15STATE_CRITICAL=2
16STATE_UNKNOWN=3
17
18if ! lsmod | grep -q conntrack; then
19 echo "OK: no conntrack modules present"
20 exit $STATE_OK
21fi
22
23max=$(sysctl net.netfilter.nf_conntrack_max | awk '{ print $3 }')
24current=$(sysctl net.netfilter.nf_conntrack_count | awk '{ print $3 }')
25
26# default thresholds
27crit=90
28warn=80
29
30# parse command line
31set +e
32OPTIONS=$(getopt w:c: "$@")
33if [ $? -ne 0 ]; then
34 echo "Usage: $0 [-w warningpercent] [-c criticalpercent]" >&2
35 echo " Check nf_conntrack_count against nf_conntrack_max" >&2
36 exit $STATE_UNKNOWN
37fi
38set -e
39
40set -- $OPTIONS
41while true; do
42 case "$1" in
43 -w) warn=$2; shift 2 ;;
44 -c) crit=$2; shift 2 ;;
45 --) shift; break ;;
46 *) break ;;
47 esac
48done
49
50percent=$((current * 100 / max))
51stats="| current=$current max=$max percent=$percent;$warn;$crit"
52
53threshold=$((max * crit / 100))
54if [ $current -gt $threshold ]; then
55 echo "CRITICAL: conntrack table nearly full. $stats"
56 exit $STATE_CRITICAL
57fi
58
59threshold=$((max * warn / 100))
60if [ $current -gt $threshold ]; then
61 echo "WARNING: conntrack table filling. $stats"
62 exit $STATE_WARNING
63fi
64
65echo "OK: conntrack table normal $stats"
66exit $STATE_OK
067
=== modified file 'hooks/config-changed'
--- hooks/config-changed 2015-05-21 15:52:29 +0000
+++ hooks/config-changed 2017-03-30 07:26:20 +0000
@@ -41,6 +41,7 @@
41LOAD=$(config-get load)41LOAD=$(config-get load)
42USERS=$(config-get users)42USERS=$(config-get users)
43SWAP=$(config-get swap)43SWAP=$(config-get swap)
44CONNTRACK=$(config-get conntrack)
4445
45if [[ "$PROCS" == "auto" ]]; then46if [[ "$PROCS" == "auto" ]]; then
46 PROC_COUNT=$(nproc)47 PROC_COUNT=$(nproc)
@@ -80,6 +81,9 @@
80echo "# Swap" > /etc/nagios/nrpe.d/check_swap.cfg81echo "# Swap" > /etc/nagios/nrpe.d/check_swap.cfg
81echo "command[check_swap]=/usr/lib/nagios/plugins/check_swap ${SWAP}" >> /etc/nagios/nrpe.d/check_swap.cfg82echo "command[check_swap]=/usr/lib/nagios/plugins/check_swap ${SWAP}" >> /etc/nagios/nrpe.d/check_swap.cfg
8283
84echo "# Conntrack" > /etc/nagios/nrpe.d/check_conntrack.cfg
85echo "command[check_conntrack]=/usr/local/lib/nagios/plugins/check_conntrack.sh ${CONNTRACK}" >> /etc/nagios/nrpe.d/check_conntrack.cfg
86
83#------------------------------------------------------87#------------------------------------------------------
84# Host check88# Host check
85#------------------------------------------------------89#------------------------------------------------------

Subscribers

People subscribed via source and target branches

to all changes: