2 # -*- encoding: utf-8; py-indent-offset: 4 -*-
3 # +------------------------------------------------------------------+
4 # | ____ _ _ __ __ _ __ |
5 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
6 # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
7 # | | |___| | | | __/ (__| < | | | | . \ |
8 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
10 # | Copyright Mathias Kettner 2016 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.
26 """This module serves constants which are needed in several components
29 from cmk
.utils
.i18n
import _
31 # TODO: Investigate Check_MK code for more defines and other places
32 # where similar strucures are defined and use the things from
33 # here or move new stuff to this module.
36 # TODO: Rename to service_state_names()
37 def core_state_names():
47 def service_state_name(state_num
, deflt
=""):
48 return core_state_names().get(state_num
, deflt
)
51 def short_service_state_names():
61 def short_service_state_name(state_num
, deflt
=""):
62 return short_service_state_names().get(state_num
, deflt
)
65 def host_state_name(state_num
, deflt
=""):
71 return states
.get(state_num
, deflt
)
74 def short_host_state_name(state_num
, deflt
=""):
75 states
= {0: _("UP"), 1: _("DOWN"), 2: _("UNREACH")}
76 return states
.get(state_num
, deflt
)
79 def weekday_name(day_num
):
80 """Returns the human readable day name of a given weekday number (starting with 0 at Monday)"""
81 return weekdays()[day_num
]
85 """Returns a list of the internal week day names"""
86 return [d
[0] for d
in weekdays_by_name()]
90 """Returns a map of weekday number (starting with 0 at Monday) to the human readable day name"""
102 def weekdays_by_name():
103 """Returns a list of two element tuples containing the weekday ID and the human readable day name"""
105 ("monday", _("Monday")),
106 ("tuesday", _("Tuesday")),
107 ("wednesday", _("Wednesday")),
108 ("thursday", _("Thursday")),
109 ("friday", _("Friday")),
110 ("saturday", _("Saturday")),
111 ("sunday", _("Sunday")),
115 def month_name(month_num
):
116 """Returns the human readable month name of a given month number
117 (starting with 0 = January)"""
134 def interface_oper_state_name(state_num
, deflt
=""):
135 return interface_oper_states().get(state_num
, deflt
)
138 def interface_oper_states():
146 7: _("lower layer down"),
147 8: _("degraded"), # artificial, not official
148 9: _("admin down"), # artificial, not official
152 def interface_port_types():
161 8: "iso88024TokenBus",
162 9: "iso88025TokenRing",
175 22: "propPointToPointSerial",
177 24: "softwareLoopback",
197 44: "frameRelayService",
207 54: "propMultiplexor",
210 57: "hippiInterface",
211 58: "frameRelayInterconnect",
251 98: "iso88025CRFPInt",
261 108: "pppMultilinkBundle",
265 112: "virtualIpAddress",
268 115: "iso88025Fiber",
270 117: "gigabitEthernet",
280 127: "docsCableMaclayer",
281 128: "docsCableDownstream",
282 129: "docsCableUpstream",
287 134: "atmSubInterface",
291 138: "digitalPowerline",
292 139: "mediaMailOverIp",
299 146: "dvbRccMacLayer",
300 147: "dvbRccDownstream",
301 148: "dvbRccUpstream",
306 153: "voiceOverFrameRelay",
308 155: "compositeLink",
310 157: "propWirelessP2P",
314 161: "ieee8023adLag",
315 162: "bgppolicyaccounting",
316 163: "frf16MfrBundle",
317 164: "h323Gatekeeper",
333 180: "propDocsWirelessMaclayer",
334 181: "propDocsWirelessDownstream",
335 182: "propDocsWirelessUpstream",
338 185: "sonetOverheadChannel",
339 186: "digitalWrapperOverheadChannel",
348 195: "opticalChannel",
349 196: "opticalTransport",
351 198: "voiceOverCable",
358 205: "docsCableUpstreamChannel",
367 214: "mpegTransport",
370 217: "pdnEtherLoop1",
371 218: "pdnEtherLoop2",
372 219: "opticalChannelGroup",
376 223: "actelisMetaLOOP",
382 229: "docsCableMCmtsDownstream",
384 231: "macSecControlledIF",
385 232: "macSecUncontrolledIF",
386 233: "aviciOpticalEther",
390 237: "ieee80216WMAN",
392 239: "dvbRcsMacLayer",
405 252: "capwapDot11Profile",
406 253: "capwapDot11Bss",
407 254: "capwapWtpVirtualRadio",
409 256: "docsCableUpstreamRfPort",
410 257: "cableDownstreamRfPort",
411 258: "vmwareVirtualNic",
421 268: "aluEponPhysicalUni",
422 269: "aluEponLogicalLink",
424 271: "aluGponPhysicalUni",
425 272: "vmwareNicTeam",
426 277: "docsOfdmDownstream",
427 278: "docsOfdmaUpstream",
432 283: "docsCableScte55d1FwdOob",
433 284: "docsCableScte55d1RetOob",
434 285: "docsCableScte55d2DsOob",
435 286: "docsCableScte55d2UsOob",