Refactoring: Changed all check parameters starting with an 'o' to the new rulespec...
[check_mk.git] / checks / win_netstat
blob7a12b7b6ad9afc3317e528e6814dfd1718dfa361
1 #!/usr/bin/python
2 # -*- encoding: utf-8; py-indent-offset: 4 -*-
3 # +------------------------------------------------------------------+
4 # | ____ _ _ __ __ _ __ |
5 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
6 # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
7 # | | |___| | | | __/ (__| < | | | | . \ |
8 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
9 # | |
10 # | Copyright Mathias Kettner 2014 mk@mathias-kettner.de |
11 # +------------------------------------------------------------------+
13 # This file is part of Check_MK.
14 # The official homepage is at http://mathias-kettner.de/check_mk.
16 # check_mk is free software; you can redistribute it and/or modify it
17 # under the terms of the GNU General Public License as published by
18 # the Free Software Foundation in version 2. check_mk is distributed
19 # in the hope that it will be useful, but WITHOUT ANY WARRANTY; with-
20 # out even the implied warranty of MERCHANTABILITY or FITNESS FOR A
21 # PARTICULAR PURPOSE. See the GNU General Public License for more de-
22 # tails. You should have received a copy of the GNU General Public
23 # License along with GNU Make; see the file COPYING. If not, write
24 # to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
25 # Boston, MA 02110-1301 USA.
27 # Example output from agent (German Windows XP)
28 # <<<win_netstat>>>
30 # Aktive Verbindungen
32 # Proto Lokale Adresse Remoteadresse Status
33 # TCP 0.0.0.0:135 0.0.0.0:0 ABH™REN
34 # TCP 0.0.0.0:445 0.0.0.0:0 ABH™REN
35 # TCP 0.0.0.0:2869 0.0.0.0:0 ABH™REN
36 # TCP 0.0.0.0:6556 0.0.0.0:0 ABH™REN
37 # TCP 10.1.1.99:139 0.0.0.0:0 ABH™REN
38 # TCP 10.1.1.99:445 10.1.1.123:52820 HERGESTELLT
39 # TCP 10.1.1.99:6556 10.1.1.50:43257 WARTEND
40 # TCP 10.1.1.99:6556 10.1.1.50:43288 WARTEND
41 # TCP 10.1.1.99:6556 10.1.1.50:43309 WARTEND
42 # TCP 127.0.0.1:1029 127.0.0.1:5354 HERGESTELLT
43 # TCP 127.0.0.1:1030 0.0.0.0:0 ABH™REN
44 # TCP 127.0.0.1:1040 127.0.0.1:27015 HERGESTELLT
45 # TCP 127.0.0.1:5354 0.0.0.0:0 ABH™REN
46 # TCP 127.0.0.1:5354 127.0.0.1:1029 HERGESTELLT
47 # TCP 127.0.0.1:27015 0.0.0.0:0 ABH™REN
48 # TCP 127.0.0.1:27015 127.0.0.1:1040 HERGESTELLT
49 # UDP 0.0.0.0:445 *:*
50 # UDP 0.0.0.0:500 *:*
51 # UDP 127.0.0.1:1042 *:*
52 # UDP 127.0.0.1:1900 *:*
54 win_netstat_states = {
55 # German
56 u"ABH\x99REN": "LISTENING",
57 "HERGESTELLT": "ESTABLISHED",
58 "WARTEND": "TIME_WAIT",
59 # Add further states in any required language here. Sorry, Windows
60 # has no "unset LANG" ;-)
64 def parse_win_netstat(info):
65 connections = []
66 for line in info:
67 if line[0] == "TCP":
68 proto, local, remote, connstate = line
69 elif line[0] == "UDP":
70 proto, local, remote = line
71 connstate = "LISTEN"
72 else:
73 continue
74 connections.append((proto, local.rsplit(":", 1), remote.rsplit(":", 1),
75 win_netstat_states.get(connstate, connstate)))
76 return connections
79 check_info["win_netstat"] = {
80 'parse_function': parse_win_netstat,
81 'check_function': check_netstat_generic,
82 'service_description': "TCP Connection %s",
83 'group': "tcp_connections",
84 'includes': ["netstat.include"],
85 'has_perfdata': True,