2 # -*- encoding: utf-8; py-indent-offset: 4 -*-
3 # +------------------------------------------------------------------+
4 # | ____ _ _ __ __ _ __ |
5 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
6 # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
7 # | | |___| | | | __/ (__| < | | | | . \ |
8 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
10 # | Copyright Mathias Kettner 2017 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.
28 # <<<mssql_connections>>>
29 # MSSQLSERVER master 16
30 # MSSQLSERVER tempdb 1
32 factory_settings
["mssql_connections_default_levels"] = {
37 def parse_mssql_connections(info
):
41 instance
, db_name
, connection_count
= line
42 connection_count
= int(connection_count
)
43 parsed
.setdefault("%s %s" % (instance
, db_name
), connection_count
)
49 def inventory_mssql_connections(parsed
):
54 def check_mssql_connections(item
, params
, parsed
):
55 # If a database is missing in the agent output there are no
56 # active connections for that database.
57 connection_count
= parsed
.get(item
, 0)
59 warn
, crit
= params
['levels']
60 if connection_count
>= crit
:
62 elif connection_count
>= warn
:
67 infotext
= "Connections: %d" % connection_count
69 infotext
+= " (warn/crit at %d/%d)" % (warn
, crit
)
70 return state
, infotext
, [('connections', connection_count
, warn
, crit
)]
73 check_info
['mssql_connections'] = {
74 'parse_function': parse_mssql_connections
,
75 'inventory_function': inventory_mssql_connections
,
76 'check_function': check_mssql_connections
,
77 'service_description': 'MSSQL Connections %s',
78 'group': 'mssql_connections',
79 'default_levels_variable': "mssql_connections_default_levels",