2 # -*- encoding: utf-8; py-indent-offset: 4 -*-
3 # +------------------------------------------------------------------+
4 # | ____ _ _ __ __ _ __ |
5 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
6 # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
7 # | | |___| | | | __/ (__| < | | | | . \ |
8 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
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 factory_settings
['cisco_ip_sla_default_levels'] = {
29 'connection_lost_occured': 'no',
30 'timeout_occured': 'no',
31 'completion_time_over_treshold_occured': 'no',
32 'latest_rtt_completion_time': (250, 500),
33 'latest_rtt_state': 'ok',
37 def parse_cisco_ip_sla(info
):
38 # since the RTT Index, Owner and Tag don't have to be set we use
39 # indices for the different items
40 precisions
= [list_
.pop() for list_
in info
[0]]
41 precisions
= {str(i
): 'ms' if p
[0] == '1' else 'us' for i
, p
in enumerate(precisions
)}
62 '19': 'ethernet ping',
63 '20': 'ethernet jitter',
64 '21': 'LSP ping pseudowire',
70 '3': 'immediate stop',
81 '3': 'over threshold',
86 '8': 'sequence error',
88 '10': 'application specific error',
91 def to_ip_address(int_list
):
92 if len(int_list
) == 4:
93 return '%d.%d.%d.%d' % tuple(int_list
)
94 elif len(int_list
) == 6:
95 return '%d:%d:%d:%d:%d:%d' % tuple(int_list
)
98 #contains description, parse function, unit and type
100 ( # rttMonEchoAdminEntry
101 ('Target address', to_ip_address
, '', None),
102 ('Source address', to_ip_address
, '', None),
104 ( # rttMonCtrlAdminEntry
105 ('Owner', None, '', None),
106 ('Tag', None, '', None),
107 ('RTT type', lambda x
: rtt_types
.get(x
, 'unknown'), '', 'option'),
108 ('Threshold', int, 'ms', 'option'),
110 ( # rttMonCtrlOperEntry
111 ('State', lambda x
: states
.get(x
, 'unknown'), '', 'option'),
112 ('Text', None, '', None),
113 ('Connection lost occured', lambda x
: 'yes' if x
== '1' else 'no', '', 'option'),
114 ('Timeout occured', lambda x
: 'yes' if x
== '1' else 'no', '', 'option'),
115 ('Completion time over treshold occured', lambda x
: 'yes' if x
== '1' else 'no', '',
118 ( # rttMonLatestRttOperEntry
119 ('Latest RTT completion time', int, 'ms/us', 'level'),
120 ('Latest RTT state', lambda x
: rtt_states
.get(x
, 'unknown'), '', 'option'),
125 for content
, entries
in zip(contents
, info
):
129 for index
, entry
in enumerate(entries
):
131 parsed
.setdefault(index
, [])
132 for (description
, parser
, unit
, type_
), value
in zip(content
, entry
):
134 value
= parser(value
)
136 unit
= precisions
[index
]
137 parsed
[index
].append((description
, value
, unit
, type_
))
142 def inventory_cisco_ip_sla(parsed
):
147 @get_parsed_item_data
148 def check_cisco_ip_sla(_item
, params
, data
):
149 for description
, value
, unit
, type_
in data
:
155 infotext
= '%s: %s %s' % (description
, value
, unit
)
157 infotext
= '%s: %s' % (description
, value
)
160 param
= params
.get(description
.lower().replace(' ', '_'))
162 if type_
== 'option':
163 if param
and param
!= value
:
165 infotext
+= ' (expected %s)' % param
166 elif type_
== 'level':
167 warn
, crit
= param
# a default level hat to exist
174 infotext
+= ' (warn/crit at %s/%s)' % (warn
, crit
)
175 factor
= 1e3
if unit
== 'ms' else 1e6
176 perfdata
= [('rtt', value
/ factor
, warn
/ factor
, crit
/ factor
)]
178 yield state
, infotext
, perfdata
181 check_info
['cisco_ip_sla'] = {
182 'parse_function': parse_cisco_ip_sla
,
183 'inventory_function': inventory_cisco_ip_sla
,
184 'check_function': check_cisco_ip_sla
,
185 'service_description': 'Cisco IP SLA %s',
186 'group': 'cisco_ip_sla',
187 'default_levels_variable': 'cisco_ip_sla_default_levels',
188 'has_perfdata': True,
189 'snmp_scan_function': lambda oid
: oid('.1.3.6.1.2.1.1.2.0') in [
190 '.1.3.6.1.4.1.9.1.2068',],
193 '.1.3.6.1.4.1.9.9.42.1.2.2.1',
195 BINARY(2), # rttMonEchoAdminTargetAddress
196 BINARY(6), # rttMonEchoAdminSourceAddress
197 # only needed to determine the unit (ms/us)
198 37, # rttMonEchoAdminPrecision
201 '.1.3.6.1.4.1.9.9.42.1.2.1.1',
203 2, # rttMonCtrlAdminOwner
204 3, # rttMonCtrlAdminTag
205 4, # rttMonCtrlAdminRttType
206 5, # rttMonCtrlAdminThreshold
209 '.1.3.6.1.4.1.9.9.42.1.2.9.1',
211 10, # rttMonCtrlOperState
212 2, # rttMonCtrlOperDiagText
213 5, # rttMonCtrlOperConnectionLostOccurred
214 6, # rttMonCtrlOperTimeoutOccurred
215 7, # rttMonCtrlOperOverThresholdOccurred
218 '.1.3.6.1.4.1.9.9.42.1.2.10.1',
220 1, # rttMonLatestRttOperCompletionTime
221 2, # rttMonLatestRttOperSense