GUI CSS: Removed snapin styles from py modules and added a _snapins.scss for the...
[check_mk.git] / checks / genua_pfstate
blob61dd6720aeadee1049c9ce1803cf7e3fa58079e4
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 Agent Output:
28 # GENUA-MIB:
29 # .1.3.6.1.4.1.3717.2.1.1.6.1 = INTEGER: 300000
30 # .1.3.6.1.4.1.3717.2.1.1.6.2 = INTEGER: 1268
31 # .1.3.6.1.4.1.3717.2.1.1.6.3 = INTEGER: 1
33 genua_pfstate_default_levels = {"used": (None, None)}
36 def inventory_genua_pfstate(info):
37 # remove empty elements due to alternative enterprise id in snmp_info
38 info = filter(None, info)
40 if not info or not info[0]:
41 return
43 if len(info[0][0]) == 3:
44 return [(None, genua_pfstate_default_levels)]
47 def pfstate(st):
48 names = {
49 '0': 'notOK',
50 '1': 'OK',
51 '2': 'unknown',
53 return names.get(st, st)
56 def check_genua_pfstate(item, params, info):
57 # remove empty elements due to alternative enterprise id in snmp_info
58 info = filter(None, info)
60 if info[0]:
61 if len(info[0][0]) == 3:
62 pfstateMax = saveint(info[0][0][0])
63 pfstateUsed = saveint(info[0][0][1])
64 pfstateStatus = info[0][0][2]
65 else:
66 return (3, "Invalid Output from Agent")
68 warn, crit = params.get("used")
69 if crit is None:
70 crit = pfstateMax
72 state = 0
73 usedsym = ""
74 statussym = ""
75 if pfstateStatus != "1":
76 state = 1
77 statussym = "(!)"
79 if crit and pfstateUsed > crit:
80 state = 2
81 usedsym = "(!!)"
82 elif warn and pfstateUsed > warn:
83 state = 1
84 usedsym = "(!)"
86 pfstatus = pfstate(str(pfstateStatus))
87 infotext = "PF State: %s%s States used: %d%s States max: %d" \
88 % (pfstatus, statussym, pfstateUsed, usedsym, pfstateMax )
89 perfdata = [("statesused", pfstateUsed, None, pfstateMax)]
90 return (state, infotext, perfdata)
93 check_info['genua_pfstate'] = {
94 "inventory_function": inventory_genua_pfstate,
95 "check_function": check_genua_pfstate,
96 "service_description": "Paketfilter Status",
97 "has_perfdata": True,
98 "group": "pf_used_states",
99 "snmp_info": [
101 ".1.3.6.1.4.1.3717.2.1.1.6",
103 1, # "pfstateMax"
104 2, # "pfstateUsed"
105 3, # "pfstateStatus"
108 ".1.3.6.1.4.1.3137.2.1.1.6",
110 1, # "pfstateMax"
111 2, # "pfstateUsed"
112 3, # "pfstateStatus"
115 "snmp_scan_function": scan_genua,
116 "includes": ["genua.include"],