*Remove empty brackets from a class, so it python 2.4 doesn't complain
[shinken.git] / shinken / modules / livestatus_broker / livestatus.py
blob3c97444ed4a033469c0695429e7ff8a0e6a0a177
1 #!/usr/bin/python
2 #Copyright (C) 2009 Gabes Jean, naparuba@gmail.com
4 #This file is part of Shinken.
6 #Shinken is free software: you can redistribute it and/or modify
7 #it under the terms of the GNU Affero General Public License as published by
8 #the Free Software Foundation, either version 3 of the License, or
9 #(at your option) any later version.
11 #Shinken is distributed in the hope that it will be useful,
12 #but WITHOUT ANY WARRANTY; without even the implied warranty of
13 #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 #GNU Affero General Public License for more details.
16 #You should have received a copy of the GNU Affero General Public License
17 #along with Shinken. If not, see <http://www.gnu.org/licenses/>.
20 #File for a Livestatus class which can be used by the status-dat-broker
21 import re
22 import Queue
23 import copy
24 import os
25 import time
26 try:
27 import json
28 except ImportError:
29 import simplejson as json
30 try:
31 import sqlite3
32 except ImportError:
33 try:
34 import pysqlite2.dbapi2 as sqlite3
35 except ImportError:
36 import sqlite as sqlite3
38 from shinken.bin import VERSION
39 from shinken.objects import Service
40 from shinken.external_command import ExternalCommand
41 from shinken.macroresolver import MacroResolver
42 from shinken.util import from_bool_to_int,from_list_to_split,from_float_to_int,to_int,to_split,get_customs_keys,get_customs_values
45 LOGCLASS_INFO = 0 # all messages not in any other class
46 LOGCLASS_ALERT = 1 # alerts: the change service/host state
47 LOGCLASS_PROGRAM = 2 # important programm events (restart, ...)
48 LOGCLASS_NOTIFICATION = 3 # host/service notifications
49 LOGCLASS_PASSIVECHECK = 4 # passive checks
50 LOGCLASS_COMMAND = 5 # external commands
51 LOGCLASS_STATE = 6 # initial or current states
52 LOGCLASS_INVALID = -1 # never stored
53 LOGCLASS_ALL = 0xffff
54 LOGOBJECT_INFO = 0
55 LOGOBJECT_HOST = 1
56 LOGOBJECT_SERVICE = 2
57 LOGOBJECT_CONTACT = 3
60 def get_livestatus_full_name(prop, ref, request):
61 """Returns a host's or a service's name in livestatus notation.
63 This function takes either a host or service object as it's first argument.
64 The third argument is a livestatus request object. The important information
65 in the request object is the separators array. It contains the character
66 that separates host_name and service_description which is used for services'
67 names with the csv output format. If the output format is json, services' names
68 are lists composed of host_name and service_description.
69 """
70 cls_name = prop.__class__.my_type
71 if request.response.outputformat == 'csv':
72 if cls_name == 'service':
73 return prop.host_name + request.response.separators[3] + prop.service_description
74 else:
75 return prop.host_name
76 elif request.response.outputformat == 'json' or request.response.outputformat == 'python':
77 if cls_name == 'service':
78 return [prop.host_name, prop.service_description]
79 else:
80 return prop.host_name
81 pass
84 def from_svc_hst_distinct_lists(dct):
85 """Transform a dict with keys hosts and services to a list."""
86 t = []
87 for h in dct['hosts']:
88 t.append(h)
89 for s in dct['services']:
90 t.append(s)
91 return t
94 def worst_host_state(state_1, state_2):
95 """Return the worst of two host states."""
96 #lambda x: reduce(lambda g, c: c if g == 0 else (c if c == 1 else g), (y.state_id for y in x), 0),
97 if state_2 == 0:
98 return state_1
99 if state_1 == 1:
100 return state_1
101 return state_2
104 def worst_service_state(state_1, state_2):
105 """Return the worst of two service states."""
106 #reduce(lambda g, c: c if g == 0 else (c if c == 2 else (c if (c == 3 and g != 2) else g)), (z.state_id for y in x for z in y.services if z.state_type_id == 1), 0),
107 if state_2 == 0:
108 return state_1
109 if state_1 == 2:
110 return state_1
111 if state_1 == 3 and state_2 != 2:
112 return state_1
113 return state_2
116 def find_pnp_perfdata_xml(name, ref, request):
117 """Check if a pnp xml file exists for a given host or service name."""
118 if request.pnp_path_readable:
119 if '/' in name:
120 # It is a service
121 if os.access(request.pnp_path + '/' + name + '.xml', os.R_OK):
122 return 1
123 else:
124 # It is a host
125 if os.access(request.pnp_path + '/' + name + '/_HOST_.xml', os.R_OK):
126 return 1
127 # If in doubt, there is no pnp file
128 return 0
131 class Problem:
132 def __init__(self, source, impacts):
133 self.source = source
134 self.impacts = impacts
138 class Logline(dict):
139 """A class which represents a line from the logfile
141 Public functions:
142 fill -- Attach host and/or service objects to a Logline object
146 def __init__(self, cursor, row):
147 for idx, col in enumerate(cursor.description):
148 setattr(self, col[0], row[idx])
151 def fill(self, hosts, services, hostname_lookup_table, servicename_lookup_table, columns):
152 """Attach host and/or service objects to a Logline object
154 Lines describing host or service events only contain host_name
155 and/or service_description. This method finds the corresponding
156 objects and adds them to the line as attributes log_host
157 and/or log_service
160 if self.logobject == LOGOBJECT_HOST:
161 if self.host_name in hostname_lookup_table:
162 setattr(self, 'log_host', hosts[hostname_lookup_table[self.host_name]])
163 elif self.logobject == LOGOBJECT_SERVICE:
164 if self.host_name in hostname_lookup_table:
165 setattr(self, 'log_host', hosts[hostname_lookup_table[self.host_name]])
166 if self.host_name + self.service_description in servicename_lookup_table:
167 setattr(self, 'log_service', services[servicename_lookup_table[self.host_name + self.service_description]])
168 return self
172 class MyLifoQueue(Queue.Queue):
173 """A class that implements a Fifo.
175 Python versions < 2.5 do not have the Queue.LifoQueue class.
176 MyLifoQueue overwrites methods of the Queue.Queue class and
177 then behaves like Queue.LifoQueue.
181 def _init(self, maxsize):
182 self.maxsize = maxsize
183 self.queue = []
186 def _qsize(self, len=len):
187 return len(self.queue)
190 def _put(self, item):
191 self.queue.append(item)
194 def _get(self):
195 return self.queue.pop()
199 class LiveStatusStack:
200 """A Lifo queue for filter functions.
202 This class inherits either from MyLifoQueue or Queue.LifoQueue
203 whatever is available with the current python version.
205 Public functions:
206 and_elements -- takes a certain number (given as argument)
207 of filters from the stack, creates a new filter and puts
208 this filter on the stack. If these filters are lambda functions,
209 the new filter is a boolean and of the underlying filters.
210 If the filters are sql where-conditions, they are also concatenated
211 with and to form a new string containing a more complex where-condition.
213 or_elements --- the same, only that the single filters are
214 combined with a logical or.
218 def __init__(self, *args, **kw):
219 self.type = 'lambda'
220 self.__class__.__bases__[0].__init__(self, *args, **kw)
223 def and_elements(self, num):
224 """Take num filters from the stack, and them and put the result back"""
225 if num > 1:
226 filters = []
227 for i in range(num):
228 filters.append(self.get())
229 # Take from the stack:
230 # Make a combined anded function
231 # Put it on the stack
232 if self.type == 'sql':
233 # Must be a SQL filter
234 and_clause = '(' + (' AND ').join([ x()[0] for x in filters ]) + ')'
235 and_values = reduce(lambda x, y: x+y, [ x()[1] for x in filters ])
236 and_filter = lambda : [and_clause, and_values]
237 else:
238 # List of functions taking parameter ref
239 def and_filter(ref):
240 myfilters = filters
241 failed = False
242 for filter in myfilters:
243 if not filter(ref):
244 failed = True
245 break
246 else:
247 pass
248 return not failed
249 self.put(and_filter)
252 def or_elements(self, num):
253 """Take num filters from the stack, or them and put the result back"""
254 if num > 1:
255 filters = []
256 for i in range(num):
257 filters.append(self.get())
258 if self.type == 'sql':
259 or_clause = '(' + (' OR ').join([ x()[0] for x in filters ]) + ')'
260 or_values = reduce(lambda x, y: x+y, [ x()[1] for x in filters ])
261 or_filter = lambda : [or_clause, or_values]
262 else:
263 def or_filter(ref):
264 myfilters = filters
265 failed = True
266 for filter in myfilters:
267 if filter(ref):
268 failed = False
269 break
270 else:
271 pass
272 return not failed
273 self.put(or_filter)
276 def get_stack(self):
277 """Return the top element from the stack or a filter which is always true"""
278 if self.qsize() == 0:
279 if self.type == 'sql':
280 return lambda : ["1 = ?", [1]]
281 else:
282 return lambda x : True
283 else:
284 return self.get()
287 try:
288 Queue.LifoQueue
289 LiveStatusStack.__bases__ = (Queue.LifoQueue,)
290 except AttributeError:
291 # Ptyhon 2.4 and 2.5 do not have it.
292 # Use our own implementation.
293 LiveStatusStack.__bases__ = (MyLifoQueue,)
296 class LiveStatus:
297 """A class that represents the status of all objects in the broker
300 # description (optional): no need to explain this
301 # prop (optional): the property of the object. If this is missing, the key is the property
302 # type (mandatory): int, float, string, list
303 # depythonize : use it if the property needs to be post-processed.
304 # fulldepythonize : the same, but the postprocessor takes three arguments. property, object, request
305 # delegate : get the property of a different object
306 # as : use it together with delegate, if the property of the other object has another name
307 out_map = {
308 'Host' : {
309 'accept_passive_checks' : {
310 'depythonize' : from_bool_to_int,
311 'description' : 'Wether passive host checks are accepted (0/1)',
312 'prop' : 'passive_checks_enabled',
313 'type' : 'int',
315 'acknowledged' : {
316 'depythonize' : from_bool_to_int,
317 'description' : 'Wether the current host problem has been acknowledged (0/1)',
318 'prop' : 'problem_has_been_acknowledged',
319 'type' : 'int',
321 'acknowledgement_type' : {
322 'description' : 'Type of acknowledgement (0: none, 1: normal, 2: stick)',
323 'type' : 'int',
325 'action_url' : {
326 'description' : 'An optional URL to custom actions or information about this host',
327 'type' : 'string',
329 'action_url_expanded' : {
330 'fulldepythonize' : lambda p, e, r: MacroResolver().resolve_simple_macros_in_string(p, e.get_data_for_checks()),
331 'description' : 'The same as action_url, but with the most important macros expanded',
332 'prop' : 'action_url',
333 'type' : 'string',
335 'active_checks_enabled' : {
336 'depythonize' : from_bool_to_int,
337 'description' : 'Wether active checks are enabled for the host (0/1)',
338 'type' : 'int',
340 'address' : {
341 'description' : 'IP address',
342 'type' : 'string',
344 'alias' : {
345 'description' : 'An alias name for the host',
346 'type' : 'string',
348 'check_command' : {
349 'depythonize' : 'call',
350 'description' : 'Nagios command for active host check of this host',
351 'type' : 'string',
353 'check_freshness' : {
354 'depythonize' : from_bool_to_int,
355 'description' : 'Wether freshness checks are activated (0/1)',
356 'type' : 'int',
358 'check_interval' : {
359 'converter' : int,
360 'description' : 'Number of basic interval lengths between two scheduled checks of the host',
361 'type' : 'float',
363 'check_options' : {
364 'description' : 'The current check option, forced, normal, freshness... (0-2)',
365 'type' : 'int',
367 'check_period' : {
368 'depythonize' : 'get_name',
369 'description' : 'Time period in which this host will be checked. If empty then the host will always be checked.',
370 'type' : 'string',
372 'check_type' : {
373 'converter' : int,
374 'description' : 'Type of check (0: active, 1: passive)',
375 'type' : 'int',
377 'checks_enabled' : {
378 'depythonize' : from_bool_to_int,
379 'description' : 'Wether checks of the host are enabled (0/1)',
380 'prop' : 'active_checks_enabled',
381 'type' : 'int',
383 'childs' : {
384 'description' : 'A list of all direct childs of the host',
385 'type' : 'list',
387 'comments' : {
388 'default' : '',
389 'depythonize' : 'id',
390 'description' : 'A list of the ids of all comments of this host',
391 'type' : 'list',
393 'contacts' : {
394 'depythonize' : 'contact_name',
395 'description' : 'A list of all contacts of this host, either direct or via a contact group',
396 'type' : 'list',
398 'current_attempt' : {
399 'converter' : int,
400 'default' : 0,
401 'description' : 'Number of the current check attempts',
402 'prop' : 'attempt',
403 'type' : 'int',
405 'current_notification_number' : {
406 'converter' : int,
407 'description' : 'Number of the current notification',
408 'type' : 'int',
410 'custom_variable_names' : {
411 'prop' : 'customs',
412 'description' : 'A list of the names of all custom variables',
413 'type' : 'list',
414 'depythonize' : get_customs_keys,
416 'custom_variable_values' : {
417 'prop' : 'customs',
418 'description' : 'A list of the values of the custom variables',
419 'type' : 'list',
420 'depythonize' : get_customs_values,
422 'display_name' : {
423 'description' : 'Optional display name of the host - not used by Nagios\' web interface',
424 'type' : 'string',
426 'downtimes' : {
427 'description' : 'A list of the ids of all scheduled downtimes of this host',
428 'type' : 'list',
430 'event_handler_enabled' : {
431 'depythonize' : from_bool_to_int,
432 'description' : 'Wether event handling is enabled (0/1)',
433 'type' : 'int',
435 'execution_time' : {
436 'converter' : float,
437 'description' : 'Time the host check needed for execution',
438 'type' : 'float',
440 'first_notification_delay' : {
441 'converter' : int,
442 'description' : 'Delay before the first notification',
443 'type' : 'float',
445 'flap_detection_enabled' : {
446 'depythonize' : from_bool_to_int,
447 'description' : 'Wether flap detection is enabled (0/1)',
448 'type' : 'int',
450 'got_business_rule' : {
451 'depythonize' : from_bool_to_int,
452 'description' : 'Wether the host state is an business rule based host or not (0/1)',
453 'type' : 'int',
455 'groups' : {
456 'default' : '',
457 'depythonize' : to_split,
458 'description' : 'A list of all host groups this host is in',
459 'prop' : 'hostgroups',
460 'type' : 'list',
462 'hard_state' : {
463 'description' : 'The effective hard state of the host (eliminates a problem in hard_state)',
464 'type' : 'int',
466 'has_been_checked' : {
467 'depythonize' : from_bool_to_int,
468 'description' : 'Wether the host has already been checked (0/1)',
469 'type' : 'int',
471 'high_flap_threshold' : {
472 'converter' : float,
473 'description' : 'High threshold of flap detection',
474 'type' : 'float',
476 'icon_image' : {
477 'description' : 'The name of an image file to be used in the web pages',
478 'type' : 'string',
480 'icon_image_alt' : {
481 'description' : 'Alternative text for the icon_image',
482 'type' : 'string',
484 'icon_image_expanded' : {
485 'description' : 'The same as icon_image, but with the most important macros expanded',
486 'type' : 'string',
488 'in_check_period' : {
489 'fulldepythonize' : lambda p, e, r: from_bool_to_int((p == None and [False] or [p.is_time_valid(r.tic)])[0]),
490 'description' : 'Wether this host is currently in its check period (0/1)',
491 'prop' : 'check_period',
492 'type' : 'int',
494 'in_notification_period' : {
495 'fulldepythonize' : lambda p, e, r: from_bool_to_int((p == None and [False] or [p.is_time_valid(r.tic)])[0]),
496 'description' : 'Wether this host is currently in its notification period (0/1)',
497 'prop' : 'notification_period',
498 'type' : 'int',
500 'initial_state' : {
501 'description' : 'Initial host state',
502 'type' : 'int',
504 'is_executing' : {
505 'default' : 0, # value in scheduler is not real-time
506 'description' : 'is there a host check currently running... (0/1)',
507 #'prop' : 'in_checking',
508 'type' : 'int',
510 'is_flapping' : {
511 'depythonize' : from_bool_to_int,
512 'description' : 'Wether the host state is flapping (0/1)',
513 'type' : 'int',
515 'is_impact' : {
516 'depythonize' : from_bool_to_int,
517 'description' : 'Wether the host state is an impact or not (0/1)',
518 'type' : 'int',
520 'is_problem' : {
521 'depythonize' : from_bool_to_int,
522 'description' : 'Wether the host state is a problem or not (0/1)',
523 'type' : 'int',
525 'last_check' : {
526 'converter' : int,
527 'depythonize' : from_float_to_int,
528 'description' : 'Time of the last check (Unix timestamp)',
529 'prop' : 'last_chk',
530 'type' : 'int',
532 'last_hard_state' : {
533 'description' : 'Last hard state',
534 'type' : 'int',
536 'last_hard_state_change' : {
537 'description' : 'Time of the last hard state change (Unix timestamp)',
538 'type' : 'int',
540 'last_notification' : {
541 'converter' : int,
542 'depythonize' : to_int,
543 'description' : 'Time of the last notification (Unix timestamp)',
544 'type' : 'int',
546 'last_state' : {
547 'description' : 'State before last state change',
548 'type' : 'int',
550 'last_state_change' : {
551 'converter' : int,
552 'depythonize' : from_float_to_int,
553 'description' : 'Time of the last state change - soft or hard (Unix timestamp)',
554 'type' : 'int',
556 'latency' : {
557 'converter' : float,
558 'description' : 'Time difference between scheduled check time and actual check time',
559 'type' : 'float',
561 'long_plugin_output' : {
562 'description' : 'Complete output from check plugin',
563 'prop' : 'long_output',
564 'type' : 'string',
566 'low_flap_threshold' : {
567 'description' : 'Low threshold of flap detection',
568 'type' : 'float',
570 'max_check_attempts' : {
571 'description' : 'Max check attempts for active host checks',
572 'type' : 'int',
574 'name' : {
575 'description' : 'Host name',
576 'prop' : 'host_name',
577 'type' : 'string',
579 'next_check' : {
580 'converter' : int,
581 'depythonize' : from_float_to_int,
582 'description' : 'Scheduled time for the next check (Unix timestamp)',
583 'prop' : 'next_chk',
584 'type' : 'int',
586 'next_notification' : {
587 'converter' : int,
588 'description' : 'Time of the next notification (Unix timestamp)',
589 'type' : 'int',
591 'notes' : {
592 'description' : 'Optional notes for this host',
593 'type' : 'string',
595 'notes_expanded' : {
596 'description' : 'The same as notes, but with the most important macros expanded',
597 'type' : 'string',
599 'notes_url' : {
600 'description' : 'An optional URL with further information about the host',
601 'type' : 'string',
603 'notes_url_expanded' : {
604 'fulldepythonize' : lambda p, e, r: MacroResolver().resolve_simple_macros_in_string(p, e.get_data_for_checks()),
605 'description' : 'Same es notes_url, but with the most important macros expanded',
606 'prop' : 'notes_url',
607 'type' : 'string',
609 'notification_interval' : {
610 'converter' : int,
611 'description' : 'Interval of periodic notification or 0 if its off',
612 'type' : 'float',
614 'notification_period' : {
615 'depythonize' : 'get_name',
616 'description' : 'Time period in which problems of this host will be notified. If empty then notification will be always',
617 'type' : 'string',
619 'notifications_enabled' : {
620 'depythonize' : from_bool_to_int,
621 'description' : 'Wether notifications of the host are enabled (0/1)',
622 'type' : 'int',
624 'num_services' : {
625 'depythonize' : lambda x: len(x),
626 'description' : 'The total number of services of the host',
627 'prop' : 'services',
628 'type' : 'list',
630 'num_services_crit' : {
631 'depythonize' : lambda x: len([y for y in x if y.state_id == 2]),
632 'description' : 'The number of the host\'s services with the soft state CRIT',
633 'prop' : 'services',
634 'type' : 'list',
636 'num_services_hard_crit' : {
637 'depythonize' : lambda x: len([y for y in x if y.state_id == 2 and y.state_type_id == 1]),
638 'description' : 'The number of the host\'s services with the hard state CRIT',
639 'prop' : 'services',
640 'type' : 'list',
642 'num_services_hard_ok' : {
643 'depythonize' : lambda x: len([y for y in x if y.state_id == 0 and y.state_type_id == 1]),
644 'description' : 'The number of the host\'s services with the hard state OK',
645 'prop' : 'services',
646 'type' : 'list',
648 'num_services_hard_unknown' : {
649 'depythonize' : lambda x: len([y for y in x if y.state_id == 3 and y.state_type_id == 1]),
650 'description' : 'The number of the host\'s services with the hard state UNKNOWN',
651 'prop' : 'services',
652 'type' : 'list',
654 'num_services_hard_warn' : {
655 'depythonize' : lambda x: len([y for y in x if y.state_id == 2 and y.state_type_id == 1]),
656 'description' : 'The number of the host\'s services with the hard state WARN',
657 'prop' : 'services',
658 'type' : 'list',
660 'num_services_ok' : {
661 'depythonize' : lambda x: len([y for y in x if y.state_id == 0]),
662 'description' : 'The number of the host\'s services with the soft state OK',
663 'prop' : 'services',
664 'type' : 'list',
666 'num_services_pending' : {
667 'depythonize' : lambda x: len([y for y in x if y.has_been_checked == 0]),
668 'description' : 'The number of the host\'s services which have not been checked yet (pending)',
669 'prop' : 'services',
670 'type' : 'list',
672 'num_services_unknown' : {
673 'depythonize' : lambda x: len([y for y in x if y.state_id == 3]),
674 'description' : 'The number of the host\'s services with the soft state UNKNOWN',
675 'prop' : 'services',
676 'type' : 'list',
678 'num_services_warn' : {
679 'depythonize' : lambda x: len([y for y in x if y.state_id == 1]),
680 'description' : 'The number of the host\'s services with the soft state WARN',
681 'prop' : 'services',
682 'type' : 'list',
684 'obsess_over_host' : {
685 'depythonize' : from_bool_to_int,
686 'description' : 'The current obsess_over_host setting... (0/1)',
687 'type' : 'int',
689 'parents' : {
690 'description' : 'A list of all direct parents of the host',
691 'type' : 'list',
693 'pending_flex_downtime' : {
694 'description' : 'Wether a flex downtime is pending (0/1)',
695 'type' : 'int',
697 'percent_state_change' : {
698 'description' : 'Percent state change',
699 'type' : 'float',
701 'perf_data' : {
702 'description' : 'Optional performance data of the last host check',
703 'type' : 'string',
705 'plugin_output' : {
706 'description' : 'Output of the last host check',
707 'prop' : 'output',
708 'type' : 'string',
710 'pnpgraph_present' : {
711 'fulldepythonize' : find_pnp_perfdata_xml,
712 'description' : 'Whether there is a PNP4Nagios graph present for this host (0/1)',
713 'prop' : 'host_name',
714 'type' : 'int',
716 'process_performance_data' : {
717 'depythonize' : from_bool_to_int,
718 'description' : 'Wether processing of performance data is enabled (0/1)',
719 'prop' : 'process_perf_data',
720 'type' : 'int',
722 'retry_interval' : {
723 'description' : 'Number of basic interval lengths between checks when retrying after a soft error',
724 'type' : 'float',
726 'scheduled_downtime_depth' : {
727 'converter' : int,
728 'description' : 'The number of downtimes this host is currently in',
729 'type' : 'int',
731 'state' : {
732 'converter' : int,
733 'description' : 'The current state of the host (0: up, 1: down, 2: unreachable)',
734 'prop' : 'state_id',
735 'type' : 'int',
737 'state_type' : {
738 'converter' : int,
739 'description' : 'Type of the current state (0: soft, 1: hard)',
740 'prop' : 'state_type_id',
741 'type' : 'int',
743 'statusmap_image' : {
744 'description' : 'The name of in image file for the status map',
745 'type' : 'string',
747 'total_services' : {
748 'description' : 'The total number of services of the host',
749 'type' : 'int',
751 'worst_service_hard_state' : {
752 'description' : 'The worst hard state of all of the host\'s services (OK <= WARN <= UNKNOWN <= CRIT)',
753 'type' : 'list',
755 'worst_service_state' : {
756 'description' : 'The worst soft state of all of the host\'s services (OK <= WARN <= UNKNOWN <= CRIT)',
757 'type' : 'list',
759 'x_3d' : {
760 'description' : '3D-Coordinates: X',
761 'type' : 'float',
763 'y_3d' : {
764 'description' : '3D-Coordinates: Y',
765 'type' : 'float',
767 'z_3d' : {
768 'description' : '3D-Coordinates: Z',
769 'type' : 'float',
771 'criticity' : {
772 'converter' : int,
773 'description' : 'The importance we gave to this host between hte minimum 0 and the maximum 5',
774 'type' : 'int',
776 'source_problems' : {
777 'description' : 'The name of the source problems (host or service)',
778 'prop' : 'source_problems',
779 'type' : 'list',
780 'depythonize' : from_svc_hst_distinct_lists,
782 'impacts' : {
783 'description' : 'List of what the source impact (list of hosts and services)',
784 'prop' : 'impacts',
785 'type' : 'list',
786 'depythonize' : from_svc_hst_distinct_lists,
788 'parent_dependencies' : {
789 'description' : 'List of the dependencies (logical, network or business one) of this host.',
790 'prop' : 'parent_dependencies',
791 'type' : 'list',
792 'depythonize' : from_svc_hst_distinct_lists,
794 'child_dependencies' : {
795 'description' : 'List of the host/service that depend on this host (logical, network or business one).',
796 'prop' : 'child_dependencies',
797 'type' : 'list',
798 'depythonize' : from_svc_hst_distinct_lists,
803 'Service' : {
804 'accept_passive_checks' : {
805 'depythonize' : from_bool_to_int,
806 'description' : 'Wether the service accepts passive checks (0/1)',
807 'prop' : 'passive_checks_enabled',
808 'type' : 'int',
810 'acknowledged' : {
811 'depythonize' : from_bool_to_int,
812 'description' : 'Wether the current service problem has been acknowledged (0/1)',
813 'prop' : 'problem_has_been_acknowledged',
814 'type' : 'int',
816 'acknowledgement_type' : {
817 'description' : 'The type of the acknownledgement (0: none, 1: normal, 2: sticky)',
818 'type' : 'int',
820 'action_url' : {
821 'description' : 'An optional URL for actions or custom information about the service',
822 'type' : 'string',
824 'action_url_expanded' : {
825 'fulldepythonize' : lambda p, e, r: MacroResolver().resolve_simple_macros_in_string(p, e.get_data_for_checks()),
826 'description' : 'The action_url with (the most important) macros expanded',
827 'prop' : 'action_url',
828 'type' : 'string',
830 'active_checks_enabled' : {
831 'depythonize' : from_bool_to_int,
832 'description' : 'Wether active checks are enabled for the service (0/1)',
833 'type' : 'int',
835 'check_command' : {
836 'depythonize' : 'call',
837 'description' : 'Nagios command used for active checks',
838 'type' : 'string',
840 'check_interval' : {
841 'description' : 'Number of basic interval lengths between two scheduled checks of the service',
842 'type' : 'float',
844 'check_options' : {
845 'description' : 'The current check option, forced, normal, freshness... (0/1)',
846 'type' : 'int',
848 'check_period' : {
849 'depythonize' : 'get_name',
850 'description' : 'The name of the check period of the service. It this is empty, the service is always checked.',
851 'type' : 'string',
853 'check_type' : {
854 'converter' : int,
855 'depythonize' : to_int,
856 'description' : 'The type of the last check (0: active, 1: passive)',
857 'type' : 'int',
859 'checks_enabled' : {
860 'depythonize' : from_bool_to_int,
861 'description' : 'Wether active checks are enabled for the service (0/1)',
862 'prop' : 'active_checks_enabled',
863 'type' : 'int',
865 'comments' : {
866 'default' : '',
867 'depythonize' : 'id',
868 'description' : 'A list of all comment ids of the service',
869 'type' : 'list',
871 'contacts' : {
872 'depythonize' : 'contact_name',
873 'description' : 'A list of all contacts of the service, either direct or via a contact group',
874 'type' : 'list',
876 'current_attempt' : {
877 'converter' : int,
878 'description' : 'The number of the current check attempt',
879 'prop' : 'attempt',
880 'type' : 'int',
882 'current_notification_number' : {
883 'description' : 'The number of the current notification',
884 'type' : 'int',
886 'custom_variable_names' : {
887 'prop' : 'customs',
888 'description' : 'A list of the names of all custom variables of the service',
889 'type' : 'list',
890 'depythonize' : get_customs_keys,
892 'custom_variable_values' : {
893 'prop' : 'customs',
894 'description' : 'A list of the values of all custom variable of the service',
895 'type' : 'list',
896 'depythonize' : get_customs_values,
898 'description' : {
899 'description' : 'Description of the service (also used as key)',
900 'prop' : 'service_description',
901 'type' : 'string',
903 'display_name' : {
904 'description' : 'An optional display name (not used by Nagios standard web pages)',
905 'type' : 'string',
907 'downtimes' : {
908 'description' : 'A list of all downtime ids of the service',
909 'type' : 'list',
911 'event_handler' : {
912 'depythonize' : 'call',
913 'description' : 'Nagios command used as event handler',
914 'type' : 'string',
916 'event_handler_enabled' : {
917 'depythonize' : from_bool_to_int,
918 'description' : 'Wether and event handler is activated for the service (0/1)',
919 'type' : 'int',
921 'execution_time' : {
922 'converter' : float,
923 'description' : 'Time the host check needed for execution',
924 'type' : 'float',
926 'first_notification_delay' : {
927 'converter' : int,
928 'description' : 'Delay before the first notification',
929 'type' : 'float',
931 'flap_detection_enabled' : {
932 'depythonize' : from_bool_to_int,
933 'description' : 'Wether flap detection is enabled for the service (0/1)',
934 'type' : 'int',
936 'got_business_rule' : {
937 'depythonize' : from_bool_to_int,
938 'description' : 'Wether the service state is an business rule based host or not (0/1)',
939 'type' : 'int',
941 'groups' : {
942 'default' : '',
943 'depythonize' : to_split,
944 'description' : 'A list of all service groups the service is in',
945 'prop' : 'servicegroups',
946 'type' : 'list',
948 'has_been_checked' : {
949 'depythonize' : from_bool_to_int,
950 'description' : 'Wether the service already has been checked (0/1)',
951 'type' : 'int',
953 'high_flap_threshold' : {
954 'description' : 'High threshold of flap detection',
955 'type' : 'float',
957 'host_accept_passive_checks' : {
958 'description' : 'Wether passive host checks are accepted (0/1)',
959 'type' : 'int',
961 'host_acknowledged' : {
962 'depythonize' : lambda x: from_bool_to_int(x.problem_has_been_acknowledged),
963 'description' : 'Wether the current host problem has been acknowledged (0/1)',
964 'prop' : 'host',
965 'type' : 'int',
967 'host_acknowledgement_type' : {
968 'description' : 'Type of acknowledgement (0: none, 1: normal, 2: stick)',
969 'type' : 'int',
971 'host_action_url' : {
972 'description' : 'An optional URL to custom actions or information about this host',
973 'type' : 'string',
975 'host_action_url_expanded' : {
976 'description' : 'The same as action_url, but with the most important macros expanded',
977 'type' : 'string',
979 'host_active_checks_enabled' : {
980 'description' : 'Wether active checks are enabled for the host (0/1)',
981 'type' : 'int',
983 'host_address' : {
984 'depythonize' : lambda x: x.address,
985 'description' : 'IP address',
986 'prop' : 'host',
987 'type' : 'string',
989 'host_alias' : {
990 'depythonize' : lambda x: x.alias,
991 'description' : 'An alias name for the host',
992 'prop' : 'host',
993 'type' : 'string',
995 'host_check_command' : {
996 'description' : 'Nagios command for active host check of this host',
997 'type' : 'string',
999 'host_check_freshness' : {
1000 'description' : 'Wether freshness checks are activated (0/1)',
1001 'type' : 'int',
1003 'host_check_interval' : {
1004 'description' : 'Number of basic interval lengths between two scheduled checks of the host',
1005 'type' : 'float',
1007 'host_check_options' : {
1008 'description' : 'The current check option, forced, normal, freshness... (0-2)',
1009 'type' : 'int',
1011 'host_check_period' : {
1012 'description' : 'Time period in which this host will be checked. If empty then the host will always be checked.',
1013 'type' : 'string',
1015 'host_check_type' : {
1016 'description' : 'Type of check (0: active, 1: passive)',
1017 'type' : 'int',
1019 'host_checks_enabled' : {
1020 'depythonize' : lambda x: from_bool_to_int(x.active_checks_enabled),
1021 'description' : 'Wether checks of the host are enabled (0/1)',
1022 'prop' : 'host',
1023 'type' : 'int',
1025 'host_childs' : {
1026 'description' : 'A list of all direct childs of the host',
1027 'type' : 'list',
1029 'host_comments' : {
1030 'default' : '',
1031 'depythonize' : lambda h: ([c.id for c in h.comments]),
1032 'description' : 'A list of the ids of all comments of this host',
1033 'prop' : 'host',
1034 'type' : 'list',
1036 'host_contacts' : {
1037 'description' : 'A list of all contacts of this host, either direct or via a contact group',
1038 'type' : 'list',
1040 'host_current_attempt' : {
1041 'description' : 'Number of the current check attempts',
1042 'type' : 'int',
1044 'host_current_notification_number' : {
1045 'description' : 'Number of the current notification',
1046 'type' : 'int',
1048 'host_custom_variable_names' : {
1049 'description' : 'A list of the names of all custom variables',
1050 'depythonize' : lambda h: get_customs_keys(h.customs),
1051 'prop' : 'host',
1052 'type' : 'list',
1054 'host_custom_variable_values' : {
1055 'description' : 'A list of the values of the custom variables',
1056 'depythonize' : lambda h: get_customs_values(h.customs),
1057 'prop' : 'host',
1058 'type' : 'list',
1060 'host_display_name' : {
1061 'description' : 'Optional display name of the host - not used by Nagios\' web interface',
1062 'type' : 'string',
1064 'host_downtimes' : {
1065 'description' : 'A list of the ids of all scheduled downtimes of this host',
1066 'type' : 'list',
1068 'host_event_handler_enabled' : {
1069 'description' : 'Wether event handling is enabled (0/1)',
1070 'type' : 'int',
1072 'host_execution_time' : {
1073 'description' : 'Time the host check needed for execution',
1074 'type' : 'float',
1076 'host_first_notification_delay' : {
1077 'description' : 'Delay before the first notification',
1078 'type' : 'float',
1080 'host_flap_detection_enabled' : {
1081 'description' : 'Wether flap detection is enabled (0/1)',
1082 'type' : 'int',
1084 'host_groups' : {
1085 'default' : '',
1086 'depythonize' : lambda x: to_split(x.hostgroups),
1087 'description' : 'A list of all host groups this host is in',
1088 'prop' : 'host',
1089 'type' : 'list',
1091 'host_hard_state' : {
1092 'description' : 'The effective hard state of the host (eliminates a problem in hard_state)',
1093 'type' : 'int',
1095 'host_has_been_checked' : {
1096 'depythonize' : lambda x: from_bool_to_int(x.has_been_checked),
1097 'description' : 'Wether the host has already been checked (0/1)',
1098 'prop' : 'host',
1099 'type' : 'int',
1101 'host_high_flap_threshold' : {
1102 'description' : 'High threshold of flap detection',
1103 'type' : 'float',
1105 'host_icon_image' : {
1106 'description' : 'The name of an image file to be used in the web pages',
1107 'type' : 'string',
1109 'host_icon_image_alt' : {
1110 'description' : 'Alternative text for the icon_image',
1111 'type' : 'string',
1113 'host_icon_image_expanded' : {
1114 'description' : 'The same as icon_image, but with the most important macros expanded',
1115 'type' : 'string',
1117 'host_in_check_period' : {
1118 'depythonize' : lambda h: from_bool_to_int((h.check_period == None and [False] or [h.check_period.is_time_valid(time.time())])[0]),
1119 'description' : 'Wether this host is currently in its check period (0/1)',
1120 'prop' : 'host',
1121 'type' : 'int',
1123 'host_in_notification_period' : {
1124 'depythonize' : lambda h: from_bool_to_int((h.notification_period == None and [False] or [h.notification_period.is_time_valid(time.time())])[0]),
1125 'description' : 'Wether this host is currently in its notification period (0/1)',
1126 'prop' : 'host',
1127 'type' : 'int',
1129 'host_initial_state' : {
1130 'description' : 'Initial host state',
1131 'type' : 'int',
1133 'host_is_executing' : {
1134 'default' : 0, # value in scheduler is not real-time
1135 'description' : 'is there a host check currently running... (0/1)',
1136 'type' : 'int',
1138 'host_is_flapping' : {
1139 'default' : '0',
1140 'depythonize' : from_bool_to_int,
1141 'description' : 'Wether the host state is flapping (0/1)',
1142 'type' : 'int',
1144 'host_last_check' : {
1145 'description' : 'Time of the last check (Unix timestamp)',
1146 'type' : 'int',
1148 'host_last_hard_state' : {
1149 'description' : 'Last hard state',
1150 'type' : 'int',
1152 'host_last_hard_state_change' : {
1153 'description' : 'Time of the last hard state change (Unix timestamp)',
1154 'type' : 'int',
1156 'host_last_notification' : {
1157 'description' : 'Time of the last notification (Unix timestamp)',
1158 'type' : 'int',
1160 'host_last_state' : {
1161 'description' : 'State before last state change',
1162 'type' : 'int',
1164 'host_last_state_change' : {
1165 'description' : 'Time of the last state change - soft or hard (Unix timestamp)',
1166 'type' : 'int',
1168 'host_latency' : {
1169 'description' : 'Time difference between scheduled check time and actual check time',
1170 'type' : 'float',
1172 'host_long_plugin_output' : {
1173 'description' : 'Complete output from check plugin',
1174 'type' : 'string',
1176 'host_low_flap_threshold' : {
1177 'description' : 'Low threshold of flap detection',
1178 'type' : 'float',
1180 'host_max_check_attempts' : {
1181 'description' : 'Max check attempts for active host checks',
1182 'type' : 'int',
1184 'host_name' : {
1185 'description' : 'Host name',
1186 'type' : 'string',
1188 'host_next_check' : {
1189 'description' : 'Scheduled time for the next check (Unix timestamp)',
1190 'type' : 'int',
1192 'host_next_notification' : {
1193 'description' : 'Time of the next notification (Unix timestamp)',
1194 'type' : 'int',
1196 'host_notes' : {
1197 'description' : 'Optional notes for this host',
1198 'type' : 'string',
1200 'host_notes_expanded' : {
1201 'description' : 'The same as notes, but with the most important macros expanded',
1202 'type' : 'string',
1204 'host_notes_url' : {
1205 'description' : 'An optional URL with further information about the host',
1206 'type' : 'string',
1208 'host_notes_url_expanded' : {
1209 'description' : 'Same es notes_url, but with the most important macros expanded',
1210 'type' : 'string',
1212 'host_notification_interval' : {
1213 'description' : 'Interval of periodic notification or 0 if its off',
1214 'type' : 'float',
1216 'host_notification_period' : {
1217 'description' : 'Time period in which problems of this host will be notified. If empty then notification will be always',
1218 'type' : 'string',
1220 'host_notifications_enabled' : {
1221 'depythonize' : lambda x: from_bool_to_int(x.notifications_enabled),
1222 'description' : 'Wether notifications of the host are enabled (0/1)',
1223 'prop' : 'host',
1224 'type' : 'int',
1226 'host_num_services' : {
1227 'depythonize' : lambda x: len(x.services),
1228 'description' : 'The total number of services of the host',
1229 'prop' : 'host',
1230 'type' : 'list',
1232 'host_num_services_crit' : {
1233 'depythonize' : lambda x: len([y for y in x.services if y.state_id == 2]),
1234 'description' : 'The number of the host\'s services with the soft state CRIT',
1235 'prop' : 'host',
1236 'type' : 'list',
1238 'host_num_services_hard_crit' : {
1239 'depythonize' : lambda x: len([y for y in x.services if y.state_id == 2 and y.state_type_id == 1]),
1240 'description' : 'The number of the host\'s services with the hard state CRIT',
1241 'prop' : 'host',
1242 'type' : 'list',
1244 'host_num_services_hard_ok' : {
1245 'depythonize' : lambda x: len([y for y in x.services if y.state_id == 0 and y.state_type_id == 1]),
1246 'description' : 'The number of the host\'s services with the hard state OK',
1247 'prop' : 'host',
1248 'type' : 'list',
1250 'host_num_services_hard_unknown' : {
1251 'depythonize' : lambda x: len([y for y in x.services if y.state_id == 3 and y.state_type_id == 1]),
1252 'description' : 'The number of the host\'s services with the hard state UNKNOWN',
1253 'prop' : 'host',
1254 'type' : 'list',
1256 'host_num_services_hard_warn' : {
1257 'depythonize' : lambda x: len([y for y in x.services if y.state_id == 2 and y.state_type_id == 1]),
1258 'description' : 'The number of the host\'s services with the hard state WARN',
1259 'prop' : 'host',
1260 'type' : 'list',
1262 'host_num_services_ok' : {
1263 'depythonize' : lambda x: len([y for y in x.services if y.state_id == 0]),
1264 'description' : 'The number of the host\'s services with the soft state OK',
1265 'prop' : 'host',
1266 'type' : 'list',
1268 'host_num_services_pending' : {
1269 'depythonize' : lambda x: len([y for y in x.services if y.has_been_checked == 0]),
1270 'description' : 'The number of the host\'s services which have not been checked yet (pending)',
1271 'prop' : 'host',
1272 'type' : 'list',
1274 'host_num_services_unknown' : {
1275 'depythonize' : lambda x: len([y for y in x.services if y.state_id == 3]),
1276 'description' : 'The number of the host\'s services with the soft state UNKNOWN',
1277 'prop' : 'host',
1278 'type' : 'list',
1280 'host_num_services_warn' : {
1281 'depythonize' : lambda x: len([y for y in x.services if y.state_id == 1]),
1282 'description' : 'The number of the host\'s services with the soft state WARN',
1283 'prop' : 'host',
1284 'type' : 'list',
1286 'host_obsess_over_host' : {
1287 'description' : 'The current obsess_over_host setting... (0/1)',
1288 'type' : 'int',
1290 'host_parents' : {
1291 'description' : 'A list of all direct parents of the host',
1292 'type' : 'list',
1294 'host_pending_flex_downtime' : {
1295 'description' : 'Wether a flex downtime is pending (0/1)',
1296 'type' : 'int',
1298 'host_percent_state_change' : {
1299 'description' : 'Percent state change',
1300 'type' : 'float',
1302 'host_perf_data' : {
1303 'description' : 'Optional performance data of the last host check',
1304 'type' : 'string',
1306 'host_plugin_output' : {
1307 'description' : 'Output of the last host check',
1308 'type' : 'string',
1310 'host_process_performance_data' : {
1311 'description' : 'Wether processing of performance data is enabled (0/1)',
1312 'type' : 'int',
1314 'host_retry_interval' : {
1315 'description' : 'Number of basic interval lengths between checks when retrying after a soft error',
1316 'type' : 'float',
1318 'host_scheduled_downtime_depth' : {
1319 'converter' : int,
1320 'depythonize' : lambda x: x.scheduled_downtime_depth,
1321 'description' : 'The number of downtimes this host is currently in',
1322 'prop' : 'host',
1323 'type' : 'int',
1325 'host_state' : {
1326 'converter' : int,
1327 'depythonize' : lambda x: x.state_id,
1328 'description' : 'The current state of the host (0: up, 1: down, 2: unreachable)',
1329 'prop' : 'host',
1330 'type' : 'int',
1332 'host_state_type' : {
1333 'description' : 'Type of the current state (0: soft, 1: hard)',
1334 'type' : 'int',
1336 'host_statusmap_image' : {
1337 'description' : 'The name of in image file for the status map',
1338 'type' : 'string',
1340 'host_total_services' : {
1341 'description' : 'The total number of services of the host',
1342 'type' : 'int',
1344 'host_worst_service_hard_state' : {
1345 'description' : 'The worst hard state of all of the host\'s services (OK <= WARN <= UNKNOWN <= CRIT)',
1346 'type' : 'list',
1348 'host_worst_service_state' : {
1349 'description' : 'The worst soft state of all of the host\'s services (OK <= WARN <= UNKNOWN <= CRIT)',
1350 'type' : 'list',
1352 'host_x_3d' : {
1353 'description' : '3D-Coordinates: X',
1354 'type' : 'float',
1356 'host_y_3d' : {
1357 'description' : '3D-Coordinates: Y',
1358 'type' : 'float',
1360 'host_z_3d' : {
1361 'description' : '3D-Coordinates: Z',
1362 'type' : 'float',
1364 'icon_image' : {
1365 'description' : 'The name of an image to be used as icon in the web interface',
1366 'type' : 'string',
1368 'icon_image_alt' : {
1369 'description' : 'An alternative text for the icon_image for browsers not displaying icons',
1370 'type' : 'string',
1372 'icon_image_expanded' : {
1373 'description' : 'The icon_image with (the most important) macros expanded',
1374 'type' : 'string',
1376 'in_check_period' : {
1377 'depythonize' : lambda tp: from_bool_to_int((tp == None and [False] or [tp.is_time_valid(time.time())])[0]),
1378 'description' : 'Wether the service is currently in its check period (0/1)',
1379 'prop' : 'check_period',
1380 'type' : 'int',
1382 'in_notification_period' : {
1383 'depythonize' : lambda tp: from_bool_to_int((tp == None and [False] or [tp.is_time_valid(time.time())])[0]),
1384 'description' : 'Wether the service is currently in its notification period (0/1)',
1385 'prop' : 'notification_period',
1386 'type' : 'int',
1388 'initial_state' : {
1389 'description' : 'The initial state of the service',
1390 'type' : 'int',
1392 'is_executing' : {
1393 'default' : 0, # value in scheduler is not real-time
1394 'description' : 'is there a service check currently running... (0/1)',
1395 'type' : 'int',
1397 'is_flapping' : {
1398 'depythonize' : from_bool_to_int,
1399 'description' : 'Wether the service is flapping (0/1)',
1400 'type' : 'int',
1402 'is_impact' : {
1403 'depythonize' : from_bool_to_int,
1404 'description' : 'Wether the host state is an impact or not (0/1)',
1405 'type' : 'int',
1407 'is_problem' : {
1408 'depythonize' : from_bool_to_int,
1409 'description' : 'Wether the host state is a problem or not (0/1)',
1410 'type' : 'int',
1412 'last_check' : {
1413 'depythonize' : from_float_to_int,
1414 'description' : 'The time of the last check (Unix timestamp)',
1415 'prop' : 'last_chk',
1416 'type' : 'int',
1418 'last_hard_state' : {
1419 'description' : 'The last hard state of the service',
1420 'type' : 'int',
1422 'last_hard_state_change' : {
1423 'description' : 'The time of the last hard state change (Unix timestamp)',
1424 'type' : 'int',
1426 'last_notification' : {
1427 'depythonize' : to_int,
1428 'description' : 'The time of the last notification (Unix timestamp)',
1429 'type' : 'int',
1431 'last_state' : {
1432 'description' : 'The last state of the service',
1433 'type' : 'int',
1435 'last_state_change' : {
1436 'depythonize' : from_float_to_int,
1437 'description' : 'The time of the last state change (Unix timestamp)',
1438 'type' : 'int',
1440 'latency' : {
1441 'depythonize' : to_int,
1442 'description' : 'Time difference between scheduled check time and actual check time',
1443 'type' : 'float',
1445 'long_plugin_output' : {
1446 'description' : 'Unabbreviated output of the last check plugin',
1447 'prop' : 'long_output',
1448 'type' : 'string',
1450 'low_flap_threshold' : {
1451 'description' : 'Low threshold of flap detection',
1452 'type' : 'float',
1454 'max_check_attempts' : {
1455 'description' : 'The maximum number of check attempts',
1456 'type' : 'int',
1458 'next_check' : {
1459 'depythonize' : from_float_to_int,
1460 'description' : 'The scheduled time of the next check (Unix timestamp)',
1461 'prop' : 'next_chk',
1462 'type' : 'int',
1464 'next_notification' : {
1465 'description' : 'The time of the next notification (Unix timestamp)',
1466 'type' : 'int',
1468 'notes' : {
1469 'description' : 'Optional notes about the service',
1470 'type' : 'string',
1472 'notes_expanded' : {
1473 'description' : 'The notes with (the most important) macros expanded',
1474 'type' : 'string',
1476 'notes_url' : {
1477 'description' : 'An optional URL for additional notes about the service',
1478 'type' : 'string',
1480 'notes_url_expanded' : {
1481 'fulldepythonize' : lambda p, e, r: MacroResolver().resolve_simple_macros_in_string(p, e.get_data_for_checks()),
1482 'description' : 'The notes_url with (the most important) macros expanded',
1483 'prop' : 'notes_url',
1484 'type' : 'string',
1486 'notification_interval' : {
1487 'description' : 'Interval of periodic notification or 0 if its off',
1488 'type' : 'float',
1490 'notification_period' : {
1491 'depythonize' : 'get_name',
1492 'description' : 'The name of the notification period of the service. It this is empty, service problems are always notified.',
1493 'type' : 'string',
1495 'notifications_enabled' : {
1496 'depythonize' : from_bool_to_int,
1497 'description' : 'Wether notifications are enabled for the service (0/1)',
1498 'type' : 'int',
1500 'obsess_over_service' : {
1501 'depythonize' : from_bool_to_int,
1502 'description' : 'Wether \'obsess_over_service\' is enabled for the service (0/1)',
1503 'type' : 'int',
1505 'percent_state_change' : {
1506 'description' : 'Percent state change',
1507 'type' : 'float',
1509 'perf_data' : {
1510 'description' : 'Performance data of the last check plugin',
1511 'type' : 'string',
1513 'plugin_output' : {
1514 'description' : 'Output of the last check plugin',
1515 'prop' : 'output',
1516 'type' : 'string',
1518 'pnpgraph_present' : {
1519 'fulldepythonize' : find_pnp_perfdata_xml,
1520 'description' : 'Whether there is a PNP4Nagios graph present for this service (0/1)',
1521 'prop' : 'get_dbg_name',
1522 'type' : 'int',
1524 'process_performance_data' : {
1525 'depythonize' : from_bool_to_int,
1526 'description' : 'Wether processing of performance data is enabled for the service (0/1)',
1527 'prop' : 'process_perf_data',
1528 'type' : 'int',
1530 'retry_interval' : {
1531 'description' : 'Number of basic interval lengths between checks when retrying after a soft error',
1532 'type' : 'float',
1534 'scheduled_downtime_depth' : {
1535 'converter' : int,
1536 'description' : 'The number of scheduled downtimes the service is currently in',
1537 'type' : 'int',
1539 'state' : {
1540 'converter' : int,
1541 'description' : 'The current state of the service (0: OK, 1: WARN, 2: CRITICAL, 3: UNKNOWN)',
1542 'prop' : 'state_id',
1543 'type' : 'int',
1545 'state_type' : {
1546 'converter' : int,
1547 'description' : 'The type of the current state (0: soft, 1: hard)',
1548 'prop' : 'state_type_id',
1549 'type' : 'int',
1551 'criticity' : {
1552 'converter' : int,
1553 'description' : 'The importance we gave to this service between hte minimum 0 and the maximum 5',
1554 'type' : 'int',
1556 'source_problems' : {
1557 'description' : 'The name of the source problems (host or service)',
1558 'prop' : 'source_problems',
1559 'type' : 'list',
1560 'depythonize' : from_svc_hst_distinct_lists,
1562 'impacts' : {
1563 'description' : 'List of what the source impact (list of hosts and services)',
1564 'prop' : 'impacts',
1565 'type' : 'list',
1566 'depythonize' : from_svc_hst_distinct_lists,
1568 'parent_dependencies' : {
1569 'description' : 'List of the dependencies (logical, network or business one) of this service.',
1570 'prop' : 'parent_dependencies',
1571 'type' : 'list',
1572 'depythonize' : from_svc_hst_distinct_lists,
1574 'child_dependencies' : {
1575 'description' : 'List of the host/service that depend on this service (logical, network or business one).',
1576 'prop' : 'child_dependencies',
1577 'type' : 'list',
1578 'depythonize' : from_svc_hst_distinct_lists,
1583 'Hostgroup' : {
1584 'action_url' : {
1585 'description' : 'An optional URL to custom actions or information about the hostgroup',
1586 'type' : 'string',
1588 'alias' : {
1589 'description' : 'An alias of the hostgroup',
1590 'type' : 'string',
1592 'members' : {
1593 'depythonize' : 'get_name',
1594 'description' : 'A list of all host names that are members of the hostgroup',
1595 'type' : 'list',
1597 'name' : {
1598 'description' : 'Name of the hostgroup',
1599 'prop' : 'hostgroup_name',
1600 'type' : 'string',
1602 'notes' : {
1603 'description' : 'Optional notes to the hostgroup',
1604 'type' : 'string',
1606 'notes_url' : {
1607 'description' : 'An optional URL with further information about the hostgroup',
1608 'type' : 'string',
1610 'num_hosts' : {
1611 'depythonize' : lambda x: len(x),
1612 'description' : 'The total number of hosts in the group',
1613 'prop' : 'get_hosts',
1614 'type' : 'list',
1616 'num_hosts_down' : {
1617 'depythonize' : lambda x: len([y for y in x if y.state_id == 1]),
1618 'description' : 'The number of hosts in the group that are down',
1619 'prop' : 'get_hosts',
1620 'type' : 'list',
1622 'num_hosts_pending' : {
1623 'depythonize' : lambda x: len([y for y in x if y.has_been_checked == 0]),
1624 'description' : 'The number of hosts in the group that are pending',
1625 'prop' : 'get_hosts',
1626 'type' : 'list',
1628 'num_hosts_unreach' : {
1629 'depythonize' : lambda x: len([y for y in x if y.state_id == 2]),
1630 'description' : 'The number of hosts in the group that are unreachable',
1631 'prop' : 'get_hosts',
1632 'type' : 'list',
1634 'num_hosts_up' : {
1635 'depythonize' : lambda x: len([y for y in x if y.state_id == 0]),
1636 'description' : 'The number of hosts in the group that are up',
1637 'prop' : 'get_hosts',
1638 'type' : 'list',
1640 'num_services' : {
1641 'depythonize' : lambda x: sum((len(y.service_ids) for y in x)),
1642 'description' : 'The total number of services of hosts in this group',
1643 'prop' : 'get_hosts',
1644 'type' : 'list',
1646 'num_services_crit' : {
1647 'depythonize' : lambda x: len([z for y in x for z in y.services if z.state_id == 2]),
1648 'description' : 'The total number of services with the state CRIT of hosts in this group',
1649 'prop' : 'get_hosts',
1650 'type' : 'list',
1652 'num_services_hard_crit' : {
1653 'depythonize' : lambda x: len([z for y in x for z in y.services if z.state_id == 2 and z.state_type_id == 1]),
1654 'description' : 'The total number of services with the state CRIT of hosts in this group',
1655 'prop' : 'get_hosts',
1656 'type' : 'list',
1658 'num_services_hard_ok' : {
1659 'depythonize' : lambda x: len([z for y in x for z in y.services if z.state_id == 0 and z.state_type_id == 1]),
1660 'description' : 'The total number of services with the state OK of hosts in this group',
1661 'prop' : 'get_hosts',
1662 'type' : 'list',
1664 'num_services_hard_unknown' : {
1665 'depythonize' : lambda x: len([z for y in x for z in y.services if z.state_id == 3 and z.state_type_id == 1]),
1666 'description' : 'The total number of services with the state UNKNOWN of hosts in this group',
1667 'prop' : 'get_hosts',
1668 'type' : 'list',
1670 'num_services_hard_warn' : {
1671 'depythonize' : lambda x: len([z for y in x for z in y.services if z.state_id == 2 and z.state_type_id == 1]),
1672 'description' : 'The total number of services with the state WARN of hosts in this group',
1673 'prop' : 'get_hosts',
1674 'type' : 'list',
1676 'num_services_ok' : {
1677 'depythonize' : lambda x: len([z for y in x for z in y.services if z.state_id == 0]),
1678 'description' : 'The total number of services with the state OK of hosts in this group',
1679 'prop' : 'get_hosts',
1680 'type' : 'list',
1682 'num_services_pending' : {
1683 'depythonize' : lambda x: len([z for y in x for z in y.services if z.has_been_checked == 0]),
1684 'description' : 'The total number of services with the state Pending of hosts in this group',
1685 'prop' : 'get_hosts',
1686 'type' : 'list',
1688 'num_services_unknown' : {
1689 'depythonize' : lambda x: len([z for y in x for z in y.services if z.state_id == 3]),
1690 'description' : 'The total number of services with the state UNKNOWN of hosts in this group',
1691 'prop' : 'get_hosts',
1692 'type' : 'list',
1694 'num_services_warn' : {
1695 'depythonize' : lambda x: len([z for y in x for z in y.services if z.state_id == 1]),
1696 'description' : 'The total number of services with the state WARN of hosts in this group',
1697 'prop' : 'get_hosts',
1698 'type' : 'list',
1700 'worst_host_state' : {
1701 'depythonize' : lambda x: reduce(worst_host_state, (y.state_id for y in x), 0),
1702 'description' : 'The worst state of all of the groups\' hosts (UP <= UNREACHABLE <= DOWN)',
1703 'prop' : 'get_hosts',
1704 'type' : 'list',
1706 'worst_service_hard_state' : {
1707 'depythonize' : lambda x: reduce(worst_service_state, (z.state_id for y in x for z in y.services if z.state_type_id == 1), 0),
1708 'description' : 'The worst state of all services that belong to a host of this group (OK <= WARN <= UNKNOWN <= CRIT)',
1709 'prop' : 'get_hosts',
1710 'type' : 'list',
1712 'worst_service_state' : {
1713 'depythonize' : lambda x: reduce(worst_service_state, (z.state_id for y in x for z in y.services), 0),
1714 'description' : 'The worst state of all services that belong to a host of this group (OK <= WARN <= UNKNOWN <= CRIT)',
1715 'prop' : 'get_hosts',
1716 'type' : 'list',
1720 'Servicegroup' : {
1721 'action_url' : {
1722 'description' : 'An optional URL to custom notes or actions on the service group',
1723 'type' : 'string',
1725 'alias' : {
1726 'description' : 'An alias of the service group',
1727 'type' : 'string',
1729 'members' : {
1730 'fulldepythonize' : get_livestatus_full_name,
1731 'description' : 'A list of all members of the service group as host/service pairs ',
1732 'type' : 'list',
1734 'name' : {
1735 'description' : 'The name of the service group',
1736 'prop' : 'servicegroup_name',
1737 'type' : 'string',
1739 'notes' : {
1740 'description' : 'Optional additional notes about the service group',
1741 'type' : 'string',
1743 'notes_url' : {
1744 'description' : 'An optional URL to further notes on the service group',
1745 'type' : 'string',
1747 'num_services' : {
1748 'converter' : int,
1749 'depythonize' : lambda x: len(x),
1750 'description' : 'The total number of services in the group',
1751 'prop' : 'get_services',
1752 'type' : 'list',
1754 'num_services_crit' : {
1755 'converter' : int,
1756 'depythonize' : lambda x: len([y for y in x if y.state_id == 2]),
1757 'description' : 'The number of services in the group that are CRIT',
1758 'prop' : 'get_services',
1759 'type' : 'list',
1761 'num_services_hard_crit' : {
1762 'converter' : int,
1763 'depythonize' : lambda x: len([y for y in x if y.state_id == 2 and y.state_type_id == 1]),
1764 'description' : 'The number of services in the group that are CRIT',
1765 'prop' : 'get_services',
1766 'type' : 'list',
1768 'num_services_hard_ok' : {
1769 'converter' : int,
1770 'depythonize' : lambda x: len([y for y in x if y.state_id == 0 and y.state_type_id == 1]),
1771 'description' : 'The number of services in the group that are OK',
1772 'prop' : 'get_services',
1773 'type' : 'list',
1775 'num_services_hard_unknown' : {
1776 'converter' : int,
1777 'depythonize' : lambda x: len([y for y in x if y.state_id == 3 and y.state_type_id == 1]),
1778 'description' : 'The number of services in the group that are UNKNOWN',
1779 'prop' : 'get_services',
1780 'type' : 'list',
1782 'num_services_hard_warn' : {
1783 'converter' : int,
1784 'depythonize' : lambda x: len([y for y in x if y.state_id == 2 and y.state_type_id == 1]),
1785 'description' : 'The number of services in the group that are WARN',
1786 'prop' : 'get_services',
1787 'type' : 'list',
1789 'num_services_ok' : {
1790 'converter' : int,
1791 'depythonize' : lambda x: len([y for y in x if y.state_id == 0]),
1792 'description' : 'The number of services in the group that are OK',
1793 'prop' : 'get_services',
1794 'type' : 'list',
1796 'num_services_pending' : {
1797 'converter' : int,
1798 'depythonize' : lambda x: len([y for y in x if y.has_been_checked == 0]),
1799 'description' : 'The number of services in the group that are PENDING',
1800 'prop' : 'get_services',
1801 'type' : 'list',
1803 'num_services_unknown' : {
1804 'converter' : int,
1805 'depythonize' : lambda x: len([y for y in x if y.state_id == 3]),
1806 'description' : 'The number of services in the group that are UNKNOWN',
1807 'prop' : 'get_services',
1808 'type' : 'list',
1810 'num_services_warn' : {
1811 'converter' : int,
1812 'depythonize' : lambda x: len([y for y in x if y.state_id == 1]),
1813 'description' : 'The number of services in the group that are WARN',
1814 'prop' : 'get_services',
1815 'type' : 'list',
1817 'worst_service_state' : {
1818 'depythonize' : lambda x: reduce(worst_service_state, (y.state_id for y in x), 0),
1819 'description' : 'The worst soft state of all of the groups services (OK <= WARN <= UNKNOWN <= CRIT)',
1820 'prop' : 'get_services',
1821 'type' : 'list',
1825 'Contact' : {
1826 'address1' : {
1827 'description' : 'The additional field address1',
1828 'type' : 'string',
1830 'address2' : {
1831 'description' : 'The additional field address2',
1832 'type' : 'string',
1834 'address3' : {
1835 'description' : 'The additional field address3',
1836 'type' : 'string',
1838 'address4' : {
1839 'description' : 'The additional field address4',
1840 'type' : 'string',
1842 'address5' : {
1843 'description' : 'The additional field address5',
1844 'type' : 'string',
1846 'address6' : {
1847 'description' : 'The additional field address6',
1848 'type' : 'string',
1850 'alias' : {
1851 'description' : 'The full name of the contact',
1852 'type' : 'string',
1854 'can_submit_commands' : {
1855 'depythonize' : from_bool_to_int,
1856 'description' : 'Wether the contact is allowed to submit commands (0/1)',
1857 'type' : 'int',
1859 'custom_variable_names' : {
1860 'description' : 'A list of all custom variables of the contact',
1861 'type' : 'list',
1863 'custom_variable_values' : {
1864 'description' : 'A list of the values of all custom variables of the contact',
1865 'type' : 'list',
1867 'email' : {
1868 'description' : 'The email address of the contact',
1869 'type' : 'string',
1871 'host_notification_period' : {
1872 'depythonize' : 'get_name',
1873 'description' : 'The time period in which the contact will be notified about host problems',
1874 'type' : 'string',
1876 'host_notifications_enabled' : {
1877 'depythonize' : from_bool_to_int,
1878 'description' : 'Wether the contact will be notified about host problems in general (0/1)',
1879 'type' : 'int',
1881 'in_host_notification_period' : {
1882 'depythonize' : from_bool_to_int,
1883 'description' : 'Wether the contact is currently in his/her host notification period (0/1)',
1884 'type' : 'int',
1886 'in_service_notification_period' : {
1887 'depythonize' : from_bool_to_int,
1888 'description' : 'Wether the contact is currently in his/her service notification period (0/1)',
1889 'type' : 'int',
1891 'name' : {
1892 'description' : 'The login name of the contact person',
1893 'prop' : 'contact_name',
1894 'type' : 'string',
1896 'pager' : {
1897 'description' : 'The pager address of the contact',
1898 'type' : 'string',
1900 'service_notification_period' : {
1901 'depythonize' : 'get_name',
1902 'description' : 'The time period in which the contact will be notified about service problems',
1903 'type' : 'string',
1905 'service_notifications_enabled' : {
1906 'depythonize' : from_bool_to_int,
1907 'description' : 'Wether the contact will be notified about service problems in general (0/1)',
1908 'type' : 'int',
1913 #Group of contacts
1914 'Contactgroup' : {
1915 'alias' : {
1916 'description' : 'The alias of the contactgroup',
1917 'type' : 'string',
1919 'members' : {
1920 'depythonize' : 'get_name',
1921 'description' : 'A list of all members of this contactgroup',
1922 'type' : 'list',
1924 'name' : {
1925 'description' : 'The name of the contactgroup',
1926 'prop' : 'contactgroup_name',
1927 'type' : 'string',
1932 #Timeperiods
1933 'Timeperiod' : {
1934 'alias' : {
1935 'description' : 'The alias of the timeperiod',
1936 'type' : 'string',
1938 'name' : {
1939 'description' : 'The name of the timeperiod',
1940 'prop' : 'timeperiod_name',
1941 'type' : 'string',
1945 #All commands (checks + notifications)
1946 'Command' : {
1947 'line' : {
1948 'description' : 'The shell command line',
1949 'prop' : 'command_line',
1950 'type' : 'string',
1952 'name' : {
1953 'description' : 'The name of the command',
1954 'prop' : 'command_name',
1955 'type' : 'string',
1960 ###Satellites
1961 #Schedulers
1962 'SchedulerLink' : {
1963 'name' : {
1964 'description' : 'The name of the scheduler',
1965 'prop' : 'scheduler_name',
1966 'type' : 'string',
1968 'address' : {
1969 'description' : 'The ip or dns adress ofthe scheduler',
1970 'prop' : 'address',
1971 'type' : 'string',
1973 'port' : {
1974 'description' : 'The TCP port of the scheduler',
1975 'prop' : 'port',
1976 'type' : 'int',
1978 'spare' : {
1979 'description' : 'If the scheduler is a spare or not',
1980 'depythonize' : from_bool_to_int,
1981 'prop' : 'spare',
1982 'type' : 'int',
1984 'weight' : {
1985 'description' : 'Weight (in terms of hosts) of the scheduler',
1986 'prop' : 'weight',
1987 'type' : 'int',
1989 'alive' : {
1990 'description' : 'If the scheduler is alive or not',
1991 'prop' : 'alive',
1992 'depythonize' : from_bool_to_int,
1993 'type' : 'int',
1999 #Pollers
2000 'PollerLink' : {
2001 'name' : {
2002 'description' : 'The name of the poller',
2003 'prop' : 'poller_name',
2004 'type' : 'string',
2006 'address' : {
2007 'description' : 'The ip or dns adress of the poller',
2008 'prop' : 'address',
2009 'type' : 'string',
2011 'port' : {
2012 'description' : 'The TCP port of the poller',
2013 'prop' : 'port',
2014 'type' : 'int',
2016 'spare' : {
2017 'description' : 'If the poller is a spare or not',
2018 'depythonize' : from_bool_to_int,
2019 'prop' : 'spare',
2020 'type' : 'int',
2022 'alive' : {
2023 'description' : 'If the poller is alive or not',
2024 'prop' : 'alive',
2025 'depythonize' : from_bool_to_int,
2026 'type' : 'int',
2031 #Reactionners
2032 'ReactionnerLink' : {
2033 'name' : {
2034 'description' : 'The name of the reactionner',
2035 'prop' : 'reactionner_name',
2036 'type' : 'string',
2038 'address' : {
2039 'description' : 'The ip or dns adress of the reactionner',
2040 'prop' : 'address',
2041 'type' : 'string',
2043 'port' : {
2044 'description' : 'The TCP port of the reactionner',
2045 'prop' : 'port',
2046 'type' : 'int',
2048 'spare' : {
2049 'description' : 'If the reactionner is a spare or not',
2050 'depythonize' : from_bool_to_int,
2051 'prop' : 'spare',
2052 'type' : 'int',
2054 'alive' : {
2055 'description' : 'If the reactionner is alive or not',
2056 'prop' : 'alive',
2057 'depythonize' : from_bool_to_int,
2058 'type' : 'int',
2063 #Brokers
2064 'BrokerLink' : {
2065 'name' : {
2066 'description' : 'The name of the broker',
2067 'prop' : 'broker_name',
2068 'type' : 'string',
2070 'address' : {
2071 'description' : 'The ip or dns adress of the broker',
2072 'prop' : 'address',
2073 'type' : 'string',
2075 'port' : {
2076 'description' : 'The TCP port of the broker',
2077 'prop' : 'port',
2078 'type' : 'int',
2080 'spare' : {
2081 'description' : 'If the broker is a spare or not',
2082 'depythonize' : from_bool_to_int,
2083 'prop' : 'spare',
2084 'type' : 'int',
2086 'alive' : {
2087 'description' : 'If the broker is alive or not',
2088 'prop' : 'alive',
2089 'depythonize' : from_bool_to_int,
2090 'type' : 'int',
2095 #Problem
2096 'Problem' : {
2097 'source' : {
2098 'description' : 'The source name of the problem (host or service)',
2099 'prop' : 'source',
2100 'type' : 'string',
2101 'fulldepythonize' : get_livestatus_full_name
2103 'impacts' : {
2104 'description' : 'List of what the source impact (list of hosts and services)',
2105 'prop' : 'impacts',
2106 'type' : 'string',
2107 'depythonize' : from_svc_hst_distinct_lists,
2112 #Downtimes
2113 'Downtime' : {
2114 'author' : {
2115 'default' : 'nobody',
2116 'description' : 'The contact that scheduled the downtime',
2117 'prop' : None,
2118 'type' : 'string',
2120 'comment' : {
2121 'default' : None,
2122 'description' : 'A comment text',
2123 'prop' : None,
2124 'type' : 'string',
2126 'duration' : {
2127 'default' : '0',
2128 'description' : 'The duration of the downtime in seconds',
2129 'prop' : None,
2130 'type' : 'int',
2132 'end_time' : {
2133 'default' : '0',
2134 'description' : 'The end time of the downtime as UNIX timestamp',
2135 'prop' : None,
2136 'type' : 'int',
2138 'entry_time' : {
2139 'default' : '0',
2140 'description' : 'The time the entry was made as UNIX timestamp',
2141 'prop' : None,
2142 'type' : 'int',
2144 'fixed' : {
2145 'default' : None,
2146 'depythonize' : from_bool_to_int,
2147 'description' : 'A 1 if the downtime is fixed, a 0 if it is flexible',
2148 'prop' : None,
2149 'type' : 'int',
2151 'host_accept_passive_checks' : {
2152 'default' : None,
2153 'description' : 'Wether passive host checks are accepted (0/1)',
2154 'prop' : None,
2155 'type' : 'int',
2157 'host_acknowledged' : {
2158 'default' : None,
2159 'description' : 'Wether the current host problem has been acknowledged (0/1)',
2160 'prop' : None,
2161 'type' : 'int',
2163 'host_acknowledgement_type' : {
2164 'default' : None,
2165 'description' : 'Type of acknowledgement (0: none, 1: normal, 2: stick)',
2166 'prop' : None,
2167 'type' : 'int',
2169 'host_action_url' : {
2170 'default' : None,
2171 'description' : 'An optional URL to custom actions or information about this host',
2172 'prop' : None,
2173 'type' : 'string',
2175 'host_action_url_expanded' : {
2176 'default' : None,
2177 'description' : 'The same as action_url, but with the most important macros expanded',
2178 'prop' : None,
2179 'type' : 'string',
2181 'host_active_checks_enabled' : {
2182 'default' : None,
2183 'description' : 'Wether active checks are enabled for the host (0/1)',
2184 'prop' : None,
2185 'type' : 'int',
2187 'host_address' : {
2188 'default' : None,
2189 'description' : 'IP address',
2190 'prop' : None,
2191 'type' : 'string',
2193 'host_alias' : {
2194 'default' : None,
2195 'description' : 'An alias name for the host',
2196 'prop' : None,
2197 'type' : 'string',
2199 'host_check_command' : {
2200 'default' : None,
2201 'description' : 'Nagios command for active host check of this host',
2202 'prop' : None,
2203 'type' : 'string',
2205 'host_check_freshness' : {
2206 'default' : None,
2207 'description' : 'Wether freshness checks are activated (0/1)',
2208 'prop' : None,
2209 'type' : 'int',
2211 'host_check_interval' : {
2212 'default' : None,
2213 'description' : 'Number of basic interval lengths between two scheduled checks of the host',
2214 'prop' : None,
2215 'type' : 'float',
2217 'host_check_options' : {
2218 'default' : None,
2219 'description' : 'The current check option, forced, normal, freshness... (0-2)',
2220 'prop' : None,
2221 'type' : 'int',
2223 'host_check_period' : {
2224 'default' : None,
2225 'description' : 'Time period in which this host will be checked. If empty then the host will always be checked.',
2226 'prop' : None,
2227 'type' : 'string',
2229 'host_check_type' : {
2230 'default' : None,
2231 'description' : 'Type of check (0: active, 1: passive)',
2232 'prop' : None,
2233 'type' : 'int',
2235 'host_checks_enabled' : {
2236 'default' : None,
2237 'description' : 'Wether checks of the host are enabled (0/1)',
2238 'prop' : None,
2239 'type' : 'int',
2241 'host_childs' : {
2242 'default' : None,
2243 'description' : 'A list of all direct childs of the host',
2244 'prop' : None,
2245 'type' : 'list',
2247 'host_comments' : {
2248 'default' : None,
2249 'description' : 'A list of the ids of all comments of this host',
2250 'prop' : None,
2251 'type' : 'list',
2253 'host_contacts' : {
2254 'default' : None,
2255 'description' : 'A list of all contacts of this host, either direct or via a contact group',
2256 'prop' : None,
2257 'type' : 'list',
2259 'host_current_attempt' : {
2260 'default' : None,
2261 'description' : 'Number of the current check attempts',
2262 'prop' : None,
2263 'type' : 'int',
2265 'host_current_notification_number' : {
2266 'default' : None,
2267 'description' : 'Number of the current notification',
2268 'prop' : None,
2269 'type' : 'int',
2271 'host_custom_variable_names' : {
2272 'default' : None,
2273 'description' : 'A list of the names of all custom variables',
2274 'prop' : None,
2275 'type' : 'list',
2277 'host_custom_variable_values' : {
2278 'default' : None,
2279 'description' : 'A list of the values of the custom variables',
2280 'prop' : None,
2281 'type' : 'list',
2283 'host_display_name' : {
2284 'default' : None,
2285 'description' : 'Optional display name of the host - not used by Nagios\' web interface',
2286 'prop' : None,
2287 'type' : 'string',
2289 'host_downtimes' : {
2290 'default' : None,
2291 'description' : 'A list of the ids of all scheduled downtimes of this host',
2292 'prop' : None,
2293 'type' : 'list',
2295 'host_event_handler_enabled' : {
2296 'default' : None,
2297 'description' : 'Wether event handling is enabled (0/1)',
2298 'prop' : None,
2299 'type' : 'int',
2301 'host_execution_time' : {
2302 'default' : None,
2303 'description' : 'Time the host check needed for execution',
2304 'prop' : None,
2305 'type' : 'float',
2307 'host_first_notification_delay' : {
2308 'default' : None,
2309 'description' : 'Delay before the first notification',
2310 'prop' : None,
2311 'type' : 'float',
2313 'host_flap_detection_enabled' : {
2314 'default' : None,
2315 'description' : 'Wether flap detection is enabled (0/1)',
2316 'prop' : None,
2317 'type' : 'int',
2319 'host_groups' : {
2320 'default' : None,
2321 'description' : 'A list of all host groups this host is in',
2322 'prop' : None,
2323 'type' : 'list',
2325 'host_hard_state' : {
2326 'default' : None,
2327 'description' : 'The effective hard state of the host (eliminates a problem in hard_state)',
2328 'prop' : None,
2329 'type' : 'int',
2331 'host_has_been_checked' : {
2332 'default' : None,
2333 'description' : 'Wether the host has already been checked (0/1)',
2334 'prop' : None,
2335 'type' : 'int',
2337 'host_high_flap_threshold' : {
2338 'default' : None,
2339 'description' : 'High threshold of flap detection',
2340 'prop' : None,
2341 'type' : 'float',
2343 'host_icon_image' : {
2344 'default' : None,
2345 'description' : 'The name of an image file to be used in the web pages',
2346 'prop' : None,
2347 'type' : 'string',
2349 'host_icon_image_alt' : {
2350 'default' : None,
2351 'description' : 'Alternative text for the icon_image',
2352 'prop' : None,
2353 'type' : 'string',
2355 'host_icon_image_expanded' : {
2356 'default' : None,
2357 'description' : 'The same as icon_image, but with the most important macros expanded',
2358 'prop' : None,
2359 'type' : 'string',
2361 'host_in_check_period' : {
2362 'default' : None,
2363 'description' : 'Wether this host is currently in its check period (0/1)',
2364 'prop' : None,
2365 'type' : 'int',
2367 'host_in_notification_period' : {
2368 'default' : None,
2369 'description' : 'Wether this host is currently in its notification period (0/1)',
2370 'prop' : None,
2371 'type' : 'int',
2373 'host_initial_state' : {
2374 'default' : None,
2375 'description' : 'Initial host state',
2376 'prop' : None,
2377 'type' : 'int',
2379 'host_is_executing' : {
2380 'default' : 0, # value in scheduler is not real-time
2381 'description' : 'is there a host check currently running... (0/1)',
2382 'prop' : None,
2383 'type' : 'int',
2385 'host_is_flapping' : {
2386 'default' : None,
2387 'description' : 'Wether the host state is flapping (0/1)',
2388 'prop' : None,
2389 'type' : 'int',
2391 'host_last_check' : {
2392 'default' : None,
2393 'description' : 'Time of the last check (Unix timestamp)',
2394 'prop' : None,
2395 'type' : 'int',
2397 'host_last_hard_state' : {
2398 'default' : None,
2399 'description' : 'Last hard state',
2400 'prop' : None,
2401 'type' : 'int',
2403 'host_last_hard_state_change' : {
2404 'default' : None,
2405 'description' : 'Time of the last hard state change (Unix timestamp)',
2406 'prop' : None,
2407 'type' : 'int',
2409 'host_last_notification' : {
2410 'default' : None,
2411 'description' : 'Time of the last notification (Unix timestamp)',
2412 'prop' : None,
2413 'type' : 'int',
2415 'host_last_state' : {
2416 'default' : None,
2417 'description' : 'State before last state change',
2418 'prop' : None,
2419 'type' : 'int',
2421 'host_last_state_change' : {
2422 'default' : None,
2423 'description' : 'Time of the last state change - soft or hard (Unix timestamp)',
2424 'prop' : None,
2425 'type' : 'int',
2427 'host_latency' : {
2428 'default' : None,
2429 'description' : 'Time difference between scheduled check time and actual check time',
2430 'prop' : None,
2431 'type' : 'float',
2433 'host_long_plugin_output' : {
2434 'default' : None,
2435 'description' : 'Complete output from check plugin',
2436 'prop' : None,
2437 'type' : 'string',
2439 'host_low_flap_threshold' : {
2440 'default' : None,
2441 'description' : 'Low threshold of flap detection',
2442 'prop' : None,
2443 'type' : 'float',
2445 'host_max_check_attempts' : {
2446 'default' : None,
2447 'description' : 'Max check attempts for active host checks',
2448 'prop' : None,
2449 'type' : 'int',
2451 'host_name' : {
2452 'default' : None,
2453 'depythonize' : lambda x: x.host_name,
2454 'description' : 'Host name',
2455 'prop' : 'ref',
2456 'type' : 'string',
2458 'host_next_check' : {
2459 'default' : None,
2460 'description' : 'Scheduled time for the next check (Unix timestamp)',
2461 'prop' : None,
2462 'type' : 'int',
2464 'host_next_notification' : {
2465 'default' : None,
2466 'description' : 'Time of the next notification (Unix timestamp)',
2467 'prop' : None,
2468 'type' : 'int',
2470 'host_notes' : {
2471 'default' : None,
2472 'description' : 'Optional notes for this host',
2473 'prop' : None,
2474 'type' : 'string',
2476 'host_notes_expanded' : {
2477 'default' : None,
2478 'description' : 'The same as notes, but with the most important macros expanded',
2479 'prop' : None,
2480 'type' : 'string',
2482 'host_notes_url' : {
2483 'default' : None,
2484 'description' : 'An optional URL with further information about the host',
2485 'prop' : None,
2486 'type' : 'string',
2488 'host_notes_url_expanded' : {
2489 'default' : None,
2490 'description' : 'Same es notes_url, but with the most important macros expanded',
2491 'prop' : None,
2492 'type' : 'string',
2494 'host_notification_interval' : {
2495 'default' : None,
2496 'description' : 'Interval of periodic notification or 0 if its off',
2497 'prop' : None,
2498 'type' : 'float',
2500 'host_notification_period' : {
2501 'default' : None,
2502 'description' : 'Time period in which problems of this host will be notified. If empty then notification will be always',
2503 'prop' : None,
2504 'type' : 'string',
2506 'host_notifications_enabled' : {
2507 'default' : None,
2508 'description' : 'Wether notifications of the host are enabled (0/1)',
2509 'prop' : None,
2510 'type' : 'int',
2512 'host_num_services' : {
2513 'default' : None,
2514 'description' : 'The total number of services of the host',
2515 'prop' : None,
2516 'type' : 'list',
2518 'host_num_services_crit' : {
2519 'default' : None,
2520 'description' : 'The number of the host\'s services with the soft state CRIT',
2521 'prop' : None,
2522 'type' : 'list',
2524 'host_num_services_hard_crit' : {
2525 'default' : None,
2526 'description' : 'The number of the host\'s services with the hard state CRIT',
2527 'prop' : None,
2528 'type' : 'list',
2530 'host_num_services_hard_ok' : {
2531 'default' : None,
2532 'description' : 'The number of the host\'s services with the hard state OK',
2533 'prop' : None,
2534 'type' : 'list',
2536 'host_num_services_hard_unknown' : {
2537 'default' : None,
2538 'description' : 'The number of the host\'s services with the hard state UNKNOWN',
2539 'prop' : None,
2540 'type' : 'list',
2542 'host_num_services_hard_warn' : {
2543 'default' : None,
2544 'description' : 'The number of the host\'s services with the hard state WARN',
2545 'prop' : None,
2546 'type' : 'list',
2548 'host_num_services_ok' : {
2549 'default' : None,
2550 'description' : 'The number of the host\'s services with the soft state OK',
2551 'prop' : None,
2552 'type' : 'list',
2554 'host_num_services_pending' : {
2555 'default' : None,
2556 'description' : 'The number of the host\'s services which have not been checked yet (pending)',
2557 'prop' : None,
2558 'type' : 'list',
2560 'host_num_services_unknown' : {
2561 'default' : None,
2562 'description' : 'The number of the host\'s services with the soft state UNKNOWN',
2563 'prop' : None,
2564 'type' : 'list',
2566 'host_num_services_warn' : {
2567 'default' : None,
2568 'description' : 'The number of the host\'s services with the soft state WARN',
2569 'prop' : None,
2570 'type' : 'list',
2572 'host_obsess_over_host' : {
2573 'default' : None,
2574 'description' : 'The current obsess_over_host setting... (0/1)',
2575 'prop' : None,
2576 'type' : 'int',
2578 'host_parents' : {
2579 'default' : None,
2580 'description' : 'A list of all direct parents of the host',
2581 'prop' : None,
2582 'type' : 'list',
2584 'host_pending_flex_downtime' : {
2585 'default' : None,
2586 'description' : 'Wether a flex downtime is pending (0/1)',
2587 'prop' : None,
2588 'type' : 'int',
2590 'host_percent_state_change' : {
2591 'default' : None,
2592 'description' : 'Percent state change',
2593 'prop' : None,
2594 'type' : 'float',
2596 'host_perf_data' : {
2597 'default' : None,
2598 'description' : 'Optional performance data of the last host check',
2599 'prop' : None,
2600 'type' : 'string',
2602 'host_plugin_output' : {
2603 'default' : None,
2604 'description' : 'Output of the last host check',
2605 'prop' : None,
2606 'type' : 'string',
2608 'host_process_performance_data' : {
2609 'default' : None,
2610 'description' : 'Wether processing of performance data is enabled (0/1)',
2611 'prop' : None,
2612 'type' : 'int',
2614 'host_retry_interval' : {
2615 'default' : None,
2616 'description' : 'Number of basic interval lengths between checks when retrying after a soft error',
2617 'prop' : None,
2618 'type' : 'float',
2620 'host_scheduled_downtime_depth' : {
2621 'default' : None,
2622 'description' : 'The number of downtimes this host is currently in',
2623 'prop' : None,
2624 'type' : 'int',
2626 'host_state' : {
2627 'default' : None,
2628 'description' : 'The current state of the host (0: up, 1: down, 2: unreachable)',
2629 'prop' : None,
2630 'type' : 'int',
2632 'host_state_type' : {
2633 'default' : None,
2634 'description' : 'Type of the current state (0: soft, 1: hard)',
2635 'prop' : None,
2636 'type' : 'int',
2638 'host_statusmap_image' : {
2639 'default' : None,
2640 'description' : 'The name of in image file for the status map',
2641 'prop' : None,
2642 'type' : 'string',
2644 'host_total_services' : {
2645 'default' : None,
2646 'description' : 'The total number of services of the host',
2647 'prop' : None,
2648 'type' : 'int',
2650 'host_worst_service_hard_state' : {
2651 'default' : None,
2652 'description' : 'The worst hard state of all of the host\'s services (OK <= WARN <= UNKNOWN <= CRIT)',
2653 'prop' : None,
2654 'type' : 'list',
2656 'host_worst_service_state' : {
2657 'default' : None,
2658 'description' : 'The worst soft state of all of the host\'s services (OK <= WARN <= UNKNOWN <= CRIT)',
2659 'prop' : None,
2660 'type' : 'list',
2662 'host_x_3d' : {
2663 'default' : None,
2664 'description' : '3D-Coordinates: X',
2665 'prop' : None,
2666 'type' : 'float',
2668 'host_y_3d' : {
2669 'default' : None,
2670 'description' : '3D-Coordinates: Y',
2671 'prop' : None,
2672 'type' : 'float',
2674 'host_z_3d' : {
2675 'default' : None,
2676 'description' : '3D-Coordinates: Z',
2677 'prop' : None,
2678 'type' : 'float',
2680 'id' : {
2681 'default' : None,
2682 'description' : 'The id of the downtime',
2683 'prop' : None,
2684 'type' : 'int',
2686 'service_accept_passive_checks' : {
2687 'default' : None,
2688 'description' : 'Wether the service accepts passive checks (0/1)',
2689 'prop' : None,
2690 'type' : 'int',
2692 'service_acknowledged' : {
2693 'default' : None,
2694 'description' : 'Wether the current service problem has been acknowledged (0/1)',
2695 'prop' : None,
2696 'type' : 'int',
2698 'service_acknowledgement_type' : {
2699 'default' : None,
2700 'description' : 'The type of the acknownledgement (0: none, 1: normal, 2: sticky)',
2701 'prop' : None,
2702 'type' : 'int',
2704 'service_action_url' : {
2705 'default' : None,
2706 'description' : 'An optional URL for actions or custom information about the service',
2707 'prop' : None,
2708 'type' : 'string',
2710 'service_action_url_expanded' : {
2711 'default' : None,
2712 'description' : 'The action_url with (the most important) macros expanded',
2713 'prop' : None,
2714 'type' : 'string',
2716 'service_active_checks_enabled' : {
2717 'default' : None,
2718 'description' : 'Wether active checks are enabled for the service (0/1)',
2719 'prop' : None,
2720 'type' : 'int',
2722 'service_check_command' : {
2723 'default' : None,
2724 'description' : 'Nagios command used for active checks',
2725 'prop' : None,
2726 'type' : 'string',
2728 'service_check_interval' : {
2729 'default' : None,
2730 'description' : 'Number of basic interval lengths between two scheduled checks of the service',
2731 'prop' : None,
2732 'type' : 'float',
2734 'service_check_options' : {
2735 'default' : None,
2736 'description' : 'The current check option, forced, normal, freshness... (0/1)',
2737 'prop' : None,
2738 'type' : 'int',
2740 'service_check_period' : {
2741 'default' : None,
2742 'description' : 'The name of the check period of the service. It this is empty, the service is always checked.',
2743 'prop' : None,
2744 'type' : 'string',
2746 'service_check_type' : {
2747 'default' : None,
2748 'description' : 'The type of the last check (0: active, 1: passive)',
2749 'prop' : None,
2750 'type' : 'int',
2752 'service_checks_enabled' : {
2753 'default' : None,
2754 'description' : 'Wether active checks are enabled for the service (0/1)',
2755 'prop' : None,
2756 'type' : 'int',
2758 'service_comments' : {
2759 'default' : None,
2760 'description' : 'A list of all comment ids of the service',
2761 'prop' : None,
2762 'type' : 'list',
2764 'service_contacts' : {
2765 'default' : None,
2766 'description' : 'A list of all contacts of the service, either direct or via a contact group',
2767 'prop' : None,
2768 'type' : 'list',
2770 'service_current_attempt' : {
2771 'default' : None,
2772 'description' : 'The number of the current check attempt',
2773 'prop' : None,
2774 'type' : 'int',
2776 'service_current_notification_number' : {
2777 'default' : None,
2778 'description' : 'The number of the current notification',
2779 'prop' : None,
2780 'type' : 'int',
2782 'service_custom_variable_names' : {
2783 'default' : None,
2784 'description' : 'A list of the names of all custom variables of the service',
2785 'prop' : None,
2786 'type' : 'list',
2788 'service_custom_variable_values' : {
2789 'default' : None,
2790 'description' : 'A list of the values of all custom variable of the service',
2791 'prop' : None,
2792 'type' : 'list',
2794 'service_description' : {
2795 'default' : None,
2796 'depythonize' : lambda x: getattr(x, 'service_description', ''),
2797 'description' : 'Description of the service (also used as key)',
2798 'prop' : 'ref',
2799 'type' : 'string',
2801 'service_display_name' : {
2802 'default' : None,
2803 'description' : 'An optional display name (not used by Nagios standard web pages)',
2804 'prop' : None,
2805 'type' : 'string',
2807 'service_downtimes' : {
2808 'default' : None,
2809 'description' : 'A list of all downtime ids of the service',
2810 'prop' : None,
2811 'type' : 'list',
2813 'service_event_handler' : {
2814 'default' : None,
2815 'description' : 'Nagios command used as event handler',
2816 'prop' : None,
2817 'type' : 'string',
2819 'service_event_handler_enabled' : {
2820 'default' : None,
2821 'description' : 'Wether and event handler is activated for the service (0/1)',
2822 'prop' : None,
2823 'type' : 'int',
2825 'service_execution_time' : {
2826 'default' : None,
2827 'description' : 'Time the host check needed for execution',
2828 'prop' : None,
2829 'type' : 'float',
2831 'service_first_notification_delay' : {
2832 'default' : None,
2833 'description' : 'Delay before the first notification',
2834 'prop' : None,
2835 'type' : 'float',
2837 'service_flap_detection_enabled' : {
2838 'default' : None,
2839 'description' : 'Wether flap detection is enabled for the service (0/1)',
2840 'prop' : None,
2841 'type' : 'int',
2843 'service_groups' : {
2844 'default' : None,
2845 'description' : 'A list of all service groups the service is in',
2846 'prop' : None,
2847 'type' : 'list',
2849 'service_has_been_checked' : {
2850 'default' : None,
2851 'description' : 'Wether the service already has been checked (0/1)',
2852 'prop' : None,
2853 'type' : 'int',
2855 'service_high_flap_threshold' : {
2856 'default' : None,
2857 'description' : 'High threshold of flap detection',
2858 'prop' : None,
2859 'type' : 'float',
2861 'service_icon_image' : {
2862 'default' : None,
2863 'description' : 'The name of an image to be used as icon in the web interface',
2864 'prop' : None,
2865 'type' : 'string',
2867 'service_icon_image_alt' : {
2868 'default' : None,
2869 'description' : 'An alternative text for the icon_image for browsers not displaying icons',
2870 'prop' : None,
2871 'type' : 'string',
2873 'service_icon_image_expanded' : {
2874 'default' : None,
2875 'description' : 'The icon_image with (the most important) macros expanded',
2876 'prop' : None,
2877 'type' : 'string',
2879 'service_in_check_period' : {
2880 'default' : None,
2881 'description' : 'Wether the service is currently in its check period (0/1)',
2882 'prop' : None,
2883 'type' : 'int',
2885 'service_in_notification_period' : {
2886 'default' : None,
2887 'description' : 'Wether the service is currently in its notification period (0/1)',
2888 'prop' : None,
2889 'type' : 'int',
2891 'service_initial_state' : {
2892 'default' : None,
2893 'description' : 'The initial state of the service',
2894 'prop' : None,
2895 'type' : 'int',
2897 'service_is_executing' : {
2898 'default' : 0, # value in scheduler is not real-time
2899 'description' : 'is there a service check currently running... (0/1)',
2900 'prop' : None,
2901 'type' : 'int',
2903 'service_is_flapping' : {
2904 'default' : None,
2905 'description' : 'Wether the service is flapping (0/1)',
2906 'prop' : None,
2907 'type' : 'int',
2909 'service_last_check' : {
2910 'default' : None,
2911 'description' : 'The time of the last check (Unix timestamp)',
2912 'prop' : None,
2913 'type' : 'int',
2915 'service_last_hard_state' : {
2916 'default' : None,
2917 'description' : 'The last hard state of the service',
2918 'prop' : None,
2919 'type' : 'int',
2921 'service_last_hard_state_change' : {
2922 'default' : None,
2923 'description' : 'The time of the last hard state change (Unix timestamp)',
2924 'prop' : None,
2925 'type' : 'int',
2927 'service_last_notification' : {
2928 'default' : None,
2929 'description' : 'The time of the last notification (Unix timestamp)',
2930 'prop' : None,
2931 'type' : 'int',
2933 'service_last_state' : {
2934 'default' : None,
2935 'description' : 'The last state of the service',
2936 'prop' : None,
2937 'type' : 'int',
2939 'service_last_state_change' : {
2940 'default' : None,
2941 'description' : 'The time of the last state change (Unix timestamp)',
2942 'prop' : None,
2943 'type' : 'int',
2945 'service_latency' : {
2946 'default' : None,
2947 'description' : 'Time difference between scheduled check time and actual check time',
2948 'prop' : None,
2949 'type' : 'float',
2951 'service_long_plugin_output' : {
2952 'default' : None,
2953 'description' : 'Unabbreviated output of the last check plugin',
2954 'prop' : None,
2955 'type' : 'string',
2957 'service_low_flap_threshold' : {
2958 'default' : None,
2959 'description' : 'Low threshold of flap detection',
2960 'prop' : None,
2961 'type' : 'float',
2963 'service_max_check_attempts' : {
2964 'default' : None,
2965 'description' : 'The maximum number of check attempts',
2966 'prop' : None,
2967 'type' : 'int',
2969 'service_next_check' : {
2970 'default' : None,
2971 'description' : 'The scheduled time of the next check (Unix timestamp)',
2972 'prop' : None,
2973 'type' : 'int',
2975 'service_next_notification' : {
2976 'default' : None,
2977 'description' : 'The time of the next notification (Unix timestamp)',
2978 'prop' : None,
2979 'type' : 'int',
2981 'service_notes' : {
2982 'default' : None,
2983 'description' : 'Optional notes about the service',
2984 'prop' : None,
2985 'type' : 'string',
2987 'service_notes_expanded' : {
2988 'default' : None,
2989 'description' : 'The notes with (the most important) macros expanded',
2990 'prop' : None,
2991 'type' : 'string',
2993 'service_notes_url' : {
2994 'default' : None,
2995 'description' : 'An optional URL for additional notes about the service',
2996 'prop' : None,
2997 'type' : 'string',
2999 'service_notes_url_expanded' : {
3000 'default' : None,
3001 'description' : 'The notes_url with (the most important) macros expanded',
3002 'prop' : None,
3003 'type' : 'string',
3005 'service_notification_interval' : {
3006 'default' : None,
3007 'description' : 'Interval of periodic notification or 0 if its off',
3008 'prop' : None,
3009 'type' : 'float',
3011 'service_notification_period' : {
3012 'default' : None,
3013 'description' : 'The name of the notification period of the service. It this is empty, service problems are always notified.',
3014 'prop' : None,
3015 'type' : 'string',
3017 'service_notifications_enabled' : {
3018 'default' : None,
3019 'description' : 'Wether notifications are enabled for the service (0/1)',
3020 'prop' : None,
3021 'type' : 'int',
3023 'service_obsess_over_service' : {
3024 'default' : None,
3025 'description' : 'Wether \'obsess_over_service\' is enabled for the service (0/1)',
3026 'prop' : None,
3027 'type' : 'int',
3029 'service_percent_state_change' : {
3030 'default' : None,
3031 'description' : 'Percent state change',
3032 'prop' : None,
3033 'type' : 'float',
3035 'service_perf_data' : {
3036 'default' : None,
3037 'description' : 'Performance data of the last check plugin',
3038 'prop' : None,
3039 'type' : 'string',
3041 'service_plugin_output' : {
3042 'default' : None,
3043 'description' : 'Output of the last check plugin',
3044 'prop' : None,
3045 'type' : 'string',
3047 'service_process_performance_data' : {
3048 'default' : None,
3049 'description' : 'Wether processing of performance data is enabled for the service (0/1)',
3050 'prop' : None,
3051 'type' : 'int',
3053 'service_retry_interval' : {
3054 'default' : None,
3055 'description' : 'Number of basic interval lengths between checks when retrying after a soft error',
3056 'prop' : None,
3057 'type' : 'float',
3059 'service_scheduled_downtime_depth' : {
3060 'default' : None,
3061 'description' : 'The number of scheduled downtimes the service is currently in',
3062 'prop' : None,
3063 'type' : 'int',
3065 'service_state' : {
3066 'default' : None,
3067 'description' : 'The current state of the service (0: OK, 1: WARN, 2: CRITICAL, 3: UNKNOWN)',
3068 'prop' : None,
3069 'type' : 'int',
3071 'service_state_type' : {
3072 'default' : None,
3073 'description' : 'The type of the current state (0: soft, 1: hard)',
3074 'prop' : None,
3075 'type' : 'int',
3077 'start_time' : {
3078 'default' : '0',
3079 'description' : 'The start time of the downtime as UNIX timestamp',
3080 'prop' : None,
3081 'type' : 'int',
3083 'triggered_by' : {
3084 'default' : None,
3085 'description' : 'The id of the downtime this downtime was triggered by or 0 if it was not triggered by another downtime',
3086 'prop' : 'trigger_id',
3087 'type' : 'int',
3089 'type' : {
3090 'default' : None,
3091 'description' : 'The type of the downtime: 0 if it is active, 1 if it is pending',
3092 'prop' : None,
3093 'type' : 'int',
3097 #Comments
3099 'Comment' : {
3100 'author' : {
3101 'default' : None,
3102 'description' : 'The contact that entered the comment',
3103 'prop' : None,
3104 'type' : 'string',
3106 'comment' : {
3107 'default' : None,
3108 'description' : 'A comment text',
3109 'prop' : None,
3110 'type' : 'string',
3112 'entry_time' : {
3113 'default' : None,
3114 'description' : 'The time the entry was made as UNIX timestamp',
3115 'prop' : None,
3116 'type' : 'int',
3118 'entry_type' : {
3119 'default' : '0',
3120 'description' : 'The type of the comment: 1 is user, 2 is downtime, 3 is flap and 4 is acknowledgement',
3121 'prop' : 'entry_type',
3122 'type' : 'int',
3124 'expire_time' : {
3125 'default' : '0',
3126 'description' : 'The time of expiry of this comment as a UNIX timestamp',
3127 'prop' : None,
3128 'type' : 'int',
3130 'expires' : {
3131 'default' : None,
3132 'depythonize' : from_bool_to_int,
3133 'description' : 'Whether this comment expires',
3134 'prop' : None,
3135 'type' : 'int',
3137 'host_accept_passive_checks' : {
3138 'default' : None,
3139 'description' : 'Wether passive host checks are accepted (0/1)',
3140 'prop' : None,
3141 'type' : 'int',
3143 'host_acknowledged' : {
3144 'default' : None,
3145 'description' : 'Wether the current host problem has been acknowledged (0/1)',
3146 'prop' : None,
3147 'type' : 'int',
3149 'host_acknowledgement_type' : {
3150 'default' : None,
3151 'description' : 'Type of acknowledgement (0: none, 1: normal, 2: stick)',
3152 'prop' : None,
3153 'type' : 'int',
3155 'host_action_url' : {
3156 'default' : None,
3157 'description' : 'An optional URL to custom actions or information about this host',
3158 'prop' : None,
3159 'type' : 'string',
3161 'host_action_url_expanded' : {
3162 'default' : None,
3163 'description' : 'The same as action_url, but with the most important macros expanded',
3164 'prop' : None,
3165 'type' : 'string',
3167 'host_active_checks_enabled' : {
3168 'default' : None,
3169 'description' : 'Wether active checks are enabled for the host (0/1)',
3170 'prop' : None,
3171 'type' : 'int',
3173 'host_address' : {
3174 'default' : None,
3175 'description' : 'IP address',
3176 'prop' : None,
3177 'type' : 'string',
3179 'host_alias' : {
3180 'default' : None,
3181 'description' : 'An alias name for the host',
3182 'prop' : None,
3183 'type' : 'string',
3185 'host_check_command' : {
3186 'default' : None,
3187 'description' : 'Nagios command for active host check of this host',
3188 'prop' : None,
3189 'type' : 'string',
3191 'host_check_freshness' : {
3192 'default' : None,
3193 'description' : 'Wether freshness checks are activated (0/1)',
3194 'prop' : None,
3195 'type' : 'int',
3197 'host_check_interval' : {
3198 'default' : None,
3199 'description' : 'Number of basic interval lengths between two scheduled checks of the host',
3200 'prop' : None,
3201 'type' : 'float',
3203 'host_check_options' : {
3204 'default' : None,
3205 'description' : 'The current check option, forced, normal, freshness... (0-2)',
3206 'prop' : None,
3207 'type' : 'int',
3209 'host_check_period' : {
3210 'default' : None,
3211 'description' : 'Time period in which this host will be checked. If empty then the host will always be checked.',
3212 'prop' : None,
3213 'type' : 'string',
3215 'host_check_type' : {
3216 'default' : None,
3217 'description' : 'Type of check (0: active, 1: passive)',
3218 'prop' : None,
3219 'type' : 'int',
3221 'host_checks_enabled' : {
3222 'default' : None,
3223 'description' : 'Wether checks of the host are enabled (0/1)',
3224 'prop' : None,
3225 'type' : 'int',
3227 'host_childs' : {
3228 'default' : None,
3229 'description' : 'A list of all direct childs of the host',
3230 'prop' : None,
3231 'type' : 'list',
3233 'host_comments' : {
3234 'default' : None,
3235 'description' : 'A list of the ids of all comments of this host',
3236 'prop' : None,
3237 'type' : 'list',
3239 'host_contacts' : {
3240 'default' : None,
3241 'description' : 'A list of all contacts of this host, either direct or via a contact group',
3242 'prop' : None,
3243 'type' : 'list',
3245 'host_current_attempt' : {
3246 'default' : None,
3247 'description' : 'Number of the current check attempts',
3248 'prop' : None,
3249 'type' : 'int',
3251 'host_current_notification_number' : {
3252 'default' : None,
3253 'description' : 'Number of the current notification',
3254 'prop' : None,
3255 'type' : 'int',
3257 'host_custom_variable_names' : {
3258 'default' : None,
3259 'description' : 'A list of the names of all custom variables',
3260 'prop' : None,
3261 'type' : 'list',
3263 'host_custom_variable_values' : {
3264 'default' : None,
3265 'description' : 'A list of the values of the custom variables',
3266 'prop' : None,
3267 'type' : 'list',
3269 'host_display_name' : {
3270 'default' : None,
3271 'description' : 'Optional display name of the host - not used by Nagios\' web interface',
3272 'prop' : None,
3273 'type' : 'string',
3275 'host_downtimes' : {
3276 'default' : None,
3277 'description' : 'A list of the ids of all scheduled downtimes of this host',
3278 'prop' : None,
3279 'type' : 'list',
3281 'host_event_handler_enabled' : {
3282 'default' : None,
3283 'description' : 'Wether event handling is enabled (0/1)',
3284 'prop' : None,
3285 'type' : 'int',
3287 'host_execution_time' : {
3288 'default' : None,
3289 'description' : 'Time the host check needed for execution',
3290 'prop' : None,
3291 'type' : 'float',
3293 'host_first_notification_delay' : {
3294 'default' : None,
3295 'description' : 'Delay before the first notification',
3296 'prop' : None,
3297 'type' : 'float',
3299 'host_flap_detection_enabled' : {
3300 'default' : None,
3301 'description' : 'Wether flap detection is enabled (0/1)',
3302 'prop' : None,
3303 'type' : 'int',
3305 'host_groups' : {
3306 'default' : None,
3307 'description' : 'A list of all host groups this host is in',
3308 'prop' : None,
3309 'type' : 'list',
3311 'host_hard_state' : {
3312 'default' : None,
3313 'description' : 'The effective hard state of the host (eliminates a problem in hard_state)',
3314 'prop' : None,
3315 'type' : 'int',
3317 'host_has_been_checked' : {
3318 'default' : None,
3319 'description' : 'Wether the host has already been checked (0/1)',
3320 'prop' : None,
3321 'type' : 'int',
3323 'host_high_flap_threshold' : {
3324 'default' : None,
3325 'description' : 'High threshold of flap detection',
3326 'prop' : None,
3327 'type' : 'float',
3329 'host_icon_image' : {
3330 'default' : None,
3331 'description' : 'The name of an image file to be used in the web pages',
3332 'prop' : None,
3333 'type' : 'string',
3335 'host_icon_image_alt' : {
3336 'default' : None,
3337 'description' : 'Alternative text for the icon_image',
3338 'prop' : None,
3339 'type' : 'string',
3341 'host_icon_image_expanded' : {
3342 'default' : None,
3343 'description' : 'The same as icon_image, but with the most important macros expanded',
3344 'prop' : None,
3345 'type' : 'string',
3347 'host_in_check_period' : {
3348 'default' : None,
3349 'description' : 'Wether this host is currently in its check period (0/1)',
3350 'prop' : None,
3351 'type' : 'int',
3353 'host_in_notification_period' : {
3354 'default' : None,
3355 'description' : 'Wether this host is currently in its notification period (0/1)',
3356 'prop' : None,
3357 'type' : 'int',
3359 'host_initial_state' : {
3360 'default' : None,
3361 'description' : 'Initial host state',
3362 'prop' : None,
3363 'type' : 'int',
3365 'host_is_executing' : {
3366 'default' : 0, # value in scheduler is not real-time
3367 'description' : 'is there a host check currently running... (0/1)',
3368 'prop' : None,
3369 'type' : 'int',
3371 'host_is_flapping' : {
3372 'default' : None,
3373 'description' : 'Wether the host state is flapping (0/1)',
3374 'prop' : None,
3375 'type' : 'int',
3377 'host_last_check' : {
3378 'default' : None,
3379 'description' : 'Time of the last check (Unix timestamp)',
3380 'prop' : None,
3381 'type' : 'int',
3383 'host_last_hard_state' : {
3384 'default' : None,
3385 'description' : 'Last hard state',
3386 'prop' : None,
3387 'type' : 'int',
3389 'host_last_hard_state_change' : {
3390 'default' : None,
3391 'description' : 'Time of the last hard state change (Unix timestamp)',
3392 'prop' : None,
3393 'type' : 'int',
3395 'host_last_notification' : {
3396 'default' : None,
3397 'description' : 'Time of the last notification (Unix timestamp)',
3398 'prop' : None,
3399 'type' : 'int',
3401 'host_last_state' : {
3402 'default' : None,
3403 'description' : 'State before last state change',
3404 'prop' : None,
3405 'type' : 'int',
3407 'host_last_state_change' : {
3408 'default' : None,
3409 'description' : 'Time of the last state change - soft or hard (Unix timestamp)',
3410 'prop' : None,
3411 'type' : 'int',
3413 'host_latency' : {
3414 'default' : None,
3415 'description' : 'Time difference between scheduled check time and actual check time',
3416 'prop' : None,
3417 'type' : 'float',
3419 'host_long_plugin_output' : {
3420 'default' : None,
3421 'description' : 'Complete output from check plugin',
3422 'prop' : None,
3423 'type' : 'string',
3425 'host_low_flap_threshold' : {
3426 'default' : None,
3427 'description' : 'Low threshold of flap detection',
3428 'prop' : None,
3429 'type' : 'float',
3431 'host_max_check_attempts' : {
3432 'default' : None,
3433 'description' : 'Max check attempts for active host checks',
3434 'prop' : None,
3435 'type' : 'int',
3437 'host_name' : {
3438 'default' : None,
3439 'depythonize' : lambda x: x.host_name,
3440 'description' : 'Host name',
3441 'prop' : 'ref',
3442 'type' : 'string',
3444 'host_next_check' : {
3445 'default' : None,
3446 'description' : 'Scheduled time for the next check (Unix timestamp)',
3447 'prop' : None,
3448 'type' : 'int',
3450 'host_next_notification' : {
3451 'default' : None,
3452 'description' : 'Time of the next notification (Unix timestamp)',
3453 'prop' : None,
3454 'type' : 'int',
3456 'host_notes' : {
3457 'default' : None,
3458 'description' : 'Optional notes for this host',
3459 'prop' : None,
3460 'type' : 'string',
3462 'host_notes_expanded' : {
3463 'default' : None,
3464 'description' : 'The same as notes, but with the most important macros expanded',
3465 'prop' : None,
3466 'type' : 'string',
3468 'host_notes_url' : {
3469 'default' : None,
3470 'description' : 'An optional URL with further information about the host',
3471 'prop' : None,
3472 'type' : 'string',
3474 'host_notes_url_expanded' : {
3475 'default' : None,
3476 'description' : 'Same es notes_url, but with the most important macros expanded',
3477 'prop' : None,
3478 'type' : 'string',
3480 'host_notification_interval' : {
3481 'default' : None,
3482 'description' : 'Interval of periodic notification or 0 if its off',
3483 'prop' : None,
3484 'type' : 'float',
3486 'host_notification_period' : {
3487 'default' : None,
3488 'description' : 'Time period in which problems of this host will be notified. If empty then notification will be always',
3489 'prop' : None,
3490 'type' : 'string',
3492 'host_notifications_enabled' : {
3493 'default' : None,
3494 'description' : 'Wether notifications of the host are enabled (0/1)',
3495 'prop' : None,
3496 'type' : 'int',
3498 'host_num_services' : {
3499 'default' : None,
3500 'description' : 'The total number of services of the host',
3501 'prop' : None,
3502 'type' : 'list',
3504 'host_num_services_crit' : {
3505 'default' : None,
3506 'description' : 'The number of the host\'s services with the soft state CRIT',
3507 'prop' : None,
3508 'type' : 'list',
3510 'host_num_services_hard_crit' : {
3511 'default' : None,
3512 'description' : 'The number of the host\'s services with the hard state CRIT',
3513 'prop' : None,
3514 'type' : 'list',
3516 'host_num_services_hard_ok' : {
3517 'default' : None,
3518 'description' : 'The number of the host\'s services with the hard state OK',
3519 'prop' : None,
3520 'type' : 'list',
3522 'host_num_services_hard_unknown' : {
3523 'default' : None,
3524 'description' : 'The number of the host\'s services with the hard state UNKNOWN',
3525 'prop' : None,
3526 'type' : 'list',
3528 'host_num_services_hard_warn' : {
3529 'default' : None,
3530 'description' : 'The number of the host\'s services with the hard state WARN',
3531 'prop' : None,
3532 'type' : 'list',
3534 'host_num_services_ok' : {
3535 'default' : None,
3536 'description' : 'The number of the host\'s services with the soft state OK',
3537 'prop' : None,
3538 'type' : 'list',
3540 'host_num_services_pending' : {
3541 'default' : None,
3542 'description' : 'The number of the host\'s services which have not been checked yet (pending)',
3543 'prop' : None,
3544 'type' : 'list',
3546 'host_num_services_unknown' : {
3547 'default' : None,
3548 'description' : 'The number of the host\'s services with the soft state UNKNOWN',
3549 'prop' : None,
3550 'type' : 'list',
3552 'host_num_services_warn' : {
3553 'default' : None,
3554 'description' : 'The number of the host\'s services with the soft state WARN',
3555 'prop' : None,
3556 'type' : 'list',
3558 'host_obsess_over_host' : {
3559 'default' : None,
3560 'description' : 'The current obsess_over_host setting... (0/1)',
3561 'prop' : None,
3562 'type' : 'int',
3564 'host_parents' : {
3565 'default' : None,
3566 'description' : 'A list of all direct parents of the host',
3567 'prop' : None,
3568 'type' : 'list',
3570 'host_pending_flex_downtime' : {
3571 'default' : None,
3572 'description' : 'Wether a flex downtime is pending (0/1)',
3573 'prop' : None,
3574 'type' : 'int',
3576 'host_percent_state_change' : {
3577 'default' : None,
3578 'description' : 'Percent state change',
3579 'prop' : None,
3580 'type' : 'float',
3582 'host_perf_data' : {
3583 'default' : None,
3584 'description' : 'Optional performance data of the last host check',
3585 'prop' : None,
3586 'type' : 'string',
3588 'host_plugin_output' : {
3589 'default' : None,
3590 'description' : 'Output of the last host check',
3591 'prop' : None,
3592 'type' : 'string',
3594 'host_process_performance_data' : {
3595 'default' : None,
3596 'description' : 'Wether processing of performance data is enabled (0/1)',
3597 'prop' : None,
3598 'type' : 'int',
3600 'host_retry_interval' : {
3601 'default' : None,
3602 'description' : 'Number of basic interval lengths between checks when retrying after a soft error',
3603 'prop' : None,
3604 'type' : 'float',
3606 'host_scheduled_downtime_depth' : {
3607 'default' : None,
3608 'description' : 'The number of downtimes this host is currently in',
3609 'prop' : None,
3610 'type' : 'int',
3612 'host_state' : {
3613 'default' : None,
3614 'description' : 'The current state of the host (0: up, 1: down, 2: unreachable)',
3615 'prop' : None,
3616 'type' : 'int',
3618 'host_state_type' : {
3619 'default' : None,
3620 'description' : 'Type of the current state (0: soft, 1: hard)',
3621 'prop' : None,
3622 'type' : 'int',
3624 'host_statusmap_image' : {
3625 'default' : None,
3626 'description' : 'The name of in image file for the status map',
3627 'prop' : None,
3628 'type' : 'string',
3630 'host_total_services' : {
3631 'default' : None,
3632 'description' : 'The total number of services of the host',
3633 'prop' : None,
3634 'type' : 'int',
3636 'host_worst_service_hard_state' : {
3637 'default' : None,
3638 'description' : 'The worst hard state of all of the host\'s services (OK <= WARN <= UNKNOWN <= CRIT)',
3639 'prop' : None,
3640 'type' : 'list',
3642 'host_worst_service_state' : {
3643 'default' : None,
3644 'description' : 'The worst soft state of all of the host\'s services (OK <= WARN <= UNKNOWN <= CRIT)',
3645 'prop' : None,
3646 'type' : 'list',
3648 'host_x_3d' : {
3649 'default' : None,
3650 'description' : '3D-Coordinates: X',
3651 'prop' : None,
3652 'type' : 'float',
3654 'host_y_3d' : {
3655 'default' : None,
3656 'description' : '3D-Coordinates: Y',
3657 'prop' : None,
3658 'type' : 'float',
3660 'host_z_3d' : {
3661 'default' : None,
3662 'description' : '3D-Coordinates: Z',
3663 'prop' : None,
3664 'type' : 'float',
3666 'id' : {
3667 'default' : None,
3668 'description' : 'The id of the comment',
3669 'prop' : None,
3670 'type' : 'int',
3672 'persistent' : {
3673 'default' : None,
3674 'depythonize' : from_bool_to_int,
3675 'description' : 'Whether this comment is persistent (0/1)',
3676 'prop' : None,
3677 'type' : 'int',
3679 'service_accept_passive_checks' : {
3680 'default' : None,
3681 'description' : 'Wether the service accepts passive checks (0/1)',
3682 'prop' : None,
3683 'type' : 'int',
3685 'service_acknowledged' : {
3686 'default' : None,
3687 'description' : 'Wether the current service problem has been acknowledged (0/1)',
3688 'prop' : None,
3689 'type' : 'int',
3691 'service_acknowledgement_type' : {
3692 'default' : None,
3693 'description' : 'The type of the acknownledgement (0: none, 1: normal, 2: sticky)',
3694 'prop' : None,
3695 'type' : 'int',
3697 'service_action_url' : {
3698 'default' : None,
3699 'description' : 'An optional URL for actions or custom information about the service',
3700 'prop' : None,
3701 'type' : 'string',
3703 'service_action_url_expanded' : {
3704 'default' : None,
3705 'description' : 'The action_url with (the most important) macros expanded',
3706 'prop' : None,
3707 'type' : 'string',
3709 'service_active_checks_enabled' : {
3710 'default' : None,
3711 'description' : 'Wether active checks are enabled for the service (0/1)',
3712 'prop' : None,
3713 'type' : 'int',
3715 'service_check_command' : {
3716 'default' : None,
3717 'description' : 'Nagios command used for active checks',
3718 'prop' : None,
3719 'type' : 'string',
3721 'service_check_interval' : {
3722 'default' : None,
3723 'description' : 'Number of basic interval lengths between two scheduled checks of the service',
3724 'prop' : None,
3725 'type' : 'float',
3727 'service_check_options' : {
3728 'default' : None,
3729 'description' : 'The current check option, forced, normal, freshness... (0/1)',
3730 'prop' : None,
3731 'type' : 'int',
3733 'service_check_period' : {
3734 'default' : None,
3735 'description' : 'The name of the check period of the service. It this is empty, the service is always checked.',
3736 'prop' : None,
3737 'type' : 'string',
3739 'service_check_type' : {
3740 'default' : None,
3741 'description' : 'The type of the last check (0: active, 1: passive)',
3742 'prop' : None,
3743 'type' : 'int',
3745 'service_checks_enabled' : {
3746 'default' : None,
3747 'description' : 'Wether active checks are enabled for the service (0/1)',
3748 'prop' : None,
3749 'type' : 'int',
3751 'service_comments' : {
3752 'default' : None,
3753 'description' : 'A list of all comment ids of the service',
3754 'prop' : None,
3755 'type' : 'list',
3757 'service_contacts' : {
3758 'default' : None,
3759 'description' : 'A list of all contacts of the service, either direct or via a contact group',
3760 'prop' : None,
3761 'type' : 'list',
3763 'service_current_attempt' : {
3764 'default' : None,
3765 'description' : 'The number of the current check attempt',
3766 'prop' : None,
3767 'type' : 'int',
3769 'service_current_notification_number' : {
3770 'default' : None,
3771 'description' : 'The number of the current notification',
3772 'prop' : None,
3773 'type' : 'int',
3775 'service_custom_variable_names' : {
3776 'default' : None,
3777 'description' : 'A list of the names of all custom variables of the service',
3778 'prop' : None,
3779 'type' : 'list',
3781 'service_custom_variable_values' : {
3782 'default' : None,
3783 'description' : 'A list of the values of all custom variable of the service',
3784 'prop' : None,
3785 'type' : 'list',
3787 'service_description' : {
3788 'default' : None,
3789 'depythonize' : lambda x: getattr(x, 'service_description', ''),
3790 'description' : 'Description of the service (also used as key)',
3791 'prop' : 'ref',
3792 'type' : 'string',
3794 'service_display_name' : {
3795 'default' : None,
3796 'description' : 'An optional display name (not used by Nagios standard web pages)',
3797 'prop' : None,
3798 'type' : 'string',
3800 'service_downtimes' : {
3801 'default' : None,
3802 'description' : 'A list of all downtime ids of the service',
3803 'prop' : None,
3804 'type' : 'list',
3806 'service_event_handler' : {
3807 'default' : None,
3808 'description' : 'Nagios command used as event handler',
3809 'prop' : None,
3810 'type' : 'string',
3812 'service_event_handler_enabled' : {
3813 'default' : None,
3814 'description' : 'Wether and event handler is activated for the service (0/1)',
3815 'prop' : None,
3816 'type' : 'int',
3818 'service_execution_time' : {
3819 'default' : None,
3820 'description' : 'Time the host check needed for execution',
3821 'prop' : None,
3822 'type' : 'float',
3824 'service_first_notification_delay' : {
3825 'default' : None,
3826 'description' : 'Delay before the first notification',
3827 'prop' : None,
3828 'type' : 'float',
3830 'service_flap_detection_enabled' : {
3831 'default' : None,
3832 'description' : 'Wether flap detection is enabled for the service (0/1)',
3833 'prop' : None,
3834 'type' : 'int',
3836 'service_groups' : {
3837 'default' : None,
3838 'description' : 'A list of all service groups the service is in',
3839 'prop' : None,
3840 'type' : 'list',
3842 'service_has_been_checked' : {
3843 'default' : None,
3844 'description' : 'Wether the service already has been checked (0/1)',
3845 'prop' : None,
3846 'type' : 'int',
3848 'service_high_flap_threshold' : {
3849 'default' : None,
3850 'description' : 'High threshold of flap detection',
3851 'prop' : None,
3852 'type' : 'float',
3854 'service_icon_image' : {
3855 'default' : None,
3856 'description' : 'The name of an image to be used as icon in the web interface',
3857 'prop' : None,
3858 'type' : 'string',
3860 'service_icon_image_alt' : {
3861 'default' : None,
3862 'description' : 'An alternative text for the icon_image for browsers not displaying icons',
3863 'prop' : None,
3864 'type' : 'string',
3866 'service_icon_image_expanded' : {
3867 'default' : None,
3868 'description' : 'The icon_image with (the most important) macros expanded',
3869 'prop' : None,
3870 'type' : 'string',
3872 'service_in_check_period' : {
3873 'default' : None,
3874 'description' : 'Wether the service is currently in its check period (0/1)',
3875 'prop' : None,
3876 'type' : 'int',
3878 'service_in_notification_period' : {
3879 'default' : None,
3880 'description' : 'Wether the service is currently in its notification period (0/1)',
3881 'prop' : None,
3882 'type' : 'int',
3884 'service_initial_state' : {
3885 'default' : None,
3886 'description' : 'The initial state of the service',
3887 'prop' : None,
3888 'type' : 'int',
3890 'service_is_executing' : {
3891 'default' : 0, # value in scheduler is not real-time
3892 'description' : 'is there a service check currently running... (0/1)',
3893 'prop' : None,
3894 'type' : 'int',
3896 'service_is_flapping' : {
3897 'default' : None,
3898 'description' : 'Wether the service is flapping (0/1)',
3899 'prop' : None,
3900 'type' : 'int',
3902 'service_last_check' : {
3903 'default' : None,
3904 'description' : 'The time of the last check (Unix timestamp)',
3905 'prop' : None,
3906 'type' : 'int',
3908 'service_last_hard_state' : {
3909 'default' : None,
3910 'description' : 'The last hard state of the service',
3911 'prop' : None,
3912 'type' : 'int',
3914 'service_last_hard_state_change' : {
3915 'default' : None,
3916 'description' : 'The time of the last hard state change (Unix timestamp)',
3917 'prop' : None,
3918 'type' : 'int',
3920 'service_last_notification' : {
3921 'default' : None,
3922 'description' : 'The time of the last notification (Unix timestamp)',
3923 'prop' : None,
3924 'type' : 'int',
3926 'service_last_state' : {
3927 'default' : None,
3928 'description' : 'The last state of the service',
3929 'prop' : None,
3930 'type' : 'int',
3932 'service_last_state_change' : {
3933 'default' : None,
3934 'description' : 'The time of the last state change (Unix timestamp)',
3935 'prop' : None,
3936 'type' : 'int',
3938 'service_latency' : {
3939 'default' : None,
3940 'description' : 'Time difference between scheduled check time and actual check time',
3941 'prop' : None,
3942 'type' : 'float',
3944 'service_long_plugin_output' : {
3945 'default' : None,
3946 'description' : 'Unabbreviated output of the last check plugin',
3947 'prop' : None,
3948 'type' : 'string',
3950 'service_low_flap_threshold' : {
3951 'default' : None,
3952 'description' : 'Low threshold of flap detection',
3953 'prop' : None,
3954 'type' : 'float',
3956 'service_max_check_attempts' : {
3957 'default' : None,
3958 'description' : 'The maximum number of check attempts',
3959 'prop' : None,
3960 'type' : 'int',
3962 'service_next_check' : {
3963 'default' : None,
3964 'description' : 'The scheduled time of the next check (Unix timestamp)',
3965 'prop' : None,
3966 'type' : 'int',
3968 'service_next_notification' : {
3969 'default' : None,
3970 'description' : 'The time of the next notification (Unix timestamp)',
3971 'prop' : None,
3972 'type' : 'int',
3974 'service_notes' : {
3975 'default' : None,
3976 'description' : 'Optional notes about the service',
3977 'prop' : None,
3978 'type' : 'string',
3980 'service_notes_expanded' : {
3981 'default' : None,
3982 'description' : 'The notes with (the most important) macros expanded',
3983 'prop' : None,
3984 'type' : 'string',
3986 'service_notes_url' : {
3987 'default' : None,
3988 'description' : 'An optional URL for additional notes about the service',
3989 'prop' : None,
3990 'type' : 'string',
3992 'service_notes_url_expanded' : {
3993 'default' : None,
3994 'description' : 'The notes_url with (the most important) macros expanded',
3995 'prop' : None,
3996 'type' : 'string',
3998 'service_notification_interval' : {
3999 'default' : None,
4000 'description' : 'Interval of periodic notification or 0 if its off',
4001 'prop' : None,
4002 'type' : 'float',
4004 'service_notification_period' : {
4005 'default' : None,
4006 'description' : 'The name of the notification period of the service. It this is empty, service problems are always notified.',
4007 'prop' : None,
4008 'type' : 'string',
4010 'service_notifications_enabled' : {
4011 'default' : None,
4012 'description' : 'Wether notifications are enabled for the service (0/1)',
4013 'prop' : None,
4014 'type' : 'int',
4016 'service_obsess_over_service' : {
4017 'default' : None,
4018 'description' : 'Wether \'obsess_over_service\' is enabled for the service (0/1)',
4019 'prop' : None,
4020 'type' : 'int',
4022 'service_percent_state_change' : {
4023 'default' : None,
4024 'description' : 'Percent state change',
4025 'prop' : None,
4026 'type' : 'float',
4028 'service_perf_data' : {
4029 'default' : None,
4030 'description' : 'Performance data of the last check plugin',
4031 'prop' : None,
4032 'type' : 'string',
4034 'service_plugin_output' : {
4035 'default' : None,
4036 'description' : 'Output of the last check plugin',
4037 'prop' : None,
4038 'type' : 'string',
4040 'service_process_performance_data' : {
4041 'default' : None,
4042 'description' : 'Wether processing of performance data is enabled for the service (0/1)',
4043 'prop' : None,
4044 'type' : 'int',
4046 'service_retry_interval' : {
4047 'default' : None,
4048 'description' : 'Number of basic interval lengths between checks when retrying after a soft error',
4049 'prop' : None,
4050 'type' : 'float',
4052 'service_scheduled_downtime_depth' : {
4053 'default' : None,
4054 'description' : 'The number of scheduled downtimes the service is currently in',
4055 'prop' : None,
4056 'type' : 'int',
4058 'service_state' : {
4059 'default' : None,
4060 'description' : 'The current state of the service (0: OK, 1: WARN, 2: CRITICAL, 3: UNKNOWN)',
4061 'prop' : None,
4062 'type' : 'int',
4064 'service_state_type' : {
4065 'default' : None,
4066 'description' : 'The type of the current state (0: soft, 1: hard)',
4067 'prop' : None,
4068 'type' : 'int',
4070 'source' : {
4071 'default' : '0',
4072 'description' : 'The source of the comment (0 is internal and 1 is external)',
4073 'prop' : None,
4074 'type' : 'int',
4076 'type' : {
4077 'default' : '1',
4078 'description' : 'The type of the comment: 1 is service, 2 is host',
4079 'prop' : 'comment_type',
4080 'type' : 'int',
4084 # loop over hostgroups then over members
4085 'Hostsbygroup' : {
4086 'hostgroup_action_url' : {
4087 'description' : 'An optional URL to custom actions or information about the hostgroup',
4088 'prop' : 'hostgroup',
4089 'type' : 'string',
4091 'hostgroup_alias' : {
4092 'depythonize' : lambda x: getattr(x, 'hostgroup_alias', ''),
4093 'description' : 'An alias of the hostgroup',
4094 'prop' : 'hostgroup',
4095 'type' : 'string',
4097 'hostgroup_members' : {
4098 'description' : 'A list of all host names that are members of the hostgroup',
4099 'prop' : 'hostgroup',
4100 'type' : 'list',
4102 'hostgroup_members_with_state' : {
4103 'description' : 'A list of all host names that are members of the hostgroup together with state and has_been_checked',
4104 'prop' : 'hostgroup',
4105 'type' : 'list',
4107 'hostgroup_name' : {
4108 'depythonize' : lambda x: getattr(x, 'hostgroup_name', ''),
4109 'description' : 'Name of the hostgroup',
4110 'prop' : 'hostgroup',
4111 'type' : 'string',
4113 'hostgroup_notes' : {
4114 'description' : 'Optional notes to the hostgroup',
4115 'prop' : 'hostgroup',
4116 'type' : 'string',
4118 'hostgroup_notes_url' : {
4119 'description' : 'An optional URL with further information about the hostgroup',
4120 'prop' : 'hostgroup',
4121 'type' : 'string',
4123 'hostgroup_num_hosts' : {
4124 'description' : 'The total number of hosts in the group',
4125 'prop' : 'hostgroup',
4126 'type' : 'int',
4128 'hostgroup_num_hosts_down' : {
4129 'description' : 'The number of hosts in the group that are down',
4130 'prop' : 'hostgroup',
4131 'type' : 'int',
4133 'hostgroup_num_hosts_pending' : {
4134 'description' : 'The number of hosts in the group that are pending',
4135 'prop' : 'hostgroup',
4136 'type' : 'int',
4138 'hostgroup_num_hosts_unreach' : {
4139 'description' : 'The number of hosts in the group that are unreachable',
4140 'prop' : 'hostgroup',
4141 'type' : 'int',
4143 'hostgroup_num_hosts_up' : {
4144 'description' : 'The number of hosts in the group that are up',
4145 'prop' : 'hostgroup',
4146 'type' : 'int',
4148 'hostgroup_num_services' : {
4149 'description' : 'The total number of services of hosts in this group',
4150 'prop' : 'hostgroup',
4151 'type' : 'int',
4153 'hostgroup_num_services_crit' : {
4154 'description' : 'The total number of services with the state CRIT of hosts in this group',
4155 'prop' : 'hostgroup',
4156 'type' : 'int',
4158 'hostgroup_num_services_hard_crit' : {
4159 'description' : 'The total number of services with the state CRIT of hosts in this group',
4160 'prop' : 'hostgroup',
4161 'type' : 'int',
4163 'hostgroup_num_services_hard_ok' : {
4164 'description' : 'The total number of services with the state OK of hosts in this group',
4165 'prop' : 'hostgroup',
4166 'type' : 'int',
4168 'hostgroup_num_services_hard_unknown' : {
4169 'description' : 'The total number of services with the state UNKNOWN of hosts in this group',
4170 'prop' : 'hostgroup',
4171 'type' : 'int',
4173 'hostgroup_num_services_hard_warn' : {
4174 'description' : 'The total number of services with the state WARN of hosts in this group',
4175 'prop' : 'hostgroup',
4176 'type' : 'int',
4178 'hostgroup_num_services_ok' : {
4179 'description' : 'The total number of services with the state OK of hosts in this group',
4180 'prop' : 'hostgroup',
4181 'type' : 'int',
4183 'hostgroup_num_services_pending' : {
4184 'description' : 'The total number of services with the state Pending of hosts in this group',
4185 'prop' : 'hostgroup',
4186 'type' : 'int',
4188 'hostgroup_num_services_unknown' : {
4189 'description' : 'The total number of services with the state UNKNOWN of hosts in this group',
4190 'prop' : 'hostgroup',
4191 'type' : 'int',
4193 'hostgroup_num_services_warn' : {
4194 'description' : 'The total number of services with the state WARN of hosts in this group',
4195 'prop' : 'hostgroup',
4196 'type' : 'int',
4198 'hostgroup_worst_host_state' : {
4199 'description' : 'The worst state of all of the groups\' hosts (UP <= UNREACHABLE <= DOWN)',
4200 'prop' : 'hostgroup',
4201 'type' : 'int',
4203 'hostgroup_worst_service_hard_state' : {
4204 'description' : 'The worst state of all services that belong to a host of this group (OK <= WARN <= UNKNOWN <= CRIT)',
4205 'prop' : 'hostgroup',
4206 'type' : 'int',
4208 'hostgroup_worst_service_state' : {
4209 'description' : 'The worst state of all services that belong to a host of this group (OK <= WARN <= UNKNOWN <= CRIT)',
4210 'prop' : 'hostgroup',
4211 'type' : 'int',
4215 'Servicesbygroup' : {
4216 'servicegroup_action_url' : {
4217 'description' : 'An optional URL to custom notes or actions on the service group',
4218 'type' : 'string',
4220 'servicegroup_alias' : {
4221 'description' : 'An alias of the service group',
4222 'type' : 'string',
4224 'servicegroup_members' : {
4225 'description' : 'A list of all members of the service group as host/service pairs',
4226 'type' : 'list',
4228 'servicegroup_members_with_state' : {
4229 'description' : 'A list of all members of the service group with state and has_been_checked',
4230 'type' : 'list',
4232 'servicegroup_name' : {
4233 'description' : 'The name of the service group',
4234 'type' : 'string',
4236 'servicegroup_notes' : {
4237 'description' : 'Optional additional notes about the service group',
4238 'type' : 'string',
4240 'servicegroup_notes_url' : {
4241 'description' : 'An optional URL to further notes on the service group',
4242 'type' : 'string',
4244 'servicegroup_num_services' : {
4245 'description' : 'The total number of services in the group',
4246 'type' : 'int',
4248 'servicegroup_num_services_crit' : {
4249 'description' : 'The number of services in the group that are CRIT',
4250 'type' : 'int',
4252 'servicegroup_num_services_hard_crit' : {
4253 'description' : 'The number of services in the group that are CRIT',
4254 'type' : 'int',
4256 'servicegroup_num_services_hard_ok' : {
4257 'description' : 'The number of services in the group that are OK',
4258 'type' : 'int',
4260 'servicegroup_num_services_hard_unknown' : {
4261 'description' : 'The number of services in the group that are UNKNOWN',
4262 'type' : 'int',
4264 'servicegroup_num_services_hard_warn' : {
4265 'description' : 'The number of services in the group that are WARN',
4266 'type' : 'int',
4268 'servicegroup_num_services_ok' : {
4269 'description' : 'The number of services in the group that are OK',
4270 'type' : 'int',
4272 'servicegroup_num_services_pending' : {
4273 'description' : 'The number of services in the group that are PENDING',
4274 'type' : 'int',
4276 'servicegroup_num_services_unknown' : {
4277 'description' : 'The number of services in the group that are UNKNOWN',
4278 'type' : 'int',
4280 'servicegroup_num_services_warn' : {
4281 'description' : 'The number of services in the group that are WARN',
4282 'type' : 'int',
4284 'servicegroup_worst_service_state' : {
4285 'description' : 'The worst soft state of all of the groups services (OK <= WARN <= UNKNOWN <= CRIT)',
4286 'type' : 'int',
4290 'Servicesbyhostgroup' : {
4291 'hostgroup_action_url' : {
4292 'description' : 'An optional URL to custom actions or information about the hostgroup',
4293 'type' : 'string',
4295 'hostgroup_alias' : {
4296 'description' : 'An alias of the hostgroup',
4297 'type' : 'string',
4299 'hostgroup_members' : {
4300 'description' : 'A list of all host names that are members of the hostgroup',
4301 'type' : 'list',
4303 'hostgroup_members_with_state' : {
4304 'description' : 'A list of all host names that are members of the hostgroup together with state and has_been_checked',
4305 'type' : 'list',
4307 'hostgroup_name' : {
4308 'depythonize' : lambda x: getattr(x, 'hostgroup_name', ''),
4309 'description' : 'Name of the hostgroup',
4310 'prop' : 'hostgroup',
4311 'type' : 'string',
4313 'hostgroup_notes' : {
4314 'description' : 'Optional notes to the hostgroup',
4315 'type' : 'string',
4317 'hostgroup_notes_url' : {
4318 'description' : 'An optional URL with further information about the hostgroup',
4319 'type' : 'string',
4321 'hostgroup_num_hosts' : {
4322 'description' : 'The total number of hosts in the group',
4323 'type' : 'int',
4325 'hostgroup_num_hosts_down' : {
4326 'description' : 'The number of hosts in the group that are down',
4327 'type' : 'int',
4329 'hostgroup_num_hosts_pending' : {
4330 'description' : 'The number of hosts in the group that are pending',
4331 'type' : 'int',
4333 'hostgroup_num_hosts_unreach' : {
4334 'description' : 'The number of hosts in the group that are unreachable',
4335 'type' : 'int',
4337 'hostgroup_num_hosts_up' : {
4338 'description' : 'The number of hosts in the group that are up',
4339 'type' : 'int',
4341 'hostgroup_num_services' : {
4342 'description' : 'The total number of services of hosts in this group',
4343 'type' : 'int',
4345 'hostgroup_num_services_crit' : {
4346 'description' : 'The total number of services with the state CRIT of hosts in this group',
4347 'type' : 'int',
4349 'hostgroup_num_services_hard_crit' : {
4350 'description' : 'The total number of services with the state CRIT of hosts in this group',
4351 'type' : 'int',
4353 'hostgroup_num_services_hard_ok' : {
4354 'description' : 'The total number of services with the state OK of hosts in this group',
4355 'type' : 'int',
4357 'hostgroup_num_services_hard_unknown' : {
4358 'description' : 'The total number of services with the state UNKNOWN of hosts in this group',
4359 'type' : 'int',
4361 'hostgroup_num_services_hard_warn' : {
4362 'description' : 'The total number of services with the state WARN of hosts in this group',
4363 'type' : 'int',
4365 'hostgroup_num_services_ok' : {
4366 'description' : 'The total number of services with the state OK of hosts in this group',
4367 'type' : 'int',
4369 'hostgroup_num_services_pending' : {
4370 'description' : 'The total number of services with the state Pending of hosts in this group',
4371 'type' : 'int',
4373 'hostgroup_num_services_unknown' : {
4374 'description' : 'The total number of services with the state UNKNOWN of hosts in this group',
4375 'type' : 'int',
4377 'hostgroup_num_services_warn' : {
4378 'description' : 'The total number of services with the state WARN of hosts in this group',
4379 'type' : 'int',
4381 'hostgroup_worst_host_state' : {
4382 'description' : 'The worst state of all of the groups\' hosts (UP <= UNREACHABLE <= DOWN)',
4383 'type' : 'int',
4385 'hostgroup_worst_service_hard_state' : {
4386 'description' : 'The worst state of all services that belong to a host of this group (OK <= WARN <= UNKNOWN <= CRIT)',
4387 'type' : 'int',
4389 'hostgroup_worst_service_state' : {
4390 'description' : 'The worst state of all services that belong to a host of this group (OK <= WARN <= UNKNOWN <= CRIT)',
4391 'type' : 'int',
4395 #All the global config parameters
4397 'Config' : {
4398 'accept_passive_host_checks' : {
4399 'default' : '0',
4400 'depythonize' : from_bool_to_int,
4401 'description' : 'Whether passive host checks are accepted in general (0/1)',
4402 'prop' : 'passive_host_checks_enabled',
4403 'type' : 'int',
4405 'accept_passive_service_checks' : {
4406 'default' : '0',
4407 'depythonize' : from_bool_to_int,
4408 'description' : 'Whether passive service checks are activated in general (0/1)',
4409 'prop' : 'passive_service_checks_enabled',
4410 'type' : 'int',
4412 'cached_log_messages' : {
4413 'default' : '0',
4414 'description' : 'The current number of log messages MK Livestatus keeps in memory',
4415 'prop' : None,
4416 'type' : 'int',
4418 'check_external_commands' : {
4419 'default' : '0',
4420 'depythonize' : from_bool_to_int,
4421 'description' : 'Whether Nagios checks for external commands at its command pipe (0/1)',
4422 'prop' : None,
4423 'type' : 'int',
4425 'check_host_freshness' : {
4426 'default' : '0',
4427 'depythonize' : from_bool_to_int,
4428 'description' : 'Whether host freshness checking is activated in general (0/1)',
4429 'prop' : None,
4430 'type' : 'int',
4432 'check_service_freshness' : {
4433 'default' : '0',
4434 'depythonize' : from_bool_to_int,
4435 'description' : 'Whether service freshness checking is activated in general (0/1)',
4436 'prop' : None,
4437 'type' : 'int',
4439 'connections' : {
4440 'default' : '0',
4441 'description' : 'The number of client connections to Livestatus since program start',
4442 'prop' : None,
4443 'type' : 'int',
4445 'connections_rate' : {
4446 'default' : '0',
4447 'description' : 'The averaged number of new client connections to Livestatus per second',
4448 'prop' : None,
4449 'type' : 'float',
4451 'enable_event_handlers' : {
4452 'default' : '0',
4453 'depythonize' : from_bool_to_int,
4454 'description' : 'Whether event handlers are activated in general (0/1)',
4455 'prop' : 'event_handlers_enabled',
4456 'type' : 'int',
4458 'enable_flap_detection' : {
4459 'default' : '0',
4460 'depythonize' : from_bool_to_int,
4461 'description' : 'Whether flap detection is activated in general (0/1)',
4462 'prop' : 'flap_detection_enabled',
4463 'type' : 'int',
4465 'enable_notifications' : {
4466 'default' : '0',
4467 'depythonize' : from_bool_to_int,
4468 'description' : 'Whether notifications are enabled in general (0/1)',
4469 'prop' : 'notifications_enabled',
4470 'type' : 'int',
4472 'execute_host_checks' : {
4473 'default' : '1',
4474 'depythonize' : from_bool_to_int,
4475 'description' : 'Whether host checks are executed in general (0/1)',
4476 'prop' : 'active_host_checks_enabled',
4477 'type' : 'int',
4479 'execute_service_checks' : {
4480 'default' : '1',
4481 'depythonize' : from_bool_to_int,
4482 'description' : 'Whether active service checks are activated in general (0/1)',
4483 'prop' : 'active_service_checks_enabled',
4484 'type' : 'int',
4486 'host_checks' : {
4487 'default' : '0',
4488 'description' : 'The number of host checks since program start',
4489 'prop' : None,
4490 'type' : 'int',
4492 'host_checks_rate' : {
4493 'default' : '0',
4494 'description' : 'the averaged number of host checks per second',
4495 'prop' : None,
4496 'type' : 'float',
4498 'interval_length' : {
4499 'default' : '0',
4500 'description' : 'The default interval length from nagios.cfg',
4501 'prop' : None,
4502 'type' : 'int',
4504 'last_command_check' : {
4505 'default' : '0',
4506 'description' : 'The time of the last check for a command as UNIX timestamp',
4507 'prop' : None,
4508 'type' : 'int',
4510 'last_log_rotation' : {
4511 'default' : '0',
4512 'description' : 'Time time of the last log file rotation',
4513 'prop' : None,
4514 'type' : 'int',
4516 'livestatus_version' : {
4517 'default' : '1.1.3-shinken',
4518 'description' : 'The version of the MK Livestatus module',
4519 'prop' : None,
4520 'type' : 'string',
4522 'nagios_pid' : {
4523 'default' : '0',
4524 'description' : 'The process ID of the Nagios main process',
4525 'prop' : 'pid',
4526 'type' : 'int',
4528 'neb_callbacks' : {
4529 'default' : '0',
4530 'description' : 'The number of NEB call backs since program start',
4531 'prop' : None,
4532 'type' : 'int',
4534 'neb_callbacks_rate' : {
4535 'default' : '0',
4536 'description' : 'The averaged number of NEB call backs per second',
4537 'prop' : None,
4538 'type' : 'float',
4540 'obsess_over_hosts' : {
4541 'default' : '0',
4542 'depythonize' : from_bool_to_int,
4543 'description' : 'Whether Nagios will obsess over host checks (0/1)',
4544 'prop' : None,
4545 'type' : 'int',
4547 'obsess_over_services' : {
4548 'default' : '0',
4549 'depythonize' : from_bool_to_int,
4550 'description' : 'Whether Nagios will obsess over service checks and run the ocsp_command (0/1)',
4551 'prop' : None,
4552 'type' : 'int',
4554 'process_performance_data' : {
4555 'default' : '0',
4556 'depythonize' : from_bool_to_int,
4557 'description' : 'Whether processing of performance data is activated in general (0/1)',
4558 'prop' : None,
4559 'type' : 'int',
4561 'program_start' : {
4562 'default' : '0',
4563 'description' : 'The time of the last program start as UNIX timestamp',
4564 'prop' : None,
4565 'type' : 'int',
4567 'program_version' : {
4568 'default' : VERSION,
4569 'description' : 'The version of the monitoring daemon',
4570 'prop' : None,
4571 'type' : 'string',
4573 'requests' : {
4574 'default' : '0',
4575 'description' : 'The number of requests to Livestatus since program start',
4576 'prop' : None,
4577 'type' : 'int',
4579 'requests_rate' : {
4580 'default' : '0',
4581 'description' : 'The averaged number of request to Livestatus per second',
4582 'prop' : None,
4583 'type' : 'float',
4585 'service_checks' : {
4586 'default' : '0',
4587 'description' : 'The number of completed service checks since program start',
4588 'prop' : None,
4589 'type' : 'int',
4591 'service_checks_rate' : {
4592 'default' : '0',
4593 'description' : 'The averaged number of service checks per second',
4594 'prop' : None,
4595 'type' : 'float',
4599 'Logline' : {
4600 'attempt' : {
4601 'description' : 'The number of the check attempt',
4602 'type' : 'int',
4604 'class' : {
4605 'description' : 'The class of the message as integer (0:info, 1:state, 2:program, 3:notification, 4:passive, 5:command)',
4606 'type' : 'int',
4608 'command_name' : {
4609 'description' : 'The name of the command of the log entry (e.g. for notifications)',
4610 'type' : 'string',
4612 'comment' : {
4613 'description' : 'A comment field used in various message types',
4614 'type' : 'string',
4616 'contact_name' : {
4617 'description' : 'The name of the contact the log entry is about (might be empty)',
4618 'type' : 'string',
4620 'current_command_line' : {
4621 'description' : 'The shell command line',
4622 'type' : 'string',
4624 'current_command_name' : {
4625 'description' : 'The name of the command',
4626 'type' : 'string',
4628 'current_contact_address1' : {
4629 'description' : 'The additional field address1',
4630 'type' : 'string',
4632 'current_contact_address2' : {
4633 'description' : 'The additional field address2',
4634 'type' : 'string',
4636 'current_contact_address3' : {
4637 'description' : 'The additional field address3',
4638 'type' : 'string',
4640 'current_contact_address4' : {
4641 'description' : 'The additional field address4',
4642 'type' : 'string',
4644 'current_contact_address5' : {
4645 'description' : 'The additional field address5',
4646 'type' : 'string',
4648 'current_contact_address6' : {
4649 'description' : 'The additional field address6',
4650 'type' : 'string',
4652 'current_contact_alias' : {
4653 'description' : 'The full name of the contact',
4654 'type' : 'string',
4656 'current_contact_can_submit_commands' : {
4657 'description' : 'Wether the contact is allowed to submit commands (0/1)',
4658 'type' : 'int',
4660 'current_contact_custom_variable_names' : {
4661 'description' : 'A list of all custom variables of the contact',
4662 'type' : 'list',
4664 'current_contact_custom_variable_values' : {
4665 'description' : 'A list of the values of all custom variables of the contact',
4666 'type' : 'list',
4668 'current_contact_email' : {
4669 'description' : 'The email address of the contact',
4670 'type' : 'string',
4672 'current_contact_host_notification_period' : {
4673 'description' : 'The time period in which the contact will be notified about host problems',
4674 'type' : 'string',
4676 'current_contact_host_notifications_enabled' : {
4677 'description' : 'Wether the contact will be notified about host problems in general (0/1)',
4678 'type' : 'int',
4680 'current_contact_in_host_notification_period' : {
4681 'description' : 'Wether the contact is currently in his/her host notification period (0/1)',
4682 'type' : 'int',
4684 'current_contact_in_service_notification_period' : {
4685 'description' : 'Wether the contact is currently in his/her service notification period (0/1)',
4686 'type' : 'int',
4688 'current_contact_name' : {
4689 'description' : 'The login name of the contact person',
4690 'type' : 'string',
4692 'current_contact_pager' : {
4693 'description' : 'The pager address of the contact',
4694 'type' : 'string',
4696 'current_contact_service_notification_period' : {
4697 'description' : 'The time period in which the contact will be notified about service problems',
4698 'type' : 'string',
4700 'current_contact_service_notifications_enabled' : {
4701 'description' : 'Wether the contact will be notified about service problems in general (0/1)',
4702 'type' : 'int',
4704 'current_host_accept_passive_checks' : {
4705 'description' : 'Wether passive host checks are accepted (0/1)',
4706 'type' : 'int',
4708 'current_host_acknowledged' : {
4709 'description' : 'Wether the current host problem has been acknowledged (0/1)',
4710 'type' : 'int',
4712 'current_host_acknowledgement_type' : {
4713 'description' : 'Type of acknowledgement (0: none, 1: normal, 2: stick)',
4714 'type' : 'int',
4716 'current_host_action_url' : {
4717 'description' : 'An optional URL to custom actions or information about this host',
4718 'type' : 'string',
4720 'current_host_action_url_expanded' : {
4721 'description' : 'The same as action_url, but with the most important macros expanded',
4722 'type' : 'string',
4724 'current_host_active_checks_enabled' : {
4725 'description' : 'Wether active checks are enabled for the host (0/1)',
4726 'type' : 'int',
4728 'current_host_address' : {
4729 'description' : 'IP address',
4730 'type' : 'string',
4732 'current_host_alias' : {
4733 'description' : 'An alias name for the host',
4734 'type' : 'string',
4736 'current_host_check_command' : {
4737 'description' : 'Nagios command for active host check of this host',
4738 'type' : 'string',
4740 'current_host_check_freshness' : {
4741 'description' : 'Wether freshness checks are activated (0/1)',
4742 'type' : 'int',
4744 'current_host_check_interval' : {
4745 'description' : 'Number of basic interval lengths between two scheduled checks of the host',
4746 'type' : 'float',
4748 'current_host_check_options' : {
4749 'description' : 'The current check option, forced, normal, freshness... (0-2)',
4750 'type' : 'int',
4752 'current_host_check_period' : {
4753 'description' : 'Time period in which this host will be checked. If empty then the host will always be checked.',
4754 'type' : 'string',
4756 'current_host_check_type' : {
4757 'description' : 'Type of check (0: active, 1: passive)',
4758 'type' : 'int',
4760 'current_host_checks_enabled' : {
4761 'description' : 'Wether checks of the host are enabled (0/1)',
4762 'type' : 'int',
4764 'current_host_childs' : {
4765 'description' : 'A list of all direct childs of the host',
4766 'type' : 'list',
4768 'current_host_comments' : {
4769 'description' : 'A list of the ids of all comments of this host',
4770 'type' : 'list',
4772 'current_host_contacts' : {
4773 'description' : 'A list of all contacts of this host, either direct or via a contact group',
4774 'type' : 'list',
4776 'current_host_current_attempt' : {
4777 'description' : 'Number of the current check attempts',
4778 'type' : 'int',
4780 'current_host_current_notification_number' : {
4781 'description' : 'Number of the current notification',
4782 'type' : 'int',
4784 'current_host_custom_variable_names' : {
4785 'description' : 'A list of the names of all custom variables',
4786 'type' : 'list',
4788 'current_host_custom_variable_values' : {
4789 'description' : 'A list of the values of the custom variables',
4790 'type' : 'list',
4792 'current_host_display_name' : {
4793 'description' : 'Optional display name of the host - not used by Nagios\' web interface',
4794 'type' : 'string',
4796 'current_host_downtimes' : {
4797 'description' : 'A list of the ids of all scheduled downtimes of this host',
4798 'type' : 'list',
4800 'current_host_event_handler_enabled' : {
4801 'description' : 'Wether event handling is enabled (0/1)',
4802 'type' : 'int',
4804 'current_host_execution_time' : {
4805 'description' : 'Time the host check needed for execution',
4806 'type' : 'float',
4808 'current_host_first_notification_delay' : {
4809 'description' : 'Delay before the first notification',
4810 'type' : 'float',
4812 'current_host_flap_detection_enabled' : {
4813 'description' : 'Wether flap detection is enabled (0/1)',
4814 'type' : 'int',
4816 'current_host_groups' : {
4817 'description' : 'A list of all host groups this host is in',
4818 'type' : 'list',
4820 'current_host_hard_state' : {
4821 'description' : 'The effective hard state of the host (eliminates a problem in hard_state)',
4822 'type' : 'int',
4824 'current_host_has_been_checked' : {
4825 'description' : 'Wether the host has already been checked (0/1)',
4826 'type' : 'int',
4828 'current_host_high_flap_threshold' : {
4829 'description' : 'High threshold of flap detection',
4830 'type' : 'float',
4832 'current_host_icon_image' : {
4833 'description' : 'The name of an image file to be used in the web pages',
4834 'type' : 'string',
4836 'current_host_icon_image_alt' : {
4837 'description' : 'Alternative text for the icon_image',
4838 'type' : 'string',
4840 'current_host_icon_image_expanded' : {
4841 'description' : 'The same as icon_image, but with the most important macros expanded',
4842 'type' : 'string',
4844 'current_host_in_check_period' : {
4845 'description' : 'Wether this host is currently in its check period (0/1)',
4846 'type' : 'int',
4848 'current_host_in_notification_period' : {
4849 'description' : 'Wether this host is currently in its notification period (0/1)',
4850 'type' : 'int',
4852 'current_host_initial_state' : {
4853 'description' : 'Initial host state',
4854 'type' : 'int',
4856 'current_host_is_executing' : {
4857 'default' : 0, # value in scheduler is not real-time
4858 'description' : 'is there a host check currently running... (0/1)',
4859 'type' : 'int',
4861 'current_host_is_flapping' : {
4862 'description' : 'Wether the host state is flapping (0/1)',
4863 'type' : 'int',
4865 'current_host_last_check' : {
4866 'description' : 'Time of the last check (Unix timestamp)',
4867 'type' : 'int',
4869 'current_host_last_hard_state' : {
4870 'description' : 'Last hard state',
4871 'type' : 'int',
4873 'current_host_last_hard_state_change' : {
4874 'description' : 'Time of the last hard state change (Unix timestamp)',
4875 'type' : 'int',
4877 'current_host_last_notification' : {
4878 'description' : 'Time of the last notification (Unix timestamp)',
4879 'type' : 'int',
4881 'current_host_last_state' : {
4882 'description' : 'State before last state change',
4883 'type' : 'int',
4885 'current_host_last_state_change' : {
4886 'description' : 'Time of the last state change - soft or hard (Unix timestamp)',
4887 'type' : 'int',
4889 'current_host_latency' : {
4890 'description' : 'Time difference between scheduled check time and actual check time',
4891 'type' : 'float',
4893 'current_host_long_plugin_output' : {
4894 'description' : 'Complete output from check plugin',
4895 'type' : 'string',
4897 'current_host_low_flap_threshold' : {
4898 'description' : 'Low threshold of flap detection',
4899 'type' : 'float',
4901 'current_host_max_check_attempts' : {
4902 'description' : 'Max check attempts for active host checks',
4903 'type' : 'int',
4905 'current_host_name' : {
4906 'default' : '',
4907 'depythonize' : lambda x: x.get_name(),
4908 'description' : 'Host name',
4909 'prop' : 'log_host',
4910 'type' : 'string',
4912 'current_host_next_check' : {
4913 'description' : 'Scheduled time for the next check (Unix timestamp)',
4914 'type' : 'int',
4916 'current_host_next_notification' : {
4917 'description' : 'Time of the next notification (Unix timestamp)',
4918 'type' : 'int',
4920 'current_host_notes' : {
4921 'description' : 'Optional notes for this host',
4922 'type' : 'string',
4924 'current_host_notes_expanded' : {
4925 'description' : 'The same as notes, but with the most important macros expanded',
4926 'type' : 'string',
4928 'current_host_notes_url' : {
4929 'description' : 'An optional URL with further information about the host',
4930 'type' : 'string',
4932 'current_host_notes_url_expanded' : {
4933 'description' : 'Same es notes_url, but with the most important macros expanded',
4934 'type' : 'string',
4936 'current_host_notification_interval' : {
4937 'description' : 'Interval of periodic notification or 0 if its off',
4938 'type' : 'float',
4940 'current_host_notification_period' : {
4941 'description' : 'Time period in which problems of this host will be notified. If empty then notification will be always',
4942 'type' : 'string',
4944 'current_host_notifications_enabled' : {
4945 'description' : 'Wether notifications of the host are enabled (0/1)',
4946 'type' : 'int',
4948 'current_host_num_services' : {
4949 'description' : 'The total number of services of the host',
4950 'type' : 'list',
4952 'current_host_num_services_crit' : {
4953 'description' : 'The number of the host\'s services with the soft state CRIT',
4954 'type' : 'list',
4956 'current_host_num_services_hard_crit' : {
4957 'description' : 'The number of the host\'s services with the hard state CRIT',
4958 'type' : 'list',
4960 'current_host_num_services_hard_ok' : {
4961 'description' : 'The number of the host\'s services with the hard state OK',
4962 'type' : 'list',
4964 'current_host_num_services_hard_unknown' : {
4965 'description' : 'The number of the host\'s services with the hard state UNKNOWN',
4966 'type' : 'list',
4968 'current_host_num_services_hard_warn' : {
4969 'description' : 'The number of the host\'s services with the hard state WARN',
4970 'type' : 'list',
4972 'current_host_num_services_ok' : {
4973 'description' : 'The number of the host\'s services with the soft state OK',
4974 'type' : 'list',
4976 'current_host_num_services_pending' : {
4977 'description' : 'The number of the host\'s services which have not been checked yet (pending)',
4978 'type' : 'list',
4980 'current_host_num_services_unknown' : {
4981 'description' : 'The number of the host\'s services with the soft state UNKNOWN',
4982 'type' : 'list',
4984 'current_host_num_services_warn' : {
4985 'description' : 'The number of the host\'s services with the soft state WARN',
4986 'type' : 'list',
4988 'current_host_obsess_over_host' : {
4989 'description' : 'The current obsess_over_host setting... (0/1)',
4990 'type' : 'int',
4992 'current_host_parents' : {
4993 'description' : 'A list of all direct parents of the host',
4994 'type' : 'list',
4996 'current_host_pending_flex_downtime' : {
4997 'description' : 'Wether a flex downtime is pending (0/1)',
4998 'type' : 'int',
5000 'current_host_percent_state_change' : {
5001 'description' : 'Percent state change',
5002 'type' : 'float',
5004 'current_host_perf_data' : {
5005 'description' : 'Optional performance data of the last host check',
5006 'type' : 'string',
5008 'current_host_plugin_output' : {
5009 'description' : 'Output of the last host check',
5010 'type' : 'string',
5012 'current_host_process_performance_data' : {
5013 'description' : 'Wether processing of performance data is enabled (0/1)',
5014 'type' : 'int',
5016 'current_host_retry_interval' : {
5017 'description' : 'Number of basic interval lengths between checks when retrying after a soft error',
5018 'type' : 'float',
5020 'current_host_scheduled_downtime_depth' : {
5021 'description' : 'The number of downtimes this host is currently in',
5022 'type' : 'int',
5024 'current_host_state' : {
5025 'description' : 'The current state of the host (0: up, 1: down, 2: unreachable)',
5026 'type' : 'int',
5028 'current_host_state_type' : {
5029 'description' : 'Type of the current state (0: soft, 1: hard)',
5030 'type' : 'int',
5032 'current_host_statusmap_image' : {
5033 'description' : 'The name of in image file for the status map',
5034 'type' : 'string',
5036 'current_host_total_services' : {
5037 'description' : 'The total number of services of the host',
5038 'type' : 'int',
5040 'current_host_worst_service_hard_state' : {
5041 'description' : 'The worst hard state of all of the host\'s services (OK <= WARN <= UNKNOWN <= CRIT)',
5042 'type' : 'list',
5044 'current_host_worst_service_state' : {
5045 'description' : 'The worst soft state of all of the host\'s services (OK <= WARN <= UNKNOWN <= CRIT)',
5046 'type' : 'list',
5048 'current_host_x_3d' : {
5049 'description' : '3D-Coordinates: X',
5050 'type' : 'float',
5052 'current_host_y_3d' : {
5053 'description' : '3D-Coordinates: Y',
5054 'type' : 'float',
5056 'current_host_z_3d' : {
5057 'description' : '3D-Coordinates: Z',
5058 'type' : 'float',
5060 'current_service_accept_passive_checks' : {
5061 'description' : 'Wether the service accepts passive checks (0/1)',
5062 'type' : 'int',
5064 'current_service_acknowledged' : {
5065 'description' : 'Wether the current service problem has been acknowledged (0/1)',
5066 'type' : 'int',
5068 'current_service_acknowledgement_type' : {
5069 'description' : 'The type of the acknownledgement (0: none, 1: normal, 2: sticky)',
5070 'type' : 'int',
5072 'current_service_action_url' : {
5073 'description' : 'An optional URL for actions or custom information about the service',
5074 'type' : 'string',
5076 'current_service_action_url_expanded' : {
5077 'description' : 'The action_url with (the most important) macros expanded',
5078 'type' : 'string',
5080 'current_service_active_checks_enabled' : {
5081 'description' : 'Wether active checks are enabled for the service (0/1)',
5082 'type' : 'int',
5084 'current_service_check_command' : {
5085 'description' : 'Nagios command used for active checks',
5086 'type' : 'string',
5088 'current_service_check_interval' : {
5089 'description' : 'Number of basic interval lengths between two scheduled checks of the service',
5090 'type' : 'float',
5092 'current_service_check_options' : {
5093 'description' : 'The current check option, forced, normal, freshness... (0/1)',
5094 'type' : 'int',
5096 'current_service_check_period' : {
5097 'description' : 'The name of the check period of the service. It this is empty, the service is always checked.',
5098 'type' : 'string',
5100 'current_service_check_type' : {
5101 'description' : 'The type of the last check (0: active, 1: passive)',
5102 'type' : 'int',
5104 'current_service_checks_enabled' : {
5105 'description' : 'Wether active checks are enabled for the service (0/1)',
5106 'type' : 'int',
5108 'current_service_comments' : {
5109 'description' : 'A list of all comment ids of the service',
5110 'type' : 'list',
5112 'current_service_contacts' : {
5113 'description' : 'A list of all contacts of the service, either direct or via a contact group',
5114 'type' : 'list',
5116 'current_service_current_attempt' : {
5117 'description' : 'The number of the current check attempt',
5118 'type' : 'int',
5120 'current_service_current_notification_number' : {
5121 'description' : 'The number of the current notification',
5122 'type' : 'int',
5124 'current_service_custom_variable_names' : {
5125 'description' : 'A list of the names of all custom variables of the service',
5126 'type' : 'list',
5128 'current_service_custom_variable_values' : {
5129 'description' : 'A list of the values of all custom variable of the service',
5130 'type' : 'list',
5132 'current_service_description' : {
5133 'default' : '',
5134 'depythonize' : lambda x: x.get_name(),
5135 'description' : 'Description of the service (also used as key)',
5136 'prop' : 'log_service',
5137 'type' : 'string',
5139 'current_service_display_name' : {
5140 'description' : 'An optional display name (not used by Nagios standard web pages)',
5141 'type' : 'string',
5143 'current_service_downtimes' : {
5144 'description' : 'A list of all downtime ids of the service',
5145 'type' : 'list',
5147 'current_service_event_handler' : {
5148 'description' : 'Nagios command used as event handler',
5149 'type' : 'string',
5151 'current_service_event_handler_enabled' : {
5152 'description' : 'Wether and event handler is activated for the service (0/1)',
5153 'type' : 'int',
5155 'current_service_execution_time' : {
5156 'description' : 'Time the host check needed for execution',
5157 'type' : 'float',
5159 'current_service_first_notification_delay' : {
5160 'description' : 'Delay before the first notification',
5161 'type' : 'float',
5163 'current_service_flap_detection_enabled' : {
5164 'description' : 'Wether flap detection is enabled for the service (0/1)',
5165 'type' : 'int',
5167 'current_service_groups' : {
5168 'description' : 'A list of all service groups the service is in',
5169 'type' : 'list',
5171 'current_service_has_been_checked' : {
5172 'description' : 'Wether the service already has been checked (0/1)',
5173 'type' : 'int',
5175 'current_service_high_flap_threshold' : {
5176 'description' : 'High threshold of flap detection',
5177 'type' : 'float',
5179 'current_service_icon_image' : {
5180 'description' : 'The name of an image to be used as icon in the web interface',
5181 'type' : 'string',
5183 'current_service_icon_image_alt' : {
5184 'description' : 'An alternative text for the icon_image for browsers not displaying icons',
5185 'type' : 'string',
5187 'current_service_icon_image_expanded' : {
5188 'description' : 'The icon_image with (the most important) macros expanded',
5189 'type' : 'string',
5191 'current_service_in_check_period' : {
5192 'description' : 'Wether the service is currently in its check period (0/1)',
5193 'type' : 'int',
5195 'current_service_in_notification_period' : {
5196 'description' : 'Wether the service is currently in its notification period (0/1)',
5197 'type' : 'int',
5199 'current_service_initial_state' : {
5200 'description' : 'The initial state of the service',
5201 'type' : 'int',
5203 'current_service_is_executing' : {
5204 'default' : 0, # value in scheduler is not real-time
5205 'description' : 'is there a service check currently running... (0/1)',
5206 'type' : 'int',
5208 'current_service_is_flapping' : {
5209 'description' : 'Wether the service is flapping (0/1)',
5210 'type' : 'int',
5212 'current_service_last_check' : {
5213 'description' : 'The time of the last check (Unix timestamp)',
5214 'type' : 'int',
5216 'current_service_last_hard_state' : {
5217 'description' : 'The last hard state of the service',
5218 'type' : 'int',
5220 'current_service_last_hard_state_change' : {
5221 'description' : 'The time of the last hard state change (Unix timestamp)',
5222 'type' : 'int',
5224 'current_service_last_notification' : {
5225 'description' : 'The time of the last notification (Unix timestamp)',
5226 'type' : 'int',
5228 'current_service_last_state' : {
5229 'description' : 'The last state of the service',
5230 'type' : 'int',
5232 'current_service_last_state_change' : {
5233 'description' : 'The time of the last state change (Unix timestamp)',
5234 'type' : 'int',
5236 'current_service_latency' : {
5237 'description' : 'Time difference between scheduled check time and actual check time',
5238 'type' : 'float',
5240 'current_service_long_plugin_output' : {
5241 'description' : 'Unabbreviated output of the last check plugin',
5242 'type' : 'string',
5244 'current_service_low_flap_threshold' : {
5245 'description' : 'Low threshold of flap detection',
5246 'type' : 'float',
5248 'current_service_max_check_attempts' : {
5249 'description' : 'The maximum number of check attempts',
5250 'type' : 'int',
5252 'current_service_next_check' : {
5253 'description' : 'The scheduled time of the next check (Unix timestamp)',
5254 'type' : 'int',
5256 'current_service_next_notification' : {
5257 'description' : 'The time of the next notification (Unix timestamp)',
5258 'type' : 'int',
5260 'current_service_notes' : {
5261 'description' : 'Optional notes about the service',
5262 'type' : 'string',
5264 'current_service_notes_expanded' : {
5265 'description' : 'The notes with (the most important) macros expanded',
5266 'type' : 'string',
5268 'current_service_notes_url' : {
5269 'description' : 'An optional URL for additional notes about the service',
5270 'type' : 'string',
5272 'current_service_notes_url_expanded' : {
5273 'description' : 'The notes_url with (the most important) macros expanded',
5274 'type' : 'string',
5276 'current_service_notification_interval' : {
5277 'description' : 'Interval of periodic notification or 0 if its off',
5278 'type' : 'float',
5280 'current_service_notification_period' : {
5281 'description' : 'The name of the notification period of the service. It this is empty, service problems are always notified.',
5282 'type' : 'string',
5284 'current_service_notifications_enabled' : {
5285 'description' : 'Wether notifications are enabled for the service (0/1)',
5286 'type' : 'int',
5288 'current_service_obsess_over_service' : {
5289 'description' : 'Wether \'obsess_over_service\' is enabled for the service (0/1)',
5290 'type' : 'int',
5292 'current_service_percent_state_change' : {
5293 'description' : 'Percent state change',
5294 'type' : 'float',
5296 'current_service_perf_data' : {
5297 'description' : 'Performance data of the last check plugin',
5298 'type' : 'string',
5300 'current_service_plugin_output' : {
5301 'description' : 'Output of the last check plugin',
5302 'type' : 'string',
5304 'current_service_process_performance_data' : {
5305 'description' : 'Wether processing of performance data is enabled for the service (0/1)',
5306 'type' : 'int',
5308 'current_service_retry_interval' : {
5309 'description' : 'Number of basic interval lengths between checks when retrying after a soft error',
5310 'type' : 'float',
5312 'current_service_scheduled_downtime_depth' : {
5313 'description' : 'The number of scheduled downtimes the service is currently in',
5314 'type' : 'int',
5316 'current_service_state' : {
5317 'description' : 'The current state of the service (0: OK, 1: WARN, 2: CRITICAL, 3: UNKNOWN)',
5318 'type' : 'int',
5320 'current_service_state_type' : {
5321 'description' : 'The type of the current state (0: soft, 1: hard)',
5322 'type' : 'int',
5324 'host_name' : {
5325 'description' : 'The name of the host the log entry is about (might be empty)',
5326 'type' : 'string',
5328 'lineno' : {
5329 'description' : 'The number of the line in the log file',
5330 'type' : 'int',
5332 'message' : {
5333 'description' : 'The complete message line including the timestamp',
5334 'type' : 'string',
5336 'options' : {
5337 'description' : 'The part of the message after the \':\'',
5338 'type' : 'string',
5340 'plugin_output' : {
5341 'description' : 'The output of the check, if any is associated with the message',
5342 'type' : 'string',
5344 'service_description' : {
5345 'description' : 'The description of the service log entry is about (might be empty)',
5346 'type' : 'string',
5348 'state' : {
5349 'default' : 0,
5350 'description' : 'The state of the host or service in question',
5351 'prop' : 'state',
5352 'type' : 'int',
5354 'state_type' : {
5355 'description' : 'The type of the state (varies on different log classes)',
5356 'type' : 'string',
5358 'time' : {
5359 'default' : 0,
5360 'description' : 'Time of the log event (UNIX timestamp)',
5361 'prop' : 'time',
5362 'type' : 'int',
5364 'type' : {
5365 'description' : 'The type of the message (text before the colon), the message itself for info messages',
5366 'type' : 'string',
5372 separators = map(lambda x: chr(int(x)), [10, 59, 44, 124])
5375 def __init__(self, configs, hostname_lookup_table, servicename_lookup_table, hosts, services, contacts, hostgroups, servicegroups, contactgroups, timeperiods, commands, schedulers, pollers, reactionners, brokers, dbconn, pnp_path, return_queue):
5376 self.configs = configs
5377 self.hostname_lookup_table = hostname_lookup_table
5378 self.servicename_lookup_table = servicename_lookup_table
5379 self.hosts = hosts
5380 self.services = services
5381 self.contacts = contacts
5382 self.hostgroups = hostgroups
5383 self.servicegroups = servicegroups
5384 self.contactgroups = contactgroups
5385 self.timeperiods = timeperiods
5386 self.commands = commands
5387 self.schedulers = schedulers
5388 self.pollers = pollers
5389 self.reactionners = reactionners
5390 self.brokers = brokers
5391 self.dbconn = dbconn
5392 LiveStatus.pnp_path = pnp_path
5393 self.debuglevel = 2
5394 self.dbconn.row_factory = self.row_factory
5395 self.return_queue = return_queue
5397 self.create_out_map_delegates()
5398 self.create_out_map_hooks()
5399 # add Host attributes to Hostsbygroup etc.
5400 for attribute in LiveStatus.out_map['Host']:
5401 LiveStatus.out_map['Hostsbygroup'][attribute] = LiveStatus.out_map['Host'][attribute]
5402 for attribute in self.out_map['Service']:
5403 LiveStatus.out_map['Servicesbygroup'][attribute] = LiveStatus.out_map['Service'][attribute]
5404 for attribute in self.out_map['Service']:
5405 LiveStatus.out_map['Servicesbyhostgroup'][attribute] = LiveStatus.out_map['Service'][attribute]
5408 def row_factory(self, cursor, row):
5409 """Handler for the sqlite fetch method."""
5410 return Logline(cursor, row)
5413 def handle_request(self, data):
5414 """Execute the livestatus request.
5416 This function creates a LiveStatusRequest method, calls the parser,
5417 handles the execution of the request and formatting of the result.
5420 request = LiveStatusRequest(self.configs, self.hostname_lookup_table, self.servicename_lookup_table, self.hosts, self.services,
5421 self.contacts, self.hostgroups, self.servicegroups, self.contactgroups, self.timeperiods, self.commands,
5422 self.schedulers, self.pollers, self.reactionners, self.brokers, self.dbconn, self.pnp_path, self.return_queue)
5423 request.parse_input(data)
5424 print "REQUEST\n%s\n" % data
5425 #print request
5426 result = request.launch_query()
5427 # Now bring the retrieved information to a form which can be sent back to the client
5428 response = request.response
5429 response.format_live_data(result, request.columns, request.aliases)
5430 output, keepalive = response.respond()
5431 print "RESPONSE\n%s\n" % output
5432 print "DURATION %.4fs" % (time.time() - request.tic)
5433 return output, keepalive
5436 def make_hook(self, hook, prop, default, func, as_prop):
5439 def hook_get_prop(elt):
5440 return getattr(elt, prop, default)
5443 def hook_get_prop_depythonize(elt):
5444 try:
5445 attr = getattr(elt, prop)
5446 if callable(attr):
5447 attr = attr()
5448 return func(attr)
5449 except:
5450 return default
5453 def hook_get_prop_depythonize_notcallable(elt):
5454 if hasattr(elt, prop):
5455 value = getattr(elt, prop)
5456 if value == None or value == 'none':
5457 return default
5458 elif isinstance(value, list):
5459 # Example: Service['comments'] = { type : 'list', depythonize : 'id' }
5461 value = [getattr(item, func)() for item in value if callable(getattr(item, func)) ] \
5462 + [getattr(item, func) for item in value if not callable(getattr(item, func)) ]
5463 return value
5464 else:
5465 f = getattr(value, func)
5466 if callable(f):
5467 return f()
5468 else:
5469 return f
5470 else:
5471 return default
5474 def hook_get_prop_full_depythonize(elt):
5475 try:
5476 value = getattr(elt, prop)
5477 if callable(value):
5478 value = value()
5479 if value == None or value == 'none':
5480 raise
5481 elif isinstance(value, list):
5482 return [func(item, elt, self) for item in value]
5483 else:
5484 return func(value, elt, self)
5485 except:
5486 return default
5489 def hook_get_prop_delegate(elt):
5490 if not as_prop:
5491 new_prop = prop
5492 else:
5493 new_prop = as_prop
5494 if hasattr(elt, func):
5495 attr = getattr(elt, func)
5496 if callable(attr):
5497 attr = attr()
5498 new_hook = self.out_map[attr.__class__.__name__][new_prop]['hook']
5499 return new_hook(attr)
5500 else:
5501 return default
5504 if hook == 'get_prop':
5505 return hook_get_prop
5506 elif hook == 'get_prop_depythonize':
5507 return hook_get_prop_depythonize
5508 elif hook == 'get_prop_depythonize_notcallable':
5509 return hook_get_prop_depythonize_notcallable
5510 elif hook == 'get_prop_full_depythonize':
5511 return hook_get_prop_full_depythonize
5512 elif hook == 'get_prop_delegate':
5513 return hook_get_prop_delegate
5516 def create_out_map_hooks(self):
5517 """Add hooks to the elements of the LiveStatus.out_map.
5519 This function analyzes the elements of the out_map.
5520 Depending on the existence of several keys like
5521 default, prop, depythonize, etc. it creates a function which
5522 resolves an attribute as fast as possible and adds this function
5523 as a new key called hook.
5526 for objtype in LiveStatus.out_map:
5527 for attribute in LiveStatus.out_map[objtype]:
5528 entry = LiveStatus.out_map[objtype][attribute]
5529 if 'prop' not in entry or entry['prop'] == None:
5530 prop = attribute
5531 else:
5532 prop = entry['prop']
5533 if 'default' in entry:
5534 default = entry['default']
5535 else:
5536 try:
5537 if entry['type'] == 'int' or entry['type'] == 'float':
5538 default = 0
5539 elif entry['type'] == 'list':
5540 default = []
5541 else:
5542 raise
5543 except:
5544 default = ''
5545 if 'delegate' in entry:
5546 entry['hook'] = self.make_hook('get_prop_delegate', prop, default, entry['delegate'], entry.setdefault('as', None))
5547 else:
5548 if 'depythonize' in entry:
5549 func = entry['depythonize']
5550 if callable(func):
5551 entry['hook'] = self.make_hook('get_prop_depythonize', prop, default, func, None)
5552 else:
5553 entry['hook'] = self.make_hook('get_prop_depythonize_notcallable', prop, default, func, None)
5554 elif 'fulldepythonize' in entry:
5555 func = entry['fulldepythonize']
5556 entry['hook'] = self.make_hook('get_prop_full_depythonize', prop, default, func, None)
5557 entry['hooktype'] = 'depythonize'
5558 else:
5559 entry['hook'] = self.make_hook('get_prop', prop, default, None, None)
5562 def create_out_map_delegates(self):
5563 """Add delegate keys for certain attributes.
5565 Some attributes are not directly reachable via prop or
5566 need a complicated depythonize function.
5567 Example: Logline (the objects created for a "GET log" request
5568 have the column current_host_state. The Logline object does
5569 not have an attribute of this name, but a log_host attribute.
5570 The Host object represented by log_host has an attribute state
5571 which is the desired current_host_state. Because it's the same
5572 for all columns starting with current_host, a rule can
5573 be applied that automatically redirects the resolving to the
5574 corresponding object. Instead of creating a complicated
5575 depythonize handler which gets log_host and then state, two new
5576 keys for Logline/current_host_state are added:
5577 delegate = log_host
5578 as = state
5579 This instructs the hook function to first get attribute state of
5580 the object represented by log_host.
5583 delegate_map = {
5584 'Logline' : {
5585 'current_service_' : 'log_service',
5586 'current_host_' : 'log_host',
5589 for objtype in LiveStatus.out_map:
5590 for attribute in LiveStatus.out_map[objtype]:
5591 entry = LiveStatus.out_map[objtype][attribute]
5592 if objtype in delegate_map:
5593 for prefix in delegate_map[objtype]:
5594 if attribute.startswith(prefix):
5595 if 'delegate' not in entry:
5596 entry['delegate'] = delegate_map[objtype][prefix]
5597 entry['as'] = attribute.replace(prefix, '')
5601 class LiveStatusResponse:
5603 """A class which represents the response to a livestatus request.
5605 Public functions:
5606 respond -- Add a header to the response text
5607 format_live_data -- Take the raw output and format it according to
5608 the desired output format (csv or json)
5612 def __init__(self, responseheader = 'off', outputformat = 'csv', keepalive = 'off', columnheaders = 'off', separators = LiveStatus.separators):
5613 self.responseheader = responseheader
5614 self.outputformat = outputformat
5615 self.keepalive = keepalive
5616 self.columnheaders = columnheaders
5617 self.separators = separators
5618 self.output = ''
5619 pass
5622 def respond(self):
5623 self.output += '\n'
5624 if self.responseheader == 'fixed16':
5625 statuscode = 200
5626 responselength = len(self.output)
5627 self.output = '%3d %11d\n' % (statuscode, responselength) + self.output
5629 return self.output, self.keepalive
5632 def format_live_data(self, result, columns, aliases):
5633 lines = []
5634 header = ''
5635 showheader = False
5636 if len(result) > 0:
5637 if self.columnheaders != 'off' or len(columns) == 0:
5638 if len(aliases) > 0:
5639 showheader = True
5640 else:
5641 showheader = True
5642 if len(columns) == 0:
5643 # Show all available columns
5644 columns = sorted(result[0].keys())
5645 elif self.columnheaders == 'on':
5646 showheader = True
5647 if self.outputformat == 'csv':
5648 for object in result:
5649 # Construct one line of output for each object found
5650 l = []
5651 for x in [object[c] for c in columns]:
5652 if isinstance(x, list):
5653 l.append(self.separators[2].join(str(y) for y in x))
5654 else:
5655 l.append(str(x))
5656 lines.append(self.separators[1].join(l))
5657 if showheader:
5658 if len(aliases) > 0:
5659 # This is for statements like "Stats: .... as alias_column
5660 lines.insert(0, self.separators[1].join([aliases[col] for col in columns]))
5661 else:
5662 lines.insert(0, self.separators[1].join(columns))
5663 self.output = self.separators[0].join(lines)
5664 elif self.outputformat == 'json' or self.outputformat == 'python':
5665 for object in result:
5666 lines.append([object[c] for c in columns])
5667 if self.columnheaders == 'on':
5668 if len(aliases) > 0:
5669 lines.insert(0, [str(aliases[col]) for col in columns])
5670 else:
5671 lines.insert(0, columns)
5672 if self.outputformat == 'json':
5673 self.output = json.dumps(lines, separators=(',', ':'))
5674 else:
5675 self.output = str(json.loads(json.dumps(lines, separators=(',', ':'))))
5678 class LiveStatusConstraints:
5679 """ Represent the constraints applied on a livestatus request """
5680 def __init__(self, filter_func, out_map, filter_map, output_map, without_filter):
5681 self.filter_func = filter_func
5682 self.out_map = out_map
5683 self.filter_map = filter_map
5684 self.output_map = output_map
5685 self.without_filter = without_filter
5688 class LiveStatusRequest(LiveStatus):
5690 """A class describing a livestatus request."""
5692 def __init__(self, configs, hostname_lookup_table, servicename_lookup_table, hosts, services, contacts, hostgroups, servicegroups, contactgroups, timeperiods, commands, schedulers, pollers, reactionners, brokers, dbconn, pnp_path, return_queue):
5693 # Runtime data form the global LiveStatus object
5694 self.configs = configs
5695 self.hostname_lookup_table = hostname_lookup_table
5696 self.servicename_lookup_table = servicename_lookup_table
5697 self.hosts = hosts
5698 self.services = services
5699 self.contacts = contacts
5700 self.hostgroups = hostgroups
5701 self.servicegroups = servicegroups
5702 self.contactgroups = contactgroups
5703 self.timeperiods = timeperiods
5704 self.commands = commands
5705 self.schedulers = schedulers
5706 self.pollers = pollers
5707 self.reactionners = reactionners
5708 self.brokers = brokers
5709 self.dbconn = dbconn
5710 self.pnp_path = pnp_path
5711 self.return_queue = return_queue
5713 # Private attributes for this specific request
5714 self.response = LiveStatusResponse(responseheader = 'off', outputformat = 'csv', keepalive = 'off', columnheaders = 'undef', separators = LiveStatus.separators)
5715 self.table = None
5716 self.columns = []
5717 self.filtercolumns = []
5718 self.prefiltercolumns = []
5719 self.stats_group_by = []
5720 self.stats_columns = []
5721 self.aliases = []
5722 self.limit = None
5723 self.extcmd = False
5724 self.out_map = self.copy_out_map_hooks()
5726 # Initialize the stacks which are needed for the Filter: and Stats:
5727 # filter- and count-operations
5728 self.filter_stack = LiveStatusStack()
5729 self.sql_filter_stack = LiveStatusStack()
5730 self.sql_filter_stack.type = 'sql'
5731 self.stats_filter_stack = LiveStatusStack()
5732 self.stats_postprocess_stack = LiveStatusStack()
5733 self.stats_request = False
5735 # Set a timestamp for this specific request
5736 self.tic = time.time()
5737 # Clients can also send their local time with the request
5738 self.client_localtime = time.time()
5741 def find_converter(self, attribute):
5742 """Return a function that converts textual numbers
5743 in the request to the correct data type"""
5744 out_map = LiveStatus.out_map[self.out_map_name]
5745 if attribute in out_map and 'type' in out_map[attribute]:
5746 if out_map[attribute]['type'] == 'int':
5747 return int
5748 elif out_map[attribute]['type'] == 'float':
5749 return float
5750 return None
5753 def set_default_out_map_name(self):
5754 """Translate the table name to the corresponding out_map key."""
5755 self.out_map_name = {
5756 'hosts' : 'Host',
5757 'services' : 'Service',
5758 'hostgroups' : 'Hostgroup',
5759 'servicegroups' : 'Servicegroup',
5760 'contacts' : 'Contact',
5761 'contactgroups' : 'Contactgroup',
5762 'comments' : 'Comment',
5763 'downtimes' : 'Downtime',
5764 'commands' : 'Command',
5765 'timeperiods' : 'Timeperiod',
5766 'hostsbygroup' : 'Hostsbygroup',
5767 'servicesbygroup' : 'Servicesbygroup',
5768 'servicesbyhostgroup' : 'Servicesbyhostgroup',
5769 'status' : 'Config',
5770 'log' : 'Logline',
5771 'schedulers' : 'SchedulerLink',
5772 'pollers' : 'PollerLink',
5773 'reactionners' : 'ReactionnerLink',
5774 'brokers' : 'BrokerLink',
5775 'problems' : 'Problem',
5776 'columns' : 'Config', # just a dummy
5777 }[self.table]
5780 def copy_out_map_hooks(self):
5781 """Update the hooks for some out_map entries.
5783 Livestatus columns which have a fulldepythonize postprocessor
5784 need an updated argument list. The third argument needs to
5785 be the request object. (When the out_map is first supplied
5786 with hooks, the third argument is the Livestatus object.)
5789 new_map = {}
5790 for objtype in LiveStatus.out_map:
5791 new_map[objtype] = {}
5792 for attribute in LiveStatus.out_map[objtype]:
5793 new_map[objtype][attribute] = {}
5794 entry = LiveStatus.out_map[objtype][attribute]
5795 if 'hooktype' in entry:
5796 if 'prop' not in entry or entry['prop'] == None:
5797 prop = attribute
5798 else:
5799 prop = entry['prop']
5800 if 'default' in entry:
5801 default = entry['default']
5802 else:
5803 if entry['type'] == 'int' or entry['type'] == 'float':
5804 default = 0
5805 else:
5806 default = ''
5807 func = entry['fulldepythonize']
5808 new_map[objtype][attribute]['hook'] = self.make_hook('get_prop_full_depythonize', prop, default, func, None)
5809 else:
5810 new_map[objtype][attribute]['hook'] = entry['hook']
5811 return new_map
5814 def __str__(self):
5815 output = "LiveStatusRequest:\n"
5816 for attr in ["table", "columns", "filtercolumns", "prefiltercolumns", "aliases", "stats_group_by", "stats_request"]:
5817 output += "request %s: %s\n" % (attr, getattr(self, attr))
5818 return output
5821 def split_command(self, line, splits=1):
5822 """Create a list from the words of a line"""
5823 return line.split(' ', splits)
5826 def split_option(self, line, splits=1):
5827 """Like split_commands, but converts numbers to int data type"""
5828 #x = [int(i) if i.isdigit() else i for i in [token.strip() for token in re.split(r"[\s]+", line, splits)]]
5829 x = map (lambda i: (i.isdigit() and int(i)) or i, [token.strip() for token in re.split(r"[\s]+", line, splits)])
5830 return x
5833 def split_option_with_columns(self, line):
5834 """Split a line in a command and a list of words"""
5835 cmd, columns = self.split_option(line)
5836 return cmd, [self.strip_table_from_column(c) for c in re.compile(r'\s+').split(columns)]
5839 def strip_table_from_column(self, column):
5840 """Cut off the table name, because it is possible
5841 to say service_state instead of state"""
5842 bygroupmatch = re.compile('(\w+)by.*group').search(self.table)
5843 if bygroupmatch:
5844 return re.sub(re.sub('s$', '', bygroupmatch.group(1)) + '_', '', column, 1)
5845 else:
5846 return re.sub(re.sub('s$', '', self.table) + '_', '', column, 1)
5849 def parse_input(self, data):
5850 """Parse the lines of a livestatus request.
5852 This function looks for keywords in input lines and
5853 sets the attributes of the request object
5856 for line in [line.strip() for line in data.splitlines()]:
5857 # Tools like NagVis send KEYWORK:option, and we prefer to have
5858 # a space folowing the :
5859 if ':' in line and not ' ' in line:
5860 line = line.replace(':', ': ')
5861 keyword = line.split(' ')[0].rstrip(':')
5862 if keyword == 'GET': # Get the name of the base table
5863 cmd, self.table = self.split_command(line)
5864 self.set_default_out_map_name()
5865 elif keyword == 'Columns': # Get the names of the desired columns
5866 cmd, self.columns = self.split_option_with_columns(line)
5867 self.response.columnheaders = 'off'
5868 elif keyword == 'ResponseHeader':
5869 cmd, responseheader = self.split_option(line)
5870 self.response.responseheader = responseheader
5871 elif keyword == 'OutputFormat':
5872 cmd, outputformat = self.split_option(line)
5873 self.response.outputformat = outputformat
5874 elif keyword == 'KeepAlive':
5875 cmd, keepalive = self.split_option(line)
5876 self.response.keepalive = keepalive
5877 elif keyword == 'ColumnHeaders':
5878 cmd, columnheaders = self.split_option(line)
5879 self.response.columnheaders = columnheaders
5880 elif keyword == 'Limit':
5881 cmd, self.limit = self.split_option(line)
5882 elif keyword == 'Filter':
5883 try:
5884 cmd, attribute, operator, reference = self.split_option(line, 3)
5885 except:
5886 cmd, attribute, operator, reference = self.split_option(line, 2) + ['']
5887 if operator in ['=', '>', '>=', '<', '<=', '=~', '~', '~~', '!=', '!>', '!>=', '!<', '!<=']:
5888 # Cut off the table name
5889 attribute = self.strip_table_from_column(attribute)
5890 # Some operators can simply be negated
5891 if operator in ['!>', '!>=', '!<', '!<=']:
5892 operator = { '!>' : '<=', '!>=' : '<', '!<' : '>=', '!<=' : '>' }[operator]
5893 # Put a function on top of the filter_stack which implements
5894 # the desired operation
5895 self.filtercolumns.append(attribute)
5896 self.prefiltercolumns.append(attribute)
5897 self.filter_stack.put(self.make_filter(operator, attribute, reference))
5898 if self.table == 'log':
5899 if attribute == 'time':
5900 self.sql_filter_stack.put(self.make_sql_filter(operator, attribute, reference))
5901 else:
5902 print "illegal operation", operator
5903 pass # illegal operation
5904 elif keyword == 'And':
5905 cmd, andnum = self.split_option(line)
5906 # Take the last andnum functions from the stack
5907 # Construct a new function which makes a logical and
5908 # Put the function back onto the stack
5909 self.filter_stack.and_elements(andnum)
5910 elif keyword == 'Or':
5911 cmd, ornum = self.split_option(line)
5912 # Take the last ornum functions from the stack
5913 # Construct a new function which makes a logical or
5914 # Put the function back onto the stack
5915 self.filter_stack.or_elements(ornum)
5916 elif keyword == 'StatsGroupBy':
5917 cmd, stats_group_by = self.split_option_with_columns(line)
5918 self.filtercolumns.extend(stats_group_by)
5919 self.stats_group_by.extend(stats_group_by)
5920 # Deprecated. If your query contains at least one Stats:-header
5921 # then Columns: has the meaning of the old StatsGroupBy: header
5922 elif keyword == 'Stats':
5923 self.stats_request = True
5924 try:
5925 cmd, attribute, operator, reference = self.split_option(line, 3)
5926 if attribute in ['sum', 'min', 'max', 'avg', 'std'] and reference.find('as ', 3) != -1:
5927 attribute, operator = operator, attribute
5928 asas, alias = reference.split(' ')
5929 self.aliases.append(alias)
5930 elif attribute in ['sum', 'min', 'max', 'avg', 'std'] and reference == '=':
5931 # Workaround for thruk-cmds like: Stats: sum latency =
5932 attribute, operator = operator, attribute
5933 reference = ''
5934 except:
5935 cmd, attribute, operator = self.split_option(line, 3)
5936 if attribute in ['sum', 'min', 'max', 'avg', 'std']:
5937 attribute, operator = operator, attribute
5938 reference = ''
5939 attribute = self.strip_table_from_column(attribute)
5940 if operator in ['=', '>', '>=', '<', '<=', '=~', '~', '~~', '!=', '!>', '!>=', '!<', '!<=']:
5941 if operator in ['!>', '!>=', '!<', '!<=']:
5942 operator = { '!>' : '<=', '!>=' : '<', '!<' : '>=', '!<=' : '>' }[operator]
5943 self.filtercolumns.append(attribute)
5944 self.stats_columns.append(attribute)
5945 self.stats_filter_stack.put(self.make_filter(operator, attribute, reference))
5946 self.stats_postprocess_stack.put(self.make_filter('count', attribute, None))
5947 elif operator in ['sum', 'min', 'max', 'avg', 'std']:
5948 self.stats_columns.append(attribute)
5949 self.stats_filter_stack.put(self.make_filter('dummy', attribute, None))
5950 self.stats_postprocess_stack.put(self.make_filter(operator, attribute, None))
5951 else:
5952 print "illegal operation", operator
5953 pass # illegal operation
5954 elif keyword == 'StatsAnd':
5955 cmd, andnum = self.split_option(line)
5956 self.stats_filter_stack.and_elements(andnum)
5957 elif keyword == 'StatsOr':
5958 cmd, ornum = self.split_option(line)
5959 self.stats_filter_stack.or_elements(ornum)
5960 elif keyword == 'Separators':
5961 cmd, sep1, sep2, sep3, sep4 = line.split(' ', 5)
5962 self.response.separators = map(lambda x: chr(int(x)), [sep1, sep2, sep3, sep4])
5963 elif keyword == 'Localtime':
5964 cmd, self.client_localtime = self.split_option(line)
5965 elif keyword == 'COMMAND':
5966 cmd, self.extcmd = line.split(' ', 1)
5967 else:
5968 # This line is not valid or not implemented
5969 print "Received a line of input which i can't handle : '%s'" % line
5970 pass
5973 def launch_query(self):
5974 """Prepare the request object's filter stacks"""
5975 if self.extcmd:
5976 # External command are send back to broker
5977 e = ExternalCommand(self.extcmd)
5978 self.return_queue.put(e)
5979 return []
5980 else:
5981 # A minimal integrity check
5982 if not self.table:
5983 return []
5985 # Make columns unique
5986 self.filtercolumns = list(set(self.filtercolumns))
5987 self.prefiltercolumns = list(set(self.prefiltercolumns))
5988 self.stats_columns = list(set(self.stats_columns))
5990 if self.stats_request:
5991 if len(self.columns) > 0:
5992 # StatsGroupBy is deprecated. Columns: can be used instead
5993 self.stats_group_by = self.columns
5994 elif len(self.stats_group_by) > 0:
5995 self.columns = self.stats_group_by + self.stats_columns
5996 #if len(self.stats_columns) > 0 and len(self.columns) == 0:
5997 if len(self.stats_columns) > 0:
5998 self.columns = self.stats_columns + self.columns
6000 # Make one big filter where the single filters are anded
6001 self.filter_stack.and_elements(self.filter_stack.qsize())
6002 try:
6003 # Remember the number of stats filters. We need these numbers as columns later.
6004 # But we need to ask now, because get_live_data() will empty the stack
6005 num_stats_filters = self.stats_filter_stack.qsize()
6006 if self.table == 'log':
6007 self.sql_filter_stack.and_elements(self.sql_filter_stack.qsize())
6008 result = self.get_live_data_log()
6009 else:
6010 # If the pnpgraph_present column is involved, then check
6011 # with each request if the pnp perfdata path exists
6012 if 'pnpgraph_present' in self.columns + self.filtercolumns + self.prefiltercolumns and self.pnp_path and os.access(self.pnp_path, os.R_OK):
6013 self.pnp_path_readable = True
6014 else:
6015 self.pnp_path_readable = False
6016 # Apply the filters on the broker's host/service/etc elements
6018 result = self.get_live_data()
6020 if self.stats_request:
6021 self.columns = range(num_stats_filters)
6022 if self.stats_group_by:
6023 self.columns = tuple(list(self.stats_group_by) + list(self.columns))
6024 if len(self.aliases) == 0:
6025 #If there were Stats: staments without "as", show no column headers at all
6026 self.response.columnheaders = 'off'
6027 else:
6028 self.response.columnheaders = 'on'
6030 return result
6031 except Exception, e:
6032 import traceback
6033 print "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
6034 print e
6035 traceback.print_exc(32)
6036 print "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
6039 def get_hosts_or_services_livedata(self, cs, key):
6040 objects = getattr(self, self.table)
6041 if not self.limit:
6042 objects = objects.values()
6043 else:
6044 objects = sorted(objects.values(), key=key)
6045 return [
6046 self.create_output(cs.output_map, y) for y in (
6047 x for x in objects
6048 if cs.without_filter or cs.filter_func(self.create_output(cs.filter_map, x)))
6051 def get_hosts_livedata(self, cs):
6052 return self.get_hosts_or_services_livedata(cs, lambda k: (k.host_name))
6054 def get_services_livedata(self, cs):
6055 return self.get_hosts_or_services_livedata(cs, lambda k: (k.host_name, k.service_description))
6057 def get_simple_livedata(self, cs):
6058 objects = getattr(self, self.table)
6059 return [ self.create_output(cs.output_map, obj) for obj in objects.values() ]
6061 def get_filtered_livedata(self, cs):
6062 objects = getattr(self, self.table).values()
6063 if cs.without_filter:
6064 return [ y for y in [ self.create_output(cs.output_map, x) for x in objects ] if cs.filter_func(y) ]
6065 res = [ x for x in objects if cs.filter_func(self.create_output(cs.filter_map, x)) ]
6066 return [ self.create_output(cs.output_map, x) for x in res ]
6068 def get_list_livedata(self, cs):
6069 t = self.table
6070 if cs.without_filter:
6071 res = [ self.create_output(cs.output_map, y) for y in
6072 reduce(list.__add__
6073 , [ getattr(x, t) for x in self.services.values() + self.hosts.values()
6074 if len(getattr(x, t)) > 0 ]
6075 , [])
6077 else:
6078 res = [ c for c in reduce(list.__add__
6079 , [ getattr(x, t) for x in self.services.values() + self.hosts.values()
6080 if len(getattr(x, t)) > 0]
6081 , []
6083 if cs.filter_func(self.create_output(cs.filter_map, c)) ]
6084 res = [ self.create_output(cs.output_map, x) for x in res ]
6085 return res
6088 def get_group_livedata(self, cs, objs, an, group_key, member_key):
6089 """ return a list of elements from a "group" of 'objs'. group can be a hostgroup or a servicegroup.
6090 objs: the objects to get elements from.
6091 an: the attribute name to set on result.
6092 group_key: the key to be used to sort the group members.
6093 member_key: the key to be used to sort each resulting element of a group member. """
6094 return [ self.create_output(cs.output_map, x) for x in (
6095 svc for svc in (
6096 setattr(og[0], an, og[1]) or og[0] for og in (
6097 ( copy.copy(item0), inner_list0[1]) for inner_list0 in (
6098 (sorted(sg1.members, key = member_key), sg1) for sg1 in
6099 sorted([sg0 for sg0 in objs if sg0.members], key = group_key)
6100 ) for item0 in inner_list0[0]
6102 ) if (cs.without_filter or cs.filter_func(self.create_output(cs.filter_map, svc))))
6105 def get_hostbygroups_livedata(self, cs):
6106 member_key = lambda k: k.host_name
6107 group_key = lambda k: k.hostgroup_name
6108 return self.get_group_livedata(cs, self.hostgroups.values(), 'hostgroup', group_key, member_key)
6110 def get_servicebygroups_livedata(self, cs):
6111 member_key = lambda k: k.get_name()
6112 group_key = lambda k: k.servicegroup_name
6113 return self.get_group_livedata(cs, self.servicegroups.values(), 'servicegroup', group_key, member_key)
6115 def get_problem_livedata(self, cs):
6116 # We will crate a problems list first with all problems and source in it
6117 # TODO : create with filter
6118 problems = []
6119 for h in self.hosts.values():
6120 if h.is_problem:
6121 pb = Problem(h, h.impacts)
6122 problems.append(pb)
6123 for s in self.services.values():
6124 if s.is_problem:
6125 pb = Problem(s, s.impacts)
6126 problems.append(pb)
6127 # Then return
6128 return [ self.create_output(cs.output_map, pb) for pb in problems ]
6130 def get_status_livedata(self, cs):
6131 cs.out_map = self.out_map['Config']
6132 return [ self.create_output(cs.output_map, c) for c in self.configs.values() ]
6134 def get_columns_livedata(self, cs):
6135 result = []
6136 result.append({
6137 'description' : 'A description of the column' , 'name' : 'description' , 'table' : 'columns' , 'type' : 'string' })
6138 result.append({
6139 'description' : 'The name of the column within the table' , 'name' : 'name' , 'table' : 'columns' , 'type' : 'string' })
6140 result.append({
6141 'description' : 'The name of the table' , 'name' : 'table' , 'table' : 'columns' , 'type' : 'string' })
6142 result.append({
6143 'description' : 'The data type of the column (int, float, string, list)' , 'name' : 'type' , 'table' : 'columns' , 'type' : 'string' })
6144 tablenames = { 'Host' : 'hosts', 'Service' : 'services', 'Hostgroup' : 'hostgroups', 'Servicegroup' : 'servicegroups', 'Contact' : 'contacts', 'Contactgroup' : 'contactgroups', 'Command' : 'commands', 'Downtime' : 'downtimes', 'Comment' : 'comments', 'Timeperiod' : 'timeperiods', 'Config' : 'status', 'Logline' : 'log', 'Statsbygroup' : 'statsgroupby', 'Hostsbygroup' : 'hostsbygroup', 'Servicesbygroup' : 'servicesbygroup', 'Servicesbyhostgroup' : 'servicesbyhostgroup' }
6145 for obj in sorted(LiveStatus.out_map, key=lambda x: x):
6146 if obj in tablenames:
6147 for attr in LiveStatus.out_map[obj]:
6148 if 'description' in LiveStatus.out_map[obj][attr] and LiveStatus.out_map[obj][attr]['description']:
6149 result.append({ 'description' : LiveStatus.out_map[obj][attr]['description'], 'name' : attr, 'table' : tablenames[obj], 'type' : LiveStatus.out_map[obj][attr]['type'] })
6150 else:
6151 result.append({'description' : 'to_do_desc', 'name' : attr, 'table' : tablenames[obj], 'type' : LiveStatus.out_map[obj][attr]['type'] })
6152 return result
6154 def get_servicebyhostgroups_livedata(self, cs):
6155 # to test..
6156 res = [ self.create_output(cs.output_map, x) for x in (
6157 svc for svc in (
6158 setattr(svchgrp[0], 'hostgroup', svchgrp[1]) or svchgrp[0] for svchgrp in (
6159 # (service, hostgroup), (service, hostgroup), (service, hostgroup), ... service objects are individuals
6160 (copy.copy(item1), inner_list1[1]) for inner_list1 in (
6161 # ([service, service, ...], hostgroup), ([service, ...], hostgroup), ... flattened by host. only if a host has services. sorted by service_description
6162 (sorted(item0.services, key = lambda k: k.service_description), inner_list0[1]) for inner_list0 in (
6163 # ([host, host, ...], hostgroup), ([host, host, host, ...], hostgroup), ... sorted by host_name
6164 (sorted(hg1.members, key = lambda k: k.host_name), hg1) for hg1 in # ([host, host], hg), ([host], hg),... hostgroup.members->explode->sort
6165 # hostgroups, sorted by hostgroup_name
6166 sorted([hg0 for hg0 in self.hostgroups.values() if hg0.members], key = lambda k: k.hostgroup_name)
6167 ) for item0 in inner_list0[0] if item0.services
6168 ) for item1 in inner_list1[0]
6170 ) if (cs.without_filter or cs.filter_func(self.create_output(cs.filter_map, svc)))
6172 return res
6175 objects_get_handlers = {
6176 'hosts': get_hosts_livedata,
6177 'services': get_services_livedata,
6178 'commands': get_simple_livedata,
6179 'schedulers': get_simple_livedata,
6180 'brokers': get_simple_livedata,
6181 'pollers': get_simple_livedata,
6182 'reactionners': get_simple_livedata,
6183 'contacts': get_filtered_livedata,
6184 'hostgroups': get_filtered_livedata,
6185 'servicegroups': get_filtered_livedata,
6186 'downtimes': get_list_livedata,
6187 'comments': get_list_livedata,
6188 'hostsbygroup': get_hostbygroups_livedata,
6189 'servicesbygroup': get_servicebygroups_livedata,
6190 'problems': get_problem_livedata,
6191 'status': get_status_livedata,
6192 'columns': get_columns_livedata,
6193 'servicesbyhostgroup': get_servicebyhostgroups_livedata
6196 def get_live_data(self):
6197 """Find the objects which match the request.
6199 This function scans a list of objects (hosts, services, etc.) and
6200 applies the filter functions first. The remaining objects are
6201 converted to simple dicts which have only the keys that were
6202 requested through Column: attributes. """
6203 # We will use prefiltercolumns here for some serious speedup.
6204 # For example, if nagvis wants Filter: host_groups >= hgxy
6205 # we don't have to use the while list of hostgroups in
6206 # the innermost loop
6207 # Filter: host_groups >= linux-servers
6208 # host_groups is a service attribute
6209 # We can get all services of all hosts of all hostgroups and filter at the end
6210 # But it would save a lot of time to already filter the hostgroups. This means host_groups must be hard-coded
6211 # Also host_name, but then we must filter the second step.
6212 # And a mixture host_groups/host_name with FilterAnd/Or? Must have several filter functions
6214 handler = self.objects_get_handlers.get(self.table, None)
6215 if not handler:
6216 print("Got unhandled table: %s" % (self.table))
6217 return []
6219 # Get the function which implements the Filter: statements
6220 filter_func = self.filter_stack.get_stack()
6221 out_map = self.out_map[self.out_map_name]
6222 filter_map = dict([(k, out_map.get(k)) for k in self.filtercolumns])
6223 output_map = dict([(k, out_map.get(k)) for k in self.columns]) or out_map
6224 without_filter = len(self.filtercolumns) == 0
6226 cs = LiveStatusConstraints(filter_func, out_map, filter_map, output_map, without_filter)
6227 res = handler(self, cs)
6229 if self.limit:
6230 res = res[:self.limit]
6232 if self.stats_request:
6233 res = self.statsify_result(res)
6235 return res
6238 def get_live_data_log(self):
6239 """Like get_live_data, but for log objects"""
6240 filter_func = self.filter_stack.get_stack()
6241 sql_filter_func = self.sql_filter_stack.get_stack()
6242 out_map = self.out_map[self.out_map_name]
6243 filter_map = dict([(k, out_map.get(k)) for k in self.filtercolumns])
6244 output_map = dict([(k, out_map.get(k)) for k in self.columns]) or out_map
6245 without_filter = len(self.filtercolumns) == 0
6246 result = []
6247 if self.table == 'log':
6248 out_map = self.out_map['Logline']
6249 # We can apply the filterstack here as well. we have columns and filtercolumns.
6250 # the only additional step is to enrich log lines with host/service-attributes
6251 # A timerange can be useful for a faster preselection of lines
6252 filter_clause, filter_values = sql_filter_func()
6253 c = self.dbconn.cursor()
6254 try:
6255 if sqlite3.paramstyle == 'pyformat':
6256 matchcount = 0
6257 for m in re.finditer(r"\?", filter_clause):
6258 filter_clause = re.sub('\\?', '%(' + str(matchcount) + ')s', filter_clause, 1)
6259 matchcount += 1
6260 filter_values = dict(zip([str(x) for x in xrange(len(filter_values))], filter_values))
6261 c.execute('SELECT * FROM logs WHERE %s' % filter_clause, filter_values)
6262 except sqlite3.Error, e:
6263 print "An error occurred:", e.args[0]
6264 dbresult = c.fetchall()
6265 if sqlite3.paramstyle == 'pyformat':
6266 dbresult = [self.row_factory(c, d) for d in dbresult]
6268 prefiltresult = [y for y in (x.fill(self.hosts, self.services, self.hostname_lookup_table, self.servicename_lookup_table, set(self.columns + self.filtercolumns)) for x in dbresult) if (without_filter or filter_func(self.create_output(filter_map, y)))]
6269 filtresult = [self.create_output(output_map, x) for x in prefiltresult]
6270 if self.stats_request:
6271 result = self.statsify_result(filtresult)
6272 else:
6273 # Results are host/service/etc dicts with the requested attributes
6274 # Columns: = keys of the dicts
6275 result = filtresult
6277 #print "result is", result
6278 return result
6281 def create_output(self, out_map, elt):
6282 """Convert an object to a dict with selected keys."""
6283 output = {}
6284 display_attributes = out_map.keys()
6285 for display in display_attributes:
6286 try:
6287 hook = out_map[display]['hook']
6288 value = hook(elt)
6289 except:
6290 value = ''
6291 output[display] = value
6292 return output
6295 def statsify_result(self, filtresult):
6296 """Applies the stats filter functions to the result.
6298 Explanation:
6299 stats_group_by is ["service_description", "host_name"]
6300 filtresult is a list of elements which have, among others, service_description and host_name attributes
6302 Step 1:
6303 groupedresult is a dict where the keys are unique combinations of the stats_group_by attributes
6304 where the values are arrays of elements which have those attributes in common
6305 Example:
6306 groupedresult[("host1","svc1")] = { host_name : "host1", service_description : "svc1", state : 2, in_downtime : 0 }
6307 groupedresult[("host1","svc2")] = { host_name : "host1", service_description : "svc2", state : 0, in_downtime : 0 }
6308 groupedresult[("host1","svc2")] = { host_name : "host1", service_description : "svc2", state : 1, in_downtime : 1 }
6310 resultdict is a dict where the keys are unique combinations of the stats_group_by attributes
6311 where the values are dicts
6312 resultdict values are dicts where the keys are attribute names from stats_group_by
6313 where the values are attribute values
6314 Example:
6315 resultdict[("host1","svc1")] = { host_name : "host1", service_description : "svc1" }
6316 resultdict[("host1","svc2")] = { host_name : "host1", service_description : "svc2" }
6317 These attributes are later used as output columns
6319 Step 2:
6320 Run the filters (1 filter for each Stats: statement) and the postprocessors (default: len)
6321 The filters are numbered. After each run, add the result to resultdictay as <filterno> : <result>
6322 Example for Stats: state = 0\nStats: state = 1\nStats: state = 2\nStats: state = 3\n
6323 resultdict[("host1","svc1")] = { host_name : "host1", service_description : "svc1", 0 : 0, 1 : 0, 2 : 1, 3 : 0 }
6324 resultdict[("host1","svc2")] = { host_name : "host1", service_description : "svc2", 0 : 1, 1 : 1, 2 : 0, 3 : 0 }
6326 Step 3:
6327 Create the final result array from resultdict
6330 result = []
6331 resultdict = {}
6332 if self.stats_group_by:
6333 # stats_group_by is a list in newer implementations
6334 if isinstance(self.stats_group_by, list):
6335 self.stats_group_by = tuple(self.stats_group_by)
6336 else:
6337 self.stats_group_by = tuple([self.stats_group_by])
6338 # Break up filtresult and prepare resultdict
6339 # rseultarr is not a simple array (for a single result line)
6340 # It is a dict with the statsgroupyby: as key
6341 groupedresult = {}
6342 for elem in filtresult:
6343 # Make a tuple consisting of the stats_group_by values
6344 stats_group_by_values = tuple([elem[c] for c in self.stats_group_by])
6345 if not stats_group_by_values in groupedresult:
6346 groupedresult[stats_group_by_values] = []
6347 groupedresult[stats_group_by_values].append(elem)
6348 for group in groupedresult:
6349 # All possible combinations of stats_group_by values. group is a tuple
6350 resultdict[group] = dict(zip(self.stats_group_by, group))
6352 #The number of Stats: statements
6353 #For each statement there is one function on the stack
6354 maxidx = self.stats_filter_stack.qsize()
6355 for i in range(maxidx):
6356 # Stats:-statements were put on a Lifo, so we need to reverse the number
6357 #stats_number = str(maxidx - i - 1)
6358 stats_number = maxidx - i - 1
6359 # First, get a filter for the attributes mentioned in Stats: statements
6360 filtfunc = self.stats_filter_stack.get()
6361 # Then, postprocess (sum, max, min,...) the results
6362 postprocess = self.stats_postprocess_stack.get()
6363 if self.stats_group_by:
6364 # Calc statistics over _all_ elements of groups
6365 # which share the same stats_filter_by
6366 for group in groupedresult:
6367 resultdict[group][stats_number] = postprocess(filter(filtfunc, groupedresult[group]))
6368 else:
6369 # Calc statistics over _all_ elements of filtresult
6370 resultdict[stats_number] = postprocess(filter(filtfunc, filtresult))
6371 if self.stats_group_by:
6372 for group in resultdict:
6373 result.append(resultdict[group])
6374 else:
6375 # Without StatsGroupBy: we have only one line
6376 result = [resultdict]
6377 return result
6380 def make_filter(self, operator, attribute, reference):
6381 if reference != None:
6382 # Reference is now datatype string. The referring object attribute on the other hand
6383 # may be an integer. (current_attempt for example)
6384 # So for the filter to work correctly (the two values compared must be
6385 # of the same type), we need to convert the reference to the desired type
6386 converter = self.find_converter(attribute)
6387 if converter:
6388 reference = converter(reference)
6390 # The filters are closures.
6391 # Add parameter Class (Host, Service), lookup datatype (default string), convert reference
6392 def eq_filter(ref):
6393 return ref[attribute] == reference
6395 def eq_nocase_filter(ref):
6396 return ref[attribute].lower() == reference.lower()
6398 def ne_filter(ref):
6399 return ref[attribute] != reference
6401 def gt_filter(ref):
6402 return ref[attribute] > reference
6404 def ge_filter(ref):
6405 return ref[attribute] >= reference
6407 def lt_filter(ref):
6408 return ref[attribute] < reference
6410 def le_filter(ref):
6411 return ref[attribute] <= reference
6413 def contains_filter(ref):
6414 return reference in ref[attribute].split(',')
6416 def match_filter(ref):
6417 p = re.compile(reference)
6418 return p.search(ref[attribute])
6420 def match_nocase_filter(ref):
6421 p = re.compile(reference, re.I)
6422 return p.search(ref[attribute])
6424 def ge_contains_filter(ref):
6425 if isinstance(ref[attribute], list):
6426 return reference in ref[attribute]
6427 else:
6428 return ref[attribute] >= reference
6430 def dummy_filter(ref):
6431 return True
6433 def count_postproc(ref):
6434 return len(ref)
6436 def extract_postproc(ref):
6437 return [float(obj[attribute]) for obj in ref]
6439 def sum_postproc(ref):
6440 return sum(float(obj[attribute]) for obj in ref)
6442 def max_postproc(ref):
6443 if ref != []:
6444 return max(float(obj[attribute]) for obj in ref)
6445 return 0
6447 def min_postproc(ref):
6448 if ref != []:
6449 return min(float(obj[attribute]) for obj in ref)
6450 return 0
6452 def avg_postproc(ref):
6453 if ref != []:
6454 return sum(float(obj[attribute]) for obj in ref) / len(ref)
6455 return 0
6457 def std_postproc(ref):
6458 return 0
6460 if operator == '=':
6461 return eq_filter
6462 elif operator == '!=':
6463 return ne_filter
6464 elif operator == '>':
6465 return gt_filter
6466 elif operator == '>=':
6467 return ge_contains_filter
6468 elif operator == '<':
6469 return lt_filter
6470 elif operator == '<=':
6471 return le_filter
6472 elif operator == '=~':
6473 return eq_nocase_filter
6474 elif operator == '~':
6475 return match_filter
6476 elif operator == '~~':
6477 return match_nocase_filter
6478 elif operator == 'dummy':
6479 return dummy_filter
6480 elif operator == 'sum':
6481 return sum_postproc
6482 elif operator == 'max':
6483 return max_postproc
6484 elif operator == 'min':
6485 return min_postproc
6486 elif operator == 'avg':
6487 return avg_postproc
6488 elif operator == 'std':
6489 return std_postproc
6490 elif operator == 'count':
6491 # postprocess for stats
6492 return count_postproc
6493 elif operator == 'extract':
6494 # postprocess for max,min,...
6495 return extract_postproc
6496 else:
6497 raise "wrong operation", operator
6500 def make_sql_filter(self, operator, attribute, reference):
6501 # The filters are text fragments which are put together to form a sql where-condition finally.
6502 # Add parameter Class (Host, Service), lookup datatype (default string), convert reference
6503 def eq_filter():
6504 if reference == '':
6505 return ['%s IS NULL' % attribute, ()]
6506 else:
6507 return ['%s = ?' % attribute, (reference, )]
6508 def ne_filter():
6509 if reference == '':
6510 return ['%s IS NOT NULL' % attribute, ()]
6511 else:
6512 return ['%s != ?' % attribute, (reference, )]
6513 def gt_filter():
6514 return ['%s > ?' % attribute, (reference, )]
6515 def ge_filter():
6516 return ['%s >= ?' % attribute, (reference, )]
6517 def lt_filter():
6518 return ['%s < ?' % attribute, (reference, )]
6519 def le_filter():
6520 return ['%s <= ?' % attribute, (reference, )]
6521 def match_filter():
6522 return ['%s LIKE ?' % attribute, ('%'+reference+'%', )]
6523 if operator == '=':
6524 return eq_filter
6525 if operator == '>':
6526 return gt_filter
6527 if operator == '>=':
6528 return ge_filter
6529 if operator == '<':
6530 return lt_filter
6531 if operator == '<=':
6532 return le_filter
6533 if operator == '!=':
6534 return ne_filter
6535 if operator == '~':
6536 return match_filter