Refactoring: Changed remaining check parameters starting with an 's' to the new rules...
[check_mk.git] / cmk / utils / defines.py
blobe94c09cd23a17808c99e572ee9b448fc689c6c90
1 #!/usr/bin/python
2 # -*- encoding: utf-8; py-indent-offset: 4 -*-
3 # +------------------------------------------------------------------+
4 # | ____ _ _ __ __ _ __ |
5 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
6 # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
7 # | | |___| | | | __/ (__| < | | | | . \ |
8 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
9 # | |
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
27 of Check_MK."""
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():
38 return {
39 -1: _("NODATA"),
40 0: _("OK"),
41 1: _("WARNING"),
42 2: _("CRITICAL"),
43 3: _("UNKNOWN"),
47 def service_state_name(state_num, deflt=""):
48 return core_state_names().get(state_num, deflt)
51 def short_service_state_names():
52 return {
53 -1: _("PEND"),
54 0: _("OK"),
55 1: _("WARN"),
56 2: _("CRIT"),
57 3: _("UNKN"),
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=""):
66 states = {
67 0: _("UP"),
68 1: _("DOWN"),
69 2: _("UNREACHABLE"),
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]
84 def weekday_ids():
85 """Returns a list of the internal week day names"""
86 return [d[0] for d in weekdays_by_name()]
89 def weekdays():
90 """Returns a map of weekday number (starting with 0 at Monday) to the human readable day name"""
91 return {
92 0: _("Monday"),
93 1: _("Tuesday"),
94 2: _("Wednesday"),
95 3: _("Thursday"),
96 4: _("Friday"),
97 5: _("Saturday"),
98 6: _("Sunday"),
102 def weekdays_by_name():
103 """Returns a list of two element tuples containing the weekday ID and the human readable day name"""
104 return [
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)"""
118 return [
119 _("January"),
120 _("February"),
121 _("March"),
122 _("April"),
123 _("May"),
124 _("June"),
125 _("July"),
126 _("August"),
127 _("September"),
128 _("October"),
129 _("November"),
130 _("December"),
131 ][month_num]
134 def interface_oper_state_name(state_num, deflt=""):
135 return interface_oper_states().get(state_num, deflt)
138 def interface_oper_states():
139 return {
140 1: _("up"),
141 2: _("down"),
142 3: _("testing"),
143 4: _("unknown"),
144 5: _("dormant"),
145 6: _("not present"),
146 7: _("lower layer down"),
147 8: _("degraded"), # artificial, not official
148 9: _("admin down"), # artificial, not official
152 def interface_port_types():
153 return {
154 1: "other",
155 2: "regular1822",
156 3: "hdh1822",
157 4: "ddnX25",
158 5: "rfc877x25",
159 6: "ethernetCsmacd",
160 7: "iso88023Csmacd",
161 8: "iso88024TokenBus",
162 9: "iso88025TokenRing",
163 10: "iso88026Man",
164 11: "starLan",
165 12: "proteon10Mbit",
166 13: "proteon80Mbit",
167 14: "hyperchannel",
168 15: "fddi",
169 16: "lapb",
170 17: "sdlc",
171 18: "ds1",
172 19: "e1",
173 20: "basicISDN",
174 21: "primaryISDN",
175 22: "propPointToPointSerial",
176 23: "ppp",
177 24: "softwareLoopback",
178 25: "eon",
179 26: "ethernet3Mbit",
180 27: "nsip",
181 28: "slip",
182 29: "ultra",
183 30: "ds3",
184 31: "sip",
185 32: "frameRelay",
186 33: "rs232",
187 34: "para",
188 35: "arcnet",
189 36: "arcnetPlus",
190 37: "atm",
191 38: "miox25",
192 39: "sonet",
193 40: "x25ple",
194 41: "iso88022llc",
195 42: "localTalk",
196 43: "smdsDxi",
197 44: "frameRelayService",
198 45: "v35",
199 46: "hssi",
200 47: "hippi",
201 48: "modem",
202 49: "aal5",
203 50: "sonetPath",
204 51: "sonetVT",
205 52: "smdsIcip",
206 53: "propVirtual",
207 54: "propMultiplexor",
208 55: "ieee80212",
209 56: "fibreChannel",
210 57: "hippiInterface",
211 58: "frameRelayInterconnect",
212 59: "aflane8023",
213 60: "aflane8025",
214 61: "cctEmul",
215 62: "fastEther",
216 63: "isdn",
217 64: "v11",
218 65: "v36",
219 66: "g703at64k",
220 67: "g703at2mb",
221 68: "qllc",
222 69: "fastEtherFX",
223 70: "channel",
224 71: "ieee80211",
225 72: "ibm370parChan",
226 73: "escon",
227 74: "dlsw",
228 75: "isdns",
229 76: "isdnu",
230 77: "lapd",
231 78: "ipSwitch",
232 79: "rsrb",
233 80: "atmLogical",
234 81: "ds0",
235 82: "ds0Bundle",
236 83: "bsc",
237 84: "async",
238 85: "cnr",
239 86: "iso88025Dtr",
240 87: "eplrs",
241 88: "arap",
242 89: "propCnls",
243 90: "hostPad",
244 91: "termPad",
245 92: "frameRelayMPI",
246 93: "x213",
247 94: "adsl",
248 95: "radsl",
249 96: "sdsl",
250 97: "vdsl",
251 98: "iso88025CRFPInt",
252 99: "myrinet",
253 100: "voiceEM",
254 101: "voiceFXO",
255 102: "voiceFXS",
256 103: "voiceEncap",
257 104: "voiceOverIp",
258 105: "atmDxi",
259 106: "atmFuni",
260 107: "atmIma",
261 108: "pppMultilinkBundle",
262 109: "ipOverCdlc",
263 110: "ipOverClaw",
264 111: "stackToStack",
265 112: "virtualIpAddress",
266 113: "mpc",
267 114: "ipOverAtm",
268 115: "iso88025Fiber",
269 116: "tdlc",
270 117: "gigabitEthernet",
271 118: "hdlc",
272 119: "lapf",
273 120: "v37",
274 121: "x25mlp",
275 122: "x25huntGroup",
276 123: "trasnpHdlc",
277 124: "interleave",
278 125: "fast",
279 126: "ip",
280 127: "docsCableMaclayer",
281 128: "docsCableDownstream",
282 129: "docsCableUpstream",
283 130: "a12MppSwitch",
284 131: "tunnel",
285 132: "coffee",
286 133: "ces",
287 134: "atmSubInterface",
288 135: "l2vlan",
289 136: "l3ipvlan",
290 137: "l3ipxvlan",
291 138: "digitalPowerline",
292 139: "mediaMailOverIp",
293 140: "dtm",
294 141: "dcn",
295 142: "ipForward",
296 143: "msdsl",
297 144: "ieee1394",
298 145: "if-gsn",
299 146: "dvbRccMacLayer",
300 147: "dvbRccDownstream",
301 148: "dvbRccUpstream",
302 149: "atmVirtual",
303 150: "mplsTunnel",
304 151: "srp",
305 152: "voiceOverAtm",
306 153: "voiceOverFrameRelay",
307 154: "idsl",
308 155: "compositeLink",
309 156: "ss7SigLink",
310 157: "propWirelessP2P",
311 158: "frForward",
312 159: "rfc1483",
313 160: "usb",
314 161: "ieee8023adLag",
315 162: "bgppolicyaccounting",
316 163: "frf16MfrBundle",
317 164: "h323Gatekeeper",
318 165: "h323Proxy",
319 166: "mpls",
320 167: "mfSigLink",
321 168: "hdsl2",
322 169: "shdsl",
323 170: "ds1FDL",
324 171: "pos",
325 172: "dvbAsiIn",
326 173: "dvbAsiOut",
327 174: "plc",
328 175: "nfas",
329 176: "tr008",
330 177: "gr303RDT",
331 178: "gr303IDT",
332 179: "isup",
333 180: "propDocsWirelessMaclayer",
334 181: "propDocsWirelessDownstream",
335 182: "propDocsWirelessUpstream",
336 183: "hiperlan2",
337 184: "propBWAp2Mp",
338 185: "sonetOverheadChannel",
339 186: "digitalWrapperOverheadChannel",
340 187: "aal2",
341 188: "radioMAC",
342 189: "atmRadio",
343 190: "imt",
344 191: "mvl",
345 192: "reachDSL",
346 193: "frDlciEndPt",
347 194: "atmVciEndPt",
348 195: "opticalChannel",
349 196: "opticalTransport",
350 197: "propAtm",
351 198: "voiceOverCable",
352 199: "infiniband",
353 200: "teLink",
354 201: "q2931",
355 202: "virtualTg",
356 203: "sipTg",
357 204: "sipSig",
358 205: "docsCableUpstreamChannel",
359 206: "econet",
360 207: "pon155",
361 208: "pon622",
362 209: "bridge",
363 210: "linegroup",
364 211: "voiceEMFGD",
365 212: "voiceFGDEANA",
366 213: "voiceDID",
367 214: "mpegTransport",
368 215: "sixToFour",
369 216: "gtp",
370 217: "pdnEtherLoop1",
371 218: "pdnEtherLoop2",
372 219: "opticalChannelGroup",
373 220: "homepna",
374 221: "gfp",
375 222: "ciscoISLvlan",
376 223: "actelisMetaLOOP",
377 224: "fcipLink",
378 225: "rpr",
379 226: "qam",
380 227: "lmp",
381 228: "cblVectaStar",
382 229: "docsCableMCmtsDownstream",
383 230: "adsl2",
384 231: "macSecControlledIF",
385 232: "macSecUncontrolledIF",
386 233: "aviciOpticalEther",
387 234: "atmbond",
388 235: "voiceFGDOS",
389 236: "mocaVersion1",
390 237: "ieee80216WMAN",
391 238: "adsl2plus",
392 239: "dvbRcsMacLayer",
393 240: "dvbTdm",
394 241: "dvbRcsTdma",
395 242: "x86Laps",
396 243: "wwanPP",
397 244: "wwanPP2",
398 245: "voiceEBS",
399 246: "ifPwType",
400 247: "ilan",
401 248: "pip",
402 249: "aluELP",
403 250: "gpon",
404 251: "vdsl2",
405 252: "capwapDot11Profile",
406 253: "capwapDot11Bss",
407 254: "capwapWtpVirtualRadio",
408 255: "bits",
409 256: "docsCableUpstreamRfPort",
410 257: "cableDownstreamRfPort",
411 258: "vmwareVirtualNic",
412 259: "ieee802154",
413 260: "otnOdu",
414 261: "otnOtu",
415 262: "ifVfiType",
416 263: "g9981",
417 264: "g9982",
418 265: "g9983",
419 266: "aluEpon",
420 267: "aluEponOnu",
421 268: "aluEponPhysicalUni",
422 269: "aluEponLogicalLink",
423 270: "aluGponOnu",
424 271: "aluGponPhysicalUni",
425 272: "vmwareNicTeam",
426 277: "docsOfdmDownstream",
427 278: "docsOfdmaUpstream",
428 279: "gfast",
429 280: "sdci",
430 281: "xboxWireless",
431 282: "fastdsl",
432 283: "docsCableScte55d1FwdOob",
433 284: "docsCableScte55d1RetOob",
434 285: "docsCableScte55d2DsOob",
435 286: "docsCableScte55d2UsOob",
436 287: "docsCableNdf",
437 288: "docsCableNdr",
438 289: "ptm",
439 290: "ghn",