*redesign: moved classes for configuration objects to "objects" subpackage.
[shinken.git] / shinken / modules / livestatus_broker / livestatus.py
blobae7246a86aef86265e8eaea791a3effe5df88b38
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
39 from shinken.objects.service 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()
288 try:
289 Queue.LifoQueue
290 LiveStatusStack.__bases__ = (Queue.LifoQueue,)
291 except AttributeError:
292 # Ptyhon 2.4 and 2.5 do not have it.
293 # Use our own implementation.
294 LiveStatusStack.__bases__ = (MyLifoQueue,)
298 class LiveStatus:
299 """A class that represents the status of all objects in the broker
302 # description (optional): no need to explain this
303 # prop (optional): the property of the object. If this is missing, the key is the property
304 # type (mandatory): int, float, string, list
305 # depythonize : use it if the property needs to be post-processed.
306 # fulldepythonize : the same, but the postprocessor takes three arguments. property, object, request
307 # delegate : get the property of a different object
308 # as : use it together with delegate, if the property of the other object has another name
309 out_map = {
310 'Host' : {
311 'accept_passive_checks' : {
312 'depythonize' : from_bool_to_int,
313 'description' : 'Wether passive host checks are accepted (0/1)',
314 'prop' : 'passive_checks_enabled',
315 'type' : 'int',
317 'acknowledged' : {
318 'depythonize' : from_bool_to_int,
319 'description' : 'Wether the current host problem has been acknowledged (0/1)',
320 'prop' : 'problem_has_been_acknowledged',
321 'type' : 'int',
323 'acknowledgement_type' : {
324 'description' : 'Type of acknowledgement (0: none, 1: normal, 2: stick)',
325 'type' : 'int',
327 'action_url' : {
328 'description' : 'An optional URL to custom actions or information about this host',
329 'type' : 'string',
331 'action_url_expanded' : {
332 'fulldepythonize' : lambda p, e, r: MacroResolver().resolve_simple_macros_in_string(p, e.get_data_for_checks()),
333 'description' : 'The same as action_url, but with the most important macros expanded',
334 'prop' : 'action_url',
335 'type' : 'string',
337 'active_checks_enabled' : {
338 'depythonize' : from_bool_to_int,
339 'description' : 'Wether active checks are enabled for the host (0/1)',
340 'type' : 'int',
342 'address' : {
343 'description' : 'IP address',
344 'type' : 'string',
346 'alias' : {
347 'description' : 'An alias name for the host',
348 'type' : 'string',
350 'check_command' : {
351 'depythonize' : 'call',
352 'description' : 'Nagios command for active host check of this host',
353 'type' : 'string',
355 'check_freshness' : {
356 'depythonize' : from_bool_to_int,
357 'description' : 'Wether freshness checks are activated (0/1)',
358 'type' : 'int',
360 'check_interval' : {
361 'converter' : int,
362 'description' : 'Number of basic interval lengths between two scheduled checks of the host',
363 'type' : 'float',
365 'check_options' : {
366 'description' : 'The current check option, forced, normal, freshness... (0-2)',
367 'type' : 'int',
369 'check_period' : {
370 'depythonize' : 'get_name',
371 'description' : 'Time period in which this host will be checked. If empty then the host will always be checked.',
372 'type' : 'string',
374 'check_type' : {
375 'converter' : int,
376 'description' : 'Type of check (0: active, 1: passive)',
377 'type' : 'int',
379 'checks_enabled' : {
380 'depythonize' : from_bool_to_int,
381 'description' : 'Wether checks of the host are enabled (0/1)',
382 'prop' : 'active_checks_enabled',
383 'type' : 'int',
385 'childs' : {
386 'description' : 'A list of all direct childs of the host',
387 'type' : 'list',
389 'comments' : {
390 'default' : '',
391 'depythonize' : 'id',
392 'description' : 'A list of the ids of all comments of this host',
393 'type' : 'list',
395 'contacts' : {
396 'depythonize' : 'contact_name',
397 'description' : 'A list of all contacts of this host, either direct or via a contact group',
398 'type' : 'list',
400 'current_attempt' : {
401 'converter' : int,
402 'default' : 0,
403 'description' : 'Number of the current check attempts',
404 'prop' : 'attempt',
405 'type' : 'int',
407 'current_notification_number' : {
408 'converter' : int,
409 'description' : 'Number of the current notification',
410 'type' : 'int',
412 'custom_variable_names' : {
413 'prop' : 'customs',
414 'description' : 'A list of the names of all custom variables',
415 'type' : 'list',
416 'depythonize' : get_customs_keys,
418 'custom_variable_values' : {
419 'prop' : 'customs',
420 'description' : 'A list of the values of the custom variables',
421 'type' : 'list',
422 'depythonize' : get_customs_values,
424 'display_name' : {
425 'description' : 'Optional display name of the host - not used by Nagios\' web interface',
426 'type' : 'string',
428 'downtimes' : {
429 'description' : 'A list of the ids of all scheduled downtimes of this host',
430 'type' : 'list',
432 'event_handler_enabled' : {
433 'depythonize' : from_bool_to_int,
434 'description' : 'Wether event handling is enabled (0/1)',
435 'type' : 'int',
437 'execution_time' : {
438 'converter' : float,
439 'description' : 'Time the host check needed for execution',
440 'type' : 'float',
442 'first_notification_delay' : {
443 'converter' : int,
444 'description' : 'Delay before the first notification',
445 'type' : 'float',
447 'flap_detection_enabled' : {
448 'depythonize' : from_bool_to_int,
449 'description' : 'Wether flap detection is enabled (0/1)',
450 'type' : 'int',
452 'got_business_rule' : {
453 'depythonize' : from_bool_to_int,
454 'description' : 'Wether the host state is an business rule based host or not (0/1)',
455 'type' : 'int',
457 'groups' : {
458 'default' : '',
459 'depythonize' : to_split,
460 'description' : 'A list of all host groups this host is in',
461 'prop' : 'hostgroups',
462 'type' : 'list',
464 'hard_state' : {
465 'description' : 'The effective hard state of the host (eliminates a problem in hard_state)',
466 'type' : 'int',
468 'has_been_checked' : {
469 'depythonize' : from_bool_to_int,
470 'description' : 'Wether the host has already been checked (0/1)',
471 'type' : 'int',
473 'high_flap_threshold' : {
474 'converter' : float,
475 'description' : 'High threshold of flap detection',
476 'type' : 'float',
478 'icon_image' : {
479 'description' : 'The name of an image file to be used in the web pages',
480 'type' : 'string',
482 'icon_image_alt' : {
483 'description' : 'Alternative text for the icon_image',
484 'type' : 'string',
486 'icon_image_expanded' : {
487 'description' : 'The same as icon_image, but with the most important macros expanded',
488 'type' : 'string',
490 'in_check_period' : {
491 'fulldepythonize' : lambda p, e, r: from_bool_to_int((p == None and [False] or [p.is_time_valid(r.tic)])[0]),
492 'description' : 'Wether this host is currently in its check period (0/1)',
493 'prop' : 'check_period',
494 'type' : 'int',
496 'in_notification_period' : {
497 'fulldepythonize' : lambda p, e, r: from_bool_to_int((p == None and [False] or [p.is_time_valid(r.tic)])[0]),
498 'description' : 'Wether this host is currently in its notification period (0/1)',
499 'prop' : 'notification_period',
500 'type' : 'int',
502 'initial_state' : {
503 'description' : 'Initial host state',
504 'type' : 'int',
506 'is_executing' : {
507 'default' : 0, # value in scheduler is not real-time
508 'description' : 'is there a host check currently running... (0/1)',
509 #'prop' : 'in_checking',
510 'type' : 'int',
512 'is_flapping' : {
513 'depythonize' : from_bool_to_int,
514 'description' : 'Wether the host state is flapping (0/1)',
515 'type' : 'int',
517 'is_impact' : {
518 'depythonize' : from_bool_to_int,
519 'description' : 'Wether the host state is an impact or not (0/1)',
520 'type' : 'int',
522 'is_problem' : {
523 'depythonize' : from_bool_to_int,
524 'description' : 'Wether the host state is a problem or not (0/1)',
525 'type' : 'int',
527 'last_check' : {
528 'converter' : int,
529 'depythonize' : from_float_to_int,
530 'description' : 'Time of the last check (Unix timestamp)',
531 'prop' : 'last_chk',
532 'type' : 'int',
534 'last_hard_state' : {
535 'description' : 'Last hard state',
536 'type' : 'int',
538 'last_hard_state_change' : {
539 'description' : 'Time of the last hard state change (Unix timestamp)',
540 'type' : 'int',
542 'last_notification' : {
543 'converter' : int,
544 'depythonize' : to_int,
545 'description' : 'Time of the last notification (Unix timestamp)',
546 'type' : 'int',
548 'last_state' : {
549 'description' : 'State before last state change',
550 'type' : 'int',
552 'last_state_change' : {
553 'converter' : int,
554 'depythonize' : from_float_to_int,
555 'description' : 'Time of the last state change - soft or hard (Unix timestamp)',
556 'type' : 'int',
558 'latency' : {
559 'converter' : float,
560 'description' : 'Time difference between scheduled check time and actual check time',
561 'type' : 'float',
563 'long_plugin_output' : {
564 'description' : 'Complete output from check plugin',
565 'prop' : 'long_output',
566 'type' : 'string',
568 'low_flap_threshold' : {
569 'description' : 'Low threshold of flap detection',
570 'type' : 'float',
572 'max_check_attempts' : {
573 'description' : 'Max check attempts for active host checks',
574 'type' : 'int',
576 'name' : {
577 'description' : 'Host name',
578 'prop' : 'host_name',
579 'type' : 'string',
581 'next_check' : {
582 'converter' : int,
583 'depythonize' : from_float_to_int,
584 'description' : 'Scheduled time for the next check (Unix timestamp)',
585 'prop' : 'next_chk',
586 'type' : 'int',
588 'next_notification' : {
589 'converter' : int,
590 'description' : 'Time of the next notification (Unix timestamp)',
591 'type' : 'int',
593 'notes' : {
594 'description' : 'Optional notes for this host',
595 'type' : 'string',
597 'notes_expanded' : {
598 'description' : 'The same as notes, but with the most important macros expanded',
599 'type' : 'string',
601 'notes_url' : {
602 'description' : 'An optional URL with further information about the host',
603 'type' : 'string',
605 'notes_url_expanded' : {
606 'fulldepythonize' : lambda p, e, r: MacroResolver().resolve_simple_macros_in_string(p, e.get_data_for_checks()),
607 'description' : 'Same es notes_url, but with the most important macros expanded',
608 'prop' : 'notes_url',
609 'type' : 'string',
611 'notification_interval' : {
612 'converter' : int,
613 'description' : 'Interval of periodic notification or 0 if its off',
614 'type' : 'float',
616 'notification_period' : {
617 'depythonize' : 'get_name',
618 'description' : 'Time period in which problems of this host will be notified. If empty then notification will be always',
619 'type' : 'string',
621 'notifications_enabled' : {
622 'depythonize' : from_bool_to_int,
623 'description' : 'Wether notifications of the host are enabled (0/1)',
624 'type' : 'int',
626 'num_services' : {
627 'depythonize' : lambda x: len(x),
628 'description' : 'The total number of services of the host',
629 'prop' : 'services',
630 'type' : 'list',
632 'num_services_crit' : {
633 'depythonize' : lambda x: len([y for y in x if y.state_id == 2]),
634 'description' : 'The number of the host\'s services with the soft state CRIT',
635 'prop' : 'services',
636 'type' : 'list',
638 'num_services_hard_crit' : {
639 'depythonize' : lambda x: len([y for y in x if y.state_id == 2 and y.state_type_id == 1]),
640 'description' : 'The number of the host\'s services with the hard state CRIT',
641 'prop' : 'services',
642 'type' : 'list',
644 'num_services_hard_ok' : {
645 'depythonize' : lambda x: len([y for y in x if y.state_id == 0 and y.state_type_id == 1]),
646 'description' : 'The number of the host\'s services with the hard state OK',
647 'prop' : 'services',
648 'type' : 'list',
650 'num_services_hard_unknown' : {
651 'depythonize' : lambda x: len([y for y in x if y.state_id == 3 and y.state_type_id == 1]),
652 'description' : 'The number of the host\'s services with the hard state UNKNOWN',
653 'prop' : 'services',
654 'type' : 'list',
656 'num_services_hard_warn' : {
657 'depythonize' : lambda x: len([y for y in x if y.state_id == 2 and y.state_type_id == 1]),
658 'description' : 'The number of the host\'s services with the hard state WARN',
659 'prop' : 'services',
660 'type' : 'list',
662 'num_services_ok' : {
663 'depythonize' : lambda x: len([y for y in x if y.state_id == 0]),
664 'description' : 'The number of the host\'s services with the soft state OK',
665 'prop' : 'services',
666 'type' : 'list',
668 'num_services_pending' : {
669 'depythonize' : lambda x: len([y for y in x if y.has_been_checked == 0]),
670 'description' : 'The number of the host\'s services which have not been checked yet (pending)',
671 'prop' : 'services',
672 'type' : 'list',
674 'num_services_unknown' : {
675 'depythonize' : lambda x: len([y for y in x if y.state_id == 3]),
676 'description' : 'The number of the host\'s services with the soft state UNKNOWN',
677 'prop' : 'services',
678 'type' : 'list',
680 'num_services_warn' : {
681 'depythonize' : lambda x: len([y for y in x if y.state_id == 1]),
682 'description' : 'The number of the host\'s services with the soft state WARN',
683 'prop' : 'services',
684 'type' : 'list',
686 'obsess_over_host' : {
687 'depythonize' : from_bool_to_int,
688 'description' : 'The current obsess_over_host setting... (0/1)',
689 'type' : 'int',
691 'parents' : {
692 'description' : 'A list of all direct parents of the host',
693 'type' : 'list',
695 'pending_flex_downtime' : {
696 'description' : 'Wether a flex downtime is pending (0/1)',
697 'type' : 'int',
699 'percent_state_change' : {
700 'description' : 'Percent state change',
701 'type' : 'float',
703 'perf_data' : {
704 'description' : 'Optional performance data of the last host check',
705 'type' : 'string',
707 'plugin_output' : {
708 'description' : 'Output of the last host check',
709 'prop' : 'output',
710 'type' : 'string',
712 'pnpgraph_present' : {
713 'fulldepythonize' : find_pnp_perfdata_xml,
714 'description' : 'Whether there is a PNP4Nagios graph present for this host (0/1)',
715 'prop' : 'host_name',
716 'type' : 'int',
718 'process_performance_data' : {
719 'depythonize' : from_bool_to_int,
720 'description' : 'Wether processing of performance data is enabled (0/1)',
721 'prop' : 'process_perf_data',
722 'type' : 'int',
724 'retry_interval' : {
725 'description' : 'Number of basic interval lengths between checks when retrying after a soft error',
726 'type' : 'float',
728 'scheduled_downtime_depth' : {
729 'converter' : int,
730 'description' : 'The number of downtimes this host is currently in',
731 'type' : 'int',
733 'state' : {
734 'converter' : int,
735 'description' : 'The current state of the host (0: up, 1: down, 2: unreachable)',
736 'prop' : 'state_id',
737 'type' : 'int',
739 'state_type' : {
740 'converter' : int,
741 'description' : 'Type of the current state (0: soft, 1: hard)',
742 'prop' : 'state_type_id',
743 'type' : 'int',
745 'statusmap_image' : {
746 'description' : 'The name of in image file for the status map',
747 'type' : 'string',
749 'total_services' : {
750 'description' : 'The total number of services of the host',
751 'type' : 'int',
753 'worst_service_hard_state' : {
754 'description' : 'The worst hard state of all of the host\'s services (OK <= WARN <= UNKNOWN <= CRIT)',
755 'type' : 'list',
757 'worst_service_state' : {
758 'description' : 'The worst soft state of all of the host\'s services (OK <= WARN <= UNKNOWN <= CRIT)',
759 'type' : 'list',
761 'x_3d' : {
762 'description' : '3D-Coordinates: X',
763 'type' : 'float',
765 'y_3d' : {
766 'description' : '3D-Coordinates: Y',
767 'type' : 'float',
769 'z_3d' : {
770 'description' : '3D-Coordinates: Z',
771 'type' : 'float',
773 'criticity' : {
774 'converter' : int,
775 'description' : 'The importance we gave to this host between hte minimum 0 and the maximum 5',
776 'type' : 'int',
778 'source_problems' : {
779 'description' : 'The name of the source problems (host or service)',
780 'prop' : 'source_problems',
781 'type' : 'list',
782 'depythonize' : from_svc_hst_distinct_lists,
784 'impacts' : {
785 'description' : 'List of what the source impact (list of hosts and services)',
786 'prop' : 'impacts',
787 'type' : 'list',
788 'depythonize' : from_svc_hst_distinct_lists,
790 'parent_dependencies' : {
791 'description' : 'List of the dependencies (logical, network or business one) of this host.',
792 'prop' : 'parent_dependencies',
793 'type' : 'list',
794 'depythonize' : from_svc_hst_distinct_lists,
796 'child_dependencies' : {
797 'description' : 'List of the host/service that depend on this host (logical, network or business one).',
798 'prop' : 'child_dependencies',
799 'type' : 'list',
800 'depythonize' : from_svc_hst_distinct_lists,
805 'Service' : {
806 'accept_passive_checks' : {
807 'depythonize' : from_bool_to_int,
808 'description' : 'Wether the service accepts passive checks (0/1)',
809 'prop' : 'passive_checks_enabled',
810 'type' : 'int',
812 'acknowledged' : {
813 'depythonize' : from_bool_to_int,
814 'description' : 'Wether the current service problem has been acknowledged (0/1)',
815 'prop' : 'problem_has_been_acknowledged',
816 'type' : 'int',
818 'acknowledgement_type' : {
819 'description' : 'The type of the acknownledgement (0: none, 1: normal, 2: sticky)',
820 'type' : 'int',
822 'action_url' : {
823 'description' : 'An optional URL for actions or custom information about the service',
824 'type' : 'string',
826 'action_url_expanded' : {
827 'fulldepythonize' : lambda p, e, r: MacroResolver().resolve_simple_macros_in_string(p, e.get_data_for_checks()),
828 'description' : 'The action_url with (the most important) macros expanded',
829 'prop' : 'action_url',
830 'type' : 'string',
832 'active_checks_enabled' : {
833 'depythonize' : from_bool_to_int,
834 'description' : 'Wether active checks are enabled for the service (0/1)',
835 'type' : 'int',
837 'check_command' : {
838 'depythonize' : 'call',
839 'description' : 'Nagios command used for active checks',
840 'type' : 'string',
842 'check_interval' : {
843 'description' : 'Number of basic interval lengths between two scheduled checks of the service',
844 'type' : 'float',
846 'check_options' : {
847 'description' : 'The current check option, forced, normal, freshness... (0/1)',
848 'type' : 'int',
850 'check_period' : {
851 'depythonize' : 'get_name',
852 'description' : 'The name of the check period of the service. It this is empty, the service is always checked.',
853 'type' : 'string',
855 'check_type' : {
856 'converter' : int,
857 'depythonize' : to_int,
858 'description' : 'The type of the last check (0: active, 1: passive)',
859 'type' : 'int',
861 'checks_enabled' : {
862 'depythonize' : from_bool_to_int,
863 'description' : 'Wether active checks are enabled for the service (0/1)',
864 'prop' : 'active_checks_enabled',
865 'type' : 'int',
867 'comments' : {
868 'default' : '',
869 'depythonize' : 'id',
870 'description' : 'A list of all comment ids of the service',
871 'type' : 'list',
873 'contacts' : {
874 'depythonize' : 'contact_name',
875 'description' : 'A list of all contacts of the service, either direct or via a contact group',
876 'type' : 'list',
878 'current_attempt' : {
879 'converter' : int,
880 'description' : 'The number of the current check attempt',
881 'prop' : 'attempt',
882 'type' : 'int',
884 'current_notification_number' : {
885 'description' : 'The number of the current notification',
886 'type' : 'int',
888 'custom_variable_names' : {
889 'prop' : 'customs',
890 'description' : 'A list of the names of all custom variables of the service',
891 'type' : 'list',
892 'depythonize' : get_customs_keys,
894 'custom_variable_values' : {
895 'prop' : 'customs',
896 'description' : 'A list of the values of all custom variable of the service',
897 'type' : 'list',
898 'depythonize' : get_customs_values,
900 'description' : {
901 'description' : 'Description of the service (also used as key)',
902 'prop' : 'service_description',
903 'type' : 'string',
905 'display_name' : {
906 'description' : 'An optional display name (not used by Nagios standard web pages)',
907 'type' : 'string',
909 'downtimes' : {
910 'description' : 'A list of all downtime ids of the service',
911 'type' : 'list',
913 'event_handler' : {
914 'depythonize' : 'call',
915 'description' : 'Nagios command used as event handler',
916 'type' : 'string',
918 'event_handler_enabled' : {
919 'depythonize' : from_bool_to_int,
920 'description' : 'Wether and event handler is activated for the service (0/1)',
921 'type' : 'int',
923 'execution_time' : {
924 'converter' : float,
925 'description' : 'Time the host check needed for execution',
926 'type' : 'float',
928 'first_notification_delay' : {
929 'converter' : int,
930 'description' : 'Delay before the first notification',
931 'type' : 'float',
933 'flap_detection_enabled' : {
934 'depythonize' : from_bool_to_int,
935 'description' : 'Wether flap detection is enabled for the service (0/1)',
936 'type' : 'int',
938 'got_business_rule' : {
939 'depythonize' : from_bool_to_int,
940 'description' : 'Wether the service state is an business rule based host or not (0/1)',
941 'type' : 'int',
943 'groups' : {
944 'default' : '',
945 'depythonize' : to_split,
946 'description' : 'A list of all service groups the service is in',
947 'prop' : 'servicegroups',
948 'type' : 'list',
950 'has_been_checked' : {
951 'depythonize' : from_bool_to_int,
952 'description' : 'Wether the service already has been checked (0/1)',
953 'type' : 'int',
955 'high_flap_threshold' : {
956 'description' : 'High threshold of flap detection',
957 'type' : 'float',
959 'host_accept_passive_checks' : {
960 'description' : 'Wether passive host checks are accepted (0/1)',
961 'type' : 'int',
963 'host_acknowledged' : {
964 'depythonize' : lambda x: from_bool_to_int(x.problem_has_been_acknowledged),
965 'description' : 'Wether the current host problem has been acknowledged (0/1)',
966 'prop' : 'host',
967 'type' : 'int',
969 'host_acknowledgement_type' : {
970 'description' : 'Type of acknowledgement (0: none, 1: normal, 2: stick)',
971 'type' : 'int',
973 'host_action_url' : {
974 'description' : 'An optional URL to custom actions or information about this host',
975 'type' : 'string',
977 'host_action_url_expanded' : {
978 'description' : 'The same as action_url, but with the most important macros expanded',
979 'type' : 'string',
981 'host_active_checks_enabled' : {
982 'description' : 'Wether active checks are enabled for the host (0/1)',
983 'type' : 'int',
985 'host_address' : {
986 'depythonize' : lambda x: x.address,
987 'description' : 'IP address',
988 'prop' : 'host',
989 'type' : 'string',
991 'host_alias' : {
992 'depythonize' : lambda x: x.alias,
993 'description' : 'An alias name for the host',
994 'prop' : 'host',
995 'type' : 'string',
997 'host_check_command' : {
998 'description' : 'Nagios command for active host check of this host',
999 'type' : 'string',
1001 'host_check_freshness' : {
1002 'description' : 'Wether freshness checks are activated (0/1)',
1003 'type' : 'int',
1005 'host_check_interval' : {
1006 'description' : 'Number of basic interval lengths between two scheduled checks of the host',
1007 'type' : 'float',
1009 'host_check_options' : {
1010 'description' : 'The current check option, forced, normal, freshness... (0-2)',
1011 'type' : 'int',
1013 'host_check_period' : {
1014 'description' : 'Time period in which this host will be checked. If empty then the host will always be checked.',
1015 'type' : 'string',
1017 'host_check_type' : {
1018 'description' : 'Type of check (0: active, 1: passive)',
1019 'type' : 'int',
1021 'host_checks_enabled' : {
1022 'depythonize' : lambda x: from_bool_to_int(x.active_checks_enabled),
1023 'description' : 'Wether checks of the host are enabled (0/1)',
1024 'prop' : 'host',
1025 'type' : 'int',
1027 'host_childs' : {
1028 'description' : 'A list of all direct childs of the host',
1029 'type' : 'list',
1031 'host_comments' : {
1032 'default' : '',
1033 'depythonize' : lambda h: ([c.id for c in h.comments]),
1034 'description' : 'A list of the ids of all comments of this host',
1035 'prop' : 'host',
1036 'type' : 'list',
1038 'host_contacts' : {
1039 'description' : 'A list of all contacts of this host, either direct or via a contact group',
1040 'type' : 'list',
1042 'host_current_attempt' : {
1043 'description' : 'Number of the current check attempts',
1044 'type' : 'int',
1046 'host_current_notification_number' : {
1047 'description' : 'Number of the current notification',
1048 'type' : 'int',
1050 'host_custom_variable_names' : {
1051 'description' : 'A list of the names of all custom variables',
1052 'depythonize' : lambda h: get_customs_keys(h.customs),
1053 'prop' : 'host',
1054 'type' : 'list',
1056 'host_custom_variable_values' : {
1057 'description' : 'A list of the values of the custom variables',
1058 'depythonize' : lambda h: get_customs_values(h.customs),
1059 'prop' : 'host',
1060 'type' : 'list',
1062 'host_display_name' : {
1063 'description' : 'Optional display name of the host - not used by Nagios\' web interface',
1064 'type' : 'string',
1066 'host_downtimes' : {
1067 'description' : 'A list of the ids of all scheduled downtimes of this host',
1068 'type' : 'list',
1070 'host_event_handler_enabled' : {
1071 'description' : 'Wether event handling is enabled (0/1)',
1072 'type' : 'int',
1074 'host_execution_time' : {
1075 'description' : 'Time the host check needed for execution',
1076 'type' : 'float',
1078 'host_first_notification_delay' : {
1079 'description' : 'Delay before the first notification',
1080 'type' : 'float',
1082 'host_flap_detection_enabled' : {
1083 'description' : 'Wether flap detection is enabled (0/1)',
1084 'type' : 'int',
1086 'host_groups' : {
1087 'default' : '',
1088 'depythonize' : lambda x: to_split(x.hostgroups),
1089 'description' : 'A list of all host groups this host is in',
1090 'prop' : 'host',
1091 'type' : 'list',
1093 'host_hard_state' : {
1094 'description' : 'The effective hard state of the host (eliminates a problem in hard_state)',
1095 'type' : 'int',
1097 'host_has_been_checked' : {
1098 'depythonize' : lambda x: from_bool_to_int(x.has_been_checked),
1099 'description' : 'Wether the host has already been checked (0/1)',
1100 'prop' : 'host',
1101 'type' : 'int',
1103 'host_high_flap_threshold' : {
1104 'description' : 'High threshold of flap detection',
1105 'type' : 'float',
1107 'host_icon_image' : {
1108 'description' : 'The name of an image file to be used in the web pages',
1109 'type' : 'string',
1111 'host_icon_image_alt' : {
1112 'description' : 'Alternative text for the icon_image',
1113 'type' : 'string',
1115 'host_icon_image_expanded' : {
1116 'description' : 'The same as icon_image, but with the most important macros expanded',
1117 'type' : 'string',
1119 'host_in_check_period' : {
1120 'depythonize' : lambda h: from_bool_to_int((h.check_period == None and [False] or [h.check_period.is_time_valid(time.time())])[0]),
1121 'description' : 'Wether this host is currently in its check period (0/1)',
1122 'prop' : 'host',
1123 'type' : 'int',
1125 'host_in_notification_period' : {
1126 'depythonize' : lambda h: from_bool_to_int((h.notification_period == None and [False] or [h.notification_period.is_time_valid(time.time())])[0]),
1127 'description' : 'Wether this host is currently in its notification period (0/1)',
1128 'prop' : 'host',
1129 'type' : 'int',
1131 'host_initial_state' : {
1132 'description' : 'Initial host state',
1133 'type' : 'int',
1135 'host_is_executing' : {
1136 'default' : 0, # value in scheduler is not real-time
1137 'description' : 'is there a host check currently running... (0/1)',
1138 'type' : 'int',
1140 'host_is_flapping' : {
1141 'default' : '0',
1142 'depythonize' : from_bool_to_int,
1143 'description' : 'Wether the host state is flapping (0/1)',
1144 'type' : 'int',
1146 'host_last_check' : {
1147 'description' : 'Time of the last check (Unix timestamp)',
1148 'type' : 'int',
1150 'host_last_hard_state' : {
1151 'description' : 'Last hard state',
1152 'type' : 'int',
1154 'host_last_hard_state_change' : {
1155 'description' : 'Time of the last hard state change (Unix timestamp)',
1156 'type' : 'int',
1158 'host_last_notification' : {
1159 'description' : 'Time of the last notification (Unix timestamp)',
1160 'type' : 'int',
1162 'host_last_state' : {
1163 'description' : 'State before last state change',
1164 'type' : 'int',
1166 'host_last_state_change' : {
1167 'description' : 'Time of the last state change - soft or hard (Unix timestamp)',
1168 'type' : 'int',
1170 'host_latency' : {
1171 'description' : 'Time difference between scheduled check time and actual check time',
1172 'type' : 'float',
1174 'host_long_plugin_output' : {
1175 'description' : 'Complete output from check plugin',
1176 'type' : 'string',
1178 'host_low_flap_threshold' : {
1179 'description' : 'Low threshold of flap detection',
1180 'type' : 'float',
1182 'host_max_check_attempts' : {
1183 'description' : 'Max check attempts for active host checks',
1184 'type' : 'int',
1186 'host_name' : {
1187 'description' : 'Host name',
1188 'type' : 'string',
1190 'host_next_check' : {
1191 'description' : 'Scheduled time for the next check (Unix timestamp)',
1192 'type' : 'int',
1194 'host_next_notification' : {
1195 'description' : 'Time of the next notification (Unix timestamp)',
1196 'type' : 'int',
1198 'host_notes' : {
1199 'description' : 'Optional notes for this host',
1200 'type' : 'string',
1202 'host_notes_expanded' : {
1203 'description' : 'The same as notes, but with the most important macros expanded',
1204 'type' : 'string',
1206 'host_notes_url' : {
1207 'description' : 'An optional URL with further information about the host',
1208 'type' : 'string',
1210 'host_notes_url_expanded' : {
1211 'description' : 'Same es notes_url, but with the most important macros expanded',
1212 'type' : 'string',
1214 'host_notification_interval' : {
1215 'description' : 'Interval of periodic notification or 0 if its off',
1216 'type' : 'float',
1218 'host_notification_period' : {
1219 'description' : 'Time period in which problems of this host will be notified. If empty then notification will be always',
1220 'type' : 'string',
1222 'host_notifications_enabled' : {
1223 'depythonize' : lambda x: from_bool_to_int(x.notifications_enabled),
1224 'description' : 'Wether notifications of the host are enabled (0/1)',
1225 'prop' : 'host',
1226 'type' : 'int',
1228 'host_num_services' : {
1229 'depythonize' : lambda x: len(x.services),
1230 'description' : 'The total number of services of the host',
1231 'prop' : 'host',
1232 'type' : 'list',
1234 'host_num_services_crit' : {
1235 'depythonize' : lambda x: len([y for y in x.services if y.state_id == 2]),
1236 'description' : 'The number of the host\'s services with the soft state CRIT',
1237 'prop' : 'host',
1238 'type' : 'list',
1240 'host_num_services_hard_crit' : {
1241 'depythonize' : lambda x: len([y for y in x.services if y.state_id == 2 and y.state_type_id == 1]),
1242 'description' : 'The number of the host\'s services with the hard state CRIT',
1243 'prop' : 'host',
1244 'type' : 'list',
1246 'host_num_services_hard_ok' : {
1247 'depythonize' : lambda x: len([y for y in x.services if y.state_id == 0 and y.state_type_id == 1]),
1248 'description' : 'The number of the host\'s services with the hard state OK',
1249 'prop' : 'host',
1250 'type' : 'list',
1252 'host_num_services_hard_unknown' : {
1253 'depythonize' : lambda x: len([y for y in x.services if y.state_id == 3 and y.state_type_id == 1]),
1254 'description' : 'The number of the host\'s services with the hard state UNKNOWN',
1255 'prop' : 'host',
1256 'type' : 'list',
1258 'host_num_services_hard_warn' : {
1259 'depythonize' : lambda x: len([y for y in x.services if y.state_id == 2 and y.state_type_id == 1]),
1260 'description' : 'The number of the host\'s services with the hard state WARN',
1261 'prop' : 'host',
1262 'type' : 'list',
1264 'host_num_services_ok' : {
1265 'depythonize' : lambda x: len([y for y in x.services if y.state_id == 0]),
1266 'description' : 'The number of the host\'s services with the soft state OK',
1267 'prop' : 'host',
1268 'type' : 'list',
1270 'host_num_services_pending' : {
1271 'depythonize' : lambda x: len([y for y in x.services if y.has_been_checked == 0]),
1272 'description' : 'The number of the host\'s services which have not been checked yet (pending)',
1273 'prop' : 'host',
1274 'type' : 'list',
1276 'host_num_services_unknown' : {
1277 'depythonize' : lambda x: len([y for y in x.services if y.state_id == 3]),
1278 'description' : 'The number of the host\'s services with the soft state UNKNOWN',
1279 'prop' : 'host',
1280 'type' : 'list',
1282 'host_num_services_warn' : {
1283 'depythonize' : lambda x: len([y for y in x.services if y.state_id == 1]),
1284 'description' : 'The number of the host\'s services with the soft state WARN',
1285 'prop' : 'host',
1286 'type' : 'list',
1288 'host_obsess_over_host' : {
1289 'description' : 'The current obsess_over_host setting... (0/1)',
1290 'type' : 'int',
1292 'host_parents' : {
1293 'description' : 'A list of all direct parents of the host',
1294 'type' : 'list',
1296 'host_pending_flex_downtime' : {
1297 'description' : 'Wether a flex downtime is pending (0/1)',
1298 'type' : 'int',
1300 'host_percent_state_change' : {
1301 'description' : 'Percent state change',
1302 'type' : 'float',
1304 'host_perf_data' : {
1305 'description' : 'Optional performance data of the last host check',
1306 'type' : 'string',
1308 'host_plugin_output' : {
1309 'description' : 'Output of the last host check',
1310 'type' : 'string',
1312 'host_process_performance_data' : {
1313 'description' : 'Wether processing of performance data is enabled (0/1)',
1314 'type' : 'int',
1316 'host_retry_interval' : {
1317 'description' : 'Number of basic interval lengths between checks when retrying after a soft error',
1318 'type' : 'float',
1320 'host_scheduled_downtime_depth' : {
1321 'converter' : int,
1322 'depythonize' : lambda x: x.scheduled_downtime_depth,
1323 'description' : 'The number of downtimes this host is currently in',
1324 'prop' : 'host',
1325 'type' : 'int',
1327 'host_state' : {
1328 'converter' : int,
1329 'depythonize' : lambda x: x.state_id,
1330 'description' : 'The current state of the host (0: up, 1: down, 2: unreachable)',
1331 'prop' : 'host',
1332 'type' : 'int',
1334 'host_state_type' : {
1335 'description' : 'Type of the current state (0: soft, 1: hard)',
1336 'type' : 'int',
1338 'host_statusmap_image' : {
1339 'description' : 'The name of in image file for the status map',
1340 'type' : 'string',
1342 'host_total_services' : {
1343 'description' : 'The total number of services of the host',
1344 'type' : 'int',
1346 'host_worst_service_hard_state' : {
1347 'description' : 'The worst hard state of all of the host\'s services (OK <= WARN <= UNKNOWN <= CRIT)',
1348 'type' : 'list',
1350 'host_worst_service_state' : {
1351 'description' : 'The worst soft state of all of the host\'s services (OK <= WARN <= UNKNOWN <= CRIT)',
1352 'type' : 'list',
1354 'host_x_3d' : {
1355 'description' : '3D-Coordinates: X',
1356 'type' : 'float',
1358 'host_y_3d' : {
1359 'description' : '3D-Coordinates: Y',
1360 'type' : 'float',
1362 'host_z_3d' : {
1363 'description' : '3D-Coordinates: Z',
1364 'type' : 'float',
1366 'icon_image' : {
1367 'description' : 'The name of an image to be used as icon in the web interface',
1368 'type' : 'string',
1370 'icon_image_alt' : {
1371 'description' : 'An alternative text for the icon_image for browsers not displaying icons',
1372 'type' : 'string',
1374 'icon_image_expanded' : {
1375 'description' : 'The icon_image with (the most important) macros expanded',
1376 'type' : 'string',
1378 'in_check_period' : {
1379 'depythonize' : lambda tp: from_bool_to_int((tp == None and [False] or [tp.is_time_valid(time.time())])[0]),
1380 'description' : 'Wether the service is currently in its check period (0/1)',
1381 'prop' : 'check_period',
1382 'type' : 'int',
1384 'in_notification_period' : {
1385 'depythonize' : lambda tp: from_bool_to_int((tp == None and [False] or [tp.is_time_valid(time.time())])[0]),
1386 'description' : 'Wether the service is currently in its notification period (0/1)',
1387 'prop' : 'notification_period',
1388 'type' : 'int',
1390 'initial_state' : {
1391 'description' : 'The initial state of the service',
1392 'type' : 'int',
1394 'is_executing' : {
1395 'default' : 0, # value in scheduler is not real-time
1396 'description' : 'is there a service check currently running... (0/1)',
1397 'type' : 'int',
1399 'is_flapping' : {
1400 'depythonize' : from_bool_to_int,
1401 'description' : 'Wether the service is flapping (0/1)',
1402 'type' : 'int',
1404 'is_impact' : {
1405 'depythonize' : from_bool_to_int,
1406 'description' : 'Wether the host state is an impact or not (0/1)',
1407 'type' : 'int',
1409 'is_problem' : {
1410 'depythonize' : from_bool_to_int,
1411 'description' : 'Wether the host state is a problem or not (0/1)',
1412 'type' : 'int',
1414 'last_check' : {
1415 'depythonize' : from_float_to_int,
1416 'description' : 'The time of the last check (Unix timestamp)',
1417 'prop' : 'last_chk',
1418 'type' : 'int',
1420 'last_hard_state' : {
1421 'description' : 'The last hard state of the service',
1422 'type' : 'int',
1424 'last_hard_state_change' : {
1425 'description' : 'The time of the last hard state change (Unix timestamp)',
1426 'type' : 'int',
1428 'last_notification' : {
1429 'depythonize' : to_int,
1430 'description' : 'The time of the last notification (Unix timestamp)',
1431 'type' : 'int',
1433 'last_state' : {
1434 'description' : 'The last state of the service',
1435 'type' : 'int',
1437 'last_state_change' : {
1438 'depythonize' : from_float_to_int,
1439 'description' : 'The time of the last state change (Unix timestamp)',
1440 'type' : 'int',
1442 'latency' : {
1443 'depythonize' : to_int,
1444 'description' : 'Time difference between scheduled check time and actual check time',
1445 'type' : 'float',
1447 'long_plugin_output' : {
1448 'description' : 'Unabbreviated output of the last check plugin',
1449 'prop' : 'long_output',
1450 'type' : 'string',
1452 'low_flap_threshold' : {
1453 'description' : 'Low threshold of flap detection',
1454 'type' : 'float',
1456 'max_check_attempts' : {
1457 'description' : 'The maximum number of check attempts',
1458 'type' : 'int',
1460 'next_check' : {
1461 'depythonize' : from_float_to_int,
1462 'description' : 'The scheduled time of the next check (Unix timestamp)',
1463 'prop' : 'next_chk',
1464 'type' : 'int',
1466 'next_notification' : {
1467 'description' : 'The time of the next notification (Unix timestamp)',
1468 'type' : 'int',
1470 'notes' : {
1471 'description' : 'Optional notes about the service',
1472 'type' : 'string',
1474 'notes_expanded' : {
1475 'description' : 'The notes with (the most important) macros expanded',
1476 'type' : 'string',
1478 'notes_url' : {
1479 'description' : 'An optional URL for additional notes about the service',
1480 'type' : 'string',
1482 'notes_url_expanded' : {
1483 'fulldepythonize' : lambda p, e, r: MacroResolver().resolve_simple_macros_in_string(p, e.get_data_for_checks()),
1484 'description' : 'The notes_url with (the most important) macros expanded',
1485 'prop' : 'notes_url',
1486 'type' : 'string',
1488 'notification_interval' : {
1489 'description' : 'Interval of periodic notification or 0 if its off',
1490 'type' : 'float',
1492 'notification_period' : {
1493 'depythonize' : 'get_name',
1494 'description' : 'The name of the notification period of the service. It this is empty, service problems are always notified.',
1495 'type' : 'string',
1497 'notifications_enabled' : {
1498 'depythonize' : from_bool_to_int,
1499 'description' : 'Wether notifications are enabled for the service (0/1)',
1500 'type' : 'int',
1502 'obsess_over_service' : {
1503 'depythonize' : from_bool_to_int,
1504 'description' : 'Wether \'obsess_over_service\' is enabled for the service (0/1)',
1505 'type' : 'int',
1507 'percent_state_change' : {
1508 'description' : 'Percent state change',
1509 'type' : 'float',
1511 'perf_data' : {
1512 'description' : 'Performance data of the last check plugin',
1513 'type' : 'string',
1515 'plugin_output' : {
1516 'description' : 'Output of the last check plugin',
1517 'prop' : 'output',
1518 'type' : 'string',
1520 'pnpgraph_present' : {
1521 'fulldepythonize' : find_pnp_perfdata_xml,
1522 'description' : 'Whether there is a PNP4Nagios graph present for this service (0/1)',
1523 'prop' : 'get_dbg_name',
1524 'type' : 'int',
1526 'process_performance_data' : {
1527 'depythonize' : from_bool_to_int,
1528 'description' : 'Wether processing of performance data is enabled for the service (0/1)',
1529 'prop' : 'process_perf_data',
1530 'type' : 'int',
1532 'retry_interval' : {
1533 'description' : 'Number of basic interval lengths between checks when retrying after a soft error',
1534 'type' : 'float',
1536 'scheduled_downtime_depth' : {
1537 'converter' : int,
1538 'description' : 'The number of scheduled downtimes the service is currently in',
1539 'type' : 'int',
1541 'state' : {
1542 'converter' : int,
1543 'description' : 'The current state of the service (0: OK, 1: WARN, 2: CRITICAL, 3: UNKNOWN)',
1544 'prop' : 'state_id',
1545 'type' : 'int',
1547 'state_type' : {
1548 'converter' : int,
1549 'description' : 'The type of the current state (0: soft, 1: hard)',
1550 'prop' : 'state_type_id',
1551 'type' : 'int',
1553 'criticity' : {
1554 'converter' : int,
1555 'description' : 'The importance we gave to this service between hte minimum 0 and the maximum 5',
1556 'type' : 'int',
1558 'source_problems' : {
1559 'description' : 'The name of the source problems (host or service)',
1560 'prop' : 'source_problems',
1561 'type' : 'list',
1562 'depythonize' : from_svc_hst_distinct_lists,
1564 'impacts' : {
1565 'description' : 'List of what the source impact (list of hosts and services)',
1566 'prop' : 'impacts',
1567 'type' : 'list',
1568 'depythonize' : from_svc_hst_distinct_lists,
1570 'parent_dependencies' : {
1571 'description' : 'List of the dependencies (logical, network or business one) of this service.',
1572 'prop' : 'parent_dependencies',
1573 'type' : 'list',
1574 'depythonize' : from_svc_hst_distinct_lists,
1576 'child_dependencies' : {
1577 'description' : 'List of the host/service that depend on this service (logical, network or business one).',
1578 'prop' : 'child_dependencies',
1579 'type' : 'list',
1580 'depythonize' : from_svc_hst_distinct_lists,
1585 'Hostgroup' : {
1586 'action_url' : {
1587 'description' : 'An optional URL to custom actions or information about the hostgroup',
1588 'type' : 'string',
1590 'alias' : {
1591 'description' : 'An alias of the hostgroup',
1592 'type' : 'string',
1594 'members' : {
1595 'depythonize' : 'get_name',
1596 'description' : 'A list of all host names that are members of the hostgroup',
1597 'type' : 'list',
1599 'name' : {
1600 'description' : 'Name of the hostgroup',
1601 'prop' : 'hostgroup_name',
1602 'type' : 'string',
1604 'notes' : {
1605 'description' : 'Optional notes to the hostgroup',
1606 'type' : 'string',
1608 'notes_url' : {
1609 'description' : 'An optional URL with further information about the hostgroup',
1610 'type' : 'string',
1612 'num_hosts' : {
1613 'depythonize' : lambda x: len(x),
1614 'description' : 'The total number of hosts in the group',
1615 'prop' : 'get_hosts',
1616 'type' : 'list',
1618 'num_hosts_down' : {
1619 'depythonize' : lambda x: len([y for y in x if y.state_id == 1]),
1620 'description' : 'The number of hosts in the group that are down',
1621 'prop' : 'get_hosts',
1622 'type' : 'list',
1624 'num_hosts_pending' : {
1625 'depythonize' : lambda x: len([y for y in x if y.has_been_checked == 0]),
1626 'description' : 'The number of hosts in the group that are pending',
1627 'prop' : 'get_hosts',
1628 'type' : 'list',
1630 'num_hosts_unreach' : {
1631 'depythonize' : lambda x: len([y for y in x if y.state_id == 2]),
1632 'description' : 'The number of hosts in the group that are unreachable',
1633 'prop' : 'get_hosts',
1634 'type' : 'list',
1636 'num_hosts_up' : {
1637 'depythonize' : lambda x: len([y for y in x if y.state_id == 0]),
1638 'description' : 'The number of hosts in the group that are up',
1639 'prop' : 'get_hosts',
1640 'type' : 'list',
1642 'num_services' : {
1643 'depythonize' : lambda x: sum((len(y.service_ids) for y in x)),
1644 'description' : 'The total number of services of hosts in this group',
1645 'prop' : 'get_hosts',
1646 'type' : 'list',
1648 'num_services_crit' : {
1649 'depythonize' : lambda x: len([z for y in x for z in y.services if z.state_id == 2]),
1650 'description' : 'The total number of services with the state CRIT of hosts in this group',
1651 'prop' : 'get_hosts',
1652 'type' : 'list',
1654 'num_services_hard_crit' : {
1655 '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]),
1656 'description' : 'The total number of services with the state CRIT of hosts in this group',
1657 'prop' : 'get_hosts',
1658 'type' : 'list',
1660 'num_services_hard_ok' : {
1661 '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]),
1662 'description' : 'The total number of services with the state OK of hosts in this group',
1663 'prop' : 'get_hosts',
1664 'type' : 'list',
1666 'num_services_hard_unknown' : {
1667 '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]),
1668 'description' : 'The total number of services with the state UNKNOWN of hosts in this group',
1669 'prop' : 'get_hosts',
1670 'type' : 'list',
1672 'num_services_hard_warn' : {
1673 '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]),
1674 'description' : 'The total number of services with the state WARN of hosts in this group',
1675 'prop' : 'get_hosts',
1676 'type' : 'list',
1678 'num_services_ok' : {
1679 'depythonize' : lambda x: len([z for y in x for z in y.services if z.state_id == 0]),
1680 'description' : 'The total number of services with the state OK of hosts in this group',
1681 'prop' : 'get_hosts',
1682 'type' : 'list',
1684 'num_services_pending' : {
1685 'depythonize' : lambda x: len([z for y in x for z in y.services if z.has_been_checked == 0]),
1686 'description' : 'The total number of services with the state Pending of hosts in this group',
1687 'prop' : 'get_hosts',
1688 'type' : 'list',
1690 'num_services_unknown' : {
1691 'depythonize' : lambda x: len([z for y in x for z in y.services if z.state_id == 3]),
1692 'description' : 'The total number of services with the state UNKNOWN of hosts in this group',
1693 'prop' : 'get_hosts',
1694 'type' : 'list',
1696 'num_services_warn' : {
1697 'depythonize' : lambda x: len([z for y in x for z in y.services if z.state_id == 1]),
1698 'description' : 'The total number of services with the state WARN of hosts in this group',
1699 'prop' : 'get_hosts',
1700 'type' : 'list',
1702 'worst_host_state' : {
1703 'depythonize' : lambda x: reduce(worst_host_state, (y.state_id for y in x), 0),
1704 'description' : 'The worst state of all of the groups\' hosts (UP <= UNREACHABLE <= DOWN)',
1705 'prop' : 'get_hosts',
1706 'type' : 'list',
1708 'worst_service_hard_state' : {
1709 '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),
1710 'description' : 'The worst state of all services that belong to a host of this group (OK <= WARN <= UNKNOWN <= CRIT)',
1711 'prop' : 'get_hosts',
1712 'type' : 'list',
1714 'worst_service_state' : {
1715 'depythonize' : lambda x: reduce(worst_service_state, (z.state_id for y in x for z in y.services), 0),
1716 'description' : 'The worst state of all services that belong to a host of this group (OK <= WARN <= UNKNOWN <= CRIT)',
1717 'prop' : 'get_hosts',
1718 'type' : 'list',
1722 'Servicegroup' : {
1723 'action_url' : {
1724 'description' : 'An optional URL to custom notes or actions on the service group',
1725 'type' : 'string',
1727 'alias' : {
1728 'description' : 'An alias of the service group',
1729 'type' : 'string',
1731 'members' : {
1732 'fulldepythonize' : get_livestatus_full_name,
1733 'description' : 'A list of all members of the service group as host/service pairs ',
1734 'type' : 'list',
1736 'name' : {
1737 'description' : 'The name of the service group',
1738 'prop' : 'servicegroup_name',
1739 'type' : 'string',
1741 'notes' : {
1742 'description' : 'Optional additional notes about the service group',
1743 'type' : 'string',
1745 'notes_url' : {
1746 'description' : 'An optional URL to further notes on the service group',
1747 'type' : 'string',
1749 'num_services' : {
1750 'converter' : int,
1751 'depythonize' : lambda x: len(x),
1752 'description' : 'The total number of services in the group',
1753 'prop' : 'get_services',
1754 'type' : 'list',
1756 'num_services_crit' : {
1757 'converter' : int,
1758 'depythonize' : lambda x: len([y for y in x if y.state_id == 2]),
1759 'description' : 'The number of services in the group that are CRIT',
1760 'prop' : 'get_services',
1761 'type' : 'list',
1763 'num_services_hard_crit' : {
1764 'converter' : int,
1765 'depythonize' : lambda x: len([y for y in x if y.state_id == 2 and y.state_type_id == 1]),
1766 'description' : 'The number of services in the group that are CRIT',
1767 'prop' : 'get_services',
1768 'type' : 'list',
1770 'num_services_hard_ok' : {
1771 'converter' : int,
1772 'depythonize' : lambda x: len([y for y in x if y.state_id == 0 and y.state_type_id == 1]),
1773 'description' : 'The number of services in the group that are OK',
1774 'prop' : 'get_services',
1775 'type' : 'list',
1777 'num_services_hard_unknown' : {
1778 'converter' : int,
1779 'depythonize' : lambda x: len([y for y in x if y.state_id == 3 and y.state_type_id == 1]),
1780 'description' : 'The number of services in the group that are UNKNOWN',
1781 'prop' : 'get_services',
1782 'type' : 'list',
1784 'num_services_hard_warn' : {
1785 'converter' : int,
1786 'depythonize' : lambda x: len([y for y in x if y.state_id == 2 and y.state_type_id == 1]),
1787 'description' : 'The number of services in the group that are WARN',
1788 'prop' : 'get_services',
1789 'type' : 'list',
1791 'num_services_ok' : {
1792 'converter' : int,
1793 'depythonize' : lambda x: len([y for y in x if y.state_id == 0]),
1794 'description' : 'The number of services in the group that are OK',
1795 'prop' : 'get_services',
1796 'type' : 'list',
1798 'num_services_pending' : {
1799 'converter' : int,
1800 'depythonize' : lambda x: len([y for y in x if y.has_been_checked == 0]),
1801 'description' : 'The number of services in the group that are PENDING',
1802 'prop' : 'get_services',
1803 'type' : 'list',
1805 'num_services_unknown' : {
1806 'converter' : int,
1807 'depythonize' : lambda x: len([y for y in x if y.state_id == 3]),
1808 'description' : 'The number of services in the group that are UNKNOWN',
1809 'prop' : 'get_services',
1810 'type' : 'list',
1812 'num_services_warn' : {
1813 'converter' : int,
1814 'depythonize' : lambda x: len([y for y in x if y.state_id == 1]),
1815 'description' : 'The number of services in the group that are WARN',
1816 'prop' : 'get_services',
1817 'type' : 'list',
1819 'worst_service_state' : {
1820 'depythonize' : lambda x: reduce(worst_service_state, (y.state_id for y in x), 0),
1821 'description' : 'The worst soft state of all of the groups services (OK <= WARN <= UNKNOWN <= CRIT)',
1822 'prop' : 'get_services',
1823 'type' : 'list',
1827 'Contact' : {
1828 'address1' : {
1829 'description' : 'The additional field address1',
1830 'type' : 'string',
1832 'address2' : {
1833 'description' : 'The additional field address2',
1834 'type' : 'string',
1836 'address3' : {
1837 'description' : 'The additional field address3',
1838 'type' : 'string',
1840 'address4' : {
1841 'description' : 'The additional field address4',
1842 'type' : 'string',
1844 'address5' : {
1845 'description' : 'The additional field address5',
1846 'type' : 'string',
1848 'address6' : {
1849 'description' : 'The additional field address6',
1850 'type' : 'string',
1852 'alias' : {
1853 'description' : 'The full name of the contact',
1854 'type' : 'string',
1856 'can_submit_commands' : {
1857 'depythonize' : from_bool_to_int,
1858 'description' : 'Wether the contact is allowed to submit commands (0/1)',
1859 'type' : 'int',
1861 'custom_variable_names' : {
1862 'description' : 'A list of all custom variables of the contact',
1863 'type' : 'list',
1865 'custom_variable_values' : {
1866 'description' : 'A list of the values of all custom variables of the contact',
1867 'type' : 'list',
1869 'email' : {
1870 'description' : 'The email address of the contact',
1871 'type' : 'string',
1873 'host_notification_period' : {
1874 'depythonize' : 'get_name',
1875 'description' : 'The time period in which the contact will be notified about host problems',
1876 'type' : 'string',
1878 'host_notifications_enabled' : {
1879 'depythonize' : from_bool_to_int,
1880 'description' : 'Wether the contact will be notified about host problems in general (0/1)',
1881 'type' : 'int',
1883 'in_host_notification_period' : {
1884 'depythonize' : from_bool_to_int,
1885 'description' : 'Wether the contact is currently in his/her host notification period (0/1)',
1886 'type' : 'int',
1888 'in_service_notification_period' : {
1889 'depythonize' : from_bool_to_int,
1890 'description' : 'Wether the contact is currently in his/her service notification period (0/1)',
1891 'type' : 'int',
1893 'name' : {
1894 'description' : 'The login name of the contact person',
1895 'prop' : 'contact_name',
1896 'type' : 'string',
1898 'pager' : {
1899 'description' : 'The pager address of the contact',
1900 'type' : 'string',
1902 'service_notification_period' : {
1903 'depythonize' : 'get_name',
1904 'description' : 'The time period in which the contact will be notified about service problems',
1905 'type' : 'string',
1907 'service_notifications_enabled' : {
1908 'depythonize' : from_bool_to_int,
1909 'description' : 'Wether the contact will be notified about service problems in general (0/1)',
1910 'type' : 'int',
1915 #Group of contacts
1916 'Contactgroup' : {
1917 'alias' : {
1918 'description' : 'The alias of the contactgroup',
1919 'type' : 'string',
1921 'members' : {
1922 'depythonize' : 'get_name',
1923 'description' : 'A list of all members of this contactgroup',
1924 'type' : 'list',
1926 'name' : {
1927 'description' : 'The name of the contactgroup',
1928 'prop' : 'contactgroup_name',
1929 'type' : 'string',
1934 #Timeperiods
1935 'Timeperiod' : {
1936 'alias' : {
1937 'description' : 'The alias of the timeperiod',
1938 'type' : 'string',
1940 'name' : {
1941 'description' : 'The name of the timeperiod',
1942 'prop' : 'timeperiod_name',
1943 'type' : 'string',
1947 #All commands (checks + notifications)
1948 'Command' : {
1949 'line' : {
1950 'description' : 'The shell command line',
1951 'prop' : 'command_line',
1952 'type' : 'string',
1954 'name' : {
1955 'description' : 'The name of the command',
1956 'prop' : 'command_name',
1957 'type' : 'string',
1962 ###Satellites
1963 #Schedulers
1964 'SchedulerLink' : {
1965 'name' : {
1966 'description' : 'The name of the scheduler',
1967 'prop' : 'scheduler_name',
1968 'type' : 'string',
1970 'address' : {
1971 'description' : 'The ip or dns adress ofthe scheduler',
1972 'prop' : 'address',
1973 'type' : 'string',
1975 'port' : {
1976 'description' : 'The TCP port of the scheduler',
1977 'prop' : 'port',
1978 'type' : 'int',
1980 'spare' : {
1981 'description' : 'If the scheduler is a spare or not',
1982 'depythonize' : from_bool_to_int,
1983 'prop' : 'spare',
1984 'type' : 'int',
1986 'weight' : {
1987 'description' : 'Weight (in terms of hosts) of the scheduler',
1988 'prop' : 'weight',
1989 'type' : 'int',
1991 'alive' : {
1992 'description' : 'If the scheduler is alive or not',
1993 'prop' : 'alive',
1994 'depythonize' : from_bool_to_int,
1995 'type' : 'int',
2001 #Pollers
2002 'PollerLink' : {
2003 'name' : {
2004 'description' : 'The name of the poller',
2005 'prop' : 'poller_name',
2006 'type' : 'string',
2008 'address' : {
2009 'description' : 'The ip or dns adress of the poller',
2010 'prop' : 'address',
2011 'type' : 'string',
2013 'port' : {
2014 'description' : 'The TCP port of the poller',
2015 'prop' : 'port',
2016 'type' : 'int',
2018 'spare' : {
2019 'description' : 'If the poller is a spare or not',
2020 'depythonize' : from_bool_to_int,
2021 'prop' : 'spare',
2022 'type' : 'int',
2024 'alive' : {
2025 'description' : 'If the poller is alive or not',
2026 'prop' : 'alive',
2027 'depythonize' : from_bool_to_int,
2028 'type' : 'int',
2033 #Reactionners
2034 'ReactionnerLink' : {
2035 'name' : {
2036 'description' : 'The name of the reactionner',
2037 'prop' : 'reactionner_name',
2038 'type' : 'string',
2040 'address' : {
2041 'description' : 'The ip or dns adress of the reactionner',
2042 'prop' : 'address',
2043 'type' : 'string',
2045 'port' : {
2046 'description' : 'The TCP port of the reactionner',
2047 'prop' : 'port',
2048 'type' : 'int',
2050 'spare' : {
2051 'description' : 'If the reactionner is a spare or not',
2052 'depythonize' : from_bool_to_int,
2053 'prop' : 'spare',
2054 'type' : 'int',
2056 'alive' : {
2057 'description' : 'If the reactionner is alive or not',
2058 'prop' : 'alive',
2059 'depythonize' : from_bool_to_int,
2060 'type' : 'int',
2065 #Brokers
2066 'BrokerLink' : {
2067 'name' : {
2068 'description' : 'The name of the broker',
2069 'prop' : 'broker_name',
2070 'type' : 'string',
2072 'address' : {
2073 'description' : 'The ip or dns adress of the broker',
2074 'prop' : 'address',
2075 'type' : 'string',
2077 'port' : {
2078 'description' : 'The TCP port of the broker',
2079 'prop' : 'port',
2080 'type' : 'int',
2082 'spare' : {
2083 'description' : 'If the broker is a spare or not',
2084 'depythonize' : from_bool_to_int,
2085 'prop' : 'spare',
2086 'type' : 'int',
2088 'alive' : {
2089 'description' : 'If the broker is alive or not',
2090 'prop' : 'alive',
2091 'depythonize' : from_bool_to_int,
2092 'type' : 'int',
2097 #Problem
2098 'Problem' : {
2099 'source' : {
2100 'description' : 'The source name of the problem (host or service)',
2101 'prop' : 'source',
2102 'type' : 'string',
2103 'fulldepythonize' : get_livestatus_full_name
2105 'impacts' : {
2106 'description' : 'List of what the source impact (list of hosts and services)',
2107 'prop' : 'impacts',
2108 'type' : 'string',
2109 'depythonize' : from_svc_hst_distinct_lists,
2114 #Downtimes
2115 'Downtime' : {
2116 'author' : {
2117 'default' : 'nobody',
2118 'description' : 'The contact that scheduled the downtime',
2119 'prop' : None,
2120 'type' : 'string',
2122 'comment' : {
2123 'default' : None,
2124 'description' : 'A comment text',
2125 'prop' : None,
2126 'type' : 'string',
2128 'duration' : {
2129 'default' : '0',
2130 'description' : 'The duration of the downtime in seconds',
2131 'prop' : None,
2132 'type' : 'int',
2134 'end_time' : {
2135 'default' : '0',
2136 'description' : 'The end time of the downtime as UNIX timestamp',
2137 'prop' : None,
2138 'type' : 'int',
2140 'entry_time' : {
2141 'default' : '0',
2142 'description' : 'The time the entry was made as UNIX timestamp',
2143 'prop' : None,
2144 'type' : 'int',
2146 'fixed' : {
2147 'default' : None,
2148 'depythonize' : from_bool_to_int,
2149 'description' : 'A 1 if the downtime is fixed, a 0 if it is flexible',
2150 'prop' : None,
2151 'type' : 'int',
2153 'host_accept_passive_checks' : {
2154 'default' : None,
2155 'description' : 'Wether passive host checks are accepted (0/1)',
2156 'prop' : None,
2157 'type' : 'int',
2159 'host_acknowledged' : {
2160 'default' : None,
2161 'description' : 'Wether the current host problem has been acknowledged (0/1)',
2162 'prop' : None,
2163 'type' : 'int',
2165 'host_acknowledgement_type' : {
2166 'default' : None,
2167 'description' : 'Type of acknowledgement (0: none, 1: normal, 2: stick)',
2168 'prop' : None,
2169 'type' : 'int',
2171 'host_action_url' : {
2172 'default' : None,
2173 'description' : 'An optional URL to custom actions or information about this host',
2174 'prop' : None,
2175 'type' : 'string',
2177 'host_action_url_expanded' : {
2178 'default' : None,
2179 'description' : 'The same as action_url, but with the most important macros expanded',
2180 'prop' : None,
2181 'type' : 'string',
2183 'host_active_checks_enabled' : {
2184 'default' : None,
2185 'description' : 'Wether active checks are enabled for the host (0/1)',
2186 'prop' : None,
2187 'type' : 'int',
2189 'host_address' : {
2190 'default' : None,
2191 'description' : 'IP address',
2192 'prop' : None,
2193 'type' : 'string',
2195 'host_alias' : {
2196 'default' : None,
2197 'description' : 'An alias name for the host',
2198 'prop' : None,
2199 'type' : 'string',
2201 'host_check_command' : {
2202 'default' : None,
2203 'description' : 'Nagios command for active host check of this host',
2204 'prop' : None,
2205 'type' : 'string',
2207 'host_check_freshness' : {
2208 'default' : None,
2209 'description' : 'Wether freshness checks are activated (0/1)',
2210 'prop' : None,
2211 'type' : 'int',
2213 'host_check_interval' : {
2214 'default' : None,
2215 'description' : 'Number of basic interval lengths between two scheduled checks of the host',
2216 'prop' : None,
2217 'type' : 'float',
2219 'host_check_options' : {
2220 'default' : None,
2221 'description' : 'The current check option, forced, normal, freshness... (0-2)',
2222 'prop' : None,
2223 'type' : 'int',
2225 'host_check_period' : {
2226 'default' : None,
2227 'description' : 'Time period in which this host will be checked. If empty then the host will always be checked.',
2228 'prop' : None,
2229 'type' : 'string',
2231 'host_check_type' : {
2232 'default' : None,
2233 'description' : 'Type of check (0: active, 1: passive)',
2234 'prop' : None,
2235 'type' : 'int',
2237 'host_checks_enabled' : {
2238 'default' : None,
2239 'description' : 'Wether checks of the host are enabled (0/1)',
2240 'prop' : None,
2241 'type' : 'int',
2243 'host_childs' : {
2244 'default' : None,
2245 'description' : 'A list of all direct childs of the host',
2246 'prop' : None,
2247 'type' : 'list',
2249 'host_comments' : {
2250 'default' : None,
2251 'description' : 'A list of the ids of all comments of this host',
2252 'prop' : None,
2253 'type' : 'list',
2255 'host_contacts' : {
2256 'default' : None,
2257 'description' : 'A list of all contacts of this host, either direct or via a contact group',
2258 'prop' : None,
2259 'type' : 'list',
2261 'host_current_attempt' : {
2262 'default' : None,
2263 'description' : 'Number of the current check attempts',
2264 'prop' : None,
2265 'type' : 'int',
2267 'host_current_notification_number' : {
2268 'default' : None,
2269 'description' : 'Number of the current notification',
2270 'prop' : None,
2271 'type' : 'int',
2273 'host_custom_variable_names' : {
2274 'default' : None,
2275 'description' : 'A list of the names of all custom variables',
2276 'prop' : None,
2277 'type' : 'list',
2279 'host_custom_variable_values' : {
2280 'default' : None,
2281 'description' : 'A list of the values of the custom variables',
2282 'prop' : None,
2283 'type' : 'list',
2285 'host_display_name' : {
2286 'default' : None,
2287 'description' : 'Optional display name of the host - not used by Nagios\' web interface',
2288 'prop' : None,
2289 'type' : 'string',
2291 'host_downtimes' : {
2292 'default' : None,
2293 'description' : 'A list of the ids of all scheduled downtimes of this host',
2294 'prop' : None,
2295 'type' : 'list',
2297 'host_event_handler_enabled' : {
2298 'default' : None,
2299 'description' : 'Wether event handling is enabled (0/1)',
2300 'prop' : None,
2301 'type' : 'int',
2303 'host_execution_time' : {
2304 'default' : None,
2305 'description' : 'Time the host check needed for execution',
2306 'prop' : None,
2307 'type' : 'float',
2309 'host_first_notification_delay' : {
2310 'default' : None,
2311 'description' : 'Delay before the first notification',
2312 'prop' : None,
2313 'type' : 'float',
2315 'host_flap_detection_enabled' : {
2316 'default' : None,
2317 'description' : 'Wether flap detection is enabled (0/1)',
2318 'prop' : None,
2319 'type' : 'int',
2321 'host_groups' : {
2322 'default' : None,
2323 'description' : 'A list of all host groups this host is in',
2324 'prop' : None,
2325 'type' : 'list',
2327 'host_hard_state' : {
2328 'default' : None,
2329 'description' : 'The effective hard state of the host (eliminates a problem in hard_state)',
2330 'prop' : None,
2331 'type' : 'int',
2333 'host_has_been_checked' : {
2334 'default' : None,
2335 'description' : 'Wether the host has already been checked (0/1)',
2336 'prop' : None,
2337 'type' : 'int',
2339 'host_high_flap_threshold' : {
2340 'default' : None,
2341 'description' : 'High threshold of flap detection',
2342 'prop' : None,
2343 'type' : 'float',
2345 'host_icon_image' : {
2346 'default' : None,
2347 'description' : 'The name of an image file to be used in the web pages',
2348 'prop' : None,
2349 'type' : 'string',
2351 'host_icon_image_alt' : {
2352 'default' : None,
2353 'description' : 'Alternative text for the icon_image',
2354 'prop' : None,
2355 'type' : 'string',
2357 'host_icon_image_expanded' : {
2358 'default' : None,
2359 'description' : 'The same as icon_image, but with the most important macros expanded',
2360 'prop' : None,
2361 'type' : 'string',
2363 'host_in_check_period' : {
2364 'default' : None,
2365 'description' : 'Wether this host is currently in its check period (0/1)',
2366 'prop' : None,
2367 'type' : 'int',
2369 'host_in_notification_period' : {
2370 'default' : None,
2371 'description' : 'Wether this host is currently in its notification period (0/1)',
2372 'prop' : None,
2373 'type' : 'int',
2375 'host_initial_state' : {
2376 'default' : None,
2377 'description' : 'Initial host state',
2378 'prop' : None,
2379 'type' : 'int',
2381 'host_is_executing' : {
2382 'default' : 0, # value in scheduler is not real-time
2383 'description' : 'is there a host check currently running... (0/1)',
2384 'prop' : None,
2385 'type' : 'int',
2387 'host_is_flapping' : {
2388 'default' : None,
2389 'description' : 'Wether the host state is flapping (0/1)',
2390 'prop' : None,
2391 'type' : 'int',
2393 'host_last_check' : {
2394 'default' : None,
2395 'description' : 'Time of the last check (Unix timestamp)',
2396 'prop' : None,
2397 'type' : 'int',
2399 'host_last_hard_state' : {
2400 'default' : None,
2401 'description' : 'Last hard state',
2402 'prop' : None,
2403 'type' : 'int',
2405 'host_last_hard_state_change' : {
2406 'default' : None,
2407 'description' : 'Time of the last hard state change (Unix timestamp)',
2408 'prop' : None,
2409 'type' : 'int',
2411 'host_last_notification' : {
2412 'default' : None,
2413 'description' : 'Time of the last notification (Unix timestamp)',
2414 'prop' : None,
2415 'type' : 'int',
2417 'host_last_state' : {
2418 'default' : None,
2419 'description' : 'State before last state change',
2420 'prop' : None,
2421 'type' : 'int',
2423 'host_last_state_change' : {
2424 'default' : None,
2425 'description' : 'Time of the last state change - soft or hard (Unix timestamp)',
2426 'prop' : None,
2427 'type' : 'int',
2429 'host_latency' : {
2430 'default' : None,
2431 'description' : 'Time difference between scheduled check time and actual check time',
2432 'prop' : None,
2433 'type' : 'float',
2435 'host_long_plugin_output' : {
2436 'default' : None,
2437 'description' : 'Complete output from check plugin',
2438 'prop' : None,
2439 'type' : 'string',
2441 'host_low_flap_threshold' : {
2442 'default' : None,
2443 'description' : 'Low threshold of flap detection',
2444 'prop' : None,
2445 'type' : 'float',
2447 'host_max_check_attempts' : {
2448 'default' : None,
2449 'description' : 'Max check attempts for active host checks',
2450 'prop' : None,
2451 'type' : 'int',
2453 'host_name' : {
2454 'default' : None,
2455 'depythonize' : lambda x: x.host_name,
2456 'description' : 'Host name',
2457 'prop' : 'ref',
2458 'type' : 'string',
2460 'host_next_check' : {
2461 'default' : None,
2462 'description' : 'Scheduled time for the next check (Unix timestamp)',
2463 'prop' : None,
2464 'type' : 'int',
2466 'host_next_notification' : {
2467 'default' : None,
2468 'description' : 'Time of the next notification (Unix timestamp)',
2469 'prop' : None,
2470 'type' : 'int',
2472 'host_notes' : {
2473 'default' : None,
2474 'description' : 'Optional notes for this host',
2475 'prop' : None,
2476 'type' : 'string',
2478 'host_notes_expanded' : {
2479 'default' : None,
2480 'description' : 'The same as notes, but with the most important macros expanded',
2481 'prop' : None,
2482 'type' : 'string',
2484 'host_notes_url' : {
2485 'default' : None,
2486 'description' : 'An optional URL with further information about the host',
2487 'prop' : None,
2488 'type' : 'string',
2490 'host_notes_url_expanded' : {
2491 'default' : None,
2492 'description' : 'Same es notes_url, but with the most important macros expanded',
2493 'prop' : None,
2494 'type' : 'string',
2496 'host_notification_interval' : {
2497 'default' : None,
2498 'description' : 'Interval of periodic notification or 0 if its off',
2499 'prop' : None,
2500 'type' : 'float',
2502 'host_notification_period' : {
2503 'default' : None,
2504 'description' : 'Time period in which problems of this host will be notified. If empty then notification will be always',
2505 'prop' : None,
2506 'type' : 'string',
2508 'host_notifications_enabled' : {
2509 'default' : None,
2510 'description' : 'Wether notifications of the host are enabled (0/1)',
2511 'prop' : None,
2512 'type' : 'int',
2514 'host_num_services' : {
2515 'default' : None,
2516 'description' : 'The total number of services of the host',
2517 'prop' : None,
2518 'type' : 'list',
2520 'host_num_services_crit' : {
2521 'default' : None,
2522 'description' : 'The number of the host\'s services with the soft state CRIT',
2523 'prop' : None,
2524 'type' : 'list',
2526 'host_num_services_hard_crit' : {
2527 'default' : None,
2528 'description' : 'The number of the host\'s services with the hard state CRIT',
2529 'prop' : None,
2530 'type' : 'list',
2532 'host_num_services_hard_ok' : {
2533 'default' : None,
2534 'description' : 'The number of the host\'s services with the hard state OK',
2535 'prop' : None,
2536 'type' : 'list',
2538 'host_num_services_hard_unknown' : {
2539 'default' : None,
2540 'description' : 'The number of the host\'s services with the hard state UNKNOWN',
2541 'prop' : None,
2542 'type' : 'list',
2544 'host_num_services_hard_warn' : {
2545 'default' : None,
2546 'description' : 'The number of the host\'s services with the hard state WARN',
2547 'prop' : None,
2548 'type' : 'list',
2550 'host_num_services_ok' : {
2551 'default' : None,
2552 'description' : 'The number of the host\'s services with the soft state OK',
2553 'prop' : None,
2554 'type' : 'list',
2556 'host_num_services_pending' : {
2557 'default' : None,
2558 'description' : 'The number of the host\'s services which have not been checked yet (pending)',
2559 'prop' : None,
2560 'type' : 'list',
2562 'host_num_services_unknown' : {
2563 'default' : None,
2564 'description' : 'The number of the host\'s services with the soft state UNKNOWN',
2565 'prop' : None,
2566 'type' : 'list',
2568 'host_num_services_warn' : {
2569 'default' : None,
2570 'description' : 'The number of the host\'s services with the soft state WARN',
2571 'prop' : None,
2572 'type' : 'list',
2574 'host_obsess_over_host' : {
2575 'default' : None,
2576 'description' : 'The current obsess_over_host setting... (0/1)',
2577 'prop' : None,
2578 'type' : 'int',
2580 'host_parents' : {
2581 'default' : None,
2582 'description' : 'A list of all direct parents of the host',
2583 'prop' : None,
2584 'type' : 'list',
2586 'host_pending_flex_downtime' : {
2587 'default' : None,
2588 'description' : 'Wether a flex downtime is pending (0/1)',
2589 'prop' : None,
2590 'type' : 'int',
2592 'host_percent_state_change' : {
2593 'default' : None,
2594 'description' : 'Percent state change',
2595 'prop' : None,
2596 'type' : 'float',
2598 'host_perf_data' : {
2599 'default' : None,
2600 'description' : 'Optional performance data of the last host check',
2601 'prop' : None,
2602 'type' : 'string',
2604 'host_plugin_output' : {
2605 'default' : None,
2606 'description' : 'Output of the last host check',
2607 'prop' : None,
2608 'type' : 'string',
2610 'host_process_performance_data' : {
2611 'default' : None,
2612 'description' : 'Wether processing of performance data is enabled (0/1)',
2613 'prop' : None,
2614 'type' : 'int',
2616 'host_retry_interval' : {
2617 'default' : None,
2618 'description' : 'Number of basic interval lengths between checks when retrying after a soft error',
2619 'prop' : None,
2620 'type' : 'float',
2622 'host_scheduled_downtime_depth' : {
2623 'default' : None,
2624 'description' : 'The number of downtimes this host is currently in',
2625 'prop' : None,
2626 'type' : 'int',
2628 'host_state' : {
2629 'default' : None,
2630 'description' : 'The current state of the host (0: up, 1: down, 2: unreachable)',
2631 'prop' : None,
2632 'type' : 'int',
2634 'host_state_type' : {
2635 'default' : None,
2636 'description' : 'Type of the current state (0: soft, 1: hard)',
2637 'prop' : None,
2638 'type' : 'int',
2640 'host_statusmap_image' : {
2641 'default' : None,
2642 'description' : 'The name of in image file for the status map',
2643 'prop' : None,
2644 'type' : 'string',
2646 'host_total_services' : {
2647 'default' : None,
2648 'description' : 'The total number of services of the host',
2649 'prop' : None,
2650 'type' : 'int',
2652 'host_worst_service_hard_state' : {
2653 'default' : None,
2654 'description' : 'The worst hard state of all of the host\'s services (OK <= WARN <= UNKNOWN <= CRIT)',
2655 'prop' : None,
2656 'type' : 'list',
2658 'host_worst_service_state' : {
2659 'default' : None,
2660 'description' : 'The worst soft state of all of the host\'s services (OK <= WARN <= UNKNOWN <= CRIT)',
2661 'prop' : None,
2662 'type' : 'list',
2664 'host_x_3d' : {
2665 'default' : None,
2666 'description' : '3D-Coordinates: X',
2667 'prop' : None,
2668 'type' : 'float',
2670 'host_y_3d' : {
2671 'default' : None,
2672 'description' : '3D-Coordinates: Y',
2673 'prop' : None,
2674 'type' : 'float',
2676 'host_z_3d' : {
2677 'default' : None,
2678 'description' : '3D-Coordinates: Z',
2679 'prop' : None,
2680 'type' : 'float',
2682 'id' : {
2683 'default' : None,
2684 'description' : 'The id of the downtime',
2685 'prop' : None,
2686 'type' : 'int',
2688 'service_accept_passive_checks' : {
2689 'default' : None,
2690 'description' : 'Wether the service accepts passive checks (0/1)',
2691 'prop' : None,
2692 'type' : 'int',
2694 'service_acknowledged' : {
2695 'default' : None,
2696 'description' : 'Wether the current service problem has been acknowledged (0/1)',
2697 'prop' : None,
2698 'type' : 'int',
2700 'service_acknowledgement_type' : {
2701 'default' : None,
2702 'description' : 'The type of the acknownledgement (0: none, 1: normal, 2: sticky)',
2703 'prop' : None,
2704 'type' : 'int',
2706 'service_action_url' : {
2707 'default' : None,
2708 'description' : 'An optional URL for actions or custom information about the service',
2709 'prop' : None,
2710 'type' : 'string',
2712 'service_action_url_expanded' : {
2713 'default' : None,
2714 'description' : 'The action_url with (the most important) macros expanded',
2715 'prop' : None,
2716 'type' : 'string',
2718 'service_active_checks_enabled' : {
2719 'default' : None,
2720 'description' : 'Wether active checks are enabled for the service (0/1)',
2721 'prop' : None,
2722 'type' : 'int',
2724 'service_check_command' : {
2725 'default' : None,
2726 'description' : 'Nagios command used for active checks',
2727 'prop' : None,
2728 'type' : 'string',
2730 'service_check_interval' : {
2731 'default' : None,
2732 'description' : 'Number of basic interval lengths between two scheduled checks of the service',
2733 'prop' : None,
2734 'type' : 'float',
2736 'service_check_options' : {
2737 'default' : None,
2738 'description' : 'The current check option, forced, normal, freshness... (0/1)',
2739 'prop' : None,
2740 'type' : 'int',
2742 'service_check_period' : {
2743 'default' : None,
2744 'description' : 'The name of the check period of the service. It this is empty, the service is always checked.',
2745 'prop' : None,
2746 'type' : 'string',
2748 'service_check_type' : {
2749 'default' : None,
2750 'description' : 'The type of the last check (0: active, 1: passive)',
2751 'prop' : None,
2752 'type' : 'int',
2754 'service_checks_enabled' : {
2755 'default' : None,
2756 'description' : 'Wether active checks are enabled for the service (0/1)',
2757 'prop' : None,
2758 'type' : 'int',
2760 'service_comments' : {
2761 'default' : None,
2762 'description' : 'A list of all comment ids of the service',
2763 'prop' : None,
2764 'type' : 'list',
2766 'service_contacts' : {
2767 'default' : None,
2768 'description' : 'A list of all contacts of the service, either direct or via a contact group',
2769 'prop' : None,
2770 'type' : 'list',
2772 'service_current_attempt' : {
2773 'default' : None,
2774 'description' : 'The number of the current check attempt',
2775 'prop' : None,
2776 'type' : 'int',
2778 'service_current_notification_number' : {
2779 'default' : None,
2780 'description' : 'The number of the current notification',
2781 'prop' : None,
2782 'type' : 'int',
2784 'service_custom_variable_names' : {
2785 'default' : None,
2786 'description' : 'A list of the names of all custom variables of the service',
2787 'prop' : None,
2788 'type' : 'list',
2790 'service_custom_variable_values' : {
2791 'default' : None,
2792 'description' : 'A list of the values of all custom variable of the service',
2793 'prop' : None,
2794 'type' : 'list',
2796 'service_description' : {
2797 'default' : None,
2798 'depythonize' : lambda x: getattr(x, 'service_description', ''),
2799 'description' : 'Description of the service (also used as key)',
2800 'prop' : 'ref',
2801 'type' : 'string',
2803 'service_display_name' : {
2804 'default' : None,
2805 'description' : 'An optional display name (not used by Nagios standard web pages)',
2806 'prop' : None,
2807 'type' : 'string',
2809 'service_downtimes' : {
2810 'default' : None,
2811 'description' : 'A list of all downtime ids of the service',
2812 'prop' : None,
2813 'type' : 'list',
2815 'service_event_handler' : {
2816 'default' : None,
2817 'description' : 'Nagios command used as event handler',
2818 'prop' : None,
2819 'type' : 'string',
2821 'service_event_handler_enabled' : {
2822 'default' : None,
2823 'description' : 'Wether and event handler is activated for the service (0/1)',
2824 'prop' : None,
2825 'type' : 'int',
2827 'service_execution_time' : {
2828 'default' : None,
2829 'description' : 'Time the host check needed for execution',
2830 'prop' : None,
2831 'type' : 'float',
2833 'service_first_notification_delay' : {
2834 'default' : None,
2835 'description' : 'Delay before the first notification',
2836 'prop' : None,
2837 'type' : 'float',
2839 'service_flap_detection_enabled' : {
2840 'default' : None,
2841 'description' : 'Wether flap detection is enabled for the service (0/1)',
2842 'prop' : None,
2843 'type' : 'int',
2845 'service_groups' : {
2846 'default' : None,
2847 'description' : 'A list of all service groups the service is in',
2848 'prop' : None,
2849 'type' : 'list',
2851 'service_has_been_checked' : {
2852 'default' : None,
2853 'description' : 'Wether the service already has been checked (0/1)',
2854 'prop' : None,
2855 'type' : 'int',
2857 'service_high_flap_threshold' : {
2858 'default' : None,
2859 'description' : 'High threshold of flap detection',
2860 'prop' : None,
2861 'type' : 'float',
2863 'service_icon_image' : {
2864 'default' : None,
2865 'description' : 'The name of an image to be used as icon in the web interface',
2866 'prop' : None,
2867 'type' : 'string',
2869 'service_icon_image_alt' : {
2870 'default' : None,
2871 'description' : 'An alternative text for the icon_image for browsers not displaying icons',
2872 'prop' : None,
2873 'type' : 'string',
2875 'service_icon_image_expanded' : {
2876 'default' : None,
2877 'description' : 'The icon_image with (the most important) macros expanded',
2878 'prop' : None,
2879 'type' : 'string',
2881 'service_in_check_period' : {
2882 'default' : None,
2883 'description' : 'Wether the service is currently in its check period (0/1)',
2884 'prop' : None,
2885 'type' : 'int',
2887 'service_in_notification_period' : {
2888 'default' : None,
2889 'description' : 'Wether the service is currently in its notification period (0/1)',
2890 'prop' : None,
2891 'type' : 'int',
2893 'service_initial_state' : {
2894 'default' : None,
2895 'description' : 'The initial state of the service',
2896 'prop' : None,
2897 'type' : 'int',
2899 'service_is_executing' : {
2900 'default' : 0, # value in scheduler is not real-time
2901 'description' : 'is there a service check currently running... (0/1)',
2902 'prop' : None,
2903 'type' : 'int',
2905 'service_is_flapping' : {
2906 'default' : None,
2907 'description' : 'Wether the service is flapping (0/1)',
2908 'prop' : None,
2909 'type' : 'int',
2911 'service_last_check' : {
2912 'default' : None,
2913 'description' : 'The time of the last check (Unix timestamp)',
2914 'prop' : None,
2915 'type' : 'int',
2917 'service_last_hard_state' : {
2918 'default' : None,
2919 'description' : 'The last hard state of the service',
2920 'prop' : None,
2921 'type' : 'int',
2923 'service_last_hard_state_change' : {
2924 'default' : None,
2925 'description' : 'The time of the last hard state change (Unix timestamp)',
2926 'prop' : None,
2927 'type' : 'int',
2929 'service_last_notification' : {
2930 'default' : None,
2931 'description' : 'The time of the last notification (Unix timestamp)',
2932 'prop' : None,
2933 'type' : 'int',
2935 'service_last_state' : {
2936 'default' : None,
2937 'description' : 'The last state of the service',
2938 'prop' : None,
2939 'type' : 'int',
2941 'service_last_state_change' : {
2942 'default' : None,
2943 'description' : 'The time of the last state change (Unix timestamp)',
2944 'prop' : None,
2945 'type' : 'int',
2947 'service_latency' : {
2948 'default' : None,
2949 'description' : 'Time difference between scheduled check time and actual check time',
2950 'prop' : None,
2951 'type' : 'float',
2953 'service_long_plugin_output' : {
2954 'default' : None,
2955 'description' : 'Unabbreviated output of the last check plugin',
2956 'prop' : None,
2957 'type' : 'string',
2959 'service_low_flap_threshold' : {
2960 'default' : None,
2961 'description' : 'Low threshold of flap detection',
2962 'prop' : None,
2963 'type' : 'float',
2965 'service_max_check_attempts' : {
2966 'default' : None,
2967 'description' : 'The maximum number of check attempts',
2968 'prop' : None,
2969 'type' : 'int',
2971 'service_next_check' : {
2972 'default' : None,
2973 'description' : 'The scheduled time of the next check (Unix timestamp)',
2974 'prop' : None,
2975 'type' : 'int',
2977 'service_next_notification' : {
2978 'default' : None,
2979 'description' : 'The time of the next notification (Unix timestamp)',
2980 'prop' : None,
2981 'type' : 'int',
2983 'service_notes' : {
2984 'default' : None,
2985 'description' : 'Optional notes about the service',
2986 'prop' : None,
2987 'type' : 'string',
2989 'service_notes_expanded' : {
2990 'default' : None,
2991 'description' : 'The notes with (the most important) macros expanded',
2992 'prop' : None,
2993 'type' : 'string',
2995 'service_notes_url' : {
2996 'default' : None,
2997 'description' : 'An optional URL for additional notes about the service',
2998 'prop' : None,
2999 'type' : 'string',
3001 'service_notes_url_expanded' : {
3002 'default' : None,
3003 'description' : 'The notes_url with (the most important) macros expanded',
3004 'prop' : None,
3005 'type' : 'string',
3007 'service_notification_interval' : {
3008 'default' : None,
3009 'description' : 'Interval of periodic notification or 0 if its off',
3010 'prop' : None,
3011 'type' : 'float',
3013 'service_notification_period' : {
3014 'default' : None,
3015 'description' : 'The name of the notification period of the service. It this is empty, service problems are always notified.',
3016 'prop' : None,
3017 'type' : 'string',
3019 'service_notifications_enabled' : {
3020 'default' : None,
3021 'description' : 'Wether notifications are enabled for the service (0/1)',
3022 'prop' : None,
3023 'type' : 'int',
3025 'service_obsess_over_service' : {
3026 'default' : None,
3027 'description' : 'Wether \'obsess_over_service\' is enabled for the service (0/1)',
3028 'prop' : None,
3029 'type' : 'int',
3031 'service_percent_state_change' : {
3032 'default' : None,
3033 'description' : 'Percent state change',
3034 'prop' : None,
3035 'type' : 'float',
3037 'service_perf_data' : {
3038 'default' : None,
3039 'description' : 'Performance data of the last check plugin',
3040 'prop' : None,
3041 'type' : 'string',
3043 'service_plugin_output' : {
3044 'default' : None,
3045 'description' : 'Output of the last check plugin',
3046 'prop' : None,
3047 'type' : 'string',
3049 'service_process_performance_data' : {
3050 'default' : None,
3051 'description' : 'Wether processing of performance data is enabled for the service (0/1)',
3052 'prop' : None,
3053 'type' : 'int',
3055 'service_retry_interval' : {
3056 'default' : None,
3057 'description' : 'Number of basic interval lengths between checks when retrying after a soft error',
3058 'prop' : None,
3059 'type' : 'float',
3061 'service_scheduled_downtime_depth' : {
3062 'default' : None,
3063 'description' : 'The number of scheduled downtimes the service is currently in',
3064 'prop' : None,
3065 'type' : 'int',
3067 'service_state' : {
3068 'default' : None,
3069 'description' : 'The current state of the service (0: OK, 1: WARN, 2: CRITICAL, 3: UNKNOWN)',
3070 'prop' : None,
3071 'type' : 'int',
3073 'service_state_type' : {
3074 'default' : None,
3075 'description' : 'The type of the current state (0: soft, 1: hard)',
3076 'prop' : None,
3077 'type' : 'int',
3079 'start_time' : {
3080 'default' : '0',
3081 'description' : 'The start time of the downtime as UNIX timestamp',
3082 'prop' : None,
3083 'type' : 'int',
3085 'triggered_by' : {
3086 'default' : None,
3087 'description' : 'The id of the downtime this downtime was triggered by or 0 if it was not triggered by another downtime',
3088 'prop' : 'trigger_id',
3089 'type' : 'int',
3091 'type' : {
3092 'default' : None,
3093 'description' : 'The type of the downtime: 0 if it is active, 1 if it is pending',
3094 'prop' : None,
3095 'type' : 'int',
3099 #Comments
3101 'Comment' : {
3102 'author' : {
3103 'default' : None,
3104 'description' : 'The contact that entered the comment',
3105 'prop' : None,
3106 'type' : 'string',
3108 'comment' : {
3109 'default' : None,
3110 'description' : 'A comment text',
3111 'prop' : None,
3112 'type' : 'string',
3114 'entry_time' : {
3115 'default' : None,
3116 'description' : 'The time the entry was made as UNIX timestamp',
3117 'prop' : None,
3118 'type' : 'int',
3120 'entry_type' : {
3121 'default' : '0',
3122 'description' : 'The type of the comment: 1 is user, 2 is downtime, 3 is flap and 4 is acknowledgement',
3123 'prop' : 'entry_type',
3124 'type' : 'int',
3126 'expire_time' : {
3127 'default' : '0',
3128 'description' : 'The time of expiry of this comment as a UNIX timestamp',
3129 'prop' : None,
3130 'type' : 'int',
3132 'expires' : {
3133 'default' : None,
3134 'depythonize' : from_bool_to_int,
3135 'description' : 'Whether this comment expires',
3136 'prop' : None,
3137 'type' : 'int',
3139 'host_accept_passive_checks' : {
3140 'default' : None,
3141 'description' : 'Wether passive host checks are accepted (0/1)',
3142 'prop' : None,
3143 'type' : 'int',
3145 'host_acknowledged' : {
3146 'default' : None,
3147 'description' : 'Wether the current host problem has been acknowledged (0/1)',
3148 'prop' : None,
3149 'type' : 'int',
3151 'host_acknowledgement_type' : {
3152 'default' : None,
3153 'description' : 'Type of acknowledgement (0: none, 1: normal, 2: stick)',
3154 'prop' : None,
3155 'type' : 'int',
3157 'host_action_url' : {
3158 'default' : None,
3159 'description' : 'An optional URL to custom actions or information about this host',
3160 'prop' : None,
3161 'type' : 'string',
3163 'host_action_url_expanded' : {
3164 'default' : None,
3165 'description' : 'The same as action_url, but with the most important macros expanded',
3166 'prop' : None,
3167 'type' : 'string',
3169 'host_active_checks_enabled' : {
3170 'default' : None,
3171 'description' : 'Wether active checks are enabled for the host (0/1)',
3172 'prop' : None,
3173 'type' : 'int',
3175 'host_address' : {
3176 'default' : None,
3177 'description' : 'IP address',
3178 'prop' : None,
3179 'type' : 'string',
3181 'host_alias' : {
3182 'default' : None,
3183 'description' : 'An alias name for the host',
3184 'prop' : None,
3185 'type' : 'string',
3187 'host_check_command' : {
3188 'default' : None,
3189 'description' : 'Nagios command for active host check of this host',
3190 'prop' : None,
3191 'type' : 'string',
3193 'host_check_freshness' : {
3194 'default' : None,
3195 'description' : 'Wether freshness checks are activated (0/1)',
3196 'prop' : None,
3197 'type' : 'int',
3199 'host_check_interval' : {
3200 'default' : None,
3201 'description' : 'Number of basic interval lengths between two scheduled checks of the host',
3202 'prop' : None,
3203 'type' : 'float',
3205 'host_check_options' : {
3206 'default' : None,
3207 'description' : 'The current check option, forced, normal, freshness... (0-2)',
3208 'prop' : None,
3209 'type' : 'int',
3211 'host_check_period' : {
3212 'default' : None,
3213 'description' : 'Time period in which this host will be checked. If empty then the host will always be checked.',
3214 'prop' : None,
3215 'type' : 'string',
3217 'host_check_type' : {
3218 'default' : None,
3219 'description' : 'Type of check (0: active, 1: passive)',
3220 'prop' : None,
3221 'type' : 'int',
3223 'host_checks_enabled' : {
3224 'default' : None,
3225 'description' : 'Wether checks of the host are enabled (0/1)',
3226 'prop' : None,
3227 'type' : 'int',
3229 'host_childs' : {
3230 'default' : None,
3231 'description' : 'A list of all direct childs of the host',
3232 'prop' : None,
3233 'type' : 'list',
3235 'host_comments' : {
3236 'default' : None,
3237 'description' : 'A list of the ids of all comments of this host',
3238 'prop' : None,
3239 'type' : 'list',
3241 'host_contacts' : {
3242 'default' : None,
3243 'description' : 'A list of all contacts of this host, either direct or via a contact group',
3244 'prop' : None,
3245 'type' : 'list',
3247 'host_current_attempt' : {
3248 'default' : None,
3249 'description' : 'Number of the current check attempts',
3250 'prop' : None,
3251 'type' : 'int',
3253 'host_current_notification_number' : {
3254 'default' : None,
3255 'description' : 'Number of the current notification',
3256 'prop' : None,
3257 'type' : 'int',
3259 'host_custom_variable_names' : {
3260 'default' : None,
3261 'description' : 'A list of the names of all custom variables',
3262 'prop' : None,
3263 'type' : 'list',
3265 'host_custom_variable_values' : {
3266 'default' : None,
3267 'description' : 'A list of the values of the custom variables',
3268 'prop' : None,
3269 'type' : 'list',
3271 'host_display_name' : {
3272 'default' : None,
3273 'description' : 'Optional display name of the host - not used by Nagios\' web interface',
3274 'prop' : None,
3275 'type' : 'string',
3277 'host_downtimes' : {
3278 'default' : None,
3279 'description' : 'A list of the ids of all scheduled downtimes of this host',
3280 'prop' : None,
3281 'type' : 'list',
3283 'host_event_handler_enabled' : {
3284 'default' : None,
3285 'description' : 'Wether event handling is enabled (0/1)',
3286 'prop' : None,
3287 'type' : 'int',
3289 'host_execution_time' : {
3290 'default' : None,
3291 'description' : 'Time the host check needed for execution',
3292 'prop' : None,
3293 'type' : 'float',
3295 'host_first_notification_delay' : {
3296 'default' : None,
3297 'description' : 'Delay before the first notification',
3298 'prop' : None,
3299 'type' : 'float',
3301 'host_flap_detection_enabled' : {
3302 'default' : None,
3303 'description' : 'Wether flap detection is enabled (0/1)',
3304 'prop' : None,
3305 'type' : 'int',
3307 'host_groups' : {
3308 'default' : None,
3309 'description' : 'A list of all host groups this host is in',
3310 'prop' : None,
3311 'type' : 'list',
3313 'host_hard_state' : {
3314 'default' : None,
3315 'description' : 'The effective hard state of the host (eliminates a problem in hard_state)',
3316 'prop' : None,
3317 'type' : 'int',
3319 'host_has_been_checked' : {
3320 'default' : None,
3321 'description' : 'Wether the host has already been checked (0/1)',
3322 'prop' : None,
3323 'type' : 'int',
3325 'host_high_flap_threshold' : {
3326 'default' : None,
3327 'description' : 'High threshold of flap detection',
3328 'prop' : None,
3329 'type' : 'float',
3331 'host_icon_image' : {
3332 'default' : None,
3333 'description' : 'The name of an image file to be used in the web pages',
3334 'prop' : None,
3335 'type' : 'string',
3337 'host_icon_image_alt' : {
3338 'default' : None,
3339 'description' : 'Alternative text for the icon_image',
3340 'prop' : None,
3341 'type' : 'string',
3343 'host_icon_image_expanded' : {
3344 'default' : None,
3345 'description' : 'The same as icon_image, but with the most important macros expanded',
3346 'prop' : None,
3347 'type' : 'string',
3349 'host_in_check_period' : {
3350 'default' : None,
3351 'description' : 'Wether this host is currently in its check period (0/1)',
3352 'prop' : None,
3353 'type' : 'int',
3355 'host_in_notification_period' : {
3356 'default' : None,
3357 'description' : 'Wether this host is currently in its notification period (0/1)',
3358 'prop' : None,
3359 'type' : 'int',
3361 'host_initial_state' : {
3362 'default' : None,
3363 'description' : 'Initial host state',
3364 'prop' : None,
3365 'type' : 'int',
3367 'host_is_executing' : {
3368 'default' : 0, # value in scheduler is not real-time
3369 'description' : 'is there a host check currently running... (0/1)',
3370 'prop' : None,
3371 'type' : 'int',
3373 'host_is_flapping' : {
3374 'default' : None,
3375 'description' : 'Wether the host state is flapping (0/1)',
3376 'prop' : None,
3377 'type' : 'int',
3379 'host_last_check' : {
3380 'default' : None,
3381 'description' : 'Time of the last check (Unix timestamp)',
3382 'prop' : None,
3383 'type' : 'int',
3385 'host_last_hard_state' : {
3386 'default' : None,
3387 'description' : 'Last hard state',
3388 'prop' : None,
3389 'type' : 'int',
3391 'host_last_hard_state_change' : {
3392 'default' : None,
3393 'description' : 'Time of the last hard state change (Unix timestamp)',
3394 'prop' : None,
3395 'type' : 'int',
3397 'host_last_notification' : {
3398 'default' : None,
3399 'description' : 'Time of the last notification (Unix timestamp)',
3400 'prop' : None,
3401 'type' : 'int',
3403 'host_last_state' : {
3404 'default' : None,
3405 'description' : 'State before last state change',
3406 'prop' : None,
3407 'type' : 'int',
3409 'host_last_state_change' : {
3410 'default' : None,
3411 'description' : 'Time of the last state change - soft or hard (Unix timestamp)',
3412 'prop' : None,
3413 'type' : 'int',
3415 'host_latency' : {
3416 'default' : None,
3417 'description' : 'Time difference between scheduled check time and actual check time',
3418 'prop' : None,
3419 'type' : 'float',
3421 'host_long_plugin_output' : {
3422 'default' : None,
3423 'description' : 'Complete output from check plugin',
3424 'prop' : None,
3425 'type' : 'string',
3427 'host_low_flap_threshold' : {
3428 'default' : None,
3429 'description' : 'Low threshold of flap detection',
3430 'prop' : None,
3431 'type' : 'float',
3433 'host_max_check_attempts' : {
3434 'default' : None,
3435 'description' : 'Max check attempts for active host checks',
3436 'prop' : None,
3437 'type' : 'int',
3439 'host_name' : {
3440 'default' : None,
3441 'depythonize' : lambda x: x.host_name,
3442 'description' : 'Host name',
3443 'prop' : 'ref',
3444 'type' : 'string',
3446 'host_next_check' : {
3447 'default' : None,
3448 'description' : 'Scheduled time for the next check (Unix timestamp)',
3449 'prop' : None,
3450 'type' : 'int',
3452 'host_next_notification' : {
3453 'default' : None,
3454 'description' : 'Time of the next notification (Unix timestamp)',
3455 'prop' : None,
3456 'type' : 'int',
3458 'host_notes' : {
3459 'default' : None,
3460 'description' : 'Optional notes for this host',
3461 'prop' : None,
3462 'type' : 'string',
3464 'host_notes_expanded' : {
3465 'default' : None,
3466 'description' : 'The same as notes, but with the most important macros expanded',
3467 'prop' : None,
3468 'type' : 'string',
3470 'host_notes_url' : {
3471 'default' : None,
3472 'description' : 'An optional URL with further information about the host',
3473 'prop' : None,
3474 'type' : 'string',
3476 'host_notes_url_expanded' : {
3477 'default' : None,
3478 'description' : 'Same es notes_url, but with the most important macros expanded',
3479 'prop' : None,
3480 'type' : 'string',
3482 'host_notification_interval' : {
3483 'default' : None,
3484 'description' : 'Interval of periodic notification or 0 if its off',
3485 'prop' : None,
3486 'type' : 'float',
3488 'host_notification_period' : {
3489 'default' : None,
3490 'description' : 'Time period in which problems of this host will be notified. If empty then notification will be always',
3491 'prop' : None,
3492 'type' : 'string',
3494 'host_notifications_enabled' : {
3495 'default' : None,
3496 'description' : 'Wether notifications of the host are enabled (0/1)',
3497 'prop' : None,
3498 'type' : 'int',
3500 'host_num_services' : {
3501 'default' : None,
3502 'description' : 'The total number of services of the host',
3503 'prop' : None,
3504 'type' : 'list',
3506 'host_num_services_crit' : {
3507 'default' : None,
3508 'description' : 'The number of the host\'s services with the soft state CRIT',
3509 'prop' : None,
3510 'type' : 'list',
3512 'host_num_services_hard_crit' : {
3513 'default' : None,
3514 'description' : 'The number of the host\'s services with the hard state CRIT',
3515 'prop' : None,
3516 'type' : 'list',
3518 'host_num_services_hard_ok' : {
3519 'default' : None,
3520 'description' : 'The number of the host\'s services with the hard state OK',
3521 'prop' : None,
3522 'type' : 'list',
3524 'host_num_services_hard_unknown' : {
3525 'default' : None,
3526 'description' : 'The number of the host\'s services with the hard state UNKNOWN',
3527 'prop' : None,
3528 'type' : 'list',
3530 'host_num_services_hard_warn' : {
3531 'default' : None,
3532 'description' : 'The number of the host\'s services with the hard state WARN',
3533 'prop' : None,
3534 'type' : 'list',
3536 'host_num_services_ok' : {
3537 'default' : None,
3538 'description' : 'The number of the host\'s services with the soft state OK',
3539 'prop' : None,
3540 'type' : 'list',
3542 'host_num_services_pending' : {
3543 'default' : None,
3544 'description' : 'The number of the host\'s services which have not been checked yet (pending)',
3545 'prop' : None,
3546 'type' : 'list',
3548 'host_num_services_unknown' : {
3549 'default' : None,
3550 'description' : 'The number of the host\'s services with the soft state UNKNOWN',
3551 'prop' : None,
3552 'type' : 'list',
3554 'host_num_services_warn' : {
3555 'default' : None,
3556 'description' : 'The number of the host\'s services with the soft state WARN',
3557 'prop' : None,
3558 'type' : 'list',
3560 'host_obsess_over_host' : {
3561 'default' : None,
3562 'description' : 'The current obsess_over_host setting... (0/1)',
3563 'prop' : None,
3564 'type' : 'int',
3566 'host_parents' : {
3567 'default' : None,
3568 'description' : 'A list of all direct parents of the host',
3569 'prop' : None,
3570 'type' : 'list',
3572 'host_pending_flex_downtime' : {
3573 'default' : None,
3574 'description' : 'Wether a flex downtime is pending (0/1)',
3575 'prop' : None,
3576 'type' : 'int',
3578 'host_percent_state_change' : {
3579 'default' : None,
3580 'description' : 'Percent state change',
3581 'prop' : None,
3582 'type' : 'float',
3584 'host_perf_data' : {
3585 'default' : None,
3586 'description' : 'Optional performance data of the last host check',
3587 'prop' : None,
3588 'type' : 'string',
3590 'host_plugin_output' : {
3591 'default' : None,
3592 'description' : 'Output of the last host check',
3593 'prop' : None,
3594 'type' : 'string',
3596 'host_process_performance_data' : {
3597 'default' : None,
3598 'description' : 'Wether processing of performance data is enabled (0/1)',
3599 'prop' : None,
3600 'type' : 'int',
3602 'host_retry_interval' : {
3603 'default' : None,
3604 'description' : 'Number of basic interval lengths between checks when retrying after a soft error',
3605 'prop' : None,
3606 'type' : 'float',
3608 'host_scheduled_downtime_depth' : {
3609 'default' : None,
3610 'description' : 'The number of downtimes this host is currently in',
3611 'prop' : None,
3612 'type' : 'int',
3614 'host_state' : {
3615 'default' : None,
3616 'description' : 'The current state of the host (0: up, 1: down, 2: unreachable)',
3617 'prop' : None,
3618 'type' : 'int',
3620 'host_state_type' : {
3621 'default' : None,
3622 'description' : 'Type of the current state (0: soft, 1: hard)',
3623 'prop' : None,
3624 'type' : 'int',
3626 'host_statusmap_image' : {
3627 'default' : None,
3628 'description' : 'The name of in image file for the status map',
3629 'prop' : None,
3630 'type' : 'string',
3632 'host_total_services' : {
3633 'default' : None,
3634 'description' : 'The total number of services of the host',
3635 'prop' : None,
3636 'type' : 'int',
3638 'host_worst_service_hard_state' : {
3639 'default' : None,
3640 'description' : 'The worst hard state of all of the host\'s services (OK <= WARN <= UNKNOWN <= CRIT)',
3641 'prop' : None,
3642 'type' : 'list',
3644 'host_worst_service_state' : {
3645 'default' : None,
3646 'description' : 'The worst soft state of all of the host\'s services (OK <= WARN <= UNKNOWN <= CRIT)',
3647 'prop' : None,
3648 'type' : 'list',
3650 'host_x_3d' : {
3651 'default' : None,
3652 'description' : '3D-Coordinates: X',
3653 'prop' : None,
3654 'type' : 'float',
3656 'host_y_3d' : {
3657 'default' : None,
3658 'description' : '3D-Coordinates: Y',
3659 'prop' : None,
3660 'type' : 'float',
3662 'host_z_3d' : {
3663 'default' : None,
3664 'description' : '3D-Coordinates: Z',
3665 'prop' : None,
3666 'type' : 'float',
3668 'id' : {
3669 'default' : None,
3670 'description' : 'The id of the comment',
3671 'prop' : None,
3672 'type' : 'int',
3674 'persistent' : {
3675 'default' : None,
3676 'depythonize' : from_bool_to_int,
3677 'description' : 'Whether this comment is persistent (0/1)',
3678 'prop' : None,
3679 'type' : 'int',
3681 'service_accept_passive_checks' : {
3682 'default' : None,
3683 'description' : 'Wether the service accepts passive checks (0/1)',
3684 'prop' : None,
3685 'type' : 'int',
3687 'service_acknowledged' : {
3688 'default' : None,
3689 'description' : 'Wether the current service problem has been acknowledged (0/1)',
3690 'prop' : None,
3691 'type' : 'int',
3693 'service_acknowledgement_type' : {
3694 'default' : None,
3695 'description' : 'The type of the acknownledgement (0: none, 1: normal, 2: sticky)',
3696 'prop' : None,
3697 'type' : 'int',
3699 'service_action_url' : {
3700 'default' : None,
3701 'description' : 'An optional URL for actions or custom information about the service',
3702 'prop' : None,
3703 'type' : 'string',
3705 'service_action_url_expanded' : {
3706 'default' : None,
3707 'description' : 'The action_url with (the most important) macros expanded',
3708 'prop' : None,
3709 'type' : 'string',
3711 'service_active_checks_enabled' : {
3712 'default' : None,
3713 'description' : 'Wether active checks are enabled for the service (0/1)',
3714 'prop' : None,
3715 'type' : 'int',
3717 'service_check_command' : {
3718 'default' : None,
3719 'description' : 'Nagios command used for active checks',
3720 'prop' : None,
3721 'type' : 'string',
3723 'service_check_interval' : {
3724 'default' : None,
3725 'description' : 'Number of basic interval lengths between two scheduled checks of the service',
3726 'prop' : None,
3727 'type' : 'float',
3729 'service_check_options' : {
3730 'default' : None,
3731 'description' : 'The current check option, forced, normal, freshness... (0/1)',
3732 'prop' : None,
3733 'type' : 'int',
3735 'service_check_period' : {
3736 'default' : None,
3737 'description' : 'The name of the check period of the service. It this is empty, the service is always checked.',
3738 'prop' : None,
3739 'type' : 'string',
3741 'service_check_type' : {
3742 'default' : None,
3743 'description' : 'The type of the last check (0: active, 1: passive)',
3744 'prop' : None,
3745 'type' : 'int',
3747 'service_checks_enabled' : {
3748 'default' : None,
3749 'description' : 'Wether active checks are enabled for the service (0/1)',
3750 'prop' : None,
3751 'type' : 'int',
3753 'service_comments' : {
3754 'default' : None,
3755 'description' : 'A list of all comment ids of the service',
3756 'prop' : None,
3757 'type' : 'list',
3759 'service_contacts' : {
3760 'default' : None,
3761 'description' : 'A list of all contacts of the service, either direct or via a contact group',
3762 'prop' : None,
3763 'type' : 'list',
3765 'service_current_attempt' : {
3766 'default' : None,
3767 'description' : 'The number of the current check attempt',
3768 'prop' : None,
3769 'type' : 'int',
3771 'service_current_notification_number' : {
3772 'default' : None,
3773 'description' : 'The number of the current notification',
3774 'prop' : None,
3775 'type' : 'int',
3777 'service_custom_variable_names' : {
3778 'default' : None,
3779 'description' : 'A list of the names of all custom variables of the service',
3780 'prop' : None,
3781 'type' : 'list',
3783 'service_custom_variable_values' : {
3784 'default' : None,
3785 'description' : 'A list of the values of all custom variable of the service',
3786 'prop' : None,
3787 'type' : 'list',
3789 'service_description' : {
3790 'default' : None,
3791 'depythonize' : lambda x: getattr(x, 'service_description', ''),
3792 'description' : 'Description of the service (also used as key)',
3793 'prop' : 'ref',
3794 'type' : 'string',
3796 'service_display_name' : {
3797 'default' : None,
3798 'description' : 'An optional display name (not used by Nagios standard web pages)',
3799 'prop' : None,
3800 'type' : 'string',
3802 'service_downtimes' : {
3803 'default' : None,
3804 'description' : 'A list of all downtime ids of the service',
3805 'prop' : None,
3806 'type' : 'list',
3808 'service_event_handler' : {
3809 'default' : None,
3810 'description' : 'Nagios command used as event handler',
3811 'prop' : None,
3812 'type' : 'string',
3814 'service_event_handler_enabled' : {
3815 'default' : None,
3816 'description' : 'Wether and event handler is activated for the service (0/1)',
3817 'prop' : None,
3818 'type' : 'int',
3820 'service_execution_time' : {
3821 'default' : None,
3822 'description' : 'Time the host check needed for execution',
3823 'prop' : None,
3824 'type' : 'float',
3826 'service_first_notification_delay' : {
3827 'default' : None,
3828 'description' : 'Delay before the first notification',
3829 'prop' : None,
3830 'type' : 'float',
3832 'service_flap_detection_enabled' : {
3833 'default' : None,
3834 'description' : 'Wether flap detection is enabled for the service (0/1)',
3835 'prop' : None,
3836 'type' : 'int',
3838 'service_groups' : {
3839 'default' : None,
3840 'description' : 'A list of all service groups the service is in',
3841 'prop' : None,
3842 'type' : 'list',
3844 'service_has_been_checked' : {
3845 'default' : None,
3846 'description' : 'Wether the service already has been checked (0/1)',
3847 'prop' : None,
3848 'type' : 'int',
3850 'service_high_flap_threshold' : {
3851 'default' : None,
3852 'description' : 'High threshold of flap detection',
3853 'prop' : None,
3854 'type' : 'float',
3856 'service_icon_image' : {
3857 'default' : None,
3858 'description' : 'The name of an image to be used as icon in the web interface',
3859 'prop' : None,
3860 'type' : 'string',
3862 'service_icon_image_alt' : {
3863 'default' : None,
3864 'description' : 'An alternative text for the icon_image for browsers not displaying icons',
3865 'prop' : None,
3866 'type' : 'string',
3868 'service_icon_image_expanded' : {
3869 'default' : None,
3870 'description' : 'The icon_image with (the most important) macros expanded',
3871 'prop' : None,
3872 'type' : 'string',
3874 'service_in_check_period' : {
3875 'default' : None,
3876 'description' : 'Wether the service is currently in its check period (0/1)',
3877 'prop' : None,
3878 'type' : 'int',
3880 'service_in_notification_period' : {
3881 'default' : None,
3882 'description' : 'Wether the service is currently in its notification period (0/1)',
3883 'prop' : None,
3884 'type' : 'int',
3886 'service_initial_state' : {
3887 'default' : None,
3888 'description' : 'The initial state of the service',
3889 'prop' : None,
3890 'type' : 'int',
3892 'service_is_executing' : {
3893 'default' : 0, # value in scheduler is not real-time
3894 'description' : 'is there a service check currently running... (0/1)',
3895 'prop' : None,
3896 'type' : 'int',
3898 'service_is_flapping' : {
3899 'default' : None,
3900 'description' : 'Wether the service is flapping (0/1)',
3901 'prop' : None,
3902 'type' : 'int',
3904 'service_last_check' : {
3905 'default' : None,
3906 'description' : 'The time of the last check (Unix timestamp)',
3907 'prop' : None,
3908 'type' : 'int',
3910 'service_last_hard_state' : {
3911 'default' : None,
3912 'description' : 'The last hard state of the service',
3913 'prop' : None,
3914 'type' : 'int',
3916 'service_last_hard_state_change' : {
3917 'default' : None,
3918 'description' : 'The time of the last hard state change (Unix timestamp)',
3919 'prop' : None,
3920 'type' : 'int',
3922 'service_last_notification' : {
3923 'default' : None,
3924 'description' : 'The time of the last notification (Unix timestamp)',
3925 'prop' : None,
3926 'type' : 'int',
3928 'service_last_state' : {
3929 'default' : None,
3930 'description' : 'The last state of the service',
3931 'prop' : None,
3932 'type' : 'int',
3934 'service_last_state_change' : {
3935 'default' : None,
3936 'description' : 'The time of the last state change (Unix timestamp)',
3937 'prop' : None,
3938 'type' : 'int',
3940 'service_latency' : {
3941 'default' : None,
3942 'description' : 'Time difference between scheduled check time and actual check time',
3943 'prop' : None,
3944 'type' : 'float',
3946 'service_long_plugin_output' : {
3947 'default' : None,
3948 'description' : 'Unabbreviated output of the last check plugin',
3949 'prop' : None,
3950 'type' : 'string',
3952 'service_low_flap_threshold' : {
3953 'default' : None,
3954 'description' : 'Low threshold of flap detection',
3955 'prop' : None,
3956 'type' : 'float',
3958 'service_max_check_attempts' : {
3959 'default' : None,
3960 'description' : 'The maximum number of check attempts',
3961 'prop' : None,
3962 'type' : 'int',
3964 'service_next_check' : {
3965 'default' : None,
3966 'description' : 'The scheduled time of the next check (Unix timestamp)',
3967 'prop' : None,
3968 'type' : 'int',
3970 'service_next_notification' : {
3971 'default' : None,
3972 'description' : 'The time of the next notification (Unix timestamp)',
3973 'prop' : None,
3974 'type' : 'int',
3976 'service_notes' : {
3977 'default' : None,
3978 'description' : 'Optional notes about the service',
3979 'prop' : None,
3980 'type' : 'string',
3982 'service_notes_expanded' : {
3983 'default' : None,
3984 'description' : 'The notes with (the most important) macros expanded',
3985 'prop' : None,
3986 'type' : 'string',
3988 'service_notes_url' : {
3989 'default' : None,
3990 'description' : 'An optional URL for additional notes about the service',
3991 'prop' : None,
3992 'type' : 'string',
3994 'service_notes_url_expanded' : {
3995 'default' : None,
3996 'description' : 'The notes_url with (the most important) macros expanded',
3997 'prop' : None,
3998 'type' : 'string',
4000 'service_notification_interval' : {
4001 'default' : None,
4002 'description' : 'Interval of periodic notification or 0 if its off',
4003 'prop' : None,
4004 'type' : 'float',
4006 'service_notification_period' : {
4007 'default' : None,
4008 'description' : 'The name of the notification period of the service. It this is empty, service problems are always notified.',
4009 'prop' : None,
4010 'type' : 'string',
4012 'service_notifications_enabled' : {
4013 'default' : None,
4014 'description' : 'Wether notifications are enabled for the service (0/1)',
4015 'prop' : None,
4016 'type' : 'int',
4018 'service_obsess_over_service' : {
4019 'default' : None,
4020 'description' : 'Wether \'obsess_over_service\' is enabled for the service (0/1)',
4021 'prop' : None,
4022 'type' : 'int',
4024 'service_percent_state_change' : {
4025 'default' : None,
4026 'description' : 'Percent state change',
4027 'prop' : None,
4028 'type' : 'float',
4030 'service_perf_data' : {
4031 'default' : None,
4032 'description' : 'Performance data of the last check plugin',
4033 'prop' : None,
4034 'type' : 'string',
4036 'service_plugin_output' : {
4037 'default' : None,
4038 'description' : 'Output of the last check plugin',
4039 'prop' : None,
4040 'type' : 'string',
4042 'service_process_performance_data' : {
4043 'default' : None,
4044 'description' : 'Wether processing of performance data is enabled for the service (0/1)',
4045 'prop' : None,
4046 'type' : 'int',
4048 'service_retry_interval' : {
4049 'default' : None,
4050 'description' : 'Number of basic interval lengths between checks when retrying after a soft error',
4051 'prop' : None,
4052 'type' : 'float',
4054 'service_scheduled_downtime_depth' : {
4055 'default' : None,
4056 'description' : 'The number of scheduled downtimes the service is currently in',
4057 'prop' : None,
4058 'type' : 'int',
4060 'service_state' : {
4061 'default' : None,
4062 'description' : 'The current state of the service (0: OK, 1: WARN, 2: CRITICAL, 3: UNKNOWN)',
4063 'prop' : None,
4064 'type' : 'int',
4066 'service_state_type' : {
4067 'default' : None,
4068 'description' : 'The type of the current state (0: soft, 1: hard)',
4069 'prop' : None,
4070 'type' : 'int',
4072 'source' : {
4073 'default' : '0',
4074 'description' : 'The source of the comment (0 is internal and 1 is external)',
4075 'prop' : None,
4076 'type' : 'int',
4078 'type' : {
4079 'default' : '1',
4080 'description' : 'The type of the comment: 1 is service, 2 is host',
4081 'prop' : 'comment_type',
4082 'type' : 'int',
4086 # loop over hostgroups then over members
4087 'Hostsbygroup' : {
4088 'hostgroup_action_url' : {
4089 'description' : 'An optional URL to custom actions or information about the hostgroup',
4090 'prop' : 'hostgroup',
4091 'type' : 'string',
4093 'hostgroup_alias' : {
4094 'depythonize' : lambda x: getattr(x, 'hostgroup_alias', ''),
4095 'description' : 'An alias of the hostgroup',
4096 'prop' : 'hostgroup',
4097 'type' : 'string',
4099 'hostgroup_members' : {
4100 'description' : 'A list of all host names that are members of the hostgroup',
4101 'prop' : 'hostgroup',
4102 'type' : 'list',
4104 'hostgroup_members_with_state' : {
4105 'description' : 'A list of all host names that are members of the hostgroup together with state and has_been_checked',
4106 'prop' : 'hostgroup',
4107 'type' : 'list',
4109 'hostgroup_name' : {
4110 'depythonize' : lambda x: getattr(x, 'hostgroup_name', ''),
4111 'description' : 'Name of the hostgroup',
4112 'prop' : 'hostgroup',
4113 'type' : 'string',
4115 'hostgroup_notes' : {
4116 'description' : 'Optional notes to the hostgroup',
4117 'prop' : 'hostgroup',
4118 'type' : 'string',
4120 'hostgroup_notes_url' : {
4121 'description' : 'An optional URL with further information about the hostgroup',
4122 'prop' : 'hostgroup',
4123 'type' : 'string',
4125 'hostgroup_num_hosts' : {
4126 'description' : 'The total number of hosts in the group',
4127 'prop' : 'hostgroup',
4128 'type' : 'int',
4130 'hostgroup_num_hosts_down' : {
4131 'description' : 'The number of hosts in the group that are down',
4132 'prop' : 'hostgroup',
4133 'type' : 'int',
4135 'hostgroup_num_hosts_pending' : {
4136 'description' : 'The number of hosts in the group that are pending',
4137 'prop' : 'hostgroup',
4138 'type' : 'int',
4140 'hostgroup_num_hosts_unreach' : {
4141 'description' : 'The number of hosts in the group that are unreachable',
4142 'prop' : 'hostgroup',
4143 'type' : 'int',
4145 'hostgroup_num_hosts_up' : {
4146 'description' : 'The number of hosts in the group that are up',
4147 'prop' : 'hostgroup',
4148 'type' : 'int',
4150 'hostgroup_num_services' : {
4151 'description' : 'The total number of services of hosts in this group',
4152 'prop' : 'hostgroup',
4153 'type' : 'int',
4155 'hostgroup_num_services_crit' : {
4156 'description' : 'The total number of services with the state CRIT of hosts in this group',
4157 'prop' : 'hostgroup',
4158 'type' : 'int',
4160 'hostgroup_num_services_hard_crit' : {
4161 'description' : 'The total number of services with the state CRIT of hosts in this group',
4162 'prop' : 'hostgroup',
4163 'type' : 'int',
4165 'hostgroup_num_services_hard_ok' : {
4166 'description' : 'The total number of services with the state OK of hosts in this group',
4167 'prop' : 'hostgroup',
4168 'type' : 'int',
4170 'hostgroup_num_services_hard_unknown' : {
4171 'description' : 'The total number of services with the state UNKNOWN of hosts in this group',
4172 'prop' : 'hostgroup',
4173 'type' : 'int',
4175 'hostgroup_num_services_hard_warn' : {
4176 'description' : 'The total number of services with the state WARN of hosts in this group',
4177 'prop' : 'hostgroup',
4178 'type' : 'int',
4180 'hostgroup_num_services_ok' : {
4181 'description' : 'The total number of services with the state OK of hosts in this group',
4182 'prop' : 'hostgroup',
4183 'type' : 'int',
4185 'hostgroup_num_services_pending' : {
4186 'description' : 'The total number of services with the state Pending of hosts in this group',
4187 'prop' : 'hostgroup',
4188 'type' : 'int',
4190 'hostgroup_num_services_unknown' : {
4191 'description' : 'The total number of services with the state UNKNOWN of hosts in this group',
4192 'prop' : 'hostgroup',
4193 'type' : 'int',
4195 'hostgroup_num_services_warn' : {
4196 'description' : 'The total number of services with the state WARN of hosts in this group',
4197 'prop' : 'hostgroup',
4198 'type' : 'int',
4200 'hostgroup_worst_host_state' : {
4201 'description' : 'The worst state of all of the groups\' hosts (UP <= UNREACHABLE <= DOWN)',
4202 'prop' : 'hostgroup',
4203 'type' : 'int',
4205 'hostgroup_worst_service_hard_state' : {
4206 'description' : 'The worst state of all services that belong to a host of this group (OK <= WARN <= UNKNOWN <= CRIT)',
4207 'prop' : 'hostgroup',
4208 'type' : 'int',
4210 'hostgroup_worst_service_state' : {
4211 'description' : 'The worst state of all services that belong to a host of this group (OK <= WARN <= UNKNOWN <= CRIT)',
4212 'prop' : 'hostgroup',
4213 'type' : 'int',
4217 'Servicesbygroup' : {
4218 'servicegroup_action_url' : {
4219 'description' : 'An optional URL to custom notes or actions on the service group',
4220 'type' : 'string',
4222 'servicegroup_alias' : {
4223 'description' : 'An alias of the service group',
4224 'type' : 'string',
4226 'servicegroup_members' : {
4227 'description' : 'A list of all members of the service group as host/service pairs',
4228 'type' : 'list',
4230 'servicegroup_members_with_state' : {
4231 'description' : 'A list of all members of the service group with state and has_been_checked',
4232 'type' : 'list',
4234 'servicegroup_name' : {
4235 'description' : 'The name of the service group',
4236 'type' : 'string',
4238 'servicegroup_notes' : {
4239 'description' : 'Optional additional notes about the service group',
4240 'type' : 'string',
4242 'servicegroup_notes_url' : {
4243 'description' : 'An optional URL to further notes on the service group',
4244 'type' : 'string',
4246 'servicegroup_num_services' : {
4247 'description' : 'The total number of services in the group',
4248 'type' : 'int',
4250 'servicegroup_num_services_crit' : {
4251 'description' : 'The number of services in the group that are CRIT',
4252 'type' : 'int',
4254 'servicegroup_num_services_hard_crit' : {
4255 'description' : 'The number of services in the group that are CRIT',
4256 'type' : 'int',
4258 'servicegroup_num_services_hard_ok' : {
4259 'description' : 'The number of services in the group that are OK',
4260 'type' : 'int',
4262 'servicegroup_num_services_hard_unknown' : {
4263 'description' : 'The number of services in the group that are UNKNOWN',
4264 'type' : 'int',
4266 'servicegroup_num_services_hard_warn' : {
4267 'description' : 'The number of services in the group that are WARN',
4268 'type' : 'int',
4270 'servicegroup_num_services_ok' : {
4271 'description' : 'The number of services in the group that are OK',
4272 'type' : 'int',
4274 'servicegroup_num_services_pending' : {
4275 'description' : 'The number of services in the group that are PENDING',
4276 'type' : 'int',
4278 'servicegroup_num_services_unknown' : {
4279 'description' : 'The number of services in the group that are UNKNOWN',
4280 'type' : 'int',
4282 'servicegroup_num_services_warn' : {
4283 'description' : 'The number of services in the group that are WARN',
4284 'type' : 'int',
4286 'servicegroup_worst_service_state' : {
4287 'description' : 'The worst soft state of all of the groups services (OK <= WARN <= UNKNOWN <= CRIT)',
4288 'type' : 'int',
4292 'Servicesbyhostgroup' : {
4293 'hostgroup_action_url' : {
4294 'description' : 'An optional URL to custom actions or information about the hostgroup',
4295 'type' : 'string',
4297 'hostgroup_alias' : {
4298 'description' : 'An alias of the hostgroup',
4299 'type' : 'string',
4301 'hostgroup_members' : {
4302 'description' : 'A list of all host names that are members of the hostgroup',
4303 'type' : 'list',
4305 'hostgroup_members_with_state' : {
4306 'description' : 'A list of all host names that are members of the hostgroup together with state and has_been_checked',
4307 'type' : 'list',
4309 'hostgroup_name' : {
4310 'depythonize' : lambda x: getattr(x, 'hostgroup_name', ''),
4311 'description' : 'Name of the hostgroup',
4312 'prop' : 'hostgroup',
4313 'type' : 'string',
4315 'hostgroup_notes' : {
4316 'description' : 'Optional notes to the hostgroup',
4317 'type' : 'string',
4319 'hostgroup_notes_url' : {
4320 'description' : 'An optional URL with further information about the hostgroup',
4321 'type' : 'string',
4323 'hostgroup_num_hosts' : {
4324 'description' : 'The total number of hosts in the group',
4325 'type' : 'int',
4327 'hostgroup_num_hosts_down' : {
4328 'description' : 'The number of hosts in the group that are down',
4329 'type' : 'int',
4331 'hostgroup_num_hosts_pending' : {
4332 'description' : 'The number of hosts in the group that are pending',
4333 'type' : 'int',
4335 'hostgroup_num_hosts_unreach' : {
4336 'description' : 'The number of hosts in the group that are unreachable',
4337 'type' : 'int',
4339 'hostgroup_num_hosts_up' : {
4340 'description' : 'The number of hosts in the group that are up',
4341 'type' : 'int',
4343 'hostgroup_num_services' : {
4344 'description' : 'The total number of services of hosts in this group',
4345 'type' : 'int',
4347 'hostgroup_num_services_crit' : {
4348 'description' : 'The total number of services with the state CRIT of hosts in this group',
4349 'type' : 'int',
4351 'hostgroup_num_services_hard_crit' : {
4352 'description' : 'The total number of services with the state CRIT of hosts in this group',
4353 'type' : 'int',
4355 'hostgroup_num_services_hard_ok' : {
4356 'description' : 'The total number of services with the state OK of hosts in this group',
4357 'type' : 'int',
4359 'hostgroup_num_services_hard_unknown' : {
4360 'description' : 'The total number of services with the state UNKNOWN of hosts in this group',
4361 'type' : 'int',
4363 'hostgroup_num_services_hard_warn' : {
4364 'description' : 'The total number of services with the state WARN of hosts in this group',
4365 'type' : 'int',
4367 'hostgroup_num_services_ok' : {
4368 'description' : 'The total number of services with the state OK of hosts in this group',
4369 'type' : 'int',
4371 'hostgroup_num_services_pending' : {
4372 'description' : 'The total number of services with the state Pending of hosts in this group',
4373 'type' : 'int',
4375 'hostgroup_num_services_unknown' : {
4376 'description' : 'The total number of services with the state UNKNOWN of hosts in this group',
4377 'type' : 'int',
4379 'hostgroup_num_services_warn' : {
4380 'description' : 'The total number of services with the state WARN of hosts in this group',
4381 'type' : 'int',
4383 'hostgroup_worst_host_state' : {
4384 'description' : 'The worst state of all of the groups\' hosts (UP <= UNREACHABLE <= DOWN)',
4385 'type' : 'int',
4387 'hostgroup_worst_service_hard_state' : {
4388 'description' : 'The worst state of all services that belong to a host of this group (OK <= WARN <= UNKNOWN <= CRIT)',
4389 'type' : 'int',
4391 'hostgroup_worst_service_state' : {
4392 'description' : 'The worst state of all services that belong to a host of this group (OK <= WARN <= UNKNOWN <= CRIT)',
4393 'type' : 'int',
4397 #All the global config parameters
4399 'Config' : {
4400 'accept_passive_host_checks' : {
4401 'default' : '0',
4402 'depythonize' : from_bool_to_int,
4403 'description' : 'Whether passive host checks are accepted in general (0/1)',
4404 'prop' : 'passive_host_checks_enabled',
4405 'type' : 'int',
4407 'accept_passive_service_checks' : {
4408 'default' : '0',
4409 'depythonize' : from_bool_to_int,
4410 'description' : 'Whether passive service checks are activated in general (0/1)',
4411 'prop' : 'passive_service_checks_enabled',
4412 'type' : 'int',
4414 'cached_log_messages' : {
4415 'default' : '0',
4416 'description' : 'The current number of log messages MK Livestatus keeps in memory',
4417 'prop' : None,
4418 'type' : 'int',
4420 'check_external_commands' : {
4421 'default' : '0',
4422 'depythonize' : from_bool_to_int,
4423 'description' : 'Whether Nagios checks for external commands at its command pipe (0/1)',
4424 'prop' : None,
4425 'type' : 'int',
4427 'check_host_freshness' : {
4428 'default' : '0',
4429 'depythonize' : from_bool_to_int,
4430 'description' : 'Whether host freshness checking is activated in general (0/1)',
4431 'prop' : None,
4432 'type' : 'int',
4434 'check_service_freshness' : {
4435 'default' : '0',
4436 'depythonize' : from_bool_to_int,
4437 'description' : 'Whether service freshness checking is activated in general (0/1)',
4438 'prop' : None,
4439 'type' : 'int',
4441 'connections' : {
4442 'default' : '0',
4443 'description' : 'The number of client connections to Livestatus since program start',
4444 'prop' : None,
4445 'type' : 'int',
4447 'connections_rate' : {
4448 'default' : '0',
4449 'description' : 'The averaged number of new client connections to Livestatus per second',
4450 'prop' : None,
4451 'type' : 'float',
4453 'enable_event_handlers' : {
4454 'default' : '0',
4455 'depythonize' : from_bool_to_int,
4456 'description' : 'Whether event handlers are activated in general (0/1)',
4457 'prop' : 'event_handlers_enabled',
4458 'type' : 'int',
4460 'enable_flap_detection' : {
4461 'default' : '0',
4462 'depythonize' : from_bool_to_int,
4463 'description' : 'Whether flap detection is activated in general (0/1)',
4464 'prop' : 'flap_detection_enabled',
4465 'type' : 'int',
4467 'enable_notifications' : {
4468 'default' : '0',
4469 'depythonize' : from_bool_to_int,
4470 'description' : 'Whether notifications are enabled in general (0/1)',
4471 'prop' : 'notifications_enabled',
4472 'type' : 'int',
4474 'execute_host_checks' : {
4475 'default' : '1',
4476 'depythonize' : from_bool_to_int,
4477 'description' : 'Whether host checks are executed in general (0/1)',
4478 'prop' : 'active_host_checks_enabled',
4479 'type' : 'int',
4481 'execute_service_checks' : {
4482 'default' : '1',
4483 'depythonize' : from_bool_to_int,
4484 'description' : 'Whether active service checks are activated in general (0/1)',
4485 'prop' : 'active_service_checks_enabled',
4486 'type' : 'int',
4488 'host_checks' : {
4489 'default' : '0',
4490 'description' : 'The number of host checks since program start',
4491 'prop' : None,
4492 'type' : 'int',
4494 'host_checks_rate' : {
4495 'default' : '0',
4496 'description' : 'the averaged number of host checks per second',
4497 'prop' : None,
4498 'type' : 'float',
4500 'interval_length' : {
4501 'default' : '0',
4502 'description' : 'The default interval length from nagios.cfg',
4503 'prop' : None,
4504 'type' : 'int',
4506 'last_command_check' : {
4507 'default' : '0',
4508 'description' : 'The time of the last check for a command as UNIX timestamp',
4509 'prop' : None,
4510 'type' : 'int',
4512 'last_log_rotation' : {
4513 'default' : '0',
4514 'description' : 'Time time of the last log file rotation',
4515 'prop' : None,
4516 'type' : 'int',
4518 'livestatus_version' : {
4519 'default' : '1.1.3-shinken',
4520 'description' : 'The version of the MK Livestatus module',
4521 'prop' : None,
4522 'type' : 'string',
4524 'nagios_pid' : {
4525 'default' : '0',
4526 'description' : 'The process ID of the Nagios main process',
4527 'prop' : 'pid',
4528 'type' : 'int',
4530 'neb_callbacks' : {
4531 'default' : '0',
4532 'description' : 'The number of NEB call backs since program start',
4533 'prop' : None,
4534 'type' : 'int',
4536 'neb_callbacks_rate' : {
4537 'default' : '0',
4538 'description' : 'The averaged number of NEB call backs per second',
4539 'prop' : None,
4540 'type' : 'float',
4542 'obsess_over_hosts' : {
4543 'default' : '0',
4544 'depythonize' : from_bool_to_int,
4545 'description' : 'Whether Nagios will obsess over host checks (0/1)',
4546 'prop' : None,
4547 'type' : 'int',
4549 'obsess_over_services' : {
4550 'default' : '0',
4551 'depythonize' : from_bool_to_int,
4552 'description' : 'Whether Nagios will obsess over service checks and run the ocsp_command (0/1)',
4553 'prop' : None,
4554 'type' : 'int',
4556 'process_performance_data' : {
4557 'default' : '0',
4558 'depythonize' : from_bool_to_int,
4559 'description' : 'Whether processing of performance data is activated in general (0/1)',
4560 'prop' : None,
4561 'type' : 'int',
4563 'program_start' : {
4564 'default' : '0',
4565 'description' : 'The time of the last program start as UNIX timestamp',
4566 'prop' : None,
4567 'type' : 'int',
4569 'program_version' : {
4570 'default' : '0.1',
4571 'description' : 'The version of the monitoring daemon',
4572 'prop' : None,
4573 'type' : 'string',
4575 'requests' : {
4576 'default' : '0',
4577 'description' : 'The number of requests to Livestatus since program start',
4578 'prop' : None,
4579 'type' : 'int',
4581 'requests_rate' : {
4582 'default' : '0',
4583 'description' : 'The averaged number of request to Livestatus per second',
4584 'prop' : None,
4585 'type' : 'float',
4587 'service_checks' : {
4588 'default' : '0',
4589 'description' : 'The number of completed service checks since program start',
4590 'prop' : None,
4591 'type' : 'int',
4593 'service_checks_rate' : {
4594 'default' : '0',
4595 'description' : 'The averaged number of service checks per second',
4596 'prop' : None,
4597 'type' : 'float',
4601 'Logline' : {
4602 'attempt' : {
4603 'description' : 'The number of the check attempt',
4604 'type' : 'int',
4606 'class' : {
4607 'description' : 'The class of the message as integer (0:info, 1:state, 2:program, 3:notification, 4:passive, 5:command)',
4608 'type' : 'int',
4610 'command_name' : {
4611 'description' : 'The name of the command of the log entry (e.g. for notifications)',
4612 'type' : 'string',
4614 'comment' : {
4615 'description' : 'A comment field used in various message types',
4616 'type' : 'string',
4618 'contact_name' : {
4619 'description' : 'The name of the contact the log entry is about (might be empty)',
4620 'type' : 'string',
4622 'current_command_line' : {
4623 'description' : 'The shell command line',
4624 'type' : 'string',
4626 'current_command_name' : {
4627 'description' : 'The name of the command',
4628 'type' : 'string',
4630 'current_contact_address1' : {
4631 'description' : 'The additional field address1',
4632 'type' : 'string',
4634 'current_contact_address2' : {
4635 'description' : 'The additional field address2',
4636 'type' : 'string',
4638 'current_contact_address3' : {
4639 'description' : 'The additional field address3',
4640 'type' : 'string',
4642 'current_contact_address4' : {
4643 'description' : 'The additional field address4',
4644 'type' : 'string',
4646 'current_contact_address5' : {
4647 'description' : 'The additional field address5',
4648 'type' : 'string',
4650 'current_contact_address6' : {
4651 'description' : 'The additional field address6',
4652 'type' : 'string',
4654 'current_contact_alias' : {
4655 'description' : 'The full name of the contact',
4656 'type' : 'string',
4658 'current_contact_can_submit_commands' : {
4659 'description' : 'Wether the contact is allowed to submit commands (0/1)',
4660 'type' : 'int',
4662 'current_contact_custom_variable_names' : {
4663 'description' : 'A list of all custom variables of the contact',
4664 'type' : 'list',
4666 'current_contact_custom_variable_values' : {
4667 'description' : 'A list of the values of all custom variables of the contact',
4668 'type' : 'list',
4670 'current_contact_email' : {
4671 'description' : 'The email address of the contact',
4672 'type' : 'string',
4674 'current_contact_host_notification_period' : {
4675 'description' : 'The time period in which the contact will be notified about host problems',
4676 'type' : 'string',
4678 'current_contact_host_notifications_enabled' : {
4679 'description' : 'Wether the contact will be notified about host problems in general (0/1)',
4680 'type' : 'int',
4682 'current_contact_in_host_notification_period' : {
4683 'description' : 'Wether the contact is currently in his/her host notification period (0/1)',
4684 'type' : 'int',
4686 'current_contact_in_service_notification_period' : {
4687 'description' : 'Wether the contact is currently in his/her service notification period (0/1)',
4688 'type' : 'int',
4690 'current_contact_name' : {
4691 'description' : 'The login name of the contact person',
4692 'type' : 'string',
4694 'current_contact_pager' : {
4695 'description' : 'The pager address of the contact',
4696 'type' : 'string',
4698 'current_contact_service_notification_period' : {
4699 'description' : 'The time period in which the contact will be notified about service problems',
4700 'type' : 'string',
4702 'current_contact_service_notifications_enabled' : {
4703 'description' : 'Wether the contact will be notified about service problems in general (0/1)',
4704 'type' : 'int',
4706 'current_host_accept_passive_checks' : {
4707 'description' : 'Wether passive host checks are accepted (0/1)',
4708 'type' : 'int',
4710 'current_host_acknowledged' : {
4711 'description' : 'Wether the current host problem has been acknowledged (0/1)',
4712 'type' : 'int',
4714 'current_host_acknowledgement_type' : {
4715 'description' : 'Type of acknowledgement (0: none, 1: normal, 2: stick)',
4716 'type' : 'int',
4718 'current_host_action_url' : {
4719 'description' : 'An optional URL to custom actions or information about this host',
4720 'type' : 'string',
4722 'current_host_action_url_expanded' : {
4723 'description' : 'The same as action_url, but with the most important macros expanded',
4724 'type' : 'string',
4726 'current_host_active_checks_enabled' : {
4727 'description' : 'Wether active checks are enabled for the host (0/1)',
4728 'type' : 'int',
4730 'current_host_address' : {
4731 'description' : 'IP address',
4732 'type' : 'string',
4734 'current_host_alias' : {
4735 'description' : 'An alias name for the host',
4736 'type' : 'string',
4738 'current_host_check_command' : {
4739 'description' : 'Nagios command for active host check of this host',
4740 'type' : 'string',
4742 'current_host_check_freshness' : {
4743 'description' : 'Wether freshness checks are activated (0/1)',
4744 'type' : 'int',
4746 'current_host_check_interval' : {
4747 'description' : 'Number of basic interval lengths between two scheduled checks of the host',
4748 'type' : 'float',
4750 'current_host_check_options' : {
4751 'description' : 'The current check option, forced, normal, freshness... (0-2)',
4752 'type' : 'int',
4754 'current_host_check_period' : {
4755 'description' : 'Time period in which this host will be checked. If empty then the host will always be checked.',
4756 'type' : 'string',
4758 'current_host_check_type' : {
4759 'description' : 'Type of check (0: active, 1: passive)',
4760 'type' : 'int',
4762 'current_host_checks_enabled' : {
4763 'description' : 'Wether checks of the host are enabled (0/1)',
4764 'type' : 'int',
4766 'current_host_childs' : {
4767 'description' : 'A list of all direct childs of the host',
4768 'type' : 'list',
4770 'current_host_comments' : {
4771 'description' : 'A list of the ids of all comments of this host',
4772 'type' : 'list',
4774 'current_host_contacts' : {
4775 'description' : 'A list of all contacts of this host, either direct or via a contact group',
4776 'type' : 'list',
4778 'current_host_current_attempt' : {
4779 'description' : 'Number of the current check attempts',
4780 'type' : 'int',
4782 'current_host_current_notification_number' : {
4783 'description' : 'Number of the current notification',
4784 'type' : 'int',
4786 'current_host_custom_variable_names' : {
4787 'description' : 'A list of the names of all custom variables',
4788 'type' : 'list',
4790 'current_host_custom_variable_values' : {
4791 'description' : 'A list of the values of the custom variables',
4792 'type' : 'list',
4794 'current_host_display_name' : {
4795 'description' : 'Optional display name of the host - not used by Nagios\' web interface',
4796 'type' : 'string',
4798 'current_host_downtimes' : {
4799 'description' : 'A list of the ids of all scheduled downtimes of this host',
4800 'type' : 'list',
4802 'current_host_event_handler_enabled' : {
4803 'description' : 'Wether event handling is enabled (0/1)',
4804 'type' : 'int',
4806 'current_host_execution_time' : {
4807 'description' : 'Time the host check needed for execution',
4808 'type' : 'float',
4810 'current_host_first_notification_delay' : {
4811 'description' : 'Delay before the first notification',
4812 'type' : 'float',
4814 'current_host_flap_detection_enabled' : {
4815 'description' : 'Wether flap detection is enabled (0/1)',
4816 'type' : 'int',
4818 'current_host_groups' : {
4819 'description' : 'A list of all host groups this host is in',
4820 'type' : 'list',
4822 'current_host_hard_state' : {
4823 'description' : 'The effective hard state of the host (eliminates a problem in hard_state)',
4824 'type' : 'int',
4826 'current_host_has_been_checked' : {
4827 'description' : 'Wether the host has already been checked (0/1)',
4828 'type' : 'int',
4830 'current_host_high_flap_threshold' : {
4831 'description' : 'High threshold of flap detection',
4832 'type' : 'float',
4834 'current_host_icon_image' : {
4835 'description' : 'The name of an image file to be used in the web pages',
4836 'type' : 'string',
4838 'current_host_icon_image_alt' : {
4839 'description' : 'Alternative text for the icon_image',
4840 'type' : 'string',
4842 'current_host_icon_image_expanded' : {
4843 'description' : 'The same as icon_image, but with the most important macros expanded',
4844 'type' : 'string',
4846 'current_host_in_check_period' : {
4847 'description' : 'Wether this host is currently in its check period (0/1)',
4848 'type' : 'int',
4850 'current_host_in_notification_period' : {
4851 'description' : 'Wether this host is currently in its notification period (0/1)',
4852 'type' : 'int',
4854 'current_host_initial_state' : {
4855 'description' : 'Initial host state',
4856 'type' : 'int',
4858 'current_host_is_executing' : {
4859 'default' : 0, # value in scheduler is not real-time
4860 'description' : 'is there a host check currently running... (0/1)',
4861 'type' : 'int',
4863 'current_host_is_flapping' : {
4864 'description' : 'Wether the host state is flapping (0/1)',
4865 'type' : 'int',
4867 'current_host_last_check' : {
4868 'description' : 'Time of the last check (Unix timestamp)',
4869 'type' : 'int',
4871 'current_host_last_hard_state' : {
4872 'description' : 'Last hard state',
4873 'type' : 'int',
4875 'current_host_last_hard_state_change' : {
4876 'description' : 'Time of the last hard state change (Unix timestamp)',
4877 'type' : 'int',
4879 'current_host_last_notification' : {
4880 'description' : 'Time of the last notification (Unix timestamp)',
4881 'type' : 'int',
4883 'current_host_last_state' : {
4884 'description' : 'State before last state change',
4885 'type' : 'int',
4887 'current_host_last_state_change' : {
4888 'description' : 'Time of the last state change - soft or hard (Unix timestamp)',
4889 'type' : 'int',
4891 'current_host_latency' : {
4892 'description' : 'Time difference between scheduled check time and actual check time',
4893 'type' : 'float',
4895 'current_host_long_plugin_output' : {
4896 'description' : 'Complete output from check plugin',
4897 'type' : 'string',
4899 'current_host_low_flap_threshold' : {
4900 'description' : 'Low threshold of flap detection',
4901 'type' : 'float',
4903 'current_host_max_check_attempts' : {
4904 'description' : 'Max check attempts for active host checks',
4905 'type' : 'int',
4907 'current_host_name' : {
4908 'default' : '',
4909 'depythonize' : lambda x: x.get_name(),
4910 'description' : 'Host name',
4911 'prop' : 'log_host',
4912 'type' : 'string',
4914 'current_host_next_check' : {
4915 'description' : 'Scheduled time for the next check (Unix timestamp)',
4916 'type' : 'int',
4918 'current_host_next_notification' : {
4919 'description' : 'Time of the next notification (Unix timestamp)',
4920 'type' : 'int',
4922 'current_host_notes' : {
4923 'description' : 'Optional notes for this host',
4924 'type' : 'string',
4926 'current_host_notes_expanded' : {
4927 'description' : 'The same as notes, but with the most important macros expanded',
4928 'type' : 'string',
4930 'current_host_notes_url' : {
4931 'description' : 'An optional URL with further information about the host',
4932 'type' : 'string',
4934 'current_host_notes_url_expanded' : {
4935 'description' : 'Same es notes_url, but with the most important macros expanded',
4936 'type' : 'string',
4938 'current_host_notification_interval' : {
4939 'description' : 'Interval of periodic notification or 0 if its off',
4940 'type' : 'float',
4942 'current_host_notification_period' : {
4943 'description' : 'Time period in which problems of this host will be notified. If empty then notification will be always',
4944 'type' : 'string',
4946 'current_host_notifications_enabled' : {
4947 'description' : 'Wether notifications of the host are enabled (0/1)',
4948 'type' : 'int',
4950 'current_host_num_services' : {
4951 'description' : 'The total number of services of the host',
4952 'type' : 'list',
4954 'current_host_num_services_crit' : {
4955 'description' : 'The number of the host\'s services with the soft state CRIT',
4956 'type' : 'list',
4958 'current_host_num_services_hard_crit' : {
4959 'description' : 'The number of the host\'s services with the hard state CRIT',
4960 'type' : 'list',
4962 'current_host_num_services_hard_ok' : {
4963 'description' : 'The number of the host\'s services with the hard state OK',
4964 'type' : 'list',
4966 'current_host_num_services_hard_unknown' : {
4967 'description' : 'The number of the host\'s services with the hard state UNKNOWN',
4968 'type' : 'list',
4970 'current_host_num_services_hard_warn' : {
4971 'description' : 'The number of the host\'s services with the hard state WARN',
4972 'type' : 'list',
4974 'current_host_num_services_ok' : {
4975 'description' : 'The number of the host\'s services with the soft state OK',
4976 'type' : 'list',
4978 'current_host_num_services_pending' : {
4979 'description' : 'The number of the host\'s services which have not been checked yet (pending)',
4980 'type' : 'list',
4982 'current_host_num_services_unknown' : {
4983 'description' : 'The number of the host\'s services with the soft state UNKNOWN',
4984 'type' : 'list',
4986 'current_host_num_services_warn' : {
4987 'description' : 'The number of the host\'s services with the soft state WARN',
4988 'type' : 'list',
4990 'current_host_obsess_over_host' : {
4991 'description' : 'The current obsess_over_host setting... (0/1)',
4992 'type' : 'int',
4994 'current_host_parents' : {
4995 'description' : 'A list of all direct parents of the host',
4996 'type' : 'list',
4998 'current_host_pending_flex_downtime' : {
4999 'description' : 'Wether a flex downtime is pending (0/1)',
5000 'type' : 'int',
5002 'current_host_percent_state_change' : {
5003 'description' : 'Percent state change',
5004 'type' : 'float',
5006 'current_host_perf_data' : {
5007 'description' : 'Optional performance data of the last host check',
5008 'type' : 'string',
5010 'current_host_plugin_output' : {
5011 'description' : 'Output of the last host check',
5012 'type' : 'string',
5014 'current_host_process_performance_data' : {
5015 'description' : 'Wether processing of performance data is enabled (0/1)',
5016 'type' : 'int',
5018 'current_host_retry_interval' : {
5019 'description' : 'Number of basic interval lengths between checks when retrying after a soft error',
5020 'type' : 'float',
5022 'current_host_scheduled_downtime_depth' : {
5023 'description' : 'The number of downtimes this host is currently in',
5024 'type' : 'int',
5026 'current_host_state' : {
5027 'description' : 'The current state of the host (0: up, 1: down, 2: unreachable)',
5028 'type' : 'int',
5030 'current_host_state_type' : {
5031 'description' : 'Type of the current state (0: soft, 1: hard)',
5032 'type' : 'int',
5034 'current_host_statusmap_image' : {
5035 'description' : 'The name of in image file for the status map',
5036 'type' : 'string',
5038 'current_host_total_services' : {
5039 'description' : 'The total number of services of the host',
5040 'type' : 'int',
5042 'current_host_worst_service_hard_state' : {
5043 'description' : 'The worst hard state of all of the host\'s services (OK <= WARN <= UNKNOWN <= CRIT)',
5044 'type' : 'list',
5046 'current_host_worst_service_state' : {
5047 'description' : 'The worst soft state of all of the host\'s services (OK <= WARN <= UNKNOWN <= CRIT)',
5048 'type' : 'list',
5050 'current_host_x_3d' : {
5051 'description' : '3D-Coordinates: X',
5052 'type' : 'float',
5054 'current_host_y_3d' : {
5055 'description' : '3D-Coordinates: Y',
5056 'type' : 'float',
5058 'current_host_z_3d' : {
5059 'description' : '3D-Coordinates: Z',
5060 'type' : 'float',
5062 'current_service_accept_passive_checks' : {
5063 'description' : 'Wether the service accepts passive checks (0/1)',
5064 'type' : 'int',
5066 'current_service_acknowledged' : {
5067 'description' : 'Wether the current service problem has been acknowledged (0/1)',
5068 'type' : 'int',
5070 'current_service_acknowledgement_type' : {
5071 'description' : 'The type of the acknownledgement (0: none, 1: normal, 2: sticky)',
5072 'type' : 'int',
5074 'current_service_action_url' : {
5075 'description' : 'An optional URL for actions or custom information about the service',
5076 'type' : 'string',
5078 'current_service_action_url_expanded' : {
5079 'description' : 'The action_url with (the most important) macros expanded',
5080 'type' : 'string',
5082 'current_service_active_checks_enabled' : {
5083 'description' : 'Wether active checks are enabled for the service (0/1)',
5084 'type' : 'int',
5086 'current_service_check_command' : {
5087 'description' : 'Nagios command used for active checks',
5088 'type' : 'string',
5090 'current_service_check_interval' : {
5091 'description' : 'Number of basic interval lengths between two scheduled checks of the service',
5092 'type' : 'float',
5094 'current_service_check_options' : {
5095 'description' : 'The current check option, forced, normal, freshness... (0/1)',
5096 'type' : 'int',
5098 'current_service_check_period' : {
5099 'description' : 'The name of the check period of the service. It this is empty, the service is always checked.',
5100 'type' : 'string',
5102 'current_service_check_type' : {
5103 'description' : 'The type of the last check (0: active, 1: passive)',
5104 'type' : 'int',
5106 'current_service_checks_enabled' : {
5107 'description' : 'Wether active checks are enabled for the service (0/1)',
5108 'type' : 'int',
5110 'current_service_comments' : {
5111 'description' : 'A list of all comment ids of the service',
5112 'type' : 'list',
5114 'current_service_contacts' : {
5115 'description' : 'A list of all contacts of the service, either direct or via a contact group',
5116 'type' : 'list',
5118 'current_service_current_attempt' : {
5119 'description' : 'The number of the current check attempt',
5120 'type' : 'int',
5122 'current_service_current_notification_number' : {
5123 'description' : 'The number of the current notification',
5124 'type' : 'int',
5126 'current_service_custom_variable_names' : {
5127 'description' : 'A list of the names of all custom variables of the service',
5128 'type' : 'list',
5130 'current_service_custom_variable_values' : {
5131 'description' : 'A list of the values of all custom variable of the service',
5132 'type' : 'list',
5134 'current_service_description' : {
5135 'default' : '',
5136 'depythonize' : lambda x: x.get_name(),
5137 'description' : 'Description of the service (also used as key)',
5138 'prop' : 'log_service',
5139 'type' : 'string',
5141 'current_service_display_name' : {
5142 'description' : 'An optional display name (not used by Nagios standard web pages)',
5143 'type' : 'string',
5145 'current_service_downtimes' : {
5146 'description' : 'A list of all downtime ids of the service',
5147 'type' : 'list',
5149 'current_service_event_handler' : {
5150 'description' : 'Nagios command used as event handler',
5151 'type' : 'string',
5153 'current_service_event_handler_enabled' : {
5154 'description' : 'Wether and event handler is activated for the service (0/1)',
5155 'type' : 'int',
5157 'current_service_execution_time' : {
5158 'description' : 'Time the host check needed for execution',
5159 'type' : 'float',
5161 'current_service_first_notification_delay' : {
5162 'description' : 'Delay before the first notification',
5163 'type' : 'float',
5165 'current_service_flap_detection_enabled' : {
5166 'description' : 'Wether flap detection is enabled for the service (0/1)',
5167 'type' : 'int',
5169 'current_service_groups' : {
5170 'description' : 'A list of all service groups the service is in',
5171 'type' : 'list',
5173 'current_service_has_been_checked' : {
5174 'description' : 'Wether the service already has been checked (0/1)',
5175 'type' : 'int',
5177 'current_service_high_flap_threshold' : {
5178 'description' : 'High threshold of flap detection',
5179 'type' : 'float',
5181 'current_service_icon_image' : {
5182 'description' : 'The name of an image to be used as icon in the web interface',
5183 'type' : 'string',
5185 'current_service_icon_image_alt' : {
5186 'description' : 'An alternative text for the icon_image for browsers not displaying icons',
5187 'type' : 'string',
5189 'current_service_icon_image_expanded' : {
5190 'description' : 'The icon_image with (the most important) macros expanded',
5191 'type' : 'string',
5193 'current_service_in_check_period' : {
5194 'description' : 'Wether the service is currently in its check period (0/1)',
5195 'type' : 'int',
5197 'current_service_in_notification_period' : {
5198 'description' : 'Wether the service is currently in its notification period (0/1)',
5199 'type' : 'int',
5201 'current_service_initial_state' : {
5202 'description' : 'The initial state of the service',
5203 'type' : 'int',
5205 'current_service_is_executing' : {
5206 'default' : 0, # value in scheduler is not real-time
5207 'description' : 'is there a service check currently running... (0/1)',
5208 'type' : 'int',
5210 'current_service_is_flapping' : {
5211 'description' : 'Wether the service is flapping (0/1)',
5212 'type' : 'int',
5214 'current_service_last_check' : {
5215 'description' : 'The time of the last check (Unix timestamp)',
5216 'type' : 'int',
5218 'current_service_last_hard_state' : {
5219 'description' : 'The last hard state of the service',
5220 'type' : 'int',
5222 'current_service_last_hard_state_change' : {
5223 'description' : 'The time of the last hard state change (Unix timestamp)',
5224 'type' : 'int',
5226 'current_service_last_notification' : {
5227 'description' : 'The time of the last notification (Unix timestamp)',
5228 'type' : 'int',
5230 'current_service_last_state' : {
5231 'description' : 'The last state of the service',
5232 'type' : 'int',
5234 'current_service_last_state_change' : {
5235 'description' : 'The time of the last state change (Unix timestamp)',
5236 'type' : 'int',
5238 'current_service_latency' : {
5239 'description' : 'Time difference between scheduled check time and actual check time',
5240 'type' : 'float',
5242 'current_service_long_plugin_output' : {
5243 'description' : 'Unabbreviated output of the last check plugin',
5244 'type' : 'string',
5246 'current_service_low_flap_threshold' : {
5247 'description' : 'Low threshold of flap detection',
5248 'type' : 'float',
5250 'current_service_max_check_attempts' : {
5251 'description' : 'The maximum number of check attempts',
5252 'type' : 'int',
5254 'current_service_next_check' : {
5255 'description' : 'The scheduled time of the next check (Unix timestamp)',
5256 'type' : 'int',
5258 'current_service_next_notification' : {
5259 'description' : 'The time of the next notification (Unix timestamp)',
5260 'type' : 'int',
5262 'current_service_notes' : {
5263 'description' : 'Optional notes about the service',
5264 'type' : 'string',
5266 'current_service_notes_expanded' : {
5267 'description' : 'The notes with (the most important) macros expanded',
5268 'type' : 'string',
5270 'current_service_notes_url' : {
5271 'description' : 'An optional URL for additional notes about the service',
5272 'type' : 'string',
5274 'current_service_notes_url_expanded' : {
5275 'description' : 'The notes_url with (the most important) macros expanded',
5276 'type' : 'string',
5278 'current_service_notification_interval' : {
5279 'description' : 'Interval of periodic notification or 0 if its off',
5280 'type' : 'float',
5282 'current_service_notification_period' : {
5283 'description' : 'The name of the notification period of the service. It this is empty, service problems are always notified.',
5284 'type' : 'string',
5286 'current_service_notifications_enabled' : {
5287 'description' : 'Wether notifications are enabled for the service (0/1)',
5288 'type' : 'int',
5290 'current_service_obsess_over_service' : {
5291 'description' : 'Wether \'obsess_over_service\' is enabled for the service (0/1)',
5292 'type' : 'int',
5294 'current_service_percent_state_change' : {
5295 'description' : 'Percent state change',
5296 'type' : 'float',
5298 'current_service_perf_data' : {
5299 'description' : 'Performance data of the last check plugin',
5300 'type' : 'string',
5302 'current_service_plugin_output' : {
5303 'description' : 'Output of the last check plugin',
5304 'type' : 'string',
5306 'current_service_process_performance_data' : {
5307 'description' : 'Wether processing of performance data is enabled for the service (0/1)',
5308 'type' : 'int',
5310 'current_service_retry_interval' : {
5311 'description' : 'Number of basic interval lengths between checks when retrying after a soft error',
5312 'type' : 'float',
5314 'current_service_scheduled_downtime_depth' : {
5315 'description' : 'The number of scheduled downtimes the service is currently in',
5316 'type' : 'int',
5318 'current_service_state' : {
5319 'description' : 'The current state of the service (0: OK, 1: WARN, 2: CRITICAL, 3: UNKNOWN)',
5320 'type' : 'int',
5322 'current_service_state_type' : {
5323 'description' : 'The type of the current state (0: soft, 1: hard)',
5324 'type' : 'int',
5326 'host_name' : {
5327 'description' : 'The name of the host the log entry is about (might be empty)',
5328 'type' : 'string',
5330 'lineno' : {
5331 'description' : 'The number of the line in the log file',
5332 'type' : 'int',
5334 'message' : {
5335 'description' : 'The complete message line including the timestamp',
5336 'type' : 'string',
5338 'options' : {
5339 'description' : 'The part of the message after the \':\'',
5340 'type' : 'string',
5342 'plugin_output' : {
5343 'description' : 'The output of the check, if any is associated with the message',
5344 'type' : 'string',
5346 'service_description' : {
5347 'description' : 'The description of the service log entry is about (might be empty)',
5348 'type' : 'string',
5350 'state' : {
5351 'default' : 0,
5352 'description' : 'The state of the host or service in question',
5353 'prop' : 'state',
5354 'type' : 'int',
5356 'state_type' : {
5357 'description' : 'The type of the state (varies on different log classes)',
5358 'type' : 'string',
5360 'time' : {
5361 'default' : 0,
5362 'description' : 'Time of the log event (UNIX timestamp)',
5363 'prop' : 'time',
5364 'type' : 'int',
5366 'type' : {
5367 'description' : 'The type of the message (text before the colon), the message itself for info messages',
5368 'type' : 'string',
5374 separators = map(lambda x: chr(int(x)), [10, 59, 44, 124])
5377 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):
5378 self.configs = configs
5379 self.hostname_lookup_table = hostname_lookup_table
5380 self.servicename_lookup_table = servicename_lookup_table
5381 self.hosts = hosts
5382 self.services = services
5383 self.contacts = contacts
5384 self.hostgroups = hostgroups
5385 self.servicegroups = servicegroups
5386 self.contactgroups = contactgroups
5387 self.timeperiods = timeperiods
5388 self.commands = commands
5389 self.schedulers = schedulers
5390 self.pollers = pollers
5391 self.reactionners = reactionners
5392 self.brokers = brokers
5393 self.dbconn = dbconn
5394 LiveStatus.pnp_path = pnp_path
5395 self.debuglevel = 2
5396 self.dbconn.row_factory = self.row_factory
5397 self.return_queue = return_queue
5399 self.create_out_map_delegates()
5400 self.create_out_map_hooks()
5401 # add Host attributes to Hostsbygroup etc.
5402 for attribute in LiveStatus.out_map['Host']:
5403 LiveStatus.out_map['Hostsbygroup'][attribute] = LiveStatus.out_map['Host'][attribute]
5404 for attribute in self.out_map['Service']:
5405 LiveStatus.out_map['Servicesbygroup'][attribute] = LiveStatus.out_map['Service'][attribute]
5406 for attribute in self.out_map['Service']:
5407 LiveStatus.out_map['Servicesbyhostgroup'][attribute] = LiveStatus.out_map['Service'][attribute]
5410 def row_factory(self, cursor, row):
5411 """Handler for the sqlite fetch method."""
5412 return Logline(cursor, row)
5415 def handle_request(self, data):
5416 """Execute the livestatus request.
5418 This function creates a LiveStatusRequest method, calls the parser,
5419 handles the execution of the request and formatting of the result.
5422 request = LiveStatusRequest(self.configs, self.hostname_lookup_table, self.servicename_lookup_table, self.hosts, self.services, self.contacts, self.hostgroups, self.servicegroups, self.contactgroups, self.timeperiods, self.commands, 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=(',', ':'))))
5679 class LiveStatusRequest(LiveStatus):
5681 """A class describing a livestatus request."""
5683 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):
5684 # Runtime data form the global LiveStatus object
5685 self.configs = configs
5686 self.hostname_lookup_table = hostname_lookup_table
5687 self.servicename_lookup_table = servicename_lookup_table
5688 self.hosts = hosts
5689 self.services = services
5690 self.contacts = contacts
5691 self.hostgroups = hostgroups
5692 self.servicegroups = servicegroups
5693 self.contactgroups = contactgroups
5694 self.timeperiods = timeperiods
5695 self.commands = commands
5696 self.schedulers = schedulers
5697 self.pollers = pollers
5698 self.reactionners = reactionners
5699 self.brokers = brokers
5700 self.dbconn = dbconn
5701 self.pnp_path = pnp_path
5702 self.return_queue = return_queue
5704 # Private attributes for this specific request
5705 self.response = LiveStatusResponse(responseheader = 'off', outputformat = 'csv', keepalive = 'off', columnheaders = 'undef', separators = LiveStatus.separators)
5706 self.table = None
5707 self.columns = []
5708 self.filtercolumns = []
5709 self.prefiltercolumns = []
5710 self.stats_group_by = []
5711 self.stats_columns = []
5712 self.aliases = []
5713 self.limit = None
5714 self.extcmd = False
5715 self.out_map = self.copy_out_map_hooks()
5717 # Initialize the stacks which are needed for the Filter: and Stats:
5718 # filter- and count-operations
5719 self.filter_stack = LiveStatusStack()
5720 self.sql_filter_stack = LiveStatusStack()
5721 self.sql_filter_stack.type = 'sql'
5722 self.stats_filter_stack = LiveStatusStack()
5723 self.stats_postprocess_stack = LiveStatusStack()
5724 self.stats_request = False
5726 # Set a timestamp for this specific request
5727 self.tic = time.time()
5728 # Clients can also send their local time with the request
5729 self.client_localtime = time.time()
5732 def find_converter(self, attribute):
5733 """Return a function that converts textual numbers
5734 in the request to the correct data type"""
5735 out_map = LiveStatus.out_map[self.out_map_name]
5736 if attribute in out_map and 'type' in out_map[attribute]:
5737 if out_map[attribute]['type'] == 'int':
5738 return int
5739 elif out_map[attribute]['type'] == 'float':
5740 return float
5741 return None
5744 def set_default_out_map_name(self):
5745 """Translate the table name to the corresponding out_map key."""
5746 self.out_map_name = {
5747 'hosts' : 'Host',
5748 'services' : 'Service',
5749 'hostgroups' : 'Hostgroup',
5750 'servicegroups' : 'Servicegroup',
5751 'contacts' : 'Contact',
5752 'contactgroups' : 'Contactgroup',
5753 'comments' : 'Comment',
5754 'downtimes' : 'Downtime',
5755 'commands' : 'Command',
5756 'timeperiods' : 'Timeperiod',
5757 'hostsbygroup' : 'Hostsbygroup',
5758 'servicesbygroup' : 'Servicesbygroup',
5759 'servicesbyhostgroup' : 'Servicesbyhostgroup',
5760 'status' : 'Config',
5761 'log' : 'Logline',
5762 'schedulers' : 'SchedulerLink',
5763 'pollers' : 'PollerLink',
5764 'reactionners' : 'ReactionnerLink',
5765 'brokers' : 'BrokerLink',
5766 'problems' : 'Problem',
5767 'columns' : 'Config', # just a dummy
5768 }[self.table]
5771 def copy_out_map_hooks(self):
5772 """Update the hooks for some out_map entries.
5774 Livestatus columns which have a fulldepythonize postprocessor
5775 need an updated argument list. The third argument needs to
5776 be the request object. (When the out_map is first supplied
5777 with hooks, the third argument is the Livestatus object.)
5780 new_map = {}
5781 for objtype in LiveStatus.out_map:
5782 new_map[objtype] = {}
5783 for attribute in LiveStatus.out_map[objtype]:
5784 new_map[objtype][attribute] = {}
5785 entry = LiveStatus.out_map[objtype][attribute]
5786 if 'hooktype' in entry:
5787 if 'prop' not in entry or entry['prop'] == None:
5788 prop = attribute
5789 else:
5790 prop = entry['prop']
5791 if 'default' in entry:
5792 default = entry['default']
5793 else:
5794 if entry['type'] == 'int' or entry['type'] == 'float':
5795 default = 0
5796 else:
5797 default = ''
5798 func = entry['fulldepythonize']
5799 new_map[objtype][attribute]['hook'] = self.make_hook('get_prop_full_depythonize', prop, default, func, None)
5800 else:
5801 new_map[objtype][attribute]['hook'] = entry['hook']
5802 return new_map
5805 def __str__(self):
5806 output = "LiveStatusRequest:\n"
5807 for attr in ["table", "columns", "filtercolumns", "prefiltercolumns", "aliases", "stats_group_by", "stats_request"]:
5808 output += "request %s: %s\n" % (attr, getattr(self, attr))
5809 return output
5812 def split_command(self, line, splits=1):
5813 """Create a list from the words of a line"""
5814 return line.split(' ', splits)
5817 def split_option(self, line, splits=1):
5818 """Like split_commands, but converts numbers to int data type"""
5819 #x = [int(i) if i.isdigit() else i for i in [token.strip() for token in re.split(r"[\s]+", line, splits)]]
5820 x = map (lambda i: (i.isdigit() and int(i)) or i, [token.strip() for token in re.split(r"[\s]+", line, splits)])
5821 return x
5824 def split_option_with_columns(self, line):
5825 """Split a line in a command and a list of words"""
5826 cmd, columns = self.split_option(line)
5827 return cmd, [self.strip_table_from_column(c) for c in re.compile(r'\s+').split(columns)]
5830 def strip_table_from_column(self, column):
5831 """Cut off the table name, because it is possible
5832 to say service_state instead of state"""
5833 bygroupmatch = re.compile('(\w+)by.*group').search(self.table)
5834 if bygroupmatch:
5835 return re.sub(re.sub('s$', '', bygroupmatch.group(1)) + '_', '', column, 1)
5836 else:
5837 return re.sub(re.sub('s$', '', self.table) + '_', '', column, 1)
5840 def parse_input(self, data):
5841 """Parse the lines of a livestatus request.
5843 This function looks for keywords in input lines and
5844 sets the attributes of the request object
5847 for line in [line.strip() for line in data.splitlines()]:
5848 # Tools like NagVis send KEYWORK:option, and we prefer to have
5849 # a space folowing the :
5850 if ':' in line and not ' ' in line:
5851 line = line.replace(':', ': ')
5852 keyword = line.split(' ')[0].rstrip(':')
5853 if keyword == 'GET': # Get the name of the base table
5854 cmd, self.table = self.split_command(line)
5855 self.set_default_out_map_name()
5856 elif keyword == 'Columns': # Get the names of the desired columns
5857 cmd, self.columns = self.split_option_with_columns(line)
5858 self.response.columnheaders = 'off'
5859 elif keyword == 'ResponseHeader':
5860 cmd, responseheader = self.split_option(line)
5861 self.response.responseheader = responseheader
5862 elif keyword == 'OutputFormat':
5863 cmd, outputformat = self.split_option(line)
5864 self.response.outputformat = outputformat
5865 elif keyword == 'KeepAlive':
5866 cmd, keepalive = self.split_option(line)
5867 self.response.keepalive = keepalive
5868 elif keyword == 'ColumnHeaders':
5869 cmd, columnheaders = self.split_option(line)
5870 self.response.columnheaders = columnheaders
5871 elif keyword == 'Limit':
5872 cmd, self.limit = self.split_option(line)
5873 elif keyword == 'Filter':
5874 try:
5875 cmd, attribute, operator, reference = self.split_option(line, 3)
5876 except:
5877 cmd, attribute, operator, reference = self.split_option(line, 2) + ['']
5878 if operator in ['=', '>', '>=', '<', '<=', '=~', '~', '~~', '!=', '!>', '!>=', '!<', '!<=']:
5879 # Cut off the table name
5880 attribute = self.strip_table_from_column(attribute)
5881 # Some operators can simply be negated
5882 if operator in ['!>', '!>=', '!<', '!<=']:
5883 operator = { '!>' : '<=', '!>=' : '<', '!<' : '>=', '!<=' : '>' }[operator]
5884 # Put a function on top of the filter_stack which implements
5885 # the desired operation
5886 self.filtercolumns.append(attribute)
5887 self.prefiltercolumns.append(attribute)
5888 self.filter_stack.put(self.make_filter(operator, attribute, reference))
5889 if self.table == 'log':
5890 if attribute == 'time':
5891 self.sql_filter_stack.put(self.make_sql_filter(operator, attribute, reference))
5892 else:
5893 print "illegal operation", operator
5894 pass # illegal operation
5895 elif keyword == 'And':
5896 cmd, andnum = self.split_option(line)
5897 # Take the last andnum functions from the stack
5898 # Construct a new function which makes a logical and
5899 # Put the function back onto the stack
5900 self.filter_stack.and_elements(andnum)
5901 elif keyword == 'Or':
5902 cmd, ornum = self.split_option(line)
5903 # Take the last ornum functions from the stack
5904 # Construct a new function which makes a logical or
5905 # Put the function back onto the stack
5906 self.filter_stack.or_elements(ornum)
5907 elif keyword == 'StatsGroupBy':
5908 cmd, stats_group_by = self.split_option_with_columns(line)
5909 self.filtercolumns.extend(stats_group_by)
5910 self.stats_group_by.extend(stats_group_by)
5911 # Deprecated. If your query contains at least one Stats:-header
5912 # then Columns: has the meaning of the old StatsGroupBy: header
5913 elif keyword == 'Stats':
5914 self.stats_request = True
5915 try:
5916 cmd, attribute, operator, reference = self.split_option(line, 3)
5917 if attribute in ['sum', 'min', 'max', 'avg', 'std'] and reference.find('as ', 3) != -1:
5918 attribute, operator = operator, attribute
5919 asas, alias = reference.split(' ')
5920 self.aliases.append(alias)
5921 elif attribute in ['sum', 'min', 'max', 'avg', 'std'] and reference == '=':
5922 # Workaround for thruk-cmds like: Stats: sum latency =
5923 attribute, operator = operator, attribute
5924 reference = ''
5925 except:
5926 cmd, attribute, operator = self.split_option(line, 3)
5927 if attribute in ['sum', 'min', 'max', 'avg', 'std']:
5928 attribute, operator = operator, attribute
5929 reference = ''
5930 attribute = self.strip_table_from_column(attribute)
5931 if operator in ['=', '>', '>=', '<', '<=', '=~', '~', '~~', '!=', '!>', '!>=', '!<', '!<=']:
5932 if operator in ['!>', '!>=', '!<', '!<=']:
5933 operator = { '!>' : '<=', '!>=' : '<', '!<' : '>=', '!<=' : '>' }[operator]
5934 self.filtercolumns.append(attribute)
5935 self.stats_columns.append(attribute)
5936 self.stats_filter_stack.put(self.make_filter(operator, attribute, reference))
5937 self.stats_postprocess_stack.put(self.make_filter('count', attribute, None))
5938 elif operator in ['sum', 'min', 'max', 'avg', 'std']:
5939 self.stats_columns.append(attribute)
5940 self.stats_filter_stack.put(self.make_filter('dummy', attribute, None))
5941 self.stats_postprocess_stack.put(self.make_filter(operator, attribute, None))
5942 else:
5943 print "illegal operation", operator
5944 pass # illegal operation
5945 elif keyword == 'StatsAnd':
5946 cmd, andnum = self.split_option(line)
5947 self.stats_filter_stack.and_elements(andnum)
5948 elif keyword == 'StatsOr':
5949 cmd, ornum = self.split_option(line)
5950 self.stats_filter_stack.or_elements(ornum)
5951 elif keyword == 'Separators':
5952 cmd, sep1, sep2, sep3, sep4 = line.split(' ', 5)
5953 self.response.separators = map(lambda x: chr(int(x)), [sep1, sep2, sep3, sep4])
5954 elif keyword == 'Localtime':
5955 cmd, self.client_localtime = self.split_option(line)
5956 elif keyword == 'COMMAND':
5957 cmd, self.extcmd = line.split(' ', 1)
5958 else:
5959 # This line is not valid or not implemented
5960 print "Received a line of input which i can't handle : '%s'" % line
5961 pass
5964 def launch_query(self):
5965 """Prepare the request object's filter stacks"""
5966 if self.extcmd:
5967 # External command are send back to broker
5968 e = ExternalCommand(self.extcmd)
5969 self.return_queue.put(e)
5970 return []
5971 else:
5972 # A minimal integrity check
5973 if not self.table:
5974 return []
5976 # Make columns unique
5977 self.filtercolumns = list(set(self.filtercolumns))
5978 self.prefiltercolumns = list(set(self.prefiltercolumns))
5979 self.stats_columns = list(set(self.stats_columns))
5981 if self.stats_request:
5982 if len(self.columns) > 0:
5983 # StatsGroupBy is deprecated. Columns: can be used instead
5984 self.stats_group_by = self.columns
5985 elif len(self.stats_group_by) > 0:
5986 self.columns = self.stats_group_by + self.stats_columns
5987 #if len(self.stats_columns) > 0 and len(self.columns) == 0:
5988 if len(self.stats_columns) > 0:
5989 self.columns = self.stats_columns + self.columns
5991 # Make one big filter where the single filters are anded
5992 self.filter_stack.and_elements(self.filter_stack.qsize())
5993 try:
5994 # Remember the number of stats filters. We need these numbers as columns later.
5995 # But we need to ask now, because get_live_data() will empty the stack
5996 num_stats_filters = self.stats_filter_stack.qsize()
5997 if self.table == 'log':
5998 self.sql_filter_stack.and_elements(self.sql_filter_stack.qsize())
5999 result = self.get_live_data_log()
6000 else:
6001 # If the pnpgraph_present column is involved, then check
6002 # with each request if the pnp perfdata path exists
6003 if 'pnpgraph_present' in self.columns + self.filtercolumns + self.prefiltercolumns and self.pnp_path and os.access(self.pnp_path, os.R_OK):
6004 self.pnp_path_readable = True
6005 else:
6006 self.pnp_path_readable = False
6007 # Apply the filters on the broker's host/service/etc elements
6009 result = self.get_live_data()
6010 if self.stats_request:
6011 self.columns = range(num_stats_filters)
6012 if self.stats_group_by:
6013 self.columns = tuple(list(self.stats_group_by) + list(self.columns))
6014 if len(self.aliases) == 0:
6015 #If there were Stats: staments without "as", show no column headers at all
6016 self.response.columnheaders = 'off'
6017 else:
6018 self.response.columnheaders = 'on'
6020 return result
6021 except Exception, e:
6022 import traceback
6023 print "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
6024 print e
6025 traceback.print_exc(32)
6026 print "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
6029 def get_live_data(self):
6030 """Find the objects which match the request.
6032 This function scans a list of objects (hosts, services, etc.) and
6033 applies the filter functions first. The remaining objects are
6034 converted to simple dicts which have only the keys that were
6035 requested through Column: attributes.
6038 result = []
6039 # Get the function which implements the Filter: statements
6040 filter_func = self.filter_stack.get_stack()
6041 out_map = self.out_map[self.out_map_name]
6042 filter_map = dict([(k, out_map.get(k)) for k in self.filtercolumns])
6043 output_map = dict([(k, out_map.get(k)) for k in self.columns]) or out_map
6044 without_filter = len(self.filtercolumns) == 0
6046 if self.table in ['hosts', 'services', 'downtimes', 'comments', 'hostgroups', 'servicegroups', 'hostsbygroup', 'servicesbygroup', 'servicesbyhostgroup']:
6047 #Scan through the objects and apply the Filter: rules
6048 if self.table == 'hosts':
6049 if not self.limit:
6050 filtresult = [self.create_output(output_map, y) for y in (x for x in self.hosts.values() if (without_filter or filter_func(self.create_output(filter_map, x))))]
6051 else:
6052 hosts = sorted(self.hosts.values(), key = lambda k: k.host_name)
6053 filtresult = [self.create_output(output_map, y) for y in (x for x in hosts if (without_filter or filter_func(self.create_output(filter_map, x))))]
6054 filtresult = filtresult[:self.limit]
6055 elif self.table == 'hostsbygroup':
6056 # instead of self.hosts.values()
6057 # loop over hostgroups, then over members, then flatten the list, then add a hostgroup attribute to each host
6058 if True:
6059 filtresult = [self.create_output(output_map, x) for x in [
6060 host for host in [
6061 setattr(hohg[0], 'hostgroup', hohg[1]) or hohg[0] for hohg in [
6062 # (host, hg), (host, hg), ... host objects are individuals
6063 (copy.copy(item0), inner_list0[1]) for inner_list0 in [
6064 # ([host, host, ...], hg), ([host], hg), ...
6065 (sorted(hg1.members, key = lambda k: k.host_name), hg1 ) for hg1 in
6066 # hostgroups sorted by hostgroup_name
6067 sorted([hg0 for hg0 in self.hostgroups.values() if hg0.members], key = lambda k: k.hostgroup_name)
6068 ] for item0 in inner_list0[0]
6070 ] if (without_filter or filter_func(self.create_output(filter_map, host)))
6072 if self.limit:
6073 filtresult = filtresult[:self.limit]
6074 elif self.table == 'services':
6075 if not self.limit:
6076 filtresult = [self.create_output(output_map, y) for y in (x for x in self.services.values() if (without_filter or filter_func(self.create_output(filter_map, x))))]
6077 else:
6078 services = sorted(self.services.values(), key = lambda k: (k.host_name, k.service_description))
6079 filtresult = [self.create_output(output_map, y) for y in (x for x in services if (without_filter or filter_func(self.create_output(filter_map, x))))]
6080 filtresult = filtresult[:self.limit]
6081 elif self.table == 'servicesbygroup':
6082 # Here we have more generators instead of list comprehensions, but in fact it makes no difference
6083 # (Tested with 2000 services)
6084 # Multisite actually uses this with limit. This is a temporary workaround because limiting requires sorting
6085 if True:
6086 filtresult = [self.create_output(output_map, x) for x in (
6087 svc for svc in (
6088 setattr(servicesg[0], 'servicegroup', servicesg[1]) or servicesg[0] for servicesg in (
6089 # (service, sg), (service, sg), ... service objects are individuals
6090 (copy.copy(item0), inner_list0[1]) for inner_list0 in (
6091 # ([service, service], sg), ([service, service, ...], sg), ... services are sorted
6092 (sorted(sg1.members, key = lambda k: k.get_name()), sg1) for sg1 in
6093 # servicegroups, sorted by their servicegroup_name
6094 sorted([sg0 for sg0 in self.servicegroups.values() if sg0.members], key = lambda k: k.servicegroup_name)
6095 ) for item0 in inner_list0[0]
6097 ) if (without_filter or filter_func(self.create_output(filter_map, svc)))
6099 if self.limit:
6100 filtresult = filtresult[:self.limit]
6101 elif self.table == 'servicesbyhostgroup':
6102 # We will use prefiltercolumns here for some serious speedup.
6103 # For example, if nagvis wants Filter: host_groups >= hgxy
6104 # we don't have to use the while list of hostgroups in
6105 # the innermost loop
6106 # Filter: host_groups >= linux-servers
6107 # host_groups is a service attribute
6108 # We can get all services of all hosts of all hostgroups and filter at the end
6109 # But it would save a lot of time to already filter the hostgroups. This means host_groups must be hard-coded
6110 # Also host_name, but then we must filter the second step.
6111 # And a mixture host_groups/host_name with FilterAnd/Or? Must have several filter functions
6112 # This is still under construction. The code can be made simpler
6113 if True:
6114 filtresult = [self.create_output(output_map, x) for x in (
6115 svc for svc in (
6116 setattr(svchgrp[0], 'hostgroup', svchgrp[1]) or svchgrp[0] for svchgrp in (
6117 # (service, hostgroup), (service, hostgroup), (service, hostgroup), ... service objects are individuals
6118 (copy.copy(item1), inner_list1[1]) for inner_list1 in (
6119 # ([service, service, ...], hostgroup), ([service, ...], hostgroup), ... flattened by host. only if a host has services. sorted by service_description
6120 (sorted(item0.services, key = lambda k: k.service_description), inner_list0[1]) for inner_list0 in (
6121 # ([host, host, ...], hostgroup), ([host, host, host, ...], hostgroup), ... sorted by host_name
6122 (sorted(hg1.members, key = lambda k: k.host_name), hg1) for hg1 in # ([host, host], hg), ([host], hg),... hostgroup.members->explode->sort
6123 # hostgroups, sorted by hostgroup_name
6124 sorted([hg0 for hg0 in self.hostgroups.values() if hg0.members], key = lambda k: k.hostgroup_name)
6125 ) for item0 in inner_list0[0] if item0.services
6126 ) for item1 in inner_list1[0]
6128 ) if (without_filter or filter_func(self.create_output(filter_map, svc)))
6130 if self.limit:
6131 filtresult = filtresult[:self.limit]
6132 elif self.table == 'downtimes':
6133 if without_filter:
6134 filtresult = [self.create_output(output_map, y) for y in reduce(list.__add__, [x.downtimes for x in self.services.values() + self.hosts.values() if len(x.downtimes) > 0], [])]
6135 else:
6136 prefiltresult = [d for d in reduce(list.__add__, [x.downtimes for x in self.services.values() + self.hosts.values() if len(x.downtimes) > 0], []) if filter_func(self.create_output(filter_map, d))]
6137 filtresult = [self.create_output(output_map, x) for x in prefiltresult]
6138 elif self.table == 'comments':
6139 if without_filter:
6140 filtresult = [self.create_output(output_map, y) for y in reduce(list.__add__, [x.comments for x in self.services.values() + self.hosts.values() if len(x.comments) > 0], [])]
6141 else:
6142 prefiltresult = [c for c in reduce(list.__add__, [x.comments for x in self.services.values() + self.hosts.values() if len(x.comments) > 0], []) if filter_func(self.create_output(filter_map, c))]
6143 filtresult = [self.create_output(output_map, x) for x in prefiltresult]
6144 elif self.table == 'hostgroups':
6145 if without_filter:
6146 filtresult = [y for y in [self.create_output(output_map, x) for x in self.hostgroups.values()] if filter_func(y)]
6147 else:
6148 prefiltresult = [x for x in self.hostgroups.values() if filter_func(self.create_output(filter_map, x))]
6149 filtresult = [self.create_output(output_map, x) for x in prefiltresult]
6150 elif self.table == 'servicegroups':
6151 if without_filter:
6152 filtresult = [y for y in [self.create_output(output_map, x) for x in self.servicegroups.values()] if filter_func(y)]
6153 else:
6154 prefiltresult = [x for x in self.servicegroups.values() if filter_func(self.create_output(filter_map, x))]
6155 filtresult = [self.create_output(output_map, x) for x in prefiltresult]
6157 result = filtresult
6158 elif self.table == 'contacts':
6159 filtresult = [self.create_output(output_map, y) for y in (x for x in self.contacts.values() if (without_filter or filter_func(self.create_output(filter_map, x))))]
6160 if self.limit:
6161 filtresult = filtresult[:self.limit]
6162 elif self.table == 'commands':
6163 for c in self.commands.values():
6164 result.append(self.create_output(output_map, c))
6165 elif self.table == 'schedulers':
6166 for s in self.schedulers.values():
6167 result.append(self.create_output(output_map, s))
6168 elif self.table == 'pollers':
6169 for s in self.pollers.values():
6170 result.append(self.create_output(output_map, s))
6171 elif self.table == 'reactionners':
6172 for s in self.reactionners.values():
6173 result.append(self.create_output(output_map, s))
6174 elif self.table == 'brokers':
6175 for s in self.brokers.values():
6176 result.append(self.create_output(output_map, s))
6177 elif self.table == 'problems':
6178 # We will crate a problems list first with all problems and source in it
6179 # TODO : create with filter
6180 problems = []
6181 for h in self.hosts.values():
6182 if h.is_problem:
6183 pb = Problem(h, h.impacts)
6184 problems.append(pb)
6185 for s in self.services.values():
6186 if s.is_problem:
6187 pb = Problem(s, s.impacts)
6188 problems.append(pb)
6189 # Then return
6190 for pb in problems:
6191 result.append(self.create_output(output_map, pb))
6192 elif self.table == 'status':
6193 out_map = self.out_map['Config']
6194 for c in self.configs.values():
6195 result.append(self.create_output(output_map, c))
6196 elif self.table == 'columns':
6197 result.append({
6198 'description' : 'A description of the column' , 'name' : 'description' , 'table' : 'columns' , 'type' : 'string' })
6199 result.append({
6200 'description' : 'The name of the column within the table' , 'name' : 'name' , 'table' : 'columns' , 'type' : 'string' })
6201 result.append({
6202 'description' : 'The name of the table' , 'name' : 'table' , 'table' : 'columns' , 'type' : 'string' })
6203 result.append({
6204 'description' : 'The data type of the column (int, float, string, list)' , 'name' : 'type' , 'table' : 'columns' , 'type' : 'string' })
6205 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' }
6206 for obj in sorted(LiveStatus.out_map, key=lambda x: x):
6207 if obj in tablenames:
6208 for attr in LiveStatus.out_map[obj]:
6209 if 'description' in LiveStatus.out_map[obj][attr] and LiveStatus.out_map[obj][attr]['description']:
6210 result.append({ 'description' : LiveStatus.out_map[obj][attr]['description'], 'name' : attr, 'table' : tablenames[obj], 'type' : LiveStatus.out_map[obj][attr]['type'] })
6211 else:
6212 result.append({'description' : 'to_do_desc', 'name' : attr, 'table' : tablenames[obj], 'type' : LiveStatus.out_map[obj][attr]['type'] })
6214 if self.stats_request:
6215 result = self.statsify_result(result)
6216 #print "result is", result
6217 return result
6220 def get_live_data_log(self):
6221 """Like get_live_data, but for log objects"""
6222 filter_func = self.filter_stack.get_stack()
6223 sql_filter_func = self.sql_filter_stack.get_stack()
6224 out_map = self.out_map[self.out_map_name]
6225 filter_map = dict([(k, out_map.get(k)) for k in self.filtercolumns])
6226 output_map = dict([(k, out_map.get(k)) for k in self.columns]) or out_map
6227 without_filter = len(self.filtercolumns) == 0
6228 result = []
6229 if self.table == 'log':
6230 out_map = self.out_map['Logline']
6231 # We can apply the filterstack here as well. we have columns and filtercolumns.
6232 # the only additional step is to enrich log lines with host/service-attributes
6233 # A timerange can be useful for a faster preselection of lines
6234 filter_clause, filter_values = sql_filter_func()
6235 c = self.dbconn.cursor()
6236 try:
6237 if sqlite3.paramstyle == 'pyformat':
6238 matchcount = 0
6239 for m in re.finditer(r"\?", filter_clause):
6240 filter_clause = re.sub('\\?', '%(' + str(matchcount) + ')s', filter_clause, 1)
6241 matchcount += 1
6242 filter_values = dict(zip([str(x) for x in xrange(len(filter_values))], filter_values))
6243 c.execute('SELECT * FROM logs WHERE %s' % filter_clause, filter_values)
6244 except sqlite3.Error, e:
6245 print "An error occurred:", e.args[0]
6246 dbresult = c.fetchall()
6247 if sqlite3.paramstyle == 'pyformat':
6248 dbresult = [self.row_factory(c, d) for d in dbresult]
6250 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)))]
6251 filtresult = [self.create_output(output_map, x) for x in prefiltresult]
6252 if self.stats_request:
6253 result = self.statsify_result(filtresult)
6254 else:
6255 # Results are host/service/etc dicts with the requested attributes
6256 # Columns: = keys of the dicts
6257 result = filtresult
6259 #print "result is", result
6260 return result
6263 def create_output(self, out_map, elt):
6264 """Convert an object to a dict with selected keys."""
6265 output = {}
6266 display_attributes = out_map.keys()
6267 for display in display_attributes:
6268 try:
6269 hook = out_map[display]['hook']
6270 value = hook(elt)
6271 except:
6272 value = ''
6273 output[display] = value
6274 return output
6277 def statsify_result(self, filtresult):
6278 """Applies the stats filter functions to the result.
6280 Explanation:
6281 stats_group_by is ["service_description", "host_name"]
6282 filtresult is a list of elements which have, among others, service_description and host_name attributes
6284 Step 1:
6285 groupedresult is a dict where the keys are unique combinations of the stats_group_by attributes
6286 where the values are arrays of elements which have those attributes in common
6287 Example:
6288 groupedresult[("host1","svc1")] = { host_name : "host1", service_description : "svc1", state : 2, in_downtime : 0 }
6289 groupedresult[("host1","svc2")] = { host_name : "host1", service_description : "svc2", state : 0, in_downtime : 0 }
6290 groupedresult[("host1","svc2")] = { host_name : "host1", service_description : "svc2", state : 1, in_downtime : 1 }
6292 resultdict is a dict where the keys are unique combinations of the stats_group_by attributes
6293 where the values are dicts
6294 resultdict values are dicts where the keys are attribute names from stats_group_by
6295 where the values are attribute values
6296 Example:
6297 resultdict[("host1","svc1")] = { host_name : "host1", service_description : "svc1" }
6298 resultdict[("host1","svc2")] = { host_name : "host1", service_description : "svc2" }
6299 These attributes are later used as output columns
6301 Step 2:
6302 Run the filters (1 filter for each Stats: statement) and the postprocessors (default: len)
6303 The filters are numbered. After each run, add the result to resultdictay as <filterno> : <result>
6304 Example for Stats: state = 0\nStats: state = 1\nStats: state = 2\nStats: state = 3\n
6305 resultdict[("host1","svc1")] = { host_name : "host1", service_description : "svc1", 0 : 0, 1 : 0, 2 : 1, 3 : 0 }
6306 resultdict[("host1","svc2")] = { host_name : "host1", service_description : "svc2", 0 : 1, 1 : 1, 2 : 0, 3 : 0 }
6308 Step 3:
6309 Create the final result array from resultdict
6312 result = []
6313 resultdict = {}
6314 if self.stats_group_by:
6315 # stats_group_by is a list in newer implementations
6316 if isinstance(self.stats_group_by, list):
6317 self.stats_group_by = tuple(self.stats_group_by)
6318 else:
6319 self.stats_group_by = tuple([self.stats_group_by])
6320 # Break up filtresult and prepare resultdict
6321 # rseultarr is not a simple array (for a single result line)
6322 # It is a dict with the statsgroupyby: as key
6323 groupedresult = {}
6324 for elem in filtresult:
6325 # Make a tuple consisting of the stats_group_by values
6326 stats_group_by_values = tuple([elem[c] for c in self.stats_group_by])
6327 if not stats_group_by_values in groupedresult:
6328 groupedresult[stats_group_by_values] = []
6329 groupedresult[stats_group_by_values].append(elem)
6330 for group in groupedresult:
6331 # All possible combinations of stats_group_by values. group is a tuple
6332 resultdict[group] = dict(zip(self.stats_group_by, group))
6334 #The number of Stats: statements
6335 #For each statement there is one function on the stack
6336 maxidx = self.stats_filter_stack.qsize()
6337 for i in range(maxidx):
6338 # Stats:-statements were put on a Lifo, so we need to reverse the number
6339 #stats_number = str(maxidx - i - 1)
6340 stats_number = maxidx - i - 1
6341 # First, get a filter for the attributes mentioned in Stats: statements
6342 filtfunc = self.stats_filter_stack.get()
6343 # Then, postprocess (sum, max, min,...) the results
6344 postprocess = self.stats_postprocess_stack.get()
6345 if self.stats_group_by:
6346 # Calc statistics over _all_ elements of groups
6347 # which share the same stats_filter_by
6348 for group in groupedresult:
6349 resultdict[group][stats_number] = postprocess(filter(filtfunc, groupedresult[group]))
6350 else:
6351 # Calc statistics over _all_ elements of filtresult
6352 resultdict[stats_number] = postprocess(filter(filtfunc, filtresult))
6353 if self.stats_group_by:
6354 for group in resultdict:
6355 result.append(resultdict[group])
6356 else:
6357 # Without StatsGroupBy: we have only one line
6358 result = [resultdict]
6359 return result
6362 def make_filter(self, operator, attribute, reference):
6363 if reference != None:
6364 # Reference is now datatype string. The referring object attribute on the other hand
6365 # may be an integer. (current_attempt for example)
6366 # So for the filter to work correctly (the two values compared must be
6367 # of the same type), we need to convert the reference to the desired type
6368 converter = self.find_converter(attribute)
6369 if converter:
6370 reference = converter(reference)
6372 # The filters are closures.
6373 # Add parameter Class (Host, Service), lookup datatype (default string), convert reference
6374 def eq_filter(ref):
6375 return ref[attribute] == reference
6377 def eq_nocase_filter(ref):
6378 return ref[attribute].lower() == reference.lower()
6380 def ne_filter(ref):
6381 return ref[attribute] != reference
6383 def gt_filter(ref):
6384 return ref[attribute] > reference
6386 def ge_filter(ref):
6387 return ref[attribute] >= reference
6389 def lt_filter(ref):
6390 return ref[attribute] < reference
6392 def le_filter(ref):
6393 return ref[attribute] <= reference
6395 def contains_filter(ref):
6396 return reference in ref[attribute].split(',')
6398 def match_filter(ref):
6399 p = re.compile(reference)
6400 return p.search(ref[attribute])
6402 def match_nocase_filter(ref):
6403 p = re.compile(reference, re.I)
6404 return p.search(ref[attribute])
6406 def ge_contains_filter(ref):
6407 if isinstance(ref[attribute], list):
6408 return reference in ref[attribute]
6409 else:
6410 return ref[attribute] >= reference
6412 def dummy_filter(ref):
6413 return True
6415 def count_postproc(ref):
6416 return len(ref)
6418 def extract_postproc(ref):
6419 return [float(obj[attribute]) for obj in ref]
6421 def sum_postproc(ref):
6422 return sum(float(obj[attribute]) for obj in ref)
6424 def max_postproc(ref):
6425 if ref != []:
6426 return max(float(obj[attribute]) for obj in ref)
6427 return 0
6429 def min_postproc(ref):
6430 if ref != []:
6431 return min(float(obj[attribute]) for obj in ref)
6432 return 0
6434 def avg_postproc(ref):
6435 if ref != []:
6436 return sum(float(obj[attribute]) for obj in ref) / len(ref)
6437 return 0
6439 def std_postproc(ref):
6440 return 0
6442 if operator == '=':
6443 return eq_filter
6444 elif operator == '!=':
6445 return ne_filter
6446 elif operator == '>':
6447 return gt_filter
6448 elif operator == '>=':
6449 return ge_contains_filter
6450 elif operator == '<':
6451 return lt_filter
6452 elif operator == '<=':
6453 return le_filter
6454 elif operator == '=~':
6455 return eq_nocase_filter
6456 elif operator == '~':
6457 return match_filter
6458 elif operator == '~~':
6459 return match_nocase_filter
6460 elif operator == 'dummy':
6461 return dummy_filter
6462 elif operator == 'sum':
6463 return sum_postproc
6464 elif operator == 'max':
6465 return max_postproc
6466 elif operator == 'min':
6467 return min_postproc
6468 elif operator == 'avg':
6469 return avg_postproc
6470 elif operator == 'std':
6471 return std_postproc
6472 elif operator == 'count':
6473 # postprocess for stats
6474 return count_postproc
6475 elif operator == 'extract':
6476 # postprocess for max,min,...
6477 return extract_postproc
6478 else:
6479 raise "wrong operation", operator
6482 def make_sql_filter(self, operator, attribute, reference):
6483 # The filters are text fragments which are put together to form a sql where-condition finally.
6484 # Add parameter Class (Host, Service), lookup datatype (default string), convert reference
6485 def eq_filter():
6486 if reference == '':
6487 return ['%s IS NULL' % attribute, ()]
6488 else:
6489 return ['%s = ?' % attribute, (reference, )]
6490 def ne_filter():
6491 if reference == '':
6492 return ['%s IS NOT NULL' % attribute, ()]
6493 else:
6494 return ['%s != ?' % attribute, (reference, )]
6495 def gt_filter():
6496 return ['%s > ?' % attribute, (reference, )]
6497 def ge_filter():
6498 return ['%s >= ?' % attribute, (reference, )]
6499 def lt_filter():
6500 return ['%s < ?' % attribute, (reference, )]
6501 def le_filter():
6502 return ['%s <= ?' % attribute, (reference, )]
6503 def match_filter():
6504 return ['%s LIKE ?' % attribute, ('%'+reference+'%', )]
6505 if operator == '=':
6506 return eq_filter
6507 if operator == '>':
6508 return gt_filter
6509 if operator == '>=':
6510 return ge_filter
6511 if operator == '<':
6512 return lt_filter
6513 if operator == '<=':
6514 return le_filter
6515 if operator == '!=':
6516 return ne_filter
6517 if operator == '~':
6518 return match_filter