Cleanup config.nodes_of
[check_mk.git] / checks / netscaler_sslcertificates
blobd7dcda30da9dba0dcfd53bf91feb1a490673f207
1 #!/usr/bin/python
2 # -*- encoding: utf-8; py-indent-offset: 4 -*-
3 # +------------------------------------------------------------------+
4 # | ____ _ _ __ __ _ __ |
5 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
6 # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
7 # | | |___| | | | __/ (__| < | | | | . \ |
8 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
9 # | |
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 # example SNMP output:
30 # .1.3.6.1.4.1.5951.4.1.1.56.1.1.1.20.67.79.77.79.68.79.95.82.83.65.95.67.101.114.116.95.65.117.116.104 COMODO_RSA_Cert_Auth
31 # .1.3.6.1.4.1.5951.4.1.1.56.1.1.1.21.110.115.45.115.101.114.118.101.114.45.99.101.114.116.105.102.105.99.97.116.101 ns-server-certificate
32 # .1.3.6.1.4.1.5951.4.1.1.56.1.1.1.25.67.79.77.79.68.79.95.82.83.65.95.67.101.114.116.95.65.117.116.104.95.82.111.111.116 COMODO_RSA_Cert_Auth_Root
33 # .1.3.6.1.4.1.5951.4.1.1.56.1.1.5.20.67.79.77.79.68.79.95.82.83.65.95.67.101.114.116.95.65.117.116.104 4286
34 # .1.3.6.1.4.1.5951.4.1.1.56.1.1.5.21.110.115.45.115.101.114.118.101.114.45.99.101.114.116.105.102.105.99.97.116.101 3655
35 # .1.3.6.1.4.1.5951.4.1.1.56.1.1.5.25.67.79.77.79.68.79.95.82.83.65.95.67.101.114.116.95.65.117.116.104.95.82.111.111.116 1106
37 factory_settings["netscaler_sslcerts_default_levels"] = {
38 "age_levels": (30, 10),
42 def inventory_netscaler_sslcerts(info):
43 for _node, certname, _daysleft in info:
44 if certname:
45 yield certname, {}
48 def check_netscaler_sslcerts(item, params, info):
49 for node, certname, daysleft in info:
50 if certname == item:
51 state, daysleft = 0, int(daysleft)
52 warn, crit = params["age_levels"]
54 if daysleft <= crit:
55 state = 2
56 elif daysleft <= warn:
57 state = 1
59 infotext = "Certificate valid for %d days" % daysleft
61 if node:
62 infotext = ": ".join([node, infotext])
64 if state > 0:
65 infotext += " (warn/crit below %s/%s)" % (warn, crit)
67 yield state, infotext, [("daysleft", daysleft, warn, crit)]
70 check_info["netscaler_sslcertificates"] = {
71 "check_function": check_netscaler_sslcerts,
72 "inventory_function": inventory_netscaler_sslcerts,
73 "service_description": "SSL Certificate %s",
74 "node_info": True,
75 "snmp_info": (
76 ".1.3.6.1.4.1.5951.4.1.1.56.1.1",
78 1, # sslCertKeyName
79 5, # sslDaysToExpire
80 ]),
81 "has_perfdata": True,
82 "snmp_scan_function": lambda oid: oid(".1.3.6.1.2.1.1.2.0").startswith(".1.3.6.1.4.1.5951.1"),
83 "group": "netscaler_sslcerts",
84 "default_levels_variable": "netscaler_sslcerts_default_levels",