/usr/share/check_mk/checks/tcp_conn_stats is in check-mk-server 1.1.12-1ubuntu1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | #!/usr/bin/python
# -*- encoding: utf-8; py-indent-offset: 4 -*-
# +------------------------------------------------------------------+
# | ____ _ _ __ __ _ __ |
# | / ___| |__ ___ ___| | __ | \/ | |/ / |
# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
# | | |___| | | | __/ (__| < | | | | . \ |
# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
# | |
# | Copyright Mathias Kettner 2010 mk@mathias-kettner.de |
# +------------------------------------------------------------------+
#
# This file is part of Check_MK.
# The official homepage is at http://mathias-kettner.de/check_mk.
#
# check_mk is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation in version 2. check_mk is distributed
# in the hope that it will be useful, but WITHOUT ANY WARRANTY; with-
# out even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE. See the GNU General Public License for more de-
# ails. You should have received a copy of the GNU General Public
# License along with GNU Make; see the file COPYING. If not, write
# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
# Boston, MA 02110-1301 USA.
tcp_conn_stats_states = [
"ESTABLISHED", # connection up and passing data
"SYN_SENT", # session has been requested by us; waiting for reply from remote endpoint
"SYN_RECV", # session has been requested by a remote endpoint for a socket on which we were listening
"LAST_ACK", # our socket is closed; remote endpoint has also shut down; we are waiting for a final acknowledgement
"CLOSE_WAIT", # remote endpoint has shut down; the kernel is waiting for the application to close the socket
"TIME_WAIT", # socket is waiting after closing for any packets left on the network
"CLOSED", # socket is not being used (FIXME. What does mean?)
"CLOSING", # our socket is shut down; remote endpoint is shut down; not all data has been sent
"FIN_WAIT1", # our socket has closed; we are in the process of tearing down the connection
"FIN_WAIT2", # the connection has been closed; our socket is waiting for the remote endpoint to shut down
]
tcp_conn_stats_default_levels = { }
def inventory_tcp_conn_stats(info):
if len(info) > 0:
return [ (None, 'tcp_conn_stats_default_levels') ]
def check_tcp_conn_stats(item, params, info):
stats = dict(info)
worst_state = 0
info = []
perfdata = []
for state in tcp_conn_stats_states:
num = int(stats.get(state, 0))
if num > 0:
infotext = "%s: %d" % (state, num)
else:
infotext = None
levels = params.get(state)
perf = [state, num]
if levels:
warn, crit = levels
perf.append(warn)
perf.append(crit)
if num >= crit:
worst_state = 2
infotext += "(!!) (critical at %d)" % crit
elif num >= warn:
worst_state = max(1, worst_state)
infotext += "(!) (warning at %d)" % warn
perfdata.append(perf)
if infotext:
info.append(infotext)
return (worst_state, "%s - %s" % (nagios_state_names[worst_state], ", ".join(info)), perfdata)
check_info['tcp_conn_stats'] = (check_tcp_conn_stats, "TCP Connections", 1, inventory_tcp_conn_stats)
|