*Fix a bug in external command handling of livesttaus
[shinken.git] / shinken / modules / livestatus_broker / livestatus.py
blob90fb0e69a38840b50494e5d6201b5f7a9b23f6f4
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
25 try:
26 Queue.LifoQueue
27 except AttributeError: # Ptyhon 2.4 and 2.5 do nto have it
28 #try to use a standard queue instead
29 Queue.LifoQueue = Queue.Queue
32 try:
33 import json
34 except ImportError:
35 import simplejson as json
36 #import sqlite3
38 from shinken.service import Service
39 from shinken.external_command import ExternalCommand
41 from shinken.util import from_bool_to_int,from_list_to_split,from_float_to_int,to_int,to_split
43 LOGCLASS_INFO = 0 # all messages not in any other class
44 LOGCLASS_ALERT = 1 # alerts: the change service/host state
45 LOGCLASS_PROGRAM = 2 # important programm events (restart, ...)
46 LOGCLASS_NOTIFICATION = 3 # host/service notifications
47 LOGCLASS_PASSIVECHECK = 4 # passive checks
48 LOGCLASS_COMMAND = 5 # external commands
49 LOGCLASS_STATE = 6 # initial or current states
50 LOGCLASS_INVALID = -1 # never stored
51 LOGCLASS_ALL = 0xffff
52 LOGOBJECT_INFO = 0
53 LOGOBJECT_HOST = 1
54 LOGOBJECT_SERVICE = 2
55 LOGOBJECT_CONTACT = 3
57 #This is a dirty hack. Service.get_name only returns service_description.
58 #For the servicegroup config we need more. host_name + separator + service_descriptio
59 def get_full_name(self):
60 if get_full_name.outputformat == 'csv':
61 return self.host_name + LiveStatus.separators[3] + self.service_description
62 elif get_full_name.outputformat == 'json':
63 return [self.host_name , self.service_description]
64 else:
65 print "Unknow output format!"
66 return ''
67 Service.get_full_name = get_full_name
70 #Another for hosts. We must have the same function for hosts and service in
71 #problem's source. So must define such a function for hosts too
72 def get_common_full_name(self):
73 cls_name = self.__class__.my_type
74 if cls_name == 'service':
75 return self.host_name + LiveStatus.separators[3] + self.service_description
76 else:
77 return self.host_name
80 #It's a dict with 2 entries : hosts a,d services. Will return a string with just
81 #full name of all elements
82 def from_svc_hst_distinct_lists(dct):
83 t = []
84 for h in dct['hosts']:
85 t.append(h)
86 for s in dct['services']:
87 t.append(s)
88 return ','.join(t)
90 #For 2 hosts state, return the worse state
91 def worst_host_state(state_1, state_2):
92 #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),
93 if state_2 == 0:
94 return state_1
95 if state_1 == 1:
96 return state_1
97 return state_2
99 ##The worst state of all services that belong to a host of this group (OK <= WARN <= UNKNOWN <= CRIT)
100 def worst_service_state(state_1, state_2):
101 #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),
102 if state_2 == 0:
103 return state_1
104 if state_1 == 2:
105 return state_1
106 if state_1 == 3 and state_2 != 2:
107 return state_1
108 return state_2
111 class Problem:
112 def __init__(self, source, impacts):
113 self.source = source
114 self.impacts = impacts
117 class Logline(dict):
118 def __init__(self, cursor, row):
119 for idx, col in enumerate(cursor.description):
120 setattr(self, col[0], row[idx])
122 def fill(self, hosts, services, hostname_lookup_table, servicename_lookup_table, columns):
123 if self.logobject == LOGOBJECT_HOST:
124 if self.host_name in hostname_lookup_table:
125 setattr(self, 'log_host', hosts[hostname_lookup_table[self.host_name]])
126 elif self.logobject == LOGOBJECT_SERVICE:
127 if self.host_name in hostname_lookup_table:
128 setattr(self, 'log_host', hosts[hostname_lookup_table[self.host_name]])
129 if self.host_name + self.service_description in servicename_lookup_table:
130 setattr(self, 'log_service', services[servicename_lookup_table[self.host_name + self.service_description]])
131 return self
134 class LiveStatus:
135 separators = map(lambda x: chr(int(x)), [10, 59, 44, 124])
136 #prop : is the internal name if it is different than the name in the output file
137 #required :
138 #depythonize :
139 #default :
140 out_map = {
141 'Host' : {
142 'accept_passive_checks' : {
143 'depythonize' : from_bool_to_int,
144 'description' : 'Wether passive host checks are accepted (0/1)',
145 'prop' : 'passive_checks_enabled',
146 'type' : 'int',
148 'acknowledged' : {
149 'depythonize' : from_bool_to_int,
150 'description' : 'Wether the current host problem has been acknowledged (0/1)',
151 'prop' : 'problem_has_been_acknowledged',
152 'type' : 'int',
154 'acknowledgement_type' : {
155 'description' : 'Type of acknowledgement (0: none, 1: normal, 2: stick)',
156 'type' : 'int',
158 'action_url' : {
159 'description' : 'An optional URL to custom actions or information about this host',
160 'type' : 'string',
162 'action_url_expanded' : {
163 'description' : 'The same as action_url, but with the most important macros expanded',
164 'type' : 'string',
166 'active_checks_enabled' : {
167 'depythonize' : from_bool_to_int,
168 'description' : 'Wether active checks are enabled for the host (0/1)',
169 'type' : 'int',
171 'address' : {
172 'description' : 'IP address',
173 'type' : 'string',
175 'alias' : {
176 'description' : 'An alias name for the host',
177 'type' : 'string',
179 'check_command' : {
180 'depythonize' : 'call',
181 'description' : 'Nagios command for active host check of this host',
182 'type' : 'string',
184 'check_freshness' : {
185 'depythonize' : from_bool_to_int,
186 'description' : 'Wether freshness checks are activated (0/1)',
187 'type' : 'int',
189 'check_interval' : {
190 'converter' : int,
191 'description' : 'Number of basic interval lengths between two scheduled checks of the host',
192 'type' : 'float',
194 'check_options' : {
195 'description' : 'The current check option, forced, normal, freshness... (0-2)',
196 'type' : 'int',
198 'check_period' : {
199 'depythonize' : 'get_name',
200 'description' : 'Time period in which this host will be checked. If empty then the host will always be checked.',
201 'type' : 'string',
203 'check_type' : {
204 'converter' : int,
205 'description' : 'Type of check (0: active, 1: passive)',
206 'type' : 'int',
208 'checks_enabled' : {
209 'depythonize' : from_bool_to_int,
210 'description' : 'Wether checks of the host are enabled (0/1)',
211 'prop' : 'active_checks_enabled',
212 'type' : 'int',
214 'childs' : {
215 'default' : '',
216 'depythonize' : from_list_to_split,
217 'description' : 'A list of all direct childs of the host',
218 'type' : 'list',
220 'comments' : {
221 'default' : '',
222 'depythonize' : 'id',
223 'description' : 'A list of the ids of all comments of this host',
224 'type' : 'list',
226 'contacts' : {
227 'depythonize' : 'contact_name',
228 'description' : 'A list of all contacts of this host, either direct or via a contact group',
229 'type' : 'list',
231 'current_attempt' : {
232 'converter' : int,
233 'default' : 0,
234 'description' : 'Number of the current check attempts',
235 'prop' : 'attempt',
236 'type' : 'int',
238 'current_notification_number' : {
239 'converter' : int,
240 'description' : 'Number of the current notification',
241 'type' : 'int',
243 'custom_variable_names' : {
244 'description' : 'A list of the names of all custom variables',
245 'type' : 'list',
247 'custom_variable_values' : {
248 'description' : 'A list of the values of the custom variables',
249 'type' : 'list',
251 'display_name' : {
252 'description' : 'Optional display name of the host - not used by Nagios\' web interface',
253 'type' : 'string',
255 'downtimes' : {
256 'description' : 'A list of the ids of all scheduled downtimes of this host',
257 'type' : 'list',
259 'event_handler_enabled' : {
260 'depythonize' : from_bool_to_int,
261 'description' : 'Wether event handling is enabled (0/1)',
262 'type' : 'int',
264 'execution_time' : {
265 'converter' : float,
266 'description' : 'Time the host check needed for execution',
267 'type' : 'float',
269 'first_notification_delay' : {
270 'converter' : int,
271 'description' : 'Delay before the first notification',
272 'type' : 'float',
274 'flap_detection_enabled' : {
275 'depythonize' : from_bool_to_int,
276 'description' : 'Wether flap detection is enabled (0/1)',
277 'type' : 'int',
279 'groups' : {
280 'default' : '',
281 'depythonize' : to_split,
282 'description' : 'A list of all host groups this host is in',
283 'prop' : 'hostgroups',
284 'type' : 'list',
286 'hard_state' : {
287 'description' : 'The effective hard state of the host (eliminates a problem in hard_state)',
288 'type' : 'int',
290 'has_been_checked' : {
291 'depythonize' : from_bool_to_int,
292 'description' : 'Wether the host has already been checked (0/1)',
293 'type' : 'int',
295 'high_flap_threshold' : {
296 'converter' : float,
297 'description' : 'High threshold of flap detection',
298 'type' : 'float',
300 'icon_image' : {
301 'description' : 'The name of an image file to be used in the web pages',
302 'type' : 'string',
304 'icon_image_alt' : {
305 'description' : 'Alternative text for the icon_image',
306 'type' : 'string',
308 'icon_image_expanded' : {
309 'description' : 'The same as icon_image, but with the most important macros expanded',
310 'type' : 'string',
312 'in_check_period' : {
313 'description' : 'Wether this host is currently in its check period (0/1)',
314 'type' : 'int',
316 'in_notification_period' : {
317 'description' : 'Wether this host is currently in its notification period (0/1)',
318 'type' : 'int',
320 'initial_state' : {
321 'description' : 'Initial host state',
322 'type' : 'int',
324 'is_executing' : {
325 'default' : 0, # value in scheduler is not real-time
326 'description' : 'is there a host check currently running... (0/1)',
327 #'prop' : 'in_checking',
328 'type' : 'int',
330 'is_flapping' : {
331 'depythonize' : from_bool_to_int,
332 'description' : 'Wether the host state is flapping (0/1)',
333 'type' : 'int',
335 'last_check' : {
336 'converter' : int,
337 'depythonize' : from_float_to_int,
338 'description' : 'Time of the last check (Unix timestamp)',
339 'prop' : 'last_chk',
340 'type' : 'int',
342 'last_hard_state' : {
343 'description' : 'Last hard state',
344 'type' : 'int',
346 'last_hard_state_change' : {
347 'description' : 'Time of the last hard state change (Unix timestamp)',
348 'type' : 'int',
350 'last_notification' : {
351 'converter' : int,
352 'depythonize' : to_int,
353 'description' : 'Time of the last notification (Unix timestamp)',
354 'type' : 'int',
356 'last_state' : {
357 'description' : 'State before last state change',
358 'type' : 'int',
360 'last_state_change' : {
361 'converter' : int,
362 'depythonize' : from_float_to_int,
363 'description' : 'Time of the last state change - soft or hard (Unix timestamp)',
364 'type' : 'int',
366 'latency' : {
367 'converter' : float,
368 'description' : 'Time difference between scheduled check time and actual check time',
369 'type' : 'float',
371 'long_plugin_output' : {
372 'description' : 'Complete output from check plugin',
373 'prop' : 'long_output',
374 'type' : 'string',
376 'low_flap_threshold' : {
377 'description' : 'Low threshold of flap detection',
378 'type' : 'float',
380 'max_check_attempts' : {
381 'description' : 'Max check attempts for active host checks',
382 'type' : 'int',
384 'name' : {
385 'description' : 'Host name',
386 'prop' : 'host_name',
387 'type' : 'string',
389 'next_check' : {
390 'converter' : int,
391 'depythonize' : from_float_to_int,
392 'description' : 'Scheduled time for the next check (Unix timestamp)',
393 'prop' : 'next_chk',
394 'type' : 'int',
396 'next_notification' : {
397 'converter' : int,
398 'description' : 'Time of the next notification (Unix timestamp)',
399 'type' : 'int',
401 'notes' : {
402 'description' : 'Optional notes for this host',
403 'type' : 'string',
405 'notes_expanded' : {
406 'description' : 'The same as notes, but with the most important macros expanded',
407 'type' : 'string',
409 'notes_url' : {
410 'description' : 'An optional URL with further information about the host',
411 'type' : 'string',
413 'notes_url_expanded' : {
414 'description' : 'Same es notes_url, but with the most important macros expanded',
415 'type' : 'string',
417 'notification_interval' : {
418 'converter' : int,
419 'description' : 'Interval of periodic notification or 0 if its off',
420 'type' : 'float',
422 'notification_period' : {
423 'depythonize' : 'get_name',
424 'description' : 'Time period in which problems of this host will be notified. If empty then notification will be always',
425 'type' : 'string',
427 'notifications_enabled' : {
428 'depythonize' : from_bool_to_int,
429 'description' : 'Wether notifications of the host are enabled (0/1)',
430 'type' : 'int',
432 'num_services' : {
433 'depythonize' : lambda x: len(x),
434 'description' : 'The total number of services of the host',
435 'prop' : 'services',
436 'type' : 'list',
438 'num_services_crit' : {
439 'depythonize' : lambda x: len([y for y in x if y.state_id == 2]),
440 'description' : 'The number of the host\'s services with the soft state CRIT',
441 'prop' : 'services',
442 'type' : 'list',
444 'num_services_hard_crit' : {
445 'depythonize' : lambda x: len([y for y in x if y.state_id == 2 and y.state_type_id == 1]),
446 'description' : 'The number of the host\'s services with the hard state CRIT',
447 'prop' : 'services',
448 'type' : 'list',
450 'num_services_hard_ok' : {
451 'depythonize' : lambda x: len([y for y in x if y.state_id == 0 and y.state_type_id == 1]),
452 'description' : 'The number of the host\'s services with the hard state OK',
453 'prop' : 'services',
454 'type' : 'list',
456 'num_services_hard_unknown' : {
457 'depythonize' : lambda x: len([y for y in x if y.state_id == 3 and y.state_type_id == 1]),
458 'description' : 'The number of the host\'s services with the hard state UNKNOWN',
459 'prop' : 'services',
460 'type' : 'list',
462 'num_services_hard_warn' : {
463 'depythonize' : lambda x: len([y for y in x if y.state_id == 2 and y.state_type_id == 1]),
464 'description' : 'The number of the host\'s services with the hard state WARN',
465 'prop' : 'services',
466 'type' : 'list',
468 'num_services_ok' : {
469 'depythonize' : lambda x: len([y for y in x if y.state_id == 0]),
470 'description' : 'The number of the host\'s services with the soft state OK',
471 'prop' : 'services',
472 'type' : 'list',
474 'num_services_pending' : {
475 'depythonize' : lambda x: len([y for y in x if y.has_been_checked == 0]),
476 'description' : 'The number of the host\'s services which have not been checked yet (pending)',
477 'prop' : 'services',
478 'type' : 'list',
480 'num_services_unknown' : {
481 'depythonize' : lambda x: len([y for y in x if y.state_id == 3]),
482 'description' : 'The number of the host\'s services with the soft state UNKNOWN',
483 'prop' : 'services',
484 'type' : 'list',
486 'num_services_warn' : {
487 'depythonize' : lambda x: len([y for y in x if y.state_id == 1]),
488 'description' : 'The number of the host\'s services with the soft state WARN',
489 'prop' : 'services',
490 'type' : 'list',
492 'obsess_over_host' : {
493 'depythonize' : from_bool_to_int,
494 'description' : 'The current obsess_over_host setting... (0/1)',
495 'type' : 'int',
497 'parents' : {
498 'depythonize' : lambda x: ','.join(x),
499 'description' : 'A list of all direct parents of the host',
500 'type' : 'list',
502 'pending_flex_downtime' : {
503 'description' : 'Wether a flex downtime is pending (0/1)',
504 'type' : 'int',
506 'percent_state_change' : {
507 'description' : 'Percent state change',
508 'type' : 'float',
510 'perf_data' : {
511 'description' : 'Optional performance data of the last host check',
512 'type' : 'string',
514 'plugin_output' : {
515 'description' : 'Output of the last host check',
516 'prop' : 'output',
517 'type' : 'string',
519 'process_performance_data' : {
520 'depythonize' : from_bool_to_int,
521 'description' : 'Wether processing of performance data is enabled (0/1)',
522 'prop' : 'process_perf_data',
523 'type' : 'int',
525 'retry_interval' : {
526 'description' : 'Number of basic interval lengths between checks when retrying after a soft error',
527 'type' : 'float',
529 'scheduled_downtime_depth' : {
530 'converter' : int,
531 'description' : 'The number of downtimes this host is currently in',
532 'type' : 'int',
534 'state' : {
535 'converter' : int,
536 'description' : 'The current state of the host (0: up, 1: down, 2: unreachable)',
537 'prop' : 'state_id',
538 'type' : 'int',
540 'state_type' : {
541 'converter' : int,
542 'description' : 'Type of the current state (0: soft, 1: hard)',
543 'prop' : 'state_type_id',
544 'type' : 'int',
546 'statusmap_image' : {
547 'description' : 'The name of in image file for the status map',
548 'type' : 'string',
550 'total_services' : {
551 'description' : 'The total number of services of the host',
552 'type' : 'int',
554 'worst_service_hard_state' : {
555 'description' : 'The worst hard state of all of the host\'s services (OK <= WARN <= UNKNOWN <= CRIT)',
556 'type' : 'list',
558 'worst_service_state' : {
559 'description' : 'The worst soft state of all of the host\'s services (OK <= WARN <= UNKNOWN <= CRIT)',
560 'type' : 'list',
562 'x_3d' : {
563 'description' : '3D-Coordinates: X',
564 'type' : 'float',
566 'y_3d' : {
567 'description' : '3D-Coordinates: Y',
568 'type' : 'float',
570 'z_3d' : {
571 'description' : '3D-Coordinates: Z',
572 'type' : 'float',
574 'criticity' : {
575 'converter' : int,
576 'description' : 'The importance we gave to this host between hte minimum 0 and the maximum 5',
577 'type' : 'int',
579 'source_problems' : {
580 'description' : 'The name of the source problems (host or service)',
581 'prop' : 'source_problems',
582 'type' : 'list',
583 'depythonize' : from_svc_hst_distinct_lists,
585 'impacts' : {
586 'description' : 'List of what the source impact (list of hosts and services)',
587 'prop' : 'impacts',
588 'type' : 'list',
589 'depythonize' : from_svc_hst_distinct_lists,
594 'Service' : {
595 'accept_passive_checks' : {
596 'depythonize' : from_bool_to_int,
597 'description' : 'Wether the service accepts passive checks (0/1)',
598 'prop' : 'passive_checks_enabled',
599 'type' : 'int',
601 'acknowledged' : {
602 'depythonize' : from_bool_to_int,
603 'description' : 'Wether the current service problem has been acknowledged (0/1)',
604 'prop' : 'problem_has_been_acknowledged',
605 'type' : 'int',
607 'acknowledgement_type' : {
608 'description' : 'The type of the acknownledgement (0: none, 1: normal, 2: sticky)',
609 'type' : 'int',
611 'action_url' : {
612 'description' : 'An optional URL for actions or custom information about the service',
613 'type' : 'string',
615 'action_url_expanded' : {
616 'description' : 'The action_url with (the most important) macros expanded',
617 'type' : 'string',
619 'active_checks_enabled' : {
620 'depythonize' : from_bool_to_int,
621 'description' : 'Wether active checks are enabled for the service (0/1)',
622 'type' : 'int',
624 'check_command' : {
625 'depythonize' : 'call',
626 'description' : 'Nagios command used for active checks',
627 'type' : 'string',
629 'check_interval' : {
630 'description' : 'Number of basic interval lengths between two scheduled checks of the service',
631 'type' : 'float',
633 'check_options' : {
634 'description' : 'The current check option, forced, normal, freshness... (0/1)',
635 'type' : 'int',
637 'check_period' : {
638 'depythonize' : 'get_name',
639 'description' : 'The name of the check period of the service. It this is empty, the service is always checked.',
640 'type' : 'string',
642 'check_type' : {
643 'converter' : int,
644 'depythonize' : to_int,
645 'description' : 'The type of the last check (0: active, 1: passive)',
646 'type' : 'int',
648 'checks_enabled' : {
649 'depythonize' : from_bool_to_int,
650 'description' : 'Wether active checks are enabled for the service (0/1)',
651 'prop' : 'active_checks_enabled',
652 'type' : 'int',
654 'comments' : {
655 'default' : '',
656 'depythonize' : 'id',
657 'description' : 'A list of all comment ids of the service',
658 'type' : 'list',
660 'contacts' : {
661 'depythonize' : 'contact_name',
662 'description' : 'A list of all contacts of the service, either direct or via a contact group',
663 'type' : 'list',
665 'current_attempt' : {
666 'converter' : int,
667 'description' : 'The number of the current check attempt',
668 'prop' : 'attempt',
669 'type' : 'int',
671 'current_notification_number' : {
672 'description' : 'The number of the current notification',
673 'type' : 'int',
675 'custom_variable_names' : {
676 'description' : 'A list of the names of all custom variables of the service',
677 'type' : 'list',
679 'custom_variable_values' : {
680 'description' : 'A list of the values of all custom variable of the service',
681 'type' : 'list',
683 'description' : {
684 'description' : 'Description of the service (also used as key)',
685 'prop' : 'service_description',
686 'type' : 'string',
688 'display_name' : {
689 'description' : 'An optional display name (not used by Nagios standard web pages)',
690 'type' : 'string',
692 'downtimes' : {
693 'description' : 'A list of all downtime ids of the service',
694 'type' : 'list',
696 'event_handler' : {
697 'depythonize' : 'call',
698 'description' : 'Nagios command used as event handler',
699 'type' : 'string',
701 'event_handler_enabled' : {
702 'depythonize' : from_bool_to_int,
703 'description' : 'Wether and event handler is activated for the service (0/1)',
704 'type' : 'int',
706 'execution_time' : {
707 'converter' : float,
708 'description' : 'Time the host check needed for execution',
709 'type' : 'float',
711 'first_notification_delay' : {
712 'converter' : int,
713 'description' : 'Delay before the first notification',
714 'type' : 'float',
716 'flap_detection_enabled' : {
717 'depythonize' : from_bool_to_int,
718 'description' : 'Wether flap detection is enabled for the service (0/1)',
719 'type' : 'int',
721 'groups' : {
722 'default' : '',
723 'depythonize' : to_split,
724 'description' : 'A list of all service groups the service is in',
725 'prop' : 'servicegroups',
726 'type' : 'list',
728 'has_been_checked' : {
729 'depythonize' : from_bool_to_int,
730 'description' : 'Wether the service already has been checked (0/1)',
731 'type' : 'int',
733 'high_flap_threshold' : {
734 'description' : 'High threshold of flap detection',
735 'type' : 'float',
737 'host_accept_passive_checks' : {
738 'description' : 'Wether passive host checks are accepted (0/1)',
739 'type' : 'int',
741 'host_acknowledged' : {
742 'depythonize' : lambda x: from_bool_to_int(x.problem_has_been_acknowledged),
743 'description' : 'Wether the current host problem has been acknowledged (0/1)',
744 'prop' : 'host',
745 'type' : 'int',
747 'host_acknowledgement_type' : {
748 'description' : 'Type of acknowledgement (0: none, 1: normal, 2: stick)',
749 'type' : 'int',
751 'host_action_url' : {
752 'description' : 'An optional URL to custom actions or information about this host',
753 'type' : 'string',
755 'host_action_url_expanded' : {
756 'description' : 'The same as action_url, but with the most important macros expanded',
757 'type' : 'string',
759 'host_active_checks_enabled' : {
760 'description' : 'Wether active checks are enabled for the host (0/1)',
761 'type' : 'int',
763 'host_address' : {
764 'description' : 'IP address',
765 'type' : 'string',
767 'host_alias' : {
768 'description' : 'An alias name for the host',
769 'type' : 'string',
771 'host_check_command' : {
772 'description' : 'Nagios command for active host check of this host',
773 'type' : 'string',
775 'host_check_freshness' : {
776 'description' : 'Wether freshness checks are activated (0/1)',
777 'type' : 'int',
779 'host_check_interval' : {
780 'description' : 'Number of basic interval lengths between two scheduled checks of the host',
781 'type' : 'float',
783 'host_check_options' : {
784 'description' : 'The current check option, forced, normal, freshness... (0-2)',
785 'type' : 'int',
787 'host_check_period' : {
788 'description' : 'Time period in which this host will be checked. If empty then the host will always be checked.',
789 'type' : 'string',
791 'host_check_type' : {
792 'description' : 'Type of check (0: active, 1: passive)',
793 'type' : 'int',
795 'host_checks_enabled' : {
796 'depythonize' : lambda x: from_bool_to_int(x.active_checks_enabled),
797 'description' : 'Wether checks of the host are enabled (0/1)',
798 'prop' : 'host',
799 'type' : 'int',
801 'host_childs' : {
802 'description' : 'A list of all direct childs of the host',
803 'type' : 'list',
805 'host_comments' : {
806 'default' : '',
807 'depythonize' : lambda h: ([c.id for c in h.comments]),
808 'description' : 'A list of the ids of all comments of this host',
809 'prop' : 'host',
810 'type' : 'list',
812 'host_contacts' : {
813 'description' : 'A list of all contacts of this host, either direct or via a contact group',
814 'type' : 'list',
816 'host_current_attempt' : {
817 'description' : 'Number of the current check attempts',
818 'type' : 'int',
820 'host_current_notification_number' : {
821 'description' : 'Number of the current notification',
822 'type' : 'int',
824 'host_custom_variable_names' : {
825 'description' : 'A list of the names of all custom variables',
826 'type' : 'list',
828 'host_custom_variable_values' : {
829 'description' : 'A list of the values of the custom variables',
830 'type' : 'list',
832 'host_display_name' : {
833 'description' : 'Optional display name of the host - not used by Nagios\' web interface',
834 'type' : 'string',
836 'host_downtimes' : {
837 'description' : 'A list of the ids of all scheduled downtimes of this host',
838 'type' : 'list',
840 'host_event_handler_enabled' : {
841 'description' : 'Wether event handling is enabled (0/1)',
842 'type' : 'int',
844 'host_execution_time' : {
845 'description' : 'Time the host check needed for execution',
846 'type' : 'float',
848 'host_first_notification_delay' : {
849 'description' : 'Delay before the first notification',
850 'type' : 'float',
852 'host_flap_detection_enabled' : {
853 'description' : 'Wether flap detection is enabled (0/1)',
854 'type' : 'int',
856 'host_groups' : {
857 'default' : '',
858 'depythonize' : lambda x: to_split(x.hostgroups),
859 'description' : 'A list of all host groups this host is in',
860 'prop' : 'host',
861 'type' : 'list',
863 'host_hard_state' : {
864 'description' : 'The effective hard state of the host (eliminates a problem in hard_state)',
865 'type' : 'int',
867 'host_has_been_checked' : {
868 'depythonize' : lambda x: from_bool_to_int(x.has_been_checked),
869 'description' : 'Wether the host has already been checked (0/1)',
870 'prop' : 'host',
871 'type' : 'int',
873 'host_high_flap_threshold' : {
874 'description' : 'High threshold of flap detection',
875 'type' : 'float',
877 'host_icon_image' : {
878 'description' : 'The name of an image file to be used in the web pages',
879 'type' : 'string',
881 'host_icon_image_alt' : {
882 'description' : 'Alternative text for the icon_image',
883 'type' : 'string',
885 'host_icon_image_expanded' : {
886 'description' : 'The same as icon_image, but with the most important macros expanded',
887 'type' : 'string',
889 'host_in_check_period' : {
890 'description' : 'Wether this host is currently in its check period (0/1)',
891 'type' : 'int',
893 'host_in_notification_period' : {
894 'description' : 'Wether this host is currently in its notification period (0/1)',
895 'type' : 'int',
897 'host_initial_state' : {
898 'description' : 'Initial host state',
899 'type' : 'int',
901 'host_is_executing' : {
902 'default' : 0, # value in scheduler is not real-time
903 'description' : 'is there a host check currently running... (0/1)',
904 'type' : 'int',
906 'host_is_flapping' : {
907 'default' : '0',
908 'depythonize' : from_bool_to_int,
909 'description' : 'Wether the host state is flapping (0/1)',
910 'type' : 'int',
912 'host_last_check' : {
913 'description' : 'Time of the last check (Unix timestamp)',
914 'type' : 'int',
916 'host_last_hard_state' : {
917 'description' : 'Last hard state',
918 'type' : 'int',
920 'host_last_hard_state_change' : {
921 'description' : 'Time of the last hard state change (Unix timestamp)',
922 'type' : 'int',
924 'host_last_notification' : {
925 'description' : 'Time of the last notification (Unix timestamp)',
926 'type' : 'int',
928 'host_last_state' : {
929 'description' : 'State before last state change',
930 'type' : 'int',
932 'host_last_state_change' : {
933 'description' : 'Time of the last state change - soft or hard (Unix timestamp)',
934 'type' : 'int',
936 'host_latency' : {
937 'description' : 'Time difference between scheduled check time and actual check time',
938 'type' : 'float',
940 'host_long_plugin_output' : {
941 'description' : 'Complete output from check plugin',
942 'type' : 'string',
944 'host_low_flap_threshold' : {
945 'description' : 'Low threshold of flap detection',
946 'type' : 'float',
948 'host_max_check_attempts' : {
949 'description' : 'Max check attempts for active host checks',
950 'type' : 'int',
952 'host_name' : {
953 'description' : 'Host name',
954 'type' : 'string',
956 'host_next_check' : {
957 'description' : 'Scheduled time for the next check (Unix timestamp)',
958 'type' : 'int',
960 'host_next_notification' : {
961 'description' : 'Time of the next notification (Unix timestamp)',
962 'type' : 'int',
964 'host_notes' : {
965 'description' : 'Optional notes for this host',
966 'type' : 'string',
968 'host_notes_expanded' : {
969 'description' : 'The same as notes, but with the most important macros expanded',
970 'type' : 'string',
972 'host_notes_url' : {
973 'description' : 'An optional URL with further information about the host',
974 'type' : 'string',
976 'host_notes_url_expanded' : {
977 'description' : 'Same es notes_url, but with the most important macros expanded',
978 'type' : 'string',
980 'host_notification_interval' : {
981 'description' : 'Interval of periodic notification or 0 if its off',
982 'type' : 'float',
984 'host_notification_period' : {
985 'description' : 'Time period in which problems of this host will be notified. If empty then notification will be always',
986 'type' : 'string',
988 'host_notifications_enabled' : {
989 'depythonize' : lambda x: from_bool_to_int(x.notifications_enabled),
990 'description' : 'Wether notifications of the host are enabled (0/1)',
991 'prop' : 'host',
992 'type' : 'int',
994 'host_num_services' : {
995 'depythonize' : lambda x: len(x.services),
996 'description' : 'The total number of services of the host',
997 'prop' : 'host',
998 'type' : 'list',
1000 'host_num_services_crit' : {
1001 'depythonize' : lambda x: len([y for y in x.services if y.state_id == 2]),
1002 'description' : 'The number of the host\'s services with the soft state CRIT',
1003 'prop' : 'host',
1004 'type' : 'list',
1006 'host_num_services_hard_crit' : {
1007 'depythonize' : lambda x: len([y for y in x.services if y.state_id == 2 and y.state_type_id == 1]),
1008 'description' : 'The number of the host\'s services with the hard state CRIT',
1009 'prop' : 'host',
1010 'type' : 'list',
1012 'host_num_services_hard_ok' : {
1013 'depythonize' : lambda x: len([y for y in x.services if y.state_id == 0 and y.state_type_id == 1]),
1014 'description' : 'The number of the host\'s services with the hard state OK',
1015 'prop' : 'host',
1016 'type' : 'list',
1018 'host_num_services_hard_unknown' : {
1019 'depythonize' : lambda x: len([y for y in x.services if y.state_id == 3 and y.state_type_id == 1]),
1020 'description' : 'The number of the host\'s services with the hard state UNKNOWN',
1021 'prop' : 'host',
1022 'type' : 'list',
1024 'host_num_services_hard_warn' : {
1025 'depythonize' : lambda x: len([y for y in x.services if y.state_id == 2 and y.state_type_id == 1]),
1026 'description' : 'The number of the host\'s services with the hard state WARN',
1027 'prop' : 'host',
1028 'type' : 'list',
1030 'host_num_services_ok' : {
1031 'depythonize' : lambda x: len([y for y in x.services if y.state_id == 0]),
1032 'description' : 'The number of the host\'s services with the soft state OK',
1033 'prop' : 'host',
1034 'type' : 'list',
1036 'host_num_services_pending' : {
1037 'depythonize' : lambda x: len([y for y in x.services if y.has_been_checked == 0]),
1038 'description' : 'The number of the host\'s services which have not been checked yet (pending)',
1039 'prop' : 'host',
1040 'type' : 'list',
1042 'host_num_services_unknown' : {
1043 'depythonize' : lambda x: len([y for y in x.services if y.state_id == 3]),
1044 'description' : 'The number of the host\'s services with the soft state UNKNOWN',
1045 'prop' : 'host',
1046 'type' : 'list',
1048 'host_num_services_warn' : {
1049 'depythonize' : lambda x: len([y for y in x.services if y.state_id == 1]),
1050 'description' : 'The number of the host\'s services with the soft state WARN',
1051 'prop' : 'host',
1052 'type' : 'list',
1054 'host_obsess_over_host' : {
1055 'description' : 'The current obsess_over_host setting... (0/1)',
1056 'type' : 'int',
1058 'host_parents' : {
1059 'description' : 'A list of all direct parents of the host',
1060 'type' : 'list',
1062 'host_pending_flex_downtime' : {
1063 'description' : 'Wether a flex downtime is pending (0/1)',
1064 'type' : 'int',
1066 'host_percent_state_change' : {
1067 'description' : 'Percent state change',
1068 'type' : 'float',
1070 'host_perf_data' : {
1071 'description' : 'Optional performance data of the last host check',
1072 'type' : 'string',
1074 'host_plugin_output' : {
1075 'description' : 'Output of the last host check',
1076 'type' : 'string',
1078 'host_process_performance_data' : {
1079 'description' : 'Wether processing of performance data is enabled (0/1)',
1080 'type' : 'int',
1082 'host_retry_interval' : {
1083 'description' : 'Number of basic interval lengths between checks when retrying after a soft error',
1084 'type' : 'float',
1086 'host_scheduled_downtime_depth' : {
1087 'converter' : int,
1088 'depythonize' : lambda x: x.scheduled_downtime_depth,
1089 'description' : 'The number of downtimes this host is currently in',
1090 'prop' : 'host',
1091 'type' : 'int',
1093 'host_state' : {
1094 'converter' : int,
1095 'depythonize' : lambda x: x.state_id,
1096 'description' : 'The current state of the host (0: up, 1: down, 2: unreachable)',
1097 'prop' : 'host',
1098 'type' : 'int',
1100 'host_state_type' : {
1101 'description' : 'Type of the current state (0: soft, 1: hard)',
1102 'type' : 'int',
1104 'host_statusmap_image' : {
1105 'description' : 'The name of in image file for the status map',
1106 'type' : 'string',
1108 'host_total_services' : {
1109 'description' : 'The total number of services of the host',
1110 'type' : 'int',
1112 'host_worst_service_hard_state' : {
1113 'description' : 'The worst hard state of all of the host\'s services (OK <= WARN <= UNKNOWN <= CRIT)',
1114 'type' : 'list',
1116 'host_worst_service_state' : {
1117 'description' : 'The worst soft state of all of the host\'s services (OK <= WARN <= UNKNOWN <= CRIT)',
1118 'type' : 'list',
1120 'host_x_3d' : {
1121 'description' : '3D-Coordinates: X',
1122 'type' : 'float',
1124 'host_y_3d' : {
1125 'description' : '3D-Coordinates: Y',
1126 'type' : 'float',
1128 'host_z_3d' : {
1129 'description' : '3D-Coordinates: Z',
1130 'type' : 'float',
1132 'icon_image' : {
1133 'description' : 'The name of an image to be used as icon in the web interface',
1134 'type' : 'string',
1136 'icon_image_alt' : {
1137 'description' : 'An alternative text for the icon_image for browsers not displaying icons',
1138 'type' : 'string',
1140 'icon_image_expanded' : {
1141 'description' : 'The icon_image with (the most important) macros expanded',
1142 'type' : 'string',
1144 'in_check_period' : {
1145 'description' : 'Wether the service is currently in its check period (0/1)',
1146 'type' : 'int',
1148 'in_notification_period' : {
1149 'description' : 'Wether the service is currently in its notification period (0/1)',
1150 'type' : 'int',
1152 'initial_state' : {
1153 'description' : 'The initial state of the service',
1154 'type' : 'int',
1156 'is_executing' : {
1157 'default' : 0, # value in scheduler is not real-time
1158 'description' : 'is there a service check currently running... (0/1)',
1159 'type' : 'int',
1161 'is_flapping' : {
1162 'depythonize' : from_bool_to_int,
1163 'description' : 'Wether the service is flapping (0/1)',
1164 'type' : 'int',
1166 'last_check' : {
1167 'depythonize' : from_float_to_int,
1168 'description' : 'The time of the last check (Unix timestamp)',
1169 'prop' : 'last_chk',
1170 'type' : 'int',
1172 'last_hard_state' : {
1173 'description' : 'The last hard state of the service',
1174 'type' : 'int',
1176 'last_hard_state_change' : {
1177 'description' : 'The time of the last hard state change (Unix timestamp)',
1178 'type' : 'int',
1180 'last_notification' : {
1181 'depythonize' : to_int,
1182 'description' : 'The time of the last notification (Unix timestamp)',
1183 'type' : 'int',
1185 'last_state' : {
1186 'description' : 'The last state of the service',
1187 'type' : 'int',
1189 'last_state_change' : {
1190 'depythonize' : from_float_to_int,
1191 'description' : 'The time of the last state change (Unix timestamp)',
1192 'type' : 'int',
1194 'latency' : {
1195 'depythonize' : to_int,
1196 'description' : 'Time difference between scheduled check time and actual check time',
1197 'type' : 'float',
1199 'long_plugin_output' : {
1200 'description' : 'Unabbreviated output of the last check plugin',
1201 'prop' : 'long_output',
1202 'type' : 'string',
1204 'low_flap_threshold' : {
1205 'description' : 'Low threshold of flap detection',
1206 'type' : 'float',
1208 'max_check_attempts' : {
1209 'description' : 'The maximum number of check attempts',
1210 'type' : 'int',
1212 'next_check' : {
1213 'depythonize' : from_float_to_int,
1214 'description' : 'The scheduled time of the next check (Unix timestamp)',
1215 'prop' : 'next_chk',
1216 'type' : 'int',
1218 'next_notification' : {
1219 'description' : 'The time of the next notification (Unix timestamp)',
1220 'type' : 'int',
1222 'notes' : {
1223 'description' : 'Optional notes about the service',
1224 'type' : 'string',
1226 'notes_expanded' : {
1227 'description' : 'The notes with (the most important) macros expanded',
1228 'type' : 'string',
1230 'notes_url' : {
1231 'description' : 'An optional URL for additional notes about the service',
1232 'type' : 'string',
1234 'notes_url_expanded' : {
1235 'description' : 'The notes_url with (the most important) macros expanded',
1236 'type' : 'string',
1238 'notification_interval' : {
1239 'description' : 'Interval of periodic notification or 0 if its off',
1240 'type' : 'float',
1242 'notification_period' : {
1243 'depythonize' : 'get_name',
1244 'description' : 'The name of the notification period of the service. It this is empty, service problems are always notified.',
1245 'type' : 'string',
1247 'notifications_enabled' : {
1248 'depythonize' : from_bool_to_int,
1249 'description' : 'Wether notifications are enabled for the service (0/1)',
1250 'type' : 'int',
1252 'obsess_over_service' : {
1253 'depythonize' : from_bool_to_int,
1254 'description' : 'Wether \'obsess_over_service\' is enabled for the service (0/1)',
1255 'type' : 'int',
1257 'percent_state_change' : {
1258 'description' : 'Percent state change',
1259 'type' : 'float',
1261 'perf_data' : {
1262 'description' : 'Performance data of the last check plugin',
1263 'type' : 'string',
1265 'plugin_output' : {
1266 'description' : 'Output of the last check plugin',
1267 'prop' : 'output',
1268 'type' : 'string',
1270 'process_performance_data' : {
1271 'depythonize' : from_bool_to_int,
1272 'description' : 'Wether processing of performance data is enabled for the service (0/1)',
1273 'prop' : 'process_perf_data',
1274 'type' : 'int',
1276 'retry_interval' : {
1277 'description' : 'Number of basic interval lengths between checks when retrying after a soft error',
1278 'type' : 'float',
1280 'scheduled_downtime_depth' : {
1281 'converter' : int,
1282 'description' : 'The number of scheduled downtimes the service is currently in',
1283 'type' : 'int',
1285 'state' : {
1286 'converter' : int,
1287 'description' : 'The current state of the service (0: OK, 1: WARN, 2: CRITICAL, 3: UNKNOWN)',
1288 'prop' : 'state_id',
1289 'type' : 'int',
1291 'state_type' : {
1292 'converter' : int,
1293 'description' : 'The type of the current state (0: soft, 1: hard)',
1294 'prop' : 'state_type_id',
1295 'type' : 'int',
1297 'criticity' : {
1298 'converter' : int,
1299 'description' : 'The importance we gave to this service between hte minimum 0 and the maximum 5',
1300 'type' : 'int',
1302 'source_problems' : {
1303 'description' : 'The name of the source problems (host or service)',
1304 'prop' : 'source_problems',
1305 'type' : 'list',
1306 'depythonize' : from_svc_hst_distinct_lists,
1308 'impacts' : {
1309 'description' : 'List of what the source impact (list of hosts and services)',
1310 'prop' : 'impacts',
1311 'type' : 'list',
1312 'depythonize' : from_svc_hst_distinct_lists,
1317 'Hostgroup' : {
1318 'action_url' : {
1319 'description' : 'An optional URL to custom actions or information about the hostgroup',
1320 'type' : 'string',
1322 'alias' : {
1323 'description' : 'An alias of the hostgroup',
1324 'type' : 'string',
1326 'members' : {
1327 'depythonize' : 'get_name',
1328 'description' : 'A list of all host names that are members of the hostgroup',
1329 'type' : 'list',
1331 'name' : {
1332 'description' : 'Name of the hostgroup',
1333 'prop' : 'hostgroup_name',
1334 'type' : 'string',
1336 'notes' : {
1337 'description' : 'Optional notes to the hostgroup',
1338 'type' : 'string',
1340 'notes_url' : {
1341 'description' : 'An optional URL with further information about the hostgroup',
1342 'type' : 'string',
1344 'num_hosts' : {
1345 'depythonize' : lambda x: len(x),
1346 'description' : 'The total number of hosts in the group',
1347 'prop' : 'get_hosts',
1348 'type' : 'list',
1350 'num_hosts_down' : {
1351 'depythonize' : lambda x: len([y for y in x if y.state_id == 1]),
1352 'description' : 'The number of hosts in the group that are down',
1353 'prop' : 'get_hosts',
1354 'type' : 'list',
1356 'num_hosts_pending' : {
1357 'depythonize' : lambda x: len([y for y in x if y.has_been_checked == 0]),
1358 'description' : 'The number of hosts in the group that are pending',
1359 'prop' : 'get_hosts',
1360 'type' : 'list',
1362 'num_hosts_unreach' : {
1363 'depythonize' : lambda x: len([y for y in x if y.state_id == 2]),
1364 'description' : 'The number of hosts in the group that are unreachable',
1365 'prop' : 'get_hosts',
1366 'type' : 'list',
1368 'num_hosts_up' : {
1369 'depythonize' : lambda x: len([y for y in x if y.state_id == 0]),
1370 'description' : 'The number of hosts in the group that are up',
1371 'prop' : 'get_hosts',
1372 'type' : 'list',
1374 'num_services' : {
1375 'depythonize' : lambda x: sum((len(y.service_ids) for y in x)),
1376 'description' : 'The total number of services of hosts in this group',
1377 'prop' : 'get_hosts',
1378 'type' : 'list',
1380 'num_services_crit' : {
1381 'depythonize' : lambda x: len([z for y in x for z in y.services if z.state_id == 2]),
1382 'description' : 'The total number of services with the state CRIT of hosts in this group',
1383 'prop' : 'get_hosts',
1384 'type' : 'list',
1386 'num_services_hard_crit' : {
1387 '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]),
1388 'description' : 'The total number of services with the state CRIT of hosts in this group',
1389 'prop' : 'get_hosts',
1390 'type' : 'list',
1392 'num_services_hard_ok' : {
1393 '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]),
1394 'description' : 'The total number of services with the state OK of hosts in this group',
1395 'prop' : 'get_hosts',
1396 'type' : 'list',
1398 'num_services_hard_unknown' : {
1399 '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]),
1400 'description' : 'The total number of services with the state UNKNOWN of hosts in this group',
1401 'prop' : 'get_hosts',
1402 'type' : 'list',
1404 'num_services_hard_warn' : {
1405 '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]),
1406 'description' : 'The total number of services with the state WARN of hosts in this group',
1407 'prop' : 'get_hosts',
1408 'type' : 'list',
1410 'num_services_ok' : {
1411 'depythonize' : lambda x: len([z for y in x for z in y.services if z.state_id == 0]),
1412 'description' : 'The total number of services with the state OK of hosts in this group',
1413 'prop' : 'get_hosts',
1414 'type' : 'list',
1416 'num_services_pending' : {
1417 'depythonize' : lambda x: len([z for y in x for z in y.services if z.has_been_checked == 0]),
1418 'description' : 'The total number of services with the state Pending of hosts in this group',
1419 'prop' : 'get_hosts',
1420 'type' : 'list',
1422 'num_services_unknown' : {
1423 'depythonize' : lambda x: len([z for y in x for z in y.services if z.state_id == 3]),
1424 'description' : 'The total number of services with the state UNKNOWN of hosts in this group',
1425 'prop' : 'get_hosts',
1426 'type' : 'list',
1428 'num_services_warn' : {
1429 'depythonize' : lambda x: len([z for y in x for z in y.services if z.state_id == 1]),
1430 'description' : 'The total number of services with the state WARN of hosts in this group',
1431 'prop' : 'get_hosts',
1432 'type' : 'list',
1434 'worst_host_state' : {
1435 'depythonize' : lambda x: reduce(worst_host_state, (y.state_id for y in x), 0),
1436 'description' : 'The worst state of all of the groups\' hosts (UP <= UNREACHABLE <= DOWN)',
1437 'prop' : 'get_hosts',
1438 'type' : 'list',
1440 'worst_service_hard_state' : {
1441 '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),
1442 'description' : 'The worst state of all services that belong to a host of this group (OK <= WARN <= UNKNOWN <= CRIT)',
1443 'prop' : 'get_hosts',
1444 'type' : 'list',
1446 'worst_service_state' : {
1447 'depythonize' : lambda x: reduce(worst_service_state, (z.state_id for y in x for z in y.services), 0),
1448 'description' : 'The worst state of all services that belong to a host of this group (OK <= WARN <= UNKNOWN <= CRIT)',
1449 'prop' : 'get_hosts',
1450 'type' : 'list',
1454 'Servicegroup' : {
1455 'action_url' : {
1456 'description' : 'An optional URL to custom notes or actions on the service group',
1457 'type' : 'string',
1459 'alias' : {
1460 'description' : 'An alias of the service group',
1461 'type' : 'string',
1463 'members' : {
1464 'depythonize' : 'get_full_name',
1465 'description' : 'A list of all members of the service group as host/service pairs ',
1466 'type' : 'list',
1468 'name' : {
1469 'description' : 'The name of the service group',
1470 'prop' : 'servicegroup_name',
1471 'type' : 'string',
1473 'notes' : {
1474 'description' : 'Optional additional notes about the service group',
1475 'type' : 'string',
1477 'notes_url' : {
1478 'description' : 'An optional URL to further notes on the service group',
1479 'type' : 'string',
1481 'num_services' : {
1482 'converter' : int,
1483 'depythonize' : lambda x: len(x),
1484 'description' : 'The total number of services in the group',
1485 'prop' : 'get_services',
1486 'type' : 'list',
1488 'num_services_crit' : {
1489 'converter' : int,
1490 'depythonize' : lambda x: len([y for y in x if y.state_id == 2]),
1491 'description' : 'The number of services in the group that are CRIT',
1492 'prop' : 'get_services',
1493 'type' : 'list',
1495 'num_services_hard_crit' : {
1496 'converter' : int,
1497 'depythonize' : lambda x: len([y for y in x if y.state_id == 2 and y.state_type_id == 1]),
1498 'description' : 'The number of services in the group that are CRIT',
1499 'prop' : 'get_services',
1500 'type' : 'list',
1502 'num_services_hard_ok' : {
1503 'converter' : int,
1504 'depythonize' : lambda x: len([y for y in x if y.state_id == 0 and y.state_type_id == 1]),
1505 'description' : 'The number of services in the group that are OK',
1506 'prop' : 'get_services',
1507 'type' : 'list',
1509 'num_services_hard_unknown' : {
1510 'converter' : int,
1511 'depythonize' : lambda x: len([y for y in x if y.state_id == 3 and y.state_type_id == 1]),
1512 'description' : 'The number of services in the group that are UNKNOWN',
1513 'prop' : 'get_services',
1514 'type' : 'list',
1516 'num_services_hard_warn' : {
1517 'converter' : int,
1518 'depythonize' : lambda x: len([y for y in x if y.state_id == 2 and y.state_type_id == 1]),
1519 'description' : 'The number of services in the group that are WARN',
1520 'prop' : 'get_services',
1521 'type' : 'list',
1523 'num_services_ok' : {
1524 'converter' : int,
1525 'depythonize' : lambda x: len([y for y in x if y.state_id == 0]),
1526 'description' : 'The number of services in the group that are OK',
1527 'prop' : 'get_services',
1528 'type' : 'list',
1530 'num_services_pending' : {
1531 'converter' : int,
1532 'depythonize' : lambda x: len([y for y in x if y.has_been_checked == 0]),
1533 'description' : 'The number of services in the group that are PENDING',
1534 'prop' : 'get_services',
1535 'type' : 'list',
1537 'num_services_unknown' : {
1538 'converter' : int,
1539 'depythonize' : lambda x: len([y for y in x if y.state_id == 3]),
1540 'description' : 'The number of services in the group that are UNKNOWN',
1541 'prop' : 'get_services',
1542 'type' : 'list',
1544 'num_services_warn' : {
1545 'converter' : int,
1546 'depythonize' : lambda x: len([y for y in x if y.state_id == 1]),
1547 'description' : 'The number of services in the group that are WARN',
1548 'prop' : 'get_services',
1549 'type' : 'list',
1551 'worst_service_state' : {
1552 'depythonize' : lambda x: reduce(worst_service_state, (y.state_id for y in x), 0),
1553 'description' : 'The worst soft state of all of the groups services (OK <= WARN <= UNKNOWN <= CRIT)',
1554 'prop' : 'get_services',
1555 'type' : 'list',
1559 'Contact' : {
1560 'address1' : {
1561 'description' : 'The additional field address1',
1562 'type' : 'string',
1564 'address2' : {
1565 'description' : 'The additional field address2',
1566 'type' : 'string',
1568 'address3' : {
1569 'description' : 'The additional field address3',
1570 'type' : 'string',
1572 'address4' : {
1573 'description' : 'The additional field address4',
1574 'type' : 'string',
1576 'address5' : {
1577 'description' : 'The additional field address5',
1578 'type' : 'string',
1580 'address6' : {
1581 'description' : 'The additional field address6',
1582 'type' : 'string',
1584 'alias' : {
1585 'description' : 'The full name of the contact',
1586 'type' : 'string',
1588 'can_submit_commands' : {
1589 'depythonize' : from_bool_to_int,
1590 'description' : 'Wether the contact is allowed to submit commands (0/1)',
1591 'type' : 'int',
1593 'custom_variable_names' : {
1594 'description' : 'A list of all custom variables of the contact',
1595 'type' : 'list',
1597 'custom_variable_values' : {
1598 'description' : 'A list of the values of all custom variables of the contact',
1599 'type' : 'list',
1601 'email' : {
1602 'description' : 'The email address of the contact',
1603 'type' : 'string',
1605 'host_notification_period' : {
1606 'depythonize' : 'get_name',
1607 'description' : 'The time period in which the contact will be notified about host problems',
1608 'type' : 'string',
1610 'host_notifications_enabled' : {
1611 'depythonize' : from_bool_to_int,
1612 'description' : 'Wether the contact will be notified about host problems in general (0/1)',
1613 'type' : 'int',
1615 'in_host_notification_period' : {
1616 'depythonize' : from_bool_to_int,
1617 'description' : 'Wether the contact is currently in his/her host notification period (0/1)',
1618 'type' : 'int',
1620 'in_service_notification_period' : {
1621 'depythonize' : from_bool_to_int,
1622 'description' : 'Wether the contact is currently in his/her service notification period (0/1)',
1623 'type' : 'int',
1625 'name' : {
1626 'description' : 'The login name of the contact person',
1627 'prop' : 'contact_name',
1628 'type' : 'string',
1630 'pager' : {
1631 'description' : 'The pager address of the contact',
1632 'type' : 'string',
1634 'service_notification_period' : {
1635 'depythonize' : 'get_name',
1636 'description' : 'The time period in which the contact will be notified about service problems',
1637 'type' : 'string',
1639 'service_notifications_enabled' : {
1640 'depythonize' : from_bool_to_int,
1641 'description' : 'Wether the contact will be notified about service problems in general (0/1)',
1642 'type' : 'int',
1647 #Group of contacts
1648 'Contactgroup' : {
1649 'alias' : {
1650 'description' : 'The alias of the contactgroup',
1651 'type' : 'string',
1653 'members' : {
1654 'depythonize' : 'get_name',
1655 'description' : 'A list of all members of this contactgroup',
1656 'type' : 'list',
1658 'name' : {
1659 'description' : 'The name of the contactgroup',
1660 'prop' : 'contactgroup_name',
1661 'type' : 'string',
1666 #Timeperiods
1667 'Timeperiod' : {
1668 'alias' : {
1669 'description' : 'The alias of the timeperiod',
1670 'type' : 'string',
1672 'name' : {
1673 'description' : 'The name of the timeperiod',
1674 'prop' : 'timeperiod_name',
1675 'type' : 'string',
1679 #All commands (checks + notifications)
1680 'Command' : {
1681 'line' : {
1682 'description' : 'The shell command line',
1683 'prop' : 'command_line',
1684 'type' : 'string',
1686 'name' : {
1687 'description' : 'The name of the command',
1688 'prop' : 'command_name',
1689 'type' : 'string',
1694 ###Satellites
1695 #Schedulers
1696 'SchedulerLink' : {
1697 'name' : {
1698 'description' : 'The name of the scheduler',
1699 'prop' : 'scheduler_name',
1700 'type' : 'string',
1702 'address' : {
1703 'description' : 'The ip or dns adress ofthe scheduler',
1704 'prop' : 'address',
1705 'type' : 'string',
1707 'port' : {
1708 'description' : 'The TCP port of the scheduler',
1709 'prop' : 'port',
1710 'type' : 'int',
1712 'spare' : {
1713 'description' : 'If the scheduler is a spare or not',
1714 'depythonize' : from_bool_to_int,
1715 'prop' : 'spare',
1716 'type' : 'int',
1718 'weight' : {
1719 'description' : 'Weight (in terms of hosts) of the scheduler',
1720 'prop' : 'weight',
1721 'type' : 'int',
1723 'alive' : {
1724 'description' : 'If the scheduler is alive or not',
1725 'prop' : 'alive',
1726 'depythonize' : from_bool_to_int,
1727 'type' : 'int',
1733 #Pollers
1734 'PollerLink' : {
1735 'name' : {
1736 'description' : 'The name of the poller',
1737 'prop' : 'poller_name',
1738 'type' : 'string',
1740 'address' : {
1741 'description' : 'The ip or dns adress of the poller',
1742 'prop' : 'address',
1743 'type' : 'string',
1745 'port' : {
1746 'description' : 'The TCP port of the poller',
1747 'prop' : 'port',
1748 'type' : 'int',
1750 'spare' : {
1751 'description' : 'If the poller is a spare or not',
1752 'depythonize' : from_bool_to_int,
1753 'prop' : 'spare',
1754 'type' : 'int',
1756 'alive' : {
1757 'description' : 'If the poller is alive or not',
1758 'prop' : 'alive',
1759 'depythonize' : from_bool_to_int,
1760 'type' : 'int',
1765 #Reactionners
1766 'ReactionnerLink' : {
1767 'name' : {
1768 'description' : 'The name of the reactionner',
1769 'prop' : 'reactionner_name',
1770 'type' : 'string',
1772 'address' : {
1773 'description' : 'The ip or dns adress of the reactionner',
1774 'prop' : 'address',
1775 'type' : 'string',
1777 'port' : {
1778 'description' : 'The TCP port of the reactionner',
1779 'prop' : 'port',
1780 'type' : 'int',
1782 'spare' : {
1783 'description' : 'If the reactionner is a spare or not',
1784 'depythonize' : from_bool_to_int,
1785 'prop' : 'spare',
1786 'type' : 'int',
1788 'alive' : {
1789 'description' : 'If the reactionner is alive or not',
1790 'prop' : 'alive',
1791 'depythonize' : from_bool_to_int,
1792 'type' : 'int',
1797 #Brokers
1798 'BrokerLink' : {
1799 'name' : {
1800 'description' : 'The name of the broker',
1801 'prop' : 'broker_name',
1802 'type' : 'string',
1804 'address' : {
1805 'description' : 'The ip or dns adress of the broker',
1806 'prop' : 'address',
1807 'type' : 'string',
1809 'port' : {
1810 'description' : 'The TCP port of the broker',
1811 'prop' : 'port',
1812 'type' : 'int',
1814 'spare' : {
1815 'description' : 'If the broker is a spare or not',
1816 'depythonize' : from_bool_to_int,
1817 'prop' : 'spare',
1818 'type' : 'int',
1820 'alive' : {
1821 'description' : 'If the broker is alive or not',
1822 'prop' : 'alive',
1823 'depythonize' : from_bool_to_int,
1824 'type' : 'int',
1829 #Problem
1830 'Problem' : {
1831 'source' : {
1832 'description' : 'The source name of the problem (host or service)',
1833 'prop' : 'source',
1834 'type' : 'string',
1835 'depythonize' : get_common_full_name
1837 'impacts' : {
1838 'description' : 'List of what the source impact (list of hosts and services)',
1839 'prop' : 'impacts',
1840 'type' : 'string',
1841 'depythonize' : from_svc_hst_distinct_lists,
1846 #Downtimes
1847 'Downtime' : {
1848 'author' : {
1849 'default' : 'nobody',
1850 'description' : 'The contact that scheduled the downtime',
1851 'prop' : None,
1852 'type' : 'string',
1854 'comment' : {
1855 'default' : None,
1856 'description' : 'A comment text',
1857 'prop' : None,
1858 'type' : 'string',
1860 'duration' : {
1861 'default' : '0',
1862 'description' : 'The duration of the downtime in seconds',
1863 'prop' : None,
1864 'type' : 'int',
1866 'end_time' : {
1867 'default' : '0',
1868 'description' : 'The end time of the downtime as UNIX timestamp',
1869 'prop' : None,
1870 'type' : 'int',
1872 'entry_time' : {
1873 'default' : '0',
1874 'description' : 'The time the entry was made as UNIX timestamp',
1875 'prop' : None,
1876 'type' : 'int',
1878 'fixed' : {
1879 'default' : None,
1880 'depythonize' : from_bool_to_int,
1881 'description' : 'A 1 if the downtime is fixed, a 0 if it is flexible',
1882 'prop' : None,
1883 'type' : 'int',
1885 'host_accept_passive_checks' : {
1886 'default' : None,
1887 'description' : 'Wether passive host checks are accepted (0/1)',
1888 'prop' : None,
1889 'type' : 'int',
1891 'host_acknowledged' : {
1892 'default' : None,
1893 'description' : 'Wether the current host problem has been acknowledged (0/1)',
1894 'prop' : None,
1895 'type' : 'int',
1897 'host_acknowledgement_type' : {
1898 'default' : None,
1899 'description' : 'Type of acknowledgement (0: none, 1: normal, 2: stick)',
1900 'prop' : None,
1901 'type' : 'int',
1903 'host_action_url' : {
1904 'default' : None,
1905 'description' : 'An optional URL to custom actions or information about this host',
1906 'prop' : None,
1907 'type' : 'string',
1909 'host_action_url_expanded' : {
1910 'default' : None,
1911 'description' : 'The same as action_url, but with the most important macros expanded',
1912 'prop' : None,
1913 'type' : 'string',
1915 'host_active_checks_enabled' : {
1916 'default' : None,
1917 'description' : 'Wether active checks are enabled for the host (0/1)',
1918 'prop' : None,
1919 'type' : 'int',
1921 'host_address' : {
1922 'default' : None,
1923 'description' : 'IP address',
1924 'prop' : None,
1925 'type' : 'string',
1927 'host_alias' : {
1928 'default' : None,
1929 'description' : 'An alias name for the host',
1930 'prop' : None,
1931 'type' : 'string',
1933 'host_check_command' : {
1934 'default' : None,
1935 'description' : 'Nagios command for active host check of this host',
1936 'prop' : None,
1937 'type' : 'string',
1939 'host_check_freshness' : {
1940 'default' : None,
1941 'description' : 'Wether freshness checks are activated (0/1)',
1942 'prop' : None,
1943 'type' : 'int',
1945 'host_check_interval' : {
1946 'default' : None,
1947 'description' : 'Number of basic interval lengths between two scheduled checks of the host',
1948 'prop' : None,
1949 'type' : 'float',
1951 'host_check_options' : {
1952 'default' : None,
1953 'description' : 'The current check option, forced, normal, freshness... (0-2)',
1954 'prop' : None,
1955 'type' : 'int',
1957 'host_check_period' : {
1958 'default' : None,
1959 'description' : 'Time period in which this host will be checked. If empty then the host will always be checked.',
1960 'prop' : None,
1961 'type' : 'string',
1963 'host_check_type' : {
1964 'default' : None,
1965 'description' : 'Type of check (0: active, 1: passive)',
1966 'prop' : None,
1967 'type' : 'int',
1969 'host_checks_enabled' : {
1970 'default' : None,
1971 'description' : 'Wether checks of the host are enabled (0/1)',
1972 'prop' : None,
1973 'type' : 'int',
1975 'host_childs' : {
1976 'default' : None,
1977 'description' : 'A list of all direct childs of the host',
1978 'prop' : None,
1979 'type' : 'list',
1981 'host_comments' : {
1982 'default' : None,
1983 'description' : 'A list of the ids of all comments of this host',
1984 'prop' : None,
1985 'type' : 'list',
1987 'host_contacts' : {
1988 'default' : None,
1989 'description' : 'A list of all contacts of this host, either direct or via a contact group',
1990 'prop' : None,
1991 'type' : 'list',
1993 'host_current_attempt' : {
1994 'default' : None,
1995 'description' : 'Number of the current check attempts',
1996 'prop' : None,
1997 'type' : 'int',
1999 'host_current_notification_number' : {
2000 'default' : None,
2001 'description' : 'Number of the current notification',
2002 'prop' : None,
2003 'type' : 'int',
2005 'host_custom_variable_names' : {
2006 'default' : None,
2007 'description' : 'A list of the names of all custom variables',
2008 'prop' : None,
2009 'type' : 'list',
2011 'host_custom_variable_values' : {
2012 'default' : None,
2013 'description' : 'A list of the values of the custom variables',
2014 'prop' : None,
2015 'type' : 'list',
2017 'host_display_name' : {
2018 'default' : None,
2019 'description' : 'Optional display name of the host - not used by Nagios\' web interface',
2020 'prop' : None,
2021 'type' : 'string',
2023 'host_downtimes' : {
2024 'default' : None,
2025 'description' : 'A list of the ids of all scheduled downtimes of this host',
2026 'prop' : None,
2027 'type' : 'list',
2029 'host_event_handler_enabled' : {
2030 'default' : None,
2031 'description' : 'Wether event handling is enabled (0/1)',
2032 'prop' : None,
2033 'type' : 'int',
2035 'host_execution_time' : {
2036 'default' : None,
2037 'description' : 'Time the host check needed for execution',
2038 'prop' : None,
2039 'type' : 'float',
2041 'host_first_notification_delay' : {
2042 'default' : None,
2043 'description' : 'Delay before the first notification',
2044 'prop' : None,
2045 'type' : 'float',
2047 'host_flap_detection_enabled' : {
2048 'default' : None,
2049 'description' : 'Wether flap detection is enabled (0/1)',
2050 'prop' : None,
2051 'type' : 'int',
2053 'host_groups' : {
2054 'default' : None,
2055 'description' : 'A list of all host groups this host is in',
2056 'prop' : None,
2057 'type' : 'list',
2059 'host_hard_state' : {
2060 'default' : None,
2061 'description' : 'The effective hard state of the host (eliminates a problem in hard_state)',
2062 'prop' : None,
2063 'type' : 'int',
2065 'host_has_been_checked' : {
2066 'default' : None,
2067 'description' : 'Wether the host has already been checked (0/1)',
2068 'prop' : None,
2069 'type' : 'int',
2071 'host_high_flap_threshold' : {
2072 'default' : None,
2073 'description' : 'High threshold of flap detection',
2074 'prop' : None,
2075 'type' : 'float',
2077 'host_icon_image' : {
2078 'default' : None,
2079 'description' : 'The name of an image file to be used in the web pages',
2080 'prop' : None,
2081 'type' : 'string',
2083 'host_icon_image_alt' : {
2084 'default' : None,
2085 'description' : 'Alternative text for the icon_image',
2086 'prop' : None,
2087 'type' : 'string',
2089 'host_icon_image_expanded' : {
2090 'default' : None,
2091 'description' : 'The same as icon_image, but with the most important macros expanded',
2092 'prop' : None,
2093 'type' : 'string',
2095 'host_in_check_period' : {
2096 'default' : None,
2097 'description' : 'Wether this host is currently in its check period (0/1)',
2098 'prop' : None,
2099 'type' : 'int',
2101 'host_in_notification_period' : {
2102 'default' : None,
2103 'description' : 'Wether this host is currently in its notification period (0/1)',
2104 'prop' : None,
2105 'type' : 'int',
2107 'host_initial_state' : {
2108 'default' : None,
2109 'description' : 'Initial host state',
2110 'prop' : None,
2111 'type' : 'int',
2113 'host_is_executing' : {
2114 'default' : 0, # value in scheduler is not real-time
2115 'description' : 'is there a host check currently running... (0/1)',
2116 'prop' : None,
2117 'type' : 'int',
2119 'host_is_flapping' : {
2120 'default' : None,
2121 'description' : 'Wether the host state is flapping (0/1)',
2122 'prop' : None,
2123 'type' : 'int',
2125 'host_last_check' : {
2126 'default' : None,
2127 'description' : 'Time of the last check (Unix timestamp)',
2128 'prop' : None,
2129 'type' : 'int',
2131 'host_last_hard_state' : {
2132 'default' : None,
2133 'description' : 'Last hard state',
2134 'prop' : None,
2135 'type' : 'int',
2137 'host_last_hard_state_change' : {
2138 'default' : None,
2139 'description' : 'Time of the last hard state change (Unix timestamp)',
2140 'prop' : None,
2141 'type' : 'int',
2143 'host_last_notification' : {
2144 'default' : None,
2145 'description' : 'Time of the last notification (Unix timestamp)',
2146 'prop' : None,
2147 'type' : 'int',
2149 'host_last_state' : {
2150 'default' : None,
2151 'description' : 'State before last state change',
2152 'prop' : None,
2153 'type' : 'int',
2155 'host_last_state_change' : {
2156 'default' : None,
2157 'description' : 'Time of the last state change - soft or hard (Unix timestamp)',
2158 'prop' : None,
2159 'type' : 'int',
2161 'host_latency' : {
2162 'default' : None,
2163 'description' : 'Time difference between scheduled check time and actual check time',
2164 'prop' : None,
2165 'type' : 'float',
2167 'host_long_plugin_output' : {
2168 'default' : None,
2169 'description' : 'Complete output from check plugin',
2170 'prop' : None,
2171 'type' : 'string',
2173 'host_low_flap_threshold' : {
2174 'default' : None,
2175 'description' : 'Low threshold of flap detection',
2176 'prop' : None,
2177 'type' : 'float',
2179 'host_max_check_attempts' : {
2180 'default' : None,
2181 'description' : 'Max check attempts for active host checks',
2182 'prop' : None,
2183 'type' : 'int',
2185 'host_name' : {
2186 'default' : None,
2187 'depythonize' : lambda x: x.host_name,
2188 'description' : 'Host name',
2189 'prop' : 'ref',
2190 'type' : 'string',
2192 'host_next_check' : {
2193 'default' : None,
2194 'description' : 'Scheduled time for the next check (Unix timestamp)',
2195 'prop' : None,
2196 'type' : 'int',
2198 'host_next_notification' : {
2199 'default' : None,
2200 'description' : 'Time of the next notification (Unix timestamp)',
2201 'prop' : None,
2202 'type' : 'int',
2204 'host_notes' : {
2205 'default' : None,
2206 'description' : 'Optional notes for this host',
2207 'prop' : None,
2208 'type' : 'string',
2210 'host_notes_expanded' : {
2211 'default' : None,
2212 'description' : 'The same as notes, but with the most important macros expanded',
2213 'prop' : None,
2214 'type' : 'string',
2216 'host_notes_url' : {
2217 'default' : None,
2218 'description' : 'An optional URL with further information about the host',
2219 'prop' : None,
2220 'type' : 'string',
2222 'host_notes_url_expanded' : {
2223 'default' : None,
2224 'description' : 'Same es notes_url, but with the most important macros expanded',
2225 'prop' : None,
2226 'type' : 'string',
2228 'host_notification_interval' : {
2229 'default' : None,
2230 'description' : 'Interval of periodic notification or 0 if its off',
2231 'prop' : None,
2232 'type' : 'float',
2234 'host_notification_period' : {
2235 'default' : None,
2236 'description' : 'Time period in which problems of this host will be notified. If empty then notification will be always',
2237 'prop' : None,
2238 'type' : 'string',
2240 'host_notifications_enabled' : {
2241 'default' : None,
2242 'description' : 'Wether notifications of the host are enabled (0/1)',
2243 'prop' : None,
2244 'type' : 'int',
2246 'host_num_services' : {
2247 'default' : None,
2248 'description' : 'The total number of services of the host',
2249 'prop' : None,
2250 'type' : 'list',
2252 'host_num_services_crit' : {
2253 'default' : None,
2254 'description' : 'The number of the host\'s services with the soft state CRIT',
2255 'prop' : None,
2256 'type' : 'list',
2258 'host_num_services_hard_crit' : {
2259 'default' : None,
2260 'description' : 'The number of the host\'s services with the hard state CRIT',
2261 'prop' : None,
2262 'type' : 'list',
2264 'host_num_services_hard_ok' : {
2265 'default' : None,
2266 'description' : 'The number of the host\'s services with the hard state OK',
2267 'prop' : None,
2268 'type' : 'list',
2270 'host_num_services_hard_unknown' : {
2271 'default' : None,
2272 'description' : 'The number of the host\'s services with the hard state UNKNOWN',
2273 'prop' : None,
2274 'type' : 'list',
2276 'host_num_services_hard_warn' : {
2277 'default' : None,
2278 'description' : 'The number of the host\'s services with the hard state WARN',
2279 'prop' : None,
2280 'type' : 'list',
2282 'host_num_services_ok' : {
2283 'default' : None,
2284 'description' : 'The number of the host\'s services with the soft state OK',
2285 'prop' : None,
2286 'type' : 'list',
2288 'host_num_services_pending' : {
2289 'default' : None,
2290 'description' : 'The number of the host\'s services which have not been checked yet (pending)',
2291 'prop' : None,
2292 'type' : 'list',
2294 'host_num_services_unknown' : {
2295 'default' : None,
2296 'description' : 'The number of the host\'s services with the soft state UNKNOWN',
2297 'prop' : None,
2298 'type' : 'list',
2300 'host_num_services_warn' : {
2301 'default' : None,
2302 'description' : 'The number of the host\'s services with the soft state WARN',
2303 'prop' : None,
2304 'type' : 'list',
2306 'host_obsess_over_host' : {
2307 'default' : None,
2308 'description' : 'The current obsess_over_host setting... (0/1)',
2309 'prop' : None,
2310 'type' : 'int',
2312 'host_parents' : {
2313 'default' : None,
2314 'description' : 'A list of all direct parents of the host',
2315 'prop' : None,
2316 'type' : 'list',
2318 'host_pending_flex_downtime' : {
2319 'default' : None,
2320 'description' : 'Wether a flex downtime is pending (0/1)',
2321 'prop' : None,
2322 'type' : 'int',
2324 'host_percent_state_change' : {
2325 'default' : None,
2326 'description' : 'Percent state change',
2327 'prop' : None,
2328 'type' : 'float',
2330 'host_perf_data' : {
2331 'default' : None,
2332 'description' : 'Optional performance data of the last host check',
2333 'prop' : None,
2334 'type' : 'string',
2336 'host_plugin_output' : {
2337 'default' : None,
2338 'description' : 'Output of the last host check',
2339 'prop' : None,
2340 'type' : 'string',
2342 'host_process_performance_data' : {
2343 'default' : None,
2344 'description' : 'Wether processing of performance data is enabled (0/1)',
2345 'prop' : None,
2346 'type' : 'int',
2348 'host_retry_interval' : {
2349 'default' : None,
2350 'description' : 'Number of basic interval lengths between checks when retrying after a soft error',
2351 'prop' : None,
2352 'type' : 'float',
2354 'host_scheduled_downtime_depth' : {
2355 'default' : None,
2356 'description' : 'The number of downtimes this host is currently in',
2357 'prop' : None,
2358 'type' : 'int',
2360 'host_state' : {
2361 'default' : None,
2362 'description' : 'The current state of the host (0: up, 1: down, 2: unreachable)',
2363 'prop' : None,
2364 'type' : 'int',
2366 'host_state_type' : {
2367 'default' : None,
2368 'description' : 'Type of the current state (0: soft, 1: hard)',
2369 'prop' : None,
2370 'type' : 'int',
2372 'host_statusmap_image' : {
2373 'default' : None,
2374 'description' : 'The name of in image file for the status map',
2375 'prop' : None,
2376 'type' : 'string',
2378 'host_total_services' : {
2379 'default' : None,
2380 'description' : 'The total number of services of the host',
2381 'prop' : None,
2382 'type' : 'int',
2384 'host_worst_service_hard_state' : {
2385 'default' : None,
2386 'description' : 'The worst hard state of all of the host\'s services (OK <= WARN <= UNKNOWN <= CRIT)',
2387 'prop' : None,
2388 'type' : 'list',
2390 'host_worst_service_state' : {
2391 'default' : None,
2392 'description' : 'The worst soft state of all of the host\'s services (OK <= WARN <= UNKNOWN <= CRIT)',
2393 'prop' : None,
2394 'type' : 'list',
2396 'host_x_3d' : {
2397 'default' : None,
2398 'description' : '3D-Coordinates: X',
2399 'prop' : None,
2400 'type' : 'float',
2402 'host_y_3d' : {
2403 'default' : None,
2404 'description' : '3D-Coordinates: Y',
2405 'prop' : None,
2406 'type' : 'float',
2408 'host_z_3d' : {
2409 'default' : None,
2410 'description' : '3D-Coordinates: Z',
2411 'prop' : None,
2412 'type' : 'float',
2414 'id' : {
2415 'default' : None,
2416 'description' : 'The id of the downtime',
2417 'prop' : None,
2418 'type' : 'int',
2420 'service_accept_passive_checks' : {
2421 'default' : None,
2422 'description' : 'Wether the service accepts passive checks (0/1)',
2423 'prop' : None,
2424 'type' : 'int',
2426 'service_acknowledged' : {
2427 'default' : None,
2428 'description' : 'Wether the current service problem has been acknowledged (0/1)',
2429 'prop' : None,
2430 'type' : 'int',
2432 'service_acknowledgement_type' : {
2433 'default' : None,
2434 'description' : 'The type of the acknownledgement (0: none, 1: normal, 2: sticky)',
2435 'prop' : None,
2436 'type' : 'int',
2438 'service_action_url' : {
2439 'default' : None,
2440 'description' : 'An optional URL for actions or custom information about the service',
2441 'prop' : None,
2442 'type' : 'string',
2444 'service_action_url_expanded' : {
2445 'default' : None,
2446 'description' : 'The action_url with (the most important) macros expanded',
2447 'prop' : None,
2448 'type' : 'string',
2450 'service_active_checks_enabled' : {
2451 'default' : None,
2452 'description' : 'Wether active checks are enabled for the service (0/1)',
2453 'prop' : None,
2454 'type' : 'int',
2456 'service_check_command' : {
2457 'default' : None,
2458 'description' : 'Nagios command used for active checks',
2459 'prop' : None,
2460 'type' : 'string',
2462 'service_check_interval' : {
2463 'default' : None,
2464 'description' : 'Number of basic interval lengths between two scheduled checks of the service',
2465 'prop' : None,
2466 'type' : 'float',
2468 'service_check_options' : {
2469 'default' : None,
2470 'description' : 'The current check option, forced, normal, freshness... (0/1)',
2471 'prop' : None,
2472 'type' : 'int',
2474 'service_check_period' : {
2475 'default' : None,
2476 'description' : 'The name of the check period of the service. It this is empty, the service is always checked.',
2477 'prop' : None,
2478 'type' : 'string',
2480 'service_check_type' : {
2481 'default' : None,
2482 'description' : 'The type of the last check (0: active, 1: passive)',
2483 'prop' : None,
2484 'type' : 'int',
2486 'service_checks_enabled' : {
2487 'default' : None,
2488 'description' : 'Wether active checks are enabled for the service (0/1)',
2489 'prop' : None,
2490 'type' : 'int',
2492 'service_comments' : {
2493 'default' : None,
2494 'description' : 'A list of all comment ids of the service',
2495 'prop' : None,
2496 'type' : 'list',
2498 'service_contacts' : {
2499 'default' : None,
2500 'description' : 'A list of all contacts of the service, either direct or via a contact group',
2501 'prop' : None,
2502 'type' : 'list',
2504 'service_current_attempt' : {
2505 'default' : None,
2506 'description' : 'The number of the current check attempt',
2507 'prop' : None,
2508 'type' : 'int',
2510 'service_current_notification_number' : {
2511 'default' : None,
2512 'description' : 'The number of the current notification',
2513 'prop' : None,
2514 'type' : 'int',
2516 'service_custom_variable_names' : {
2517 'default' : None,
2518 'description' : 'A list of the names of all custom variables of the service',
2519 'prop' : None,
2520 'type' : 'list',
2522 'service_custom_variable_values' : {
2523 'default' : None,
2524 'description' : 'A list of the values of all custom variable of the service',
2525 'prop' : None,
2526 'type' : 'list',
2528 'service_description' : {
2529 'default' : None,
2530 'depythonize' : lambda x: getattr(x, 'service_description', ''),
2531 'description' : 'Description of the service (also used as key)',
2532 'prop' : 'ref',
2533 'type' : 'string',
2535 'service_display_name' : {
2536 'default' : None,
2537 'description' : 'An optional display name (not used by Nagios standard web pages)',
2538 'prop' : None,
2539 'type' : 'string',
2541 'service_downtimes' : {
2542 'default' : None,
2543 'description' : 'A list of all downtime ids of the service',
2544 'prop' : None,
2545 'type' : 'list',
2547 'service_event_handler' : {
2548 'default' : None,
2549 'description' : 'Nagios command used as event handler',
2550 'prop' : None,
2551 'type' : 'string',
2553 'service_event_handler_enabled' : {
2554 'default' : None,
2555 'description' : 'Wether and event handler is activated for the service (0/1)',
2556 'prop' : None,
2557 'type' : 'int',
2559 'service_execution_time' : {
2560 'default' : None,
2561 'description' : 'Time the host check needed for execution',
2562 'prop' : None,
2563 'type' : 'float',
2565 'service_first_notification_delay' : {
2566 'default' : None,
2567 'description' : 'Delay before the first notification',
2568 'prop' : None,
2569 'type' : 'float',
2571 'service_flap_detection_enabled' : {
2572 'default' : None,
2573 'description' : 'Wether flap detection is enabled for the service (0/1)',
2574 'prop' : None,
2575 'type' : 'int',
2577 'service_groups' : {
2578 'default' : None,
2579 'description' : 'A list of all service groups the service is in',
2580 'prop' : None,
2581 'type' : 'list',
2583 'service_has_been_checked' : {
2584 'default' : None,
2585 'description' : 'Wether the service already has been checked (0/1)',
2586 'prop' : None,
2587 'type' : 'int',
2589 'service_high_flap_threshold' : {
2590 'default' : None,
2591 'description' : 'High threshold of flap detection',
2592 'prop' : None,
2593 'type' : 'float',
2595 'service_icon_image' : {
2596 'default' : None,
2597 'description' : 'The name of an image to be used as icon in the web interface',
2598 'prop' : None,
2599 'type' : 'string',
2601 'service_icon_image_alt' : {
2602 'default' : None,
2603 'description' : 'An alternative text for the icon_image for browsers not displaying icons',
2604 'prop' : None,
2605 'type' : 'string',
2607 'service_icon_image_expanded' : {
2608 'default' : None,
2609 'description' : 'The icon_image with (the most important) macros expanded',
2610 'prop' : None,
2611 'type' : 'string',
2613 'service_in_check_period' : {
2614 'default' : None,
2615 'description' : 'Wether the service is currently in its check period (0/1)',
2616 'prop' : None,
2617 'type' : 'int',
2619 'service_in_notification_period' : {
2620 'default' : None,
2621 'description' : 'Wether the service is currently in its notification period (0/1)',
2622 'prop' : None,
2623 'type' : 'int',
2625 'service_initial_state' : {
2626 'default' : None,
2627 'description' : 'The initial state of the service',
2628 'prop' : None,
2629 'type' : 'int',
2631 'service_is_executing' : {
2632 'default' : 0, # value in scheduler is not real-time
2633 'description' : 'is there a service check currently running... (0/1)',
2634 'prop' : None,
2635 'type' : 'int',
2637 'service_is_flapping' : {
2638 'default' : None,
2639 'description' : 'Wether the service is flapping (0/1)',
2640 'prop' : None,
2641 'type' : 'int',
2643 'service_last_check' : {
2644 'default' : None,
2645 'description' : 'The time of the last check (Unix timestamp)',
2646 'prop' : None,
2647 'type' : 'int',
2649 'service_last_hard_state' : {
2650 'default' : None,
2651 'description' : 'The last hard state of the service',
2652 'prop' : None,
2653 'type' : 'int',
2655 'service_last_hard_state_change' : {
2656 'default' : None,
2657 'description' : 'The time of the last hard state change (Unix timestamp)',
2658 'prop' : None,
2659 'type' : 'int',
2661 'service_last_notification' : {
2662 'default' : None,
2663 'description' : 'The time of the last notification (Unix timestamp)',
2664 'prop' : None,
2665 'type' : 'int',
2667 'service_last_state' : {
2668 'default' : None,
2669 'description' : 'The last state of the service',
2670 'prop' : None,
2671 'type' : 'int',
2673 'service_last_state_change' : {
2674 'default' : None,
2675 'description' : 'The time of the last state change (Unix timestamp)',
2676 'prop' : None,
2677 'type' : 'int',
2679 'service_latency' : {
2680 'default' : None,
2681 'description' : 'Time difference between scheduled check time and actual check time',
2682 'prop' : None,
2683 'type' : 'float',
2685 'service_long_plugin_output' : {
2686 'default' : None,
2687 'description' : 'Unabbreviated output of the last check plugin',
2688 'prop' : None,
2689 'type' : 'string',
2691 'service_low_flap_threshold' : {
2692 'default' : None,
2693 'description' : 'Low threshold of flap detection',
2694 'prop' : None,
2695 'type' : 'float',
2697 'service_max_check_attempts' : {
2698 'default' : None,
2699 'description' : 'The maximum number of check attempts',
2700 'prop' : None,
2701 'type' : 'int',
2703 'service_next_check' : {
2704 'default' : None,
2705 'description' : 'The scheduled time of the next check (Unix timestamp)',
2706 'prop' : None,
2707 'type' : 'int',
2709 'service_next_notification' : {
2710 'default' : None,
2711 'description' : 'The time of the next notification (Unix timestamp)',
2712 'prop' : None,
2713 'type' : 'int',
2715 'service_notes' : {
2716 'default' : None,
2717 'description' : 'Optional notes about the service',
2718 'prop' : None,
2719 'type' : 'string',
2721 'service_notes_expanded' : {
2722 'default' : None,
2723 'description' : 'The notes with (the most important) macros expanded',
2724 'prop' : None,
2725 'type' : 'string',
2727 'service_notes_url' : {
2728 'default' : None,
2729 'description' : 'An optional URL for additional notes about the service',
2730 'prop' : None,
2731 'type' : 'string',
2733 'service_notes_url_expanded' : {
2734 'default' : None,
2735 'description' : 'The notes_url with (the most important) macros expanded',
2736 'prop' : None,
2737 'type' : 'string',
2739 'service_notification_interval' : {
2740 'default' : None,
2741 'description' : 'Interval of periodic notification or 0 if its off',
2742 'prop' : None,
2743 'type' : 'float',
2745 'service_notification_period' : {
2746 'default' : None,
2747 'description' : 'The name of the notification period of the service. It this is empty, service problems are always notified.',
2748 'prop' : None,
2749 'type' : 'string',
2751 'service_notifications_enabled' : {
2752 'default' : None,
2753 'description' : 'Wether notifications are enabled for the service (0/1)',
2754 'prop' : None,
2755 'type' : 'int',
2757 'service_obsess_over_service' : {
2758 'default' : None,
2759 'description' : 'Wether \'obsess_over_service\' is enabled for the service (0/1)',
2760 'prop' : None,
2761 'type' : 'int',
2763 'service_percent_state_change' : {
2764 'default' : None,
2765 'description' : 'Percent state change',
2766 'prop' : None,
2767 'type' : 'float',
2769 'service_perf_data' : {
2770 'default' : None,
2771 'description' : 'Performance data of the last check plugin',
2772 'prop' : None,
2773 'type' : 'string',
2775 'service_plugin_output' : {
2776 'default' : None,
2777 'description' : 'Output of the last check plugin',
2778 'prop' : None,
2779 'type' : 'string',
2781 'service_process_performance_data' : {
2782 'default' : None,
2783 'description' : 'Wether processing of performance data is enabled for the service (0/1)',
2784 'prop' : None,
2785 'type' : 'int',
2787 'service_retry_interval' : {
2788 'default' : None,
2789 'description' : 'Number of basic interval lengths between checks when retrying after a soft error',
2790 'prop' : None,
2791 'type' : 'float',
2793 'service_scheduled_downtime_depth' : {
2794 'default' : None,
2795 'description' : 'The number of scheduled downtimes the service is currently in',
2796 'prop' : None,
2797 'type' : 'int',
2799 'service_state' : {
2800 'default' : None,
2801 'description' : 'The current state of the service (0: OK, 1: WARN, 2: CRITICAL, 3: UNKNOWN)',
2802 'prop' : None,
2803 'type' : 'int',
2805 'service_state_type' : {
2806 'default' : None,
2807 'description' : 'The type of the current state (0: soft, 1: hard)',
2808 'prop' : None,
2809 'type' : 'int',
2811 'start_time' : {
2812 'default' : '0',
2813 'description' : 'The start time of the downtime as UNIX timestamp',
2814 'prop' : None,
2815 'type' : 'int',
2817 'triggered_by' : {
2818 'default' : None,
2819 'description' : 'The id of the downtime this downtime was triggered by or 0 if it was not triggered by another downtime',
2820 'prop' : 'trigger_id',
2821 'type' : 'int',
2823 'type' : {
2824 'default' : None,
2825 'description' : 'The type of the downtime: 0 if it is active, 1 if it is pending',
2826 'prop' : None,
2827 'type' : 'int',
2831 #Comments
2833 'Comment' : {
2834 'author' : {
2835 'default' : None,
2836 'description' : 'The contact that entered the comment',
2837 'prop' : None,
2838 'type' : 'string',
2840 'comment' : {
2841 'default' : None,
2842 'description' : 'A comment text',
2843 'prop' : None,
2844 'type' : 'string',
2846 'entry_time' : {
2847 'default' : None,
2848 'description' : 'The time the entry was made as UNIX timestamp',
2849 'prop' : None,
2850 'type' : 'int',
2852 'entry_type' : {
2853 'default' : '0',
2854 'description' : 'The type of the comment: 1 is user, 2 is downtime, 3 is flap and 4 is acknowledgement',
2855 'prop' : 'entry_type',
2856 'type' : 'int',
2858 'expire_time' : {
2859 'default' : '0',
2860 'description' : 'The time of expiry of this comment as a UNIX timestamp',
2861 'prop' : None,
2862 'type' : 'int',
2864 'expires' : {
2865 'default' : None,
2866 'depythonize' : from_bool_to_int,
2867 'description' : 'Whether this comment expires',
2868 'prop' : None,
2869 'type' : 'int',
2871 'host_accept_passive_checks' : {
2872 'default' : None,
2873 'description' : 'Wether passive host checks are accepted (0/1)',
2874 'prop' : None,
2875 'type' : 'int',
2877 'host_acknowledged' : {
2878 'default' : None,
2879 'description' : 'Wether the current host problem has been acknowledged (0/1)',
2880 'prop' : None,
2881 'type' : 'int',
2883 'host_acknowledgement_type' : {
2884 'default' : None,
2885 'description' : 'Type of acknowledgement (0: none, 1: normal, 2: stick)',
2886 'prop' : None,
2887 'type' : 'int',
2889 'host_action_url' : {
2890 'default' : None,
2891 'description' : 'An optional URL to custom actions or information about this host',
2892 'prop' : None,
2893 'type' : 'string',
2895 'host_action_url_expanded' : {
2896 'default' : None,
2897 'description' : 'The same as action_url, but with the most important macros expanded',
2898 'prop' : None,
2899 'type' : 'string',
2901 'host_active_checks_enabled' : {
2902 'default' : None,
2903 'description' : 'Wether active checks are enabled for the host (0/1)',
2904 'prop' : None,
2905 'type' : 'int',
2907 'host_address' : {
2908 'default' : None,
2909 'description' : 'IP address',
2910 'prop' : None,
2911 'type' : 'string',
2913 'host_alias' : {
2914 'default' : None,
2915 'description' : 'An alias name for the host',
2916 'prop' : None,
2917 'type' : 'string',
2919 'host_check_command' : {
2920 'default' : None,
2921 'description' : 'Nagios command for active host check of this host',
2922 'prop' : None,
2923 'type' : 'string',
2925 'host_check_freshness' : {
2926 'default' : None,
2927 'description' : 'Wether freshness checks are activated (0/1)',
2928 'prop' : None,
2929 'type' : 'int',
2931 'host_check_interval' : {
2932 'default' : None,
2933 'description' : 'Number of basic interval lengths between two scheduled checks of the host',
2934 'prop' : None,
2935 'type' : 'float',
2937 'host_check_options' : {
2938 'default' : None,
2939 'description' : 'The current check option, forced, normal, freshness... (0-2)',
2940 'prop' : None,
2941 'type' : 'int',
2943 'host_check_period' : {
2944 'default' : None,
2945 'description' : 'Time period in which this host will be checked. If empty then the host will always be checked.',
2946 'prop' : None,
2947 'type' : 'string',
2949 'host_check_type' : {
2950 'default' : None,
2951 'description' : 'Type of check (0: active, 1: passive)',
2952 'prop' : None,
2953 'type' : 'int',
2955 'host_checks_enabled' : {
2956 'default' : None,
2957 'description' : 'Wether checks of the host are enabled (0/1)',
2958 'prop' : None,
2959 'type' : 'int',
2961 'host_childs' : {
2962 'default' : None,
2963 'description' : 'A list of all direct childs of the host',
2964 'prop' : None,
2965 'type' : 'list',
2967 'host_comments' : {
2968 'default' : None,
2969 'description' : 'A list of the ids of all comments of this host',
2970 'prop' : None,
2971 'type' : 'list',
2973 'host_contacts' : {
2974 'default' : None,
2975 'description' : 'A list of all contacts of this host, either direct or via a contact group',
2976 'prop' : None,
2977 'type' : 'list',
2979 'host_current_attempt' : {
2980 'default' : None,
2981 'description' : 'Number of the current check attempts',
2982 'prop' : None,
2983 'type' : 'int',
2985 'host_current_notification_number' : {
2986 'default' : None,
2987 'description' : 'Number of the current notification',
2988 'prop' : None,
2989 'type' : 'int',
2991 'host_custom_variable_names' : {
2992 'default' : None,
2993 'description' : 'A list of the names of all custom variables',
2994 'prop' : None,
2995 'type' : 'list',
2997 'host_custom_variable_values' : {
2998 'default' : None,
2999 'description' : 'A list of the values of the custom variables',
3000 'prop' : None,
3001 'type' : 'list',
3003 'host_display_name' : {
3004 'default' : None,
3005 'description' : 'Optional display name of the host - not used by Nagios\' web interface',
3006 'prop' : None,
3007 'type' : 'string',
3009 'host_downtimes' : {
3010 'default' : None,
3011 'description' : 'A list of the ids of all scheduled downtimes of this host',
3012 'prop' : None,
3013 'type' : 'list',
3015 'host_event_handler_enabled' : {
3016 'default' : None,
3017 'description' : 'Wether event handling is enabled (0/1)',
3018 'prop' : None,
3019 'type' : 'int',
3021 'host_execution_time' : {
3022 'default' : None,
3023 'description' : 'Time the host check needed for execution',
3024 'prop' : None,
3025 'type' : 'float',
3027 'host_first_notification_delay' : {
3028 'default' : None,
3029 'description' : 'Delay before the first notification',
3030 'prop' : None,
3031 'type' : 'float',
3033 'host_flap_detection_enabled' : {
3034 'default' : None,
3035 'description' : 'Wether flap detection is enabled (0/1)',
3036 'prop' : None,
3037 'type' : 'int',
3039 'host_groups' : {
3040 'default' : None,
3041 'description' : 'A list of all host groups this host is in',
3042 'prop' : None,
3043 'type' : 'list',
3045 'host_hard_state' : {
3046 'default' : None,
3047 'description' : 'The effective hard state of the host (eliminates a problem in hard_state)',
3048 'prop' : None,
3049 'type' : 'int',
3051 'host_has_been_checked' : {
3052 'default' : None,
3053 'description' : 'Wether the host has already been checked (0/1)',
3054 'prop' : None,
3055 'type' : 'int',
3057 'host_high_flap_threshold' : {
3058 'default' : None,
3059 'description' : 'High threshold of flap detection',
3060 'prop' : None,
3061 'type' : 'float',
3063 'host_icon_image' : {
3064 'default' : None,
3065 'description' : 'The name of an image file to be used in the web pages',
3066 'prop' : None,
3067 'type' : 'string',
3069 'host_icon_image_alt' : {
3070 'default' : None,
3071 'description' : 'Alternative text for the icon_image',
3072 'prop' : None,
3073 'type' : 'string',
3075 'host_icon_image_expanded' : {
3076 'default' : None,
3077 'description' : 'The same as icon_image, but with the most important macros expanded',
3078 'prop' : None,
3079 'type' : 'string',
3081 'host_in_check_period' : {
3082 'default' : None,
3083 'description' : 'Wether this host is currently in its check period (0/1)',
3084 'prop' : None,
3085 'type' : 'int',
3087 'host_in_notification_period' : {
3088 'default' : None,
3089 'description' : 'Wether this host is currently in its notification period (0/1)',
3090 'prop' : None,
3091 'type' : 'int',
3093 'host_initial_state' : {
3094 'default' : None,
3095 'description' : 'Initial host state',
3096 'prop' : None,
3097 'type' : 'int',
3099 'host_is_executing' : {
3100 'default' : 0, # value in scheduler is not real-time
3101 'description' : 'is there a host check currently running... (0/1)',
3102 'prop' : None,
3103 'type' : 'int',
3105 'host_is_flapping' : {
3106 'default' : None,
3107 'description' : 'Wether the host state is flapping (0/1)',
3108 'prop' : None,
3109 'type' : 'int',
3111 'host_last_check' : {
3112 'default' : None,
3113 'description' : 'Time of the last check (Unix timestamp)',
3114 'prop' : None,
3115 'type' : 'int',
3117 'host_last_hard_state' : {
3118 'default' : None,
3119 'description' : 'Last hard state',
3120 'prop' : None,
3121 'type' : 'int',
3123 'host_last_hard_state_change' : {
3124 'default' : None,
3125 'description' : 'Time of the last hard state change (Unix timestamp)',
3126 'prop' : None,
3127 'type' : 'int',
3129 'host_last_notification' : {
3130 'default' : None,
3131 'description' : 'Time of the last notification (Unix timestamp)',
3132 'prop' : None,
3133 'type' : 'int',
3135 'host_last_state' : {
3136 'default' : None,
3137 'description' : 'State before last state change',
3138 'prop' : None,
3139 'type' : 'int',
3141 'host_last_state_change' : {
3142 'default' : None,
3143 'description' : 'Time of the last state change - soft or hard (Unix timestamp)',
3144 'prop' : None,
3145 'type' : 'int',
3147 'host_latency' : {
3148 'default' : None,
3149 'description' : 'Time difference between scheduled check time and actual check time',
3150 'prop' : None,
3151 'type' : 'float',
3153 'host_long_plugin_output' : {
3154 'default' : None,
3155 'description' : 'Complete output from check plugin',
3156 'prop' : None,
3157 'type' : 'string',
3159 'host_low_flap_threshold' : {
3160 'default' : None,
3161 'description' : 'Low threshold of flap detection',
3162 'prop' : None,
3163 'type' : 'float',
3165 'host_max_check_attempts' : {
3166 'default' : None,
3167 'description' : 'Max check attempts for active host checks',
3168 'prop' : None,
3169 'type' : 'int',
3171 'host_name' : {
3172 'default' : None,
3173 'depythonize' : lambda x: x.host_name,
3174 'description' : 'Host name',
3175 'prop' : 'ref',
3176 'type' : 'string',
3178 'host_next_check' : {
3179 'default' : None,
3180 'description' : 'Scheduled time for the next check (Unix timestamp)',
3181 'prop' : None,
3182 'type' : 'int',
3184 'host_next_notification' : {
3185 'default' : None,
3186 'description' : 'Time of the next notification (Unix timestamp)',
3187 'prop' : None,
3188 'type' : 'int',
3190 'host_notes' : {
3191 'default' : None,
3192 'description' : 'Optional notes for this host',
3193 'prop' : None,
3194 'type' : 'string',
3196 'host_notes_expanded' : {
3197 'default' : None,
3198 'description' : 'The same as notes, but with the most important macros expanded',
3199 'prop' : None,
3200 'type' : 'string',
3202 'host_notes_url' : {
3203 'default' : None,
3204 'description' : 'An optional URL with further information about the host',
3205 'prop' : None,
3206 'type' : 'string',
3208 'host_notes_url_expanded' : {
3209 'default' : None,
3210 'description' : 'Same es notes_url, but with the most important macros expanded',
3211 'prop' : None,
3212 'type' : 'string',
3214 'host_notification_interval' : {
3215 'default' : None,
3216 'description' : 'Interval of periodic notification or 0 if its off',
3217 'prop' : None,
3218 'type' : 'float',
3220 'host_notification_period' : {
3221 'default' : None,
3222 'description' : 'Time period in which problems of this host will be notified. If empty then notification will be always',
3223 'prop' : None,
3224 'type' : 'string',
3226 'host_notifications_enabled' : {
3227 'default' : None,
3228 'description' : 'Wether notifications of the host are enabled (0/1)',
3229 'prop' : None,
3230 'type' : 'int',
3232 'host_num_services' : {
3233 'default' : None,
3234 'description' : 'The total number of services of the host',
3235 'prop' : None,
3236 'type' : 'list',
3238 'host_num_services_crit' : {
3239 'default' : None,
3240 'description' : 'The number of the host\'s services with the soft state CRIT',
3241 'prop' : None,
3242 'type' : 'list',
3244 'host_num_services_hard_crit' : {
3245 'default' : None,
3246 'description' : 'The number of the host\'s services with the hard state CRIT',
3247 'prop' : None,
3248 'type' : 'list',
3250 'host_num_services_hard_ok' : {
3251 'default' : None,
3252 'description' : 'The number of the host\'s services with the hard state OK',
3253 'prop' : None,
3254 'type' : 'list',
3256 'host_num_services_hard_unknown' : {
3257 'default' : None,
3258 'description' : 'The number of the host\'s services with the hard state UNKNOWN',
3259 'prop' : None,
3260 'type' : 'list',
3262 'host_num_services_hard_warn' : {
3263 'default' : None,
3264 'description' : 'The number of the host\'s services with the hard state WARN',
3265 'prop' : None,
3266 'type' : 'list',
3268 'host_num_services_ok' : {
3269 'default' : None,
3270 'description' : 'The number of the host\'s services with the soft state OK',
3271 'prop' : None,
3272 'type' : 'list',
3274 'host_num_services_pending' : {
3275 'default' : None,
3276 'description' : 'The number of the host\'s services which have not been checked yet (pending)',
3277 'prop' : None,
3278 'type' : 'list',
3280 'host_num_services_unknown' : {
3281 'default' : None,
3282 'description' : 'The number of the host\'s services with the soft state UNKNOWN',
3283 'prop' : None,
3284 'type' : 'list',
3286 'host_num_services_warn' : {
3287 'default' : None,
3288 'description' : 'The number of the host\'s services with the soft state WARN',
3289 'prop' : None,
3290 'type' : 'list',
3292 'host_obsess_over_host' : {
3293 'default' : None,
3294 'description' : 'The current obsess_over_host setting... (0/1)',
3295 'prop' : None,
3296 'type' : 'int',
3298 'host_parents' : {
3299 'default' : None,
3300 'description' : 'A list of all direct parents of the host',
3301 'prop' : None,
3302 'type' : 'list',
3304 'host_pending_flex_downtime' : {
3305 'default' : None,
3306 'description' : 'Wether a flex downtime is pending (0/1)',
3307 'prop' : None,
3308 'type' : 'int',
3310 'host_percent_state_change' : {
3311 'default' : None,
3312 'description' : 'Percent state change',
3313 'prop' : None,
3314 'type' : 'float',
3316 'host_perf_data' : {
3317 'default' : None,
3318 'description' : 'Optional performance data of the last host check',
3319 'prop' : None,
3320 'type' : 'string',
3322 'host_plugin_output' : {
3323 'default' : None,
3324 'description' : 'Output of the last host check',
3325 'prop' : None,
3326 'type' : 'string',
3328 'host_process_performance_data' : {
3329 'default' : None,
3330 'description' : 'Wether processing of performance data is enabled (0/1)',
3331 'prop' : None,
3332 'type' : 'int',
3334 'host_retry_interval' : {
3335 'default' : None,
3336 'description' : 'Number of basic interval lengths between checks when retrying after a soft error',
3337 'prop' : None,
3338 'type' : 'float',
3340 'host_scheduled_downtime_depth' : {
3341 'default' : None,
3342 'description' : 'The number of downtimes this host is currently in',
3343 'prop' : None,
3344 'type' : 'int',
3346 'host_state' : {
3347 'default' : None,
3348 'description' : 'The current state of the host (0: up, 1: down, 2: unreachable)',
3349 'prop' : None,
3350 'type' : 'int',
3352 'host_state_type' : {
3353 'default' : None,
3354 'description' : 'Type of the current state (0: soft, 1: hard)',
3355 'prop' : None,
3356 'type' : 'int',
3358 'host_statusmap_image' : {
3359 'default' : None,
3360 'description' : 'The name of in image file for the status map',
3361 'prop' : None,
3362 'type' : 'string',
3364 'host_total_services' : {
3365 'default' : None,
3366 'description' : 'The total number of services of the host',
3367 'prop' : None,
3368 'type' : 'int',
3370 'host_worst_service_hard_state' : {
3371 'default' : None,
3372 'description' : 'The worst hard state of all of the host\'s services (OK <= WARN <= UNKNOWN <= CRIT)',
3373 'prop' : None,
3374 'type' : 'list',
3376 'host_worst_service_state' : {
3377 'default' : None,
3378 'description' : 'The worst soft state of all of the host\'s services (OK <= WARN <= UNKNOWN <= CRIT)',
3379 'prop' : None,
3380 'type' : 'list',
3382 'host_x_3d' : {
3383 'default' : None,
3384 'description' : '3D-Coordinates: X',
3385 'prop' : None,
3386 'type' : 'float',
3388 'host_y_3d' : {
3389 'default' : None,
3390 'description' : '3D-Coordinates: Y',
3391 'prop' : None,
3392 'type' : 'float',
3394 'host_z_3d' : {
3395 'default' : None,
3396 'description' : '3D-Coordinates: Z',
3397 'prop' : None,
3398 'type' : 'float',
3400 'id' : {
3401 'default' : None,
3402 'description' : 'The id of the comment',
3403 'prop' : None,
3404 'type' : 'int',
3406 'persistent' : {
3407 'default' : None,
3408 'depythonize' : from_bool_to_int,
3409 'description' : 'Whether this comment is persistent (0/1)',
3410 'prop' : None,
3411 'type' : 'int',
3413 'service_accept_passive_checks' : {
3414 'default' : None,
3415 'description' : 'Wether the service accepts passive checks (0/1)',
3416 'prop' : None,
3417 'type' : 'int',
3419 'service_acknowledged' : {
3420 'default' : None,
3421 'description' : 'Wether the current service problem has been acknowledged (0/1)',
3422 'prop' : None,
3423 'type' : 'int',
3425 'service_acknowledgement_type' : {
3426 'default' : None,
3427 'description' : 'The type of the acknownledgement (0: none, 1: normal, 2: sticky)',
3428 'prop' : None,
3429 'type' : 'int',
3431 'service_action_url' : {
3432 'default' : None,
3433 'description' : 'An optional URL for actions or custom information about the service',
3434 'prop' : None,
3435 'type' : 'string',
3437 'service_action_url_expanded' : {
3438 'default' : None,
3439 'description' : 'The action_url with (the most important) macros expanded',
3440 'prop' : None,
3441 'type' : 'string',
3443 'service_active_checks_enabled' : {
3444 'default' : None,
3445 'description' : 'Wether active checks are enabled for the service (0/1)',
3446 'prop' : None,
3447 'type' : 'int',
3449 'service_check_command' : {
3450 'default' : None,
3451 'description' : 'Nagios command used for active checks',
3452 'prop' : None,
3453 'type' : 'string',
3455 'service_check_interval' : {
3456 'default' : None,
3457 'description' : 'Number of basic interval lengths between two scheduled checks of the service',
3458 'prop' : None,
3459 'type' : 'float',
3461 'service_check_options' : {
3462 'default' : None,
3463 'description' : 'The current check option, forced, normal, freshness... (0/1)',
3464 'prop' : None,
3465 'type' : 'int',
3467 'service_check_period' : {
3468 'default' : None,
3469 'description' : 'The name of the check period of the service. It this is empty, the service is always checked.',
3470 'prop' : None,
3471 'type' : 'string',
3473 'service_check_type' : {
3474 'default' : None,
3475 'description' : 'The type of the last check (0: active, 1: passive)',
3476 'prop' : None,
3477 'type' : 'int',
3479 'service_checks_enabled' : {
3480 'default' : None,
3481 'description' : 'Wether active checks are enabled for the service (0/1)',
3482 'prop' : None,
3483 'type' : 'int',
3485 'service_comments' : {
3486 'default' : None,
3487 'description' : 'A list of all comment ids of the service',
3488 'prop' : None,
3489 'type' : 'list',
3491 'service_contacts' : {
3492 'default' : None,
3493 'description' : 'A list of all contacts of the service, either direct or via a contact group',
3494 'prop' : None,
3495 'type' : 'list',
3497 'service_current_attempt' : {
3498 'default' : None,
3499 'description' : 'The number of the current check attempt',
3500 'prop' : None,
3501 'type' : 'int',
3503 'service_current_notification_number' : {
3504 'default' : None,
3505 'description' : 'The number of the current notification',
3506 'prop' : None,
3507 'type' : 'int',
3509 'service_custom_variable_names' : {
3510 'default' : None,
3511 'description' : 'A list of the names of all custom variables of the service',
3512 'prop' : None,
3513 'type' : 'list',
3515 'service_custom_variable_values' : {
3516 'default' : None,
3517 'description' : 'A list of the values of all custom variable of the service',
3518 'prop' : None,
3519 'type' : 'list',
3521 'service_description' : {
3522 'default' : None,
3523 'depythonize' : lambda x: getattr(x, 'service_description', ''),
3524 'description' : 'Description of the service (also used as key)',
3525 'prop' : 'ref',
3526 'type' : 'string',
3528 'service_display_name' : {
3529 'default' : None,
3530 'description' : 'An optional display name (not used by Nagios standard web pages)',
3531 'prop' : None,
3532 'type' : 'string',
3534 'service_downtimes' : {
3535 'default' : None,
3536 'description' : 'A list of all downtime ids of the service',
3537 'prop' : None,
3538 'type' : 'list',
3540 'service_event_handler' : {
3541 'default' : None,
3542 'description' : 'Nagios command used as event handler',
3543 'prop' : None,
3544 'type' : 'string',
3546 'service_event_handler_enabled' : {
3547 'default' : None,
3548 'description' : 'Wether and event handler is activated for the service (0/1)',
3549 'prop' : None,
3550 'type' : 'int',
3552 'service_execution_time' : {
3553 'default' : None,
3554 'description' : 'Time the host check needed for execution',
3555 'prop' : None,
3556 'type' : 'float',
3558 'service_first_notification_delay' : {
3559 'default' : None,
3560 'description' : 'Delay before the first notification',
3561 'prop' : None,
3562 'type' : 'float',
3564 'service_flap_detection_enabled' : {
3565 'default' : None,
3566 'description' : 'Wether flap detection is enabled for the service (0/1)',
3567 'prop' : None,
3568 'type' : 'int',
3570 'service_groups' : {
3571 'default' : None,
3572 'description' : 'A list of all service groups the service is in',
3573 'prop' : None,
3574 'type' : 'list',
3576 'service_has_been_checked' : {
3577 'default' : None,
3578 'description' : 'Wether the service already has been checked (0/1)',
3579 'prop' : None,
3580 'type' : 'int',
3582 'service_high_flap_threshold' : {
3583 'default' : None,
3584 'description' : 'High threshold of flap detection',
3585 'prop' : None,
3586 'type' : 'float',
3588 'service_icon_image' : {
3589 'default' : None,
3590 'description' : 'The name of an image to be used as icon in the web interface',
3591 'prop' : None,
3592 'type' : 'string',
3594 'service_icon_image_alt' : {
3595 'default' : None,
3596 'description' : 'An alternative text for the icon_image for browsers not displaying icons',
3597 'prop' : None,
3598 'type' : 'string',
3600 'service_icon_image_expanded' : {
3601 'default' : None,
3602 'description' : 'The icon_image with (the most important) macros expanded',
3603 'prop' : None,
3604 'type' : 'string',
3606 'service_in_check_period' : {
3607 'default' : None,
3608 'description' : 'Wether the service is currently in its check period (0/1)',
3609 'prop' : None,
3610 'type' : 'int',
3612 'service_in_notification_period' : {
3613 'default' : None,
3614 'description' : 'Wether the service is currently in its notification period (0/1)',
3615 'prop' : None,
3616 'type' : 'int',
3618 'service_initial_state' : {
3619 'default' : None,
3620 'description' : 'The initial state of the service',
3621 'prop' : None,
3622 'type' : 'int',
3624 'service_is_executing' : {
3625 'default' : 0, # value in scheduler is not real-time
3626 'description' : 'is there a service check currently running... (0/1)',
3627 'prop' : None,
3628 'type' : 'int',
3630 'service_is_flapping' : {
3631 'default' : None,
3632 'description' : 'Wether the service is flapping (0/1)',
3633 'prop' : None,
3634 'type' : 'int',
3636 'service_last_check' : {
3637 'default' : None,
3638 'description' : 'The time of the last check (Unix timestamp)',
3639 'prop' : None,
3640 'type' : 'int',
3642 'service_last_hard_state' : {
3643 'default' : None,
3644 'description' : 'The last hard state of the service',
3645 'prop' : None,
3646 'type' : 'int',
3648 'service_last_hard_state_change' : {
3649 'default' : None,
3650 'description' : 'The time of the last hard state change (Unix timestamp)',
3651 'prop' : None,
3652 'type' : 'int',
3654 'service_last_notification' : {
3655 'default' : None,
3656 'description' : 'The time of the last notification (Unix timestamp)',
3657 'prop' : None,
3658 'type' : 'int',
3660 'service_last_state' : {
3661 'default' : None,
3662 'description' : 'The last state of the service',
3663 'prop' : None,
3664 'type' : 'int',
3666 'service_last_state_change' : {
3667 'default' : None,
3668 'description' : 'The time of the last state change (Unix timestamp)',
3669 'prop' : None,
3670 'type' : 'int',
3672 'service_latency' : {
3673 'default' : None,
3674 'description' : 'Time difference between scheduled check time and actual check time',
3675 'prop' : None,
3676 'type' : 'float',
3678 'service_long_plugin_output' : {
3679 'default' : None,
3680 'description' : 'Unabbreviated output of the last check plugin',
3681 'prop' : None,
3682 'type' : 'string',
3684 'service_low_flap_threshold' : {
3685 'default' : None,
3686 'description' : 'Low threshold of flap detection',
3687 'prop' : None,
3688 'type' : 'float',
3690 'service_max_check_attempts' : {
3691 'default' : None,
3692 'description' : 'The maximum number of check attempts',
3693 'prop' : None,
3694 'type' : 'int',
3696 'service_next_check' : {
3697 'default' : None,
3698 'description' : 'The scheduled time of the next check (Unix timestamp)',
3699 'prop' : None,
3700 'type' : 'int',
3702 'service_next_notification' : {
3703 'default' : None,
3704 'description' : 'The time of the next notification (Unix timestamp)',
3705 'prop' : None,
3706 'type' : 'int',
3708 'service_notes' : {
3709 'default' : None,
3710 'description' : 'Optional notes about the service',
3711 'prop' : None,
3712 'type' : 'string',
3714 'service_notes_expanded' : {
3715 'default' : None,
3716 'description' : 'The notes with (the most important) macros expanded',
3717 'prop' : None,
3718 'type' : 'string',
3720 'service_notes_url' : {
3721 'default' : None,
3722 'description' : 'An optional URL for additional notes about the service',
3723 'prop' : None,
3724 'type' : 'string',
3726 'service_notes_url_expanded' : {
3727 'default' : None,
3728 'description' : 'The notes_url with (the most important) macros expanded',
3729 'prop' : None,
3730 'type' : 'string',
3732 'service_notification_interval' : {
3733 'default' : None,
3734 'description' : 'Interval of periodic notification or 0 if its off',
3735 'prop' : None,
3736 'type' : 'float',
3738 'service_notification_period' : {
3739 'default' : None,
3740 'description' : 'The name of the notification period of the service. It this is empty, service problems are always notified.',
3741 'prop' : None,
3742 'type' : 'string',
3744 'service_notifications_enabled' : {
3745 'default' : None,
3746 'description' : 'Wether notifications are enabled for the service (0/1)',
3747 'prop' : None,
3748 'type' : 'int',
3750 'service_obsess_over_service' : {
3751 'default' : None,
3752 'description' : 'Wether \'obsess_over_service\' is enabled for the service (0/1)',
3753 'prop' : None,
3754 'type' : 'int',
3756 'service_percent_state_change' : {
3757 'default' : None,
3758 'description' : 'Percent state change',
3759 'prop' : None,
3760 'type' : 'float',
3762 'service_perf_data' : {
3763 'default' : None,
3764 'description' : 'Performance data of the last check plugin',
3765 'prop' : None,
3766 'type' : 'string',
3768 'service_plugin_output' : {
3769 'default' : None,
3770 'description' : 'Output of the last check plugin',
3771 'prop' : None,
3772 'type' : 'string',
3774 'service_process_performance_data' : {
3775 'default' : None,
3776 'description' : 'Wether processing of performance data is enabled for the service (0/1)',
3777 'prop' : None,
3778 'type' : 'int',
3780 'service_retry_interval' : {
3781 'default' : None,
3782 'description' : 'Number of basic interval lengths between checks when retrying after a soft error',
3783 'prop' : None,
3784 'type' : 'float',
3786 'service_scheduled_downtime_depth' : {
3787 'default' : None,
3788 'description' : 'The number of scheduled downtimes the service is currently in',
3789 'prop' : None,
3790 'type' : 'int',
3792 'service_state' : {
3793 'default' : None,
3794 'description' : 'The current state of the service (0: OK, 1: WARN, 2: CRITICAL, 3: UNKNOWN)',
3795 'prop' : None,
3796 'type' : 'int',
3798 'service_state_type' : {
3799 'default' : None,
3800 'description' : 'The type of the current state (0: soft, 1: hard)',
3801 'prop' : None,
3802 'type' : 'int',
3804 'source' : {
3805 'default' : '0',
3806 'description' : 'The source of the comment (0 is internal and 1 is external)',
3807 'prop' : None,
3808 'type' : 'int',
3810 'type' : {
3811 'default' : '1',
3812 'description' : 'The type of the comment: 1 is service, 2 is host',
3813 'prop' : 'comment_type',
3814 'type' : 'int',
3818 # loop over hostgroups then over members
3819 'Hostsbygroup' : {
3820 'hostgroup_action_url' : {
3821 'description' : 'An optional URL to custom actions or information about the hostgroup',
3822 'prop' : 'hostgroup',
3823 'type' : 'string',
3825 'hostgroup_alias' : {
3826 'description' : 'An alias of the hostgroup',
3827 'prop' : 'hostgroup',
3828 'type' : 'string',
3830 'hostgroup_members' : {
3831 'description' : 'A list of all host names that are members of the hostgroup',
3832 'prop' : 'hostgroup',
3833 'type' : 'list',
3835 'hostgroup_members_with_state' : {
3836 'description' : 'A list of all host names that are members of the hostgroup together with state and has_been_checked',
3837 'prop' : 'hostgroup',
3838 'type' : 'list',
3840 'hostgroup_name' : {
3841 'depythonize' : lambda x: getattr(x, 'hostgroup_name', ''),
3842 'description' : 'Name of the hostgroup',
3843 'prop' : 'hostgroup',
3844 'type' : 'string',
3846 'hostgroup_notes' : {
3847 'description' : 'Optional notes to the hostgroup',
3848 'prop' : 'hostgroup',
3849 'type' : 'string',
3851 'hostgroup_notes_url' : {
3852 'description' : 'An optional URL with further information about the hostgroup',
3853 'prop' : 'hostgroup',
3854 'type' : 'string',
3856 'hostgroup_num_hosts' : {
3857 'description' : 'The total number of hosts in the group',
3858 'prop' : 'hostgroup',
3859 'type' : 'int',
3861 'hostgroup_num_hosts_down' : {
3862 'description' : 'The number of hosts in the group that are down',
3863 'prop' : 'hostgroup',
3864 'type' : 'int',
3866 'hostgroup_num_hosts_pending' : {
3867 'description' : 'The number of hosts in the group that are pending',
3868 'prop' : 'hostgroup',
3869 'type' : 'int',
3871 'hostgroup_num_hosts_unreach' : {
3872 'description' : 'The number of hosts in the group that are unreachable',
3873 'prop' : 'hostgroup',
3874 'type' : 'int',
3876 'hostgroup_num_hosts_up' : {
3877 'description' : 'The number of hosts in the group that are up',
3878 'prop' : 'hostgroup',
3879 'type' : 'int',
3881 'hostgroup_num_services' : {
3882 'description' : 'The total number of services of hosts in this group',
3883 'prop' : 'hostgroup',
3884 'type' : 'int',
3886 'hostgroup_num_services_crit' : {
3887 'description' : 'The total number of services with the state CRIT of hosts in this group',
3888 'prop' : 'hostgroup',
3889 'type' : 'int',
3891 'hostgroup_num_services_hard_crit' : {
3892 'description' : 'The total number of services with the state CRIT of hosts in this group',
3893 'prop' : 'hostgroup',
3894 'type' : 'int',
3896 'hostgroup_num_services_hard_ok' : {
3897 'description' : 'The total number of services with the state OK of hosts in this group',
3898 'prop' : 'hostgroup',
3899 'type' : 'int',
3901 'hostgroup_num_services_hard_unknown' : {
3902 'description' : 'The total number of services with the state UNKNOWN of hosts in this group',
3903 'prop' : 'hostgroup',
3904 'type' : 'int',
3906 'hostgroup_num_services_hard_warn' : {
3907 'description' : 'The total number of services with the state WARN of hosts in this group',
3908 'prop' : 'hostgroup',
3909 'type' : 'int',
3911 'hostgroup_num_services_ok' : {
3912 'description' : 'The total number of services with the state OK of hosts in this group',
3913 'prop' : 'hostgroup',
3914 'type' : 'int',
3916 'hostgroup_num_services_pending' : {
3917 'description' : 'The total number of services with the state Pending of hosts in this group',
3918 'prop' : 'hostgroup',
3919 'type' : 'int',
3921 'hostgroup_num_services_unknown' : {
3922 'description' : 'The total number of services with the state UNKNOWN of hosts in this group',
3923 'prop' : 'hostgroup',
3924 'type' : 'int',
3926 'hostgroup_num_services_warn' : {
3927 'description' : 'The total number of services with the state WARN of hosts in this group',
3928 'prop' : 'hostgroup',
3929 'type' : 'int',
3931 'hostgroup_worst_host_state' : {
3932 'description' : 'The worst state of all of the groups\' hosts (UP <= UNREACHABLE <= DOWN)',
3933 'prop' : 'hostgroup',
3934 'type' : 'int',
3936 'hostgroup_worst_service_hard_state' : {
3937 'description' : 'The worst state of all services that belong to a host of this group (OK <= WARN <= UNKNOWN <= CRIT)',
3938 'prop' : 'hostgroup',
3939 'type' : 'int',
3941 'hostgroup_worst_service_state' : {
3942 'description' : 'The worst state of all services that belong to a host of this group (OK <= WARN <= UNKNOWN <= CRIT)',
3943 'prop' : 'hostgroup',
3944 'type' : 'int',
3948 'Servicesbygroup' : {
3949 'servicegroup_action_url' : {
3950 'description' : 'An optional URL to custom notes or actions on the service group',
3951 'type' : 'string',
3953 'servicegroup_alias' : {
3954 'description' : 'An alias of the service group',
3955 'type' : 'string',
3957 'servicegroup_members' : {
3958 'description' : 'A list of all members of the service group as host/service pairs',
3959 'type' : 'list',
3961 'servicegroup_members_with_state' : {
3962 'description' : 'A list of all members of the service group with state and has_been_checked',
3963 'type' : 'list',
3965 'servicegroup_name' : {
3966 'description' : 'The name of the service group',
3967 'type' : 'string',
3969 'servicegroup_notes' : {
3970 'description' : 'Optional additional notes about the service group',
3971 'type' : 'string',
3973 'servicegroup_notes_url' : {
3974 'description' : 'An optional URL to further notes on the service group',
3975 'type' : 'string',
3977 'servicegroup_num_services' : {
3978 'description' : 'The total number of services in the group',
3979 'type' : 'int',
3981 'servicegroup_num_services_crit' : {
3982 'description' : 'The number of services in the group that are CRIT',
3983 'type' : 'int',
3985 'servicegroup_num_services_hard_crit' : {
3986 'description' : 'The number of services in the group that are CRIT',
3987 'type' : 'int',
3989 'servicegroup_num_services_hard_ok' : {
3990 'description' : 'The number of services in the group that are OK',
3991 'type' : 'int',
3993 'servicegroup_num_services_hard_unknown' : {
3994 'description' : 'The number of services in the group that are UNKNOWN',
3995 'type' : 'int',
3997 'servicegroup_num_services_hard_warn' : {
3998 'description' : 'The number of services in the group that are WARN',
3999 'type' : 'int',
4001 'servicegroup_num_services_ok' : {
4002 'description' : 'The number of services in the group that are OK',
4003 'type' : 'int',
4005 'servicegroup_num_services_pending' : {
4006 'description' : 'The number of services in the group that are PENDING',
4007 'type' : 'int',
4009 'servicegroup_num_services_unknown' : {
4010 'description' : 'The number of services in the group that are UNKNOWN',
4011 'type' : 'int',
4013 'servicegroup_num_services_warn' : {
4014 'description' : 'The number of services in the group that are WARN',
4015 'type' : 'int',
4017 'servicegroup_worst_service_state' : {
4018 'description' : 'The worst soft state of all of the groups services (OK <= WARN <= UNKNOWN <= CRIT)',
4019 'type' : 'int',
4023 'Servicesbyhostgroup' : {
4024 'hostgroup_action_url' : {
4025 'description' : 'An optional URL to custom actions or information about the hostgroup',
4026 'type' : 'string',
4028 'hostgroup_alias' : {
4029 'description' : 'An alias of the hostgroup',
4030 'type' : 'string',
4032 'hostgroup_members' : {
4033 'description' : 'A list of all host names that are members of the hostgroup',
4034 'type' : 'list',
4036 'hostgroup_members_with_state' : {
4037 'description' : 'A list of all host names that are members of the hostgroup together with state and has_been_checked',
4038 'type' : 'list',
4040 'hostgroup_name' : {
4041 'depythonize' : lambda x: getattr(x, 'hostgroup_name', ''),
4042 'description' : 'Name of the hostgroup',
4043 'prop' : 'hostgroup',
4044 'type' : 'string',
4046 'hostgroup_notes' : {
4047 'description' : 'Optional notes to the hostgroup',
4048 'type' : 'string',
4050 'hostgroup_notes_url' : {
4051 'description' : 'An optional URL with further information about the hostgroup',
4052 'type' : 'string',
4054 'hostgroup_num_hosts' : {
4055 'description' : 'The total number of hosts in the group',
4056 'type' : 'int',
4058 'hostgroup_num_hosts_down' : {
4059 'description' : 'The number of hosts in the group that are down',
4060 'type' : 'int',
4062 'hostgroup_num_hosts_pending' : {
4063 'description' : 'The number of hosts in the group that are pending',
4064 'type' : 'int',
4066 'hostgroup_num_hosts_unreach' : {
4067 'description' : 'The number of hosts in the group that are unreachable',
4068 'type' : 'int',
4070 'hostgroup_num_hosts_up' : {
4071 'description' : 'The number of hosts in the group that are up',
4072 'type' : 'int',
4074 'hostgroup_num_services' : {
4075 'description' : 'The total number of services of hosts in this group',
4076 'type' : 'int',
4078 'hostgroup_num_services_crit' : {
4079 'description' : 'The total number of services with the state CRIT of hosts in this group',
4080 'type' : 'int',
4082 'hostgroup_num_services_hard_crit' : {
4083 'description' : 'The total number of services with the state CRIT of hosts in this group',
4084 'type' : 'int',
4086 'hostgroup_num_services_hard_ok' : {
4087 'description' : 'The total number of services with the state OK of hosts in this group',
4088 'type' : 'int',
4090 'hostgroup_num_services_hard_unknown' : {
4091 'description' : 'The total number of services with the state UNKNOWN of hosts in this group',
4092 'type' : 'int',
4094 'hostgroup_num_services_hard_warn' : {
4095 'description' : 'The total number of services with the state WARN of hosts in this group',
4096 'type' : 'int',
4098 'hostgroup_num_services_ok' : {
4099 'description' : 'The total number of services with the state OK of hosts in this group',
4100 'type' : 'int',
4102 'hostgroup_num_services_pending' : {
4103 'description' : 'The total number of services with the state Pending of hosts in this group',
4104 'type' : 'int',
4106 'hostgroup_num_services_unknown' : {
4107 'description' : 'The total number of services with the state UNKNOWN of hosts in this group',
4108 'type' : 'int',
4110 'hostgroup_num_services_warn' : {
4111 'description' : 'The total number of services with the state WARN of hosts in this group',
4112 'type' : 'int',
4114 'hostgroup_worst_host_state' : {
4115 'description' : 'The worst state of all of the groups\' hosts (UP <= UNREACHABLE <= DOWN)',
4116 'type' : 'int',
4118 'hostgroup_worst_service_hard_state' : {
4119 'description' : 'The worst state of all services that belong to a host of this group (OK <= WARN <= UNKNOWN <= CRIT)',
4120 'type' : 'int',
4122 'hostgroup_worst_service_state' : {
4123 'description' : 'The worst state of all services that belong to a host of this group (OK <= WARN <= UNKNOWN <= CRIT)',
4124 'type' : 'int',
4128 #All the global config parameters
4130 'Config' : {
4131 'accept_passive_host_checks' : {
4132 'default' : '0',
4133 'depythonize' : from_bool_to_int,
4134 'description' : 'Whether passive host checks are accepted in general (0/1)',
4135 'prop' : 'passive_host_checks_enabled',
4136 'type' : 'int',
4138 'accept_passive_service_checks' : {
4139 'default' : '0',
4140 'depythonize' : from_bool_to_int,
4141 'description' : 'Whether passive service checks are activated in general (0/1)',
4142 'prop' : 'passive_service_checks_enabled',
4143 'type' : 'int',
4145 'cached_log_messages' : {
4146 'default' : '0',
4147 'description' : 'The current number of log messages MK Livestatus keeps in memory',
4148 'prop' : None,
4149 'type' : 'int',
4151 'check_external_commands' : {
4152 'default' : '0',
4153 'depythonize' : from_bool_to_int,
4154 'description' : 'Whether Nagios checks for external commands at its command pipe (0/1)',
4155 'prop' : None,
4156 'type' : 'int',
4158 'check_host_freshness' : {
4159 'default' : '0',
4160 'depythonize' : from_bool_to_int,
4161 'description' : 'Whether host freshness checking is activated in general (0/1)',
4162 'prop' : None,
4163 'type' : 'int',
4165 'check_service_freshness' : {
4166 'default' : '0',
4167 'depythonize' : from_bool_to_int,
4168 'description' : 'Whether service freshness checking is activated in general (0/1)',
4169 'prop' : None,
4170 'type' : 'int',
4172 'connections' : {
4173 'default' : '0',
4174 'description' : 'The number of client connections to Livestatus since program start',
4175 'prop' : None,
4176 'type' : 'int',
4178 'connections_rate' : {
4179 'default' : '0',
4180 'description' : 'The averaged number of new client connections to Livestatus per second',
4181 'prop' : None,
4182 'type' : 'float',
4184 'enable_event_handlers' : {
4185 'default' : '0',
4186 'depythonize' : from_bool_to_int,
4187 'description' : 'Whether event handlers are activated in general (0/1)',
4188 'prop' : 'event_handlers_enabled',
4189 'type' : 'int',
4191 'enable_flap_detection' : {
4192 'default' : '0',
4193 'depythonize' : from_bool_to_int,
4194 'description' : 'Whether flap detection is activated in general (0/1)',
4195 'prop' : 'flap_detection_enabled',
4196 'type' : 'int',
4198 'enable_notifications' : {
4199 'default' : '0',
4200 'depythonize' : from_bool_to_int,
4201 'description' : 'Whether notifications are enabled in general (0/1)',
4202 'prop' : 'notifications_enabled',
4203 'type' : 'int',
4205 'execute_host_checks' : {
4206 'default' : '1',
4207 'depythonize' : from_bool_to_int,
4208 'description' : 'Whether host checks are executed in general (0/1)',
4209 'prop' : 'active_host_checks_enabled',
4210 'type' : 'int',
4212 'execute_service_checks' : {
4213 'default' : '1',
4214 'depythonize' : from_bool_to_int,
4215 'description' : 'Whether active service checks are activated in general (0/1)',
4216 'prop' : 'active_service_checks_enabled',
4217 'type' : 'int',
4219 'host_checks' : {
4220 'default' : '0',
4221 'description' : 'The number of host checks since program start',
4222 'prop' : None,
4223 'type' : 'int',
4225 'host_checks_rate' : {
4226 'default' : '0',
4227 'description' : 'the averaged number of host checks per second',
4228 'prop' : None,
4229 'type' : 'float',
4231 'interval_length' : {
4232 'default' : '0',
4233 'description' : 'The default interval length from nagios.cfg',
4234 'prop' : None,
4235 'type' : 'int',
4237 'last_command_check' : {
4238 'default' : '0',
4239 'description' : 'The time of the last check for a command as UNIX timestamp',
4240 'prop' : None,
4241 'type' : 'int',
4243 'last_log_rotation' : {
4244 'default' : '0',
4245 'description' : 'Time time of the last log file rotation',
4246 'prop' : None,
4247 'type' : 'int',
4249 'livestatus_version' : {
4250 'default' : '1.1.3',
4251 'description' : 'The version of the MK Livestatus module',
4252 'prop' : None,
4253 'type' : 'string',
4255 'nagios_pid' : {
4256 'default' : '0',
4257 'description' : 'The process ID of the Nagios main process',
4258 'prop' : 'pid',
4259 'type' : 'int',
4261 'neb_callbacks' : {
4262 'default' : '0',
4263 'description' : 'The number of NEB call backs since program start',
4264 'prop' : None,
4265 'type' : 'int',
4267 'neb_callbacks_rate' : {
4268 'default' : '0',
4269 'description' : 'The averaged number of NEB call backs per second',
4270 'prop' : None,
4271 'type' : 'float',
4273 'obsess_over_hosts' : {
4274 'default' : '0',
4275 'depythonize' : from_bool_to_int,
4276 'description' : 'Whether Nagios will obsess over host checks (0/1)',
4277 'prop' : None,
4278 'type' : 'int',
4280 'obsess_over_services' : {
4281 'default' : '0',
4282 'depythonize' : from_bool_to_int,
4283 'description' : 'Whether Nagios will obsess over service checks and run the ocsp_command (0/1)',
4284 'prop' : None,
4285 'type' : 'int',
4287 'process_performance_data' : {
4288 'default' : '0',
4289 'depythonize' : from_bool_to_int,
4290 'description' : 'Whether processing of performance data is activated in general (0/1)',
4291 'prop' : None,
4292 'type' : 'int',
4294 'program_start' : {
4295 'default' : '0',
4296 'description' : 'The time of the last program start as UNIX timestamp',
4297 'prop' : None,
4298 'type' : 'int',
4300 'program_version' : {
4301 'default' : '0.1',
4302 'description' : 'The version of the monitoring daemon',
4303 'prop' : None,
4304 'type' : 'string',
4306 'requests' : {
4307 'default' : '0',
4308 'description' : 'The number of requests to Livestatus since program start',
4309 'prop' : None,
4310 'type' : 'int',
4312 'requests_rate' : {
4313 'default' : '0',
4314 'description' : 'The averaged number of request to Livestatus per second',
4315 'prop' : None,
4316 'type' : 'float',
4318 'service_checks' : {
4319 'default' : '0',
4320 'description' : 'The number of completed service checks since program start',
4321 'prop' : None,
4322 'type' : 'int',
4324 'service_checks_rate' : {
4325 'default' : '0',
4326 'description' : 'The averaged number of service checks per second',
4327 'prop' : None,
4328 'type' : 'float',
4333 #Logs
4335 'Logline' : {
4336 'attempt' : {
4337 'description' : 'The number of the check attempt',
4338 'type' : 'int',
4340 'class' : {
4341 'description' : 'The class of the message as integer (0:info, 1:state, 2:program, 3:notification, 4:passive, 5:command)',
4342 'type' : 'int',
4344 'command_name' : {
4345 'description' : 'The name of the command of the log entry (e.g. for notifications)',
4346 'type' : 'string',
4348 'comment' : {
4349 'description' : 'A comment field used in various message types',
4350 'type' : 'string',
4352 'contact_name' : {
4353 'description' : 'The name of the contact the log entry is about (might be empty)',
4354 'type' : 'string',
4356 'current_command_line' : {
4357 'description' : 'The shell command line',
4358 'type' : 'string',
4360 'current_command_name' : {
4361 'description' : 'The name of the command',
4362 'type' : 'string',
4364 'current_contact_address1' : {
4365 'description' : 'The additional field address1',
4366 'type' : 'string',
4368 'current_contact_address2' : {
4369 'description' : 'The additional field address2',
4370 'type' : 'string',
4372 'current_contact_address3' : {
4373 'description' : 'The additional field address3',
4374 'type' : 'string',
4376 'current_contact_address4' : {
4377 'description' : 'The additional field address4',
4378 'type' : 'string',
4380 'current_contact_address5' : {
4381 'description' : 'The additional field address5',
4382 'type' : 'string',
4384 'current_contact_address6' : {
4385 'description' : 'The additional field address6',
4386 'type' : 'string',
4388 'current_contact_alias' : {
4389 'description' : 'The full name of the contact',
4390 'type' : 'string',
4392 'current_contact_can_submit_commands' : {
4393 'description' : 'Wether the contact is allowed to submit commands (0/1)',
4394 'type' : 'int',
4396 'current_contact_custom_variable_names' : {
4397 'description' : 'A list of all custom variables of the contact',
4398 'type' : 'list',
4400 'current_contact_custom_variable_values' : {
4401 'description' : 'A list of the values of all custom variables of the contact',
4402 'type' : 'list',
4404 'current_contact_email' : {
4405 'description' : 'The email address of the contact',
4406 'type' : 'string',
4408 'current_contact_host_notification_period' : {
4409 'description' : 'The time period in which the contact will be notified about host problems',
4410 'type' : 'string',
4412 'current_contact_host_notifications_enabled' : {
4413 'description' : 'Wether the contact will be notified about host problems in general (0/1)',
4414 'type' : 'int',
4416 'current_contact_in_host_notification_period' : {
4417 'description' : 'Wether the contact is currently in his/her host notification period (0/1)',
4418 'type' : 'int',
4420 'current_contact_in_service_notification_period' : {
4421 'description' : 'Wether the contact is currently in his/her service notification period (0/1)',
4422 'type' : 'int',
4424 'current_contact_name' : {
4425 'description' : 'The login name of the contact person',
4426 'type' : 'string',
4428 'current_contact_pager' : {
4429 'description' : 'The pager address of the contact',
4430 'type' : 'string',
4432 'current_contact_service_notification_period' : {
4433 'description' : 'The time period in which the contact will be notified about service problems',
4434 'type' : 'string',
4436 'current_contact_service_notifications_enabled' : {
4437 'description' : 'Wether the contact will be notified about service problems in general (0/1)',
4438 'type' : 'int',
4440 'current_host_accept_passive_checks' : {
4441 'description' : 'Wether passive host checks are accepted (0/1)',
4442 'type' : 'int',
4444 'current_host_acknowledged' : {
4445 'description' : 'Wether the current host problem has been acknowledged (0/1)',
4446 'type' : 'int',
4448 'current_host_acknowledgement_type' : {
4449 'description' : 'Type of acknowledgement (0: none, 1: normal, 2: stick)',
4450 'type' : 'int',
4452 'current_host_action_url' : {
4453 'description' : 'An optional URL to custom actions or information about this host',
4454 'type' : 'string',
4456 'current_host_action_url_expanded' : {
4457 'description' : 'The same as action_url, but with the most important macros expanded',
4458 'type' : 'string',
4460 'current_host_active_checks_enabled' : {
4461 'description' : 'Wether active checks are enabled for the host (0/1)',
4462 'type' : 'int',
4464 'current_host_address' : {
4465 'description' : 'IP address',
4466 'type' : 'string',
4468 'current_host_alias' : {
4469 'description' : 'An alias name for the host',
4470 'type' : 'string',
4472 'current_host_check_command' : {
4473 'description' : 'Nagios command for active host check of this host',
4474 'type' : 'string',
4476 'current_host_check_freshness' : {
4477 'description' : 'Wether freshness checks are activated (0/1)',
4478 'type' : 'int',
4480 'current_host_check_interval' : {
4481 'description' : 'Number of basic interval lengths between two scheduled checks of the host',
4482 'type' : 'float',
4484 'current_host_check_options' : {
4485 'description' : 'The current check option, forced, normal, freshness... (0-2)',
4486 'type' : 'int',
4488 'current_host_check_period' : {
4489 'description' : 'Time period in which this host will be checked. If empty then the host will always be checked.',
4490 'type' : 'string',
4492 'current_host_check_type' : {
4493 'description' : 'Type of check (0: active, 1: passive)',
4494 'type' : 'int',
4496 'current_host_checks_enabled' : {
4497 'description' : 'Wether checks of the host are enabled (0/1)',
4498 'type' : 'int',
4500 'current_host_childs' : {
4501 'description' : 'A list of all direct childs of the host',
4502 'type' : 'list',
4504 'current_host_comments' : {
4505 'description' : 'A list of the ids of all comments of this host',
4506 'type' : 'list',
4508 'current_host_contacts' : {
4509 'description' : 'A list of all contacts of this host, either direct or via a contact group',
4510 'type' : 'list',
4512 'current_host_current_attempt' : {
4513 'description' : 'Number of the current check attempts',
4514 'type' : 'int',
4516 'current_host_current_notification_number' : {
4517 'description' : 'Number of the current notification',
4518 'type' : 'int',
4520 'current_host_custom_variable_names' : {
4521 'description' : 'A list of the names of all custom variables',
4522 'type' : 'list',
4524 'current_host_custom_variable_values' : {
4525 'description' : 'A list of the values of the custom variables',
4526 'type' : 'list',
4528 'current_host_display_name' : {
4529 'description' : 'Optional display name of the host - not used by Nagios\' web interface',
4530 'type' : 'string',
4532 'current_host_downtimes' : {
4533 'description' : 'A list of the ids of all scheduled downtimes of this host',
4534 'type' : 'list',
4536 'current_host_event_handler_enabled' : {
4537 'description' : 'Wether event handling is enabled (0/1)',
4538 'type' : 'int',
4540 'current_host_execution_time' : {
4541 'description' : 'Time the host check needed for execution',
4542 'type' : 'float',
4544 'current_host_first_notification_delay' : {
4545 'description' : 'Delay before the first notification',
4546 'type' : 'float',
4548 'current_host_flap_detection_enabled' : {
4549 'description' : 'Wether flap detection is enabled (0/1)',
4550 'type' : 'int',
4552 'current_host_groups' : {
4553 'description' : 'A list of all host groups this host is in',
4554 'type' : 'list',
4556 'current_host_hard_state' : {
4557 'description' : 'The effective hard state of the host (eliminates a problem in hard_state)',
4558 'type' : 'int',
4560 'current_host_has_been_checked' : {
4561 'description' : 'Wether the host has already been checked (0/1)',
4562 'type' : 'int',
4564 'current_host_high_flap_threshold' : {
4565 'description' : 'High threshold of flap detection',
4566 'type' : 'float',
4568 'current_host_icon_image' : {
4569 'description' : 'The name of an image file to be used in the web pages',
4570 'type' : 'string',
4572 'current_host_icon_image_alt' : {
4573 'description' : 'Alternative text for the icon_image',
4574 'type' : 'string',
4576 'current_host_icon_image_expanded' : {
4577 'description' : 'The same as icon_image, but with the most important macros expanded',
4578 'type' : 'string',
4580 'current_host_in_check_period' : {
4581 'description' : 'Wether this host is currently in its check period (0/1)',
4582 'type' : 'int',
4584 'current_host_in_notification_period' : {
4585 'description' : 'Wether this host is currently in its notification period (0/1)',
4586 'type' : 'int',
4588 'current_host_initial_state' : {
4589 'description' : 'Initial host state',
4590 'type' : 'int',
4592 'current_host_is_executing' : {
4593 'default' : 0, # value in scheduler is not real-time
4594 'description' : 'is there a host check currently running... (0/1)',
4595 'type' : 'int',
4597 'current_host_is_flapping' : {
4598 'description' : 'Wether the host state is flapping (0/1)',
4599 'type' : 'int',
4601 'current_host_last_check' : {
4602 'description' : 'Time of the last check (Unix timestamp)',
4603 'type' : 'int',
4605 'current_host_last_hard_state' : {
4606 'description' : 'Last hard state',
4607 'type' : 'int',
4609 'current_host_last_hard_state_change' : {
4610 'description' : 'Time of the last hard state change (Unix timestamp)',
4611 'type' : 'int',
4613 'current_host_last_notification' : {
4614 'description' : 'Time of the last notification (Unix timestamp)',
4615 'type' : 'int',
4617 'current_host_last_state' : {
4618 'description' : 'State before last state change',
4619 'type' : 'int',
4621 'current_host_last_state_change' : {
4622 'description' : 'Time of the last state change - soft or hard (Unix timestamp)',
4623 'type' : 'int',
4625 'current_host_latency' : {
4626 'description' : 'Time difference between scheduled check time and actual check time',
4627 'type' : 'float',
4629 'current_host_long_plugin_output' : {
4630 'description' : 'Complete output from check plugin',
4631 'type' : 'string',
4633 'current_host_low_flap_threshold' : {
4634 'description' : 'Low threshold of flap detection',
4635 'type' : 'float',
4637 'current_host_max_check_attempts' : {
4638 'description' : 'Max check attempts for active host checks',
4639 'type' : 'int',
4641 'current_host_name' : {
4642 'default' : '',
4643 'depythonize' : lambda x: x.get_name(),
4644 'description' : 'Host name',
4645 'prop' : 'log_host',
4646 'type' : 'string',
4648 'current_host_next_check' : {
4649 'description' : 'Scheduled time for the next check (Unix timestamp)',
4650 'type' : 'int',
4652 'current_host_next_notification' : {
4653 'description' : 'Time of the next notification (Unix timestamp)',
4654 'type' : 'int',
4656 'current_host_notes' : {
4657 'description' : 'Optional notes for this host',
4658 'type' : 'string',
4660 'current_host_notes_expanded' : {
4661 'description' : 'The same as notes, but with the most important macros expanded',
4662 'type' : 'string',
4664 'current_host_notes_url' : {
4665 'description' : 'An optional URL with further information about the host',
4666 'type' : 'string',
4668 'current_host_notes_url_expanded' : {
4669 'description' : 'Same es notes_url, but with the most important macros expanded',
4670 'type' : 'string',
4672 'current_host_notification_interval' : {
4673 'description' : 'Interval of periodic notification or 0 if its off',
4674 'type' : 'float',
4676 'current_host_notification_period' : {
4677 'description' : 'Time period in which problems of this host will be notified. If empty then notification will be always',
4678 'type' : 'string',
4680 'current_host_notifications_enabled' : {
4681 'description' : 'Wether notifications of the host are enabled (0/1)',
4682 'type' : 'int',
4684 'current_host_num_services' : {
4685 'description' : 'The total number of services of the host',
4686 'type' : 'list',
4688 'current_host_num_services_crit' : {
4689 'description' : 'The number of the host\'s services with the soft state CRIT',
4690 'type' : 'list',
4692 'current_host_num_services_hard_crit' : {
4693 'description' : 'The number of the host\'s services with the hard state CRIT',
4694 'type' : 'list',
4696 'current_host_num_services_hard_ok' : {
4697 'description' : 'The number of the host\'s services with the hard state OK',
4698 'type' : 'list',
4700 'current_host_num_services_hard_unknown' : {
4701 'description' : 'The number of the host\'s services with the hard state UNKNOWN',
4702 'type' : 'list',
4704 'current_host_num_services_hard_warn' : {
4705 'description' : 'The number of the host\'s services with the hard state WARN',
4706 'type' : 'list',
4708 'current_host_num_services_ok' : {
4709 'description' : 'The number of the host\'s services with the soft state OK',
4710 'type' : 'list',
4712 'current_host_num_services_pending' : {
4713 'description' : 'The number of the host\'s services which have not been checked yet (pending)',
4714 'type' : 'list',
4716 'current_host_num_services_unknown' : {
4717 'description' : 'The number of the host\'s services with the soft state UNKNOWN',
4718 'type' : 'list',
4720 'current_host_num_services_warn' : {
4721 'description' : 'The number of the host\'s services with the soft state WARN',
4722 'type' : 'list',
4724 'current_host_obsess_over_host' : {
4725 'description' : 'The current obsess_over_host setting... (0/1)',
4726 'type' : 'int',
4728 'current_host_parents' : {
4729 'description' : 'A list of all direct parents of the host',
4730 'type' : 'list',
4732 'current_host_pending_flex_downtime' : {
4733 'description' : 'Wether a flex downtime is pending (0/1)',
4734 'type' : 'int',
4736 'current_host_percent_state_change' : {
4737 'description' : 'Percent state change',
4738 'type' : 'float',
4740 'current_host_perf_data' : {
4741 'description' : 'Optional performance data of the last host check',
4742 'type' : 'string',
4744 'current_host_plugin_output' : {
4745 'description' : 'Output of the last host check',
4746 'type' : 'string',
4748 'current_host_process_performance_data' : {
4749 'description' : 'Wether processing of performance data is enabled (0/1)',
4750 'type' : 'int',
4752 'current_host_retry_interval' : {
4753 'description' : 'Number of basic interval lengths between checks when retrying after a soft error',
4754 'type' : 'float',
4756 'current_host_scheduled_downtime_depth' : {
4757 'description' : 'The number of downtimes this host is currently in',
4758 'type' : 'int',
4760 'current_host_state' : {
4761 'description' : 'The current state of the host (0: up, 1: down, 2: unreachable)',
4762 'type' : 'int',
4764 'current_host_state_type' : {
4765 'description' : 'Type of the current state (0: soft, 1: hard)',
4766 'type' : 'int',
4768 'current_host_statusmap_image' : {
4769 'description' : 'The name of in image file for the status map',
4770 'type' : 'string',
4772 'current_host_total_services' : {
4773 'description' : 'The total number of services of the host',
4774 'type' : 'int',
4776 'current_host_worst_service_hard_state' : {
4777 'description' : 'The worst hard state of all of the host\'s services (OK <= WARN <= UNKNOWN <= CRIT)',
4778 'type' : 'list',
4780 'current_host_worst_service_state' : {
4781 'description' : 'The worst soft state of all of the host\'s services (OK <= WARN <= UNKNOWN <= CRIT)',
4782 'type' : 'list',
4784 'current_host_x_3d' : {
4785 'description' : '3D-Coordinates: X',
4786 'type' : 'float',
4788 'current_host_y_3d' : {
4789 'description' : '3D-Coordinates: Y',
4790 'type' : 'float',
4792 'current_host_z_3d' : {
4793 'description' : '3D-Coordinates: Z',
4794 'type' : 'float',
4796 'current_service_accept_passive_checks' : {
4797 'description' : 'Wether the service accepts passive checks (0/1)',
4798 'type' : 'int',
4800 'current_service_acknowledged' : {
4801 'description' : 'Wether the current service problem has been acknowledged (0/1)',
4802 'type' : 'int',
4804 'current_service_acknowledgement_type' : {
4805 'description' : 'The type of the acknownledgement (0: none, 1: normal, 2: sticky)',
4806 'type' : 'int',
4808 'current_service_action_url' : {
4809 'description' : 'An optional URL for actions or custom information about the service',
4810 'type' : 'string',
4812 'current_service_action_url_expanded' : {
4813 'description' : 'The action_url with (the most important) macros expanded',
4814 'type' : 'string',
4816 'current_service_active_checks_enabled' : {
4817 'description' : 'Wether active checks are enabled for the service (0/1)',
4818 'type' : 'int',
4820 'current_service_check_command' : {
4821 'description' : 'Nagios command used for active checks',
4822 'type' : 'string',
4824 'current_service_check_interval' : {
4825 'description' : 'Number of basic interval lengths between two scheduled checks of the service',
4826 'type' : 'float',
4828 'current_service_check_options' : {
4829 'description' : 'The current check option, forced, normal, freshness... (0/1)',
4830 'type' : 'int',
4832 'current_service_check_period' : {
4833 'description' : 'The name of the check period of the service. It this is empty, the service is always checked.',
4834 'type' : 'string',
4836 'current_service_check_type' : {
4837 'description' : 'The type of the last check (0: active, 1: passive)',
4838 'type' : 'int',
4840 'current_service_checks_enabled' : {
4841 'description' : 'Wether active checks are enabled for the service (0/1)',
4842 'type' : 'int',
4844 'current_service_comments' : {
4845 'description' : 'A list of all comment ids of the service',
4846 'type' : 'list',
4848 'current_service_contacts' : {
4849 'description' : 'A list of all contacts of the service, either direct or via a contact group',
4850 'type' : 'list',
4852 'current_service_current_attempt' : {
4853 'description' : 'The number of the current check attempt',
4854 'type' : 'int',
4856 'current_service_current_notification_number' : {
4857 'description' : 'The number of the current notification',
4858 'type' : 'int',
4860 'current_service_custom_variable_names' : {
4861 'description' : 'A list of the names of all custom variables of the service',
4862 'type' : 'list',
4864 'current_service_custom_variable_values' : {
4865 'description' : 'A list of the values of all custom variable of the service',
4866 'type' : 'list',
4868 'current_service_description' : {
4869 'default' : '',
4870 'depythonize' : lambda x: x.get_name(),
4871 'description' : 'Description of the service (also used as key)',
4872 'prop' : 'log_service',
4873 'type' : 'string',
4875 'current_service_display_name' : {
4876 'description' : 'An optional display name (not used by Nagios standard web pages)',
4877 'type' : 'string',
4879 'current_service_downtimes' : {
4880 'description' : 'A list of all downtime ids of the service',
4881 'type' : 'list',
4883 'current_service_event_handler' : {
4884 'description' : 'Nagios command used as event handler',
4885 'type' : 'string',
4887 'current_service_event_handler_enabled' : {
4888 'description' : 'Wether and event handler is activated for the service (0/1)',
4889 'type' : 'int',
4891 'current_service_execution_time' : {
4892 'description' : 'Time the host check needed for execution',
4893 'type' : 'float',
4895 'current_service_first_notification_delay' : {
4896 'description' : 'Delay before the first notification',
4897 'type' : 'float',
4899 'current_service_flap_detection_enabled' : {
4900 'description' : 'Wether flap detection is enabled for the service (0/1)',
4901 'type' : 'int',
4903 'current_service_groups' : {
4904 'description' : 'A list of all service groups the service is in',
4905 'type' : 'list',
4907 'current_service_has_been_checked' : {
4908 'description' : 'Wether the service already has been checked (0/1)',
4909 'type' : 'int',
4911 'current_service_high_flap_threshold' : {
4912 'description' : 'High threshold of flap detection',
4913 'type' : 'float',
4915 'current_service_icon_image' : {
4916 'description' : 'The name of an image to be used as icon in the web interface',
4917 'type' : 'string',
4919 'current_service_icon_image_alt' : {
4920 'description' : 'An alternative text for the icon_image for browsers not displaying icons',
4921 'type' : 'string',
4923 'current_service_icon_image_expanded' : {
4924 'description' : 'The icon_image with (the most important) macros expanded',
4925 'type' : 'string',
4927 'current_service_in_check_period' : {
4928 'description' : 'Wether the service is currently in its check period (0/1)',
4929 'type' : 'int',
4931 'current_service_in_notification_period' : {
4932 'description' : 'Wether the service is currently in its notification period (0/1)',
4933 'type' : 'int',
4935 'current_service_initial_state' : {
4936 'description' : 'The initial state of the service',
4937 'type' : 'int',
4939 'current_service_is_executing' : {
4940 'default' : 0, # value in scheduler is not real-time
4941 'description' : 'is there a service check currently running... (0/1)',
4942 'type' : 'int',
4944 'current_service_is_flapping' : {
4945 'description' : 'Wether the service is flapping (0/1)',
4946 'type' : 'int',
4948 'current_service_last_check' : {
4949 'description' : 'The time of the last check (Unix timestamp)',
4950 'type' : 'int',
4952 'current_service_last_hard_state' : {
4953 'description' : 'The last hard state of the service',
4954 'type' : 'int',
4956 'current_service_last_hard_state_change' : {
4957 'description' : 'The time of the last hard state change (Unix timestamp)',
4958 'type' : 'int',
4960 'current_service_last_notification' : {
4961 'description' : 'The time of the last notification (Unix timestamp)',
4962 'type' : 'int',
4964 'current_service_last_state' : {
4965 'description' : 'The last state of the service',
4966 'type' : 'int',
4968 'current_service_last_state_change' : {
4969 'description' : 'The time of the last state change (Unix timestamp)',
4970 'type' : 'int',
4972 'current_service_latency' : {
4973 'description' : 'Time difference between scheduled check time and actual check time',
4974 'type' : 'float',
4976 'current_service_long_plugin_output' : {
4977 'description' : 'Unabbreviated output of the last check plugin',
4978 'type' : 'string',
4980 'current_service_low_flap_threshold' : {
4981 'description' : 'Low threshold of flap detection',
4982 'type' : 'float',
4984 'current_service_max_check_attempts' : {
4985 'description' : 'The maximum number of check attempts',
4986 'type' : 'int',
4988 'current_service_next_check' : {
4989 'description' : 'The scheduled time of the next check (Unix timestamp)',
4990 'type' : 'int',
4992 'current_service_next_notification' : {
4993 'description' : 'The time of the next notification (Unix timestamp)',
4994 'type' : 'int',
4996 'current_service_notes' : {
4997 'description' : 'Optional notes about the service',
4998 'type' : 'string',
5000 'current_service_notes_expanded' : {
5001 'description' : 'The notes with (the most important) macros expanded',
5002 'type' : 'string',
5004 'current_service_notes_url' : {
5005 'description' : 'An optional URL for additional notes about the service',
5006 'type' : 'string',
5008 'current_service_notes_url_expanded' : {
5009 'description' : 'The notes_url with (the most important) macros expanded',
5010 'type' : 'string',
5012 'current_service_notification_interval' : {
5013 'description' : 'Interval of periodic notification or 0 if its off',
5014 'type' : 'float',
5016 'current_service_notification_period' : {
5017 'description' : 'The name of the notification period of the service. It this is empty, service problems are always notified.',
5018 'type' : 'string',
5020 'current_service_notifications_enabled' : {
5021 'description' : 'Wether notifications are enabled for the service (0/1)',
5022 'type' : 'int',
5024 'current_service_obsess_over_service' : {
5025 'description' : 'Wether \'obsess_over_service\' is enabled for the service (0/1)',
5026 'type' : 'int',
5028 'current_service_percent_state_change' : {
5029 'description' : 'Percent state change',
5030 'type' : 'float',
5032 'current_service_perf_data' : {
5033 'description' : 'Performance data of the last check plugin',
5034 'type' : 'string',
5036 'current_service_plugin_output' : {
5037 'description' : 'Output of the last check plugin',
5038 'type' : 'string',
5040 'current_service_process_performance_data' : {
5041 'description' : 'Wether processing of performance data is enabled for the service (0/1)',
5042 'type' : 'int',
5044 'current_service_retry_interval' : {
5045 'description' : 'Number of basic interval lengths between checks when retrying after a soft error',
5046 'type' : 'float',
5048 'current_service_scheduled_downtime_depth' : {
5049 'description' : 'The number of scheduled downtimes the service is currently in',
5050 'type' : 'int',
5052 'current_service_state' : {
5053 'description' : 'The current state of the service (0: OK, 1: WARN, 2: CRITICAL, 3: UNKNOWN)',
5054 'type' : 'int',
5056 'current_service_state_type' : {
5057 'description' : 'The type of the current state (0: soft, 1: hard)',
5058 'type' : 'int',
5060 'host_name' : {
5061 'description' : 'The name of the host the log entry is about (might be empty)',
5062 'type' : 'string',
5064 'lineno' : {
5065 'description' : 'The number of the line in the log file',
5066 'type' : 'int',
5068 'message' : {
5069 'description' : 'The complete message line including the timestamp',
5070 'type' : 'string',
5072 'options' : {
5073 'description' : 'The part of the message after the \':\'',
5074 'type' : 'string',
5076 'plugin_output' : {
5077 'description' : 'The output of the check, if any is associated with the message',
5078 'type' : 'string',
5080 'service_description' : {
5081 'description' : 'The description of the service log entry is about (might be empty)',
5082 'type' : 'string',
5084 'state' : {
5085 'default' : 0,
5086 'description' : 'The state of the host or service in question',
5087 'prop' : 'state',
5088 'type' : 'int',
5090 'state_type' : {
5091 'description' : 'The type of the state (varies on different log classes)',
5092 'type' : 'string',
5094 'time' : {
5095 'default' : 0,
5096 'description' : 'Time of the log event (UNIX timestamp)',
5097 'prop' : 'time',
5098 'type' : 'int',
5100 'type' : {
5101 'description' : 'The type of the message (text before the colon), the message itself for info messages',
5102 'type' : 'string',
5109 def __init__(self, configs, hostname_lookup_table, servicename_lookup_table, hosts, services, contacts, hostgroups, servicegroups, contactgroups, timeperiods, commands, schedulers, pollers, reactionners, brokers, dbconn, return_queue):
5110 #self.conf = scheduler.conf
5111 #self.scheduler = scheduler
5112 self.configs = configs
5113 self.hostname_lookup_table = hostname_lookup_table
5114 self.servicename_lookup_table = servicename_lookup_table
5115 self.hosts = hosts
5116 self.services = services
5117 self.contacts = contacts
5118 self.hostgroups = hostgroups
5119 self.servicegroups = servicegroups
5120 self.contactgroups = contactgroups
5121 self.timeperiods = timeperiods
5122 self.commands = commands
5123 self.schedulers = schedulers
5124 self.pollers = pollers
5125 self.reactionners = reactionners
5126 self.brokers = brokers
5127 self.dbconn = dbconn
5128 self.debuglevel = 2
5129 self.dbconn.row_factory = self.row_factory
5130 self.return_queue = return_queue
5131 self.inversed_stack_queue = (Queue.LifoQueue == Queue.Queue) # if the Queue is not in the good order for python 2.4
5132 # add Host attributes to Hostsbygroup
5133 for attribute in LiveStatus.out_map['Host']:
5134 LiveStatus.out_map['Hostsbygroup'][attribute] = LiveStatus.out_map['Host'][attribute]
5135 for attribute in LiveStatus.out_map['Service']:
5136 LiveStatus.out_map['Servicesbygroup'][attribute] = LiveStatus.out_map['Service'][attribute]
5137 for attribute in LiveStatus.out_map['Service']:
5138 LiveStatus.out_map['Servicesbyhostgroup'][attribute] = LiveStatus.out_map['Service'][attribute]
5141 def debug(self, debuglevel, message):
5142 f = open("/tmp/livestatus.debug", "a")
5143 f.write(message)
5144 f.write("\n")
5145 f.close()
5146 if self.debuglevel >= debuglevel:
5147 print message
5150 # Find the converter function for a table/attribute pair
5151 def find_converter(self, table, attribute):
5152 out_map = {
5153 'hosts' : LiveStatus.out_map['Host'],
5154 'services' : LiveStatus.out_map['Service'],
5155 'hostgroups' : LiveStatus.out_map['Hostgroup'],
5156 'servicegroups' : LiveStatus.out_map['Servicegroup'],
5157 'contacts' : LiveStatus.out_map['Contact'],
5158 'contactgroups' : LiveStatus.out_map['Contactgroup'],
5159 'comments' : LiveStatus.out_map['Comment'],
5160 'downtimes' : LiveStatus.out_map['Downtime'],
5161 'commands' : LiveStatus.out_map['Command'],
5162 'timeperiods' : LiveStatus.out_map['Timeperiod'],
5163 'hostsbygroup' : LiveStatus.out_map['Hostsbygroup'],
5164 'servicesbygroup' : LiveStatus.out_map['Servicesbygroup'],
5165 'servicesbyhostgroup' : LiveStatus.out_map['Servicesbyhostgroup'],
5166 'status' : LiveStatus.out_map['Config'],
5167 'log' : LiveStatus.out_map['Logline'],
5168 'schedulers' : LiveStatus.out_map['SchedulerLink'],
5169 'pollers' : LiveStatus.out_map['PollerLink'],
5170 'reactionners' : LiveStatus.out_map['ReactionnerLink'],
5171 'brokers' : LiveStatus.out_map['BrokerLink'],
5172 'problems' : LiveStatus.out_map['Problem'],
5173 }[table]
5174 if attribute in out_map and 'type' in out_map[attribute]:
5175 if out_map[attribute]['type'] == 'int':
5176 return int
5177 elif out_map[attribute]['type'] == 'float':
5178 return float
5179 #if attribute in out_map and 'converter' in out_map[attribute]:
5180 # return out_map[attribute]['converter']
5181 return None
5184 def create_output(self, type_map, elt, attributes, filterattributes):
5185 output = {}
5186 # type_map is usually LiveStatus.out_map[elt.__class__.__name__]
5187 # But instead of Host it can also be Hostbygroup
5188 if len(attributes + filterattributes) == 0:
5189 display_attributes = type_map.keys()
5190 else:
5191 display_attributes = list(set(attributes + filterattributes))
5192 for display in display_attributes:
5193 value = ''
5194 if display not in type_map:
5195 # no mapping, use it as a direct attribute
5196 value = getattr(elt, display, '')
5197 else:
5198 if 'prop' not in type_map[display] or type_map[display]['prop'] == None:
5199 # display is listed, but prop is not set. this must be a direct attribute
5200 prop = display
5201 else:
5202 # We have a prop, this means some kind of mapping between the display name (livestatus column)
5203 # and an internal name must happen
5204 prop = type_map[display]['prop']
5205 value = getattr(elt, prop, None)
5206 # Some attributes of Contact/Host are by defautl 'none'
5207 # TODO: look if this can be None in contact.py, host.py
5208 if value == 'none':
5209 value = None
5210 if value != None:
5211 # The name/function listed in prop exists
5212 #Maybe it's not a value, but a function link
5213 if callable(value):
5214 value = value()
5215 if display in type_map and 'depythonize' in type_map[display]:
5216 f = type_map[display]['depythonize']
5217 if callable(f):
5218 #for example "from_list_to_split". value is an array and f takes the array as an argument
5219 value = f(value)
5220 else:
5221 if isinstance(value, list):
5222 #depythonize's argument might be an attribute or a method
5223 #example: members is an array of hosts and we want get_name() of each element
5224 value = [getattr(item, f)() for item in value if callable(getattr(item, f)) ] \
5225 + [getattr(item, f) for item in value if not callable(getattr(item, f)) ]
5226 #at least servicegroups are nested [host,service],.. The need some flattening
5228 #I thin the 2 above lines are create a problem in json output at least
5229 #with service groups members that need to be [[hostname, desc], [hostname, desc]]
5230 #value = [y for x in value if isinstance(x, list) for y in x] + \
5231 # [x for x in value if not isinstance(x, list)]
5232 #print "DBG: Final value:", value
5234 else:
5235 #ok not a direct function, maybe a functin provided by value...
5236 f = getattr(value, f)
5237 if callable(f):
5238 value = f()
5239 else:
5240 value = f
5242 if len(str(value)) == 0:
5243 value = ''
5244 elif 'default' in type_map[display]:
5245 # display is not a known attribute, there is no prop for mapping, but
5246 # at least we have a default value
5247 value = type_map[display]['default']
5248 else:
5249 value = ''
5250 output[display] = value
5251 return output
5254 def get_live_data(self, table, columns, prefiltercolumns, filtercolumns, limit, filter_stack, stats_filter_stack, stats_postprocess_stack, stats_group_by):
5255 result = []
5256 if table in ['hosts', 'services', 'downtimes', 'comments', 'hostgroups', 'servicegroups', 'hostsbygroup', 'servicesbygroup', 'servicesbyhostgroup']:
5257 #Scan through the objects and apply the Filter: rules
5258 if table == 'hosts':
5259 type_map = LiveStatus.out_map['Host']
5260 without_filter = len(filtercolumns) == 0
5261 if not limit:
5262 filtresult = [self.create_output(type_map, y, columns, []) for y in (x for x in self.hosts.values() if (without_filter or filter_stack(self.create_output(type_map, x, [], filtercolumns))))]
5263 else:
5264 hosts = sorted(self.hosts.values(), key = lambda k: k.host_name)
5265 if len(filtercolumns) == 0:
5266 filtresult = [y for y in [self.create_output(type_map, x, columns, filtercolumns) for x in hosts] if filter_stack(y)]
5267 else:
5268 prefiltresult = (x for x in hosts if filter_stack(self.create_output(type_map, x, [], filtercolumns)))
5269 filtresult = [self.create_output(x, columns, filtercolumns) for x in prefiltresult]
5270 filtresult = filtresult[:limit]
5271 elif table == 'hostsbygroup':
5272 type_map = LiveStatus.out_map['Hostsbygroup']
5273 # instead of self.hosts.values()
5274 # loop over hostgroups, then over members, then flatten the list, then add a hostgroup attribute to each host
5275 without_filter = len(filtercolumns) == 0
5276 if not limit:
5277 filtresult = [self.create_output(type_map, x, columns, []) for x in [
5278 host for host in [
5279 setattr(hohg[0], 'hostgroup', hohg[1]) or hohg[0] for hohg in [
5280 # (host, hg), (host, hg), ... host objects are individuals
5281 (copy.copy(item0), inner_list0[1]) for inner_list0 in [
5282 # ([host, host, ...], hg), ([host], hg), ...
5283 (sorted(hg1.members, key = lambda k: k.host_name), hg1 ) for hg1 in
5284 # hostgroups sorted by hostgroup_name
5285 sorted([hg0 for hg0 in self.hostgroups.values() if hg0.members], key = lambda k: k.hostgroup_name)
5286 ] for item0 in inner_list0[0]
5288 ] if (without_filter or filter_stack(self.create_output(type_map, host, [], filtercolumns)))
5290 else:
5291 # Now implemented. Why would one limit this anyway?
5292 pass
5293 elif table == 'services':
5294 type_map = LiveStatus.out_map['Service']
5295 without_filter = len(filtercolumns) == 0
5296 if not limit:
5297 filtresult = [self.create_output(type_map, y, columns, []) for y in (x for x in self.services.values() if (without_filter or filter_stack(self.create_output(type_map, x, [], filtercolumns))))]
5298 else:
5299 services = sorted(self.services.values(), key = lambda k: (k.host_name, k.service_description))
5300 if len(filtercolumns) == 0:
5301 filtresult = [y for y in [self.create_output(type_map, x, columns, filtercolumns) for x in services] if filter_stack(y)]
5302 else:
5303 prefiltresult = (x for x in services if filter_stack(self.create_output(type_map, x, [], filtercolumns)))
5304 filtresult = [self.create_output(type_map, x, columns, filtercolumns) for x in prefiltresult]
5305 filtresult = filtresult[:limit]
5306 elif table == 'servicesbygroup':
5307 type_map = LiveStatus.out_map['Servicesbygroup']
5308 without_filter = len(filtercolumns) == 0
5309 # Here we have more generators instead of list comprehensions, but in fact it makes no difference
5310 # (Tested with 2000 services)
5311 if not limit:
5312 filtresult = [self.create_output(type_map, x, columns, []) for x in (
5313 svc for svc in (
5314 setattr(servicesg[0], 'servicegroup', servicesg[1]) or servicesg[0] for servicesg in (
5315 # (service, sg), (service, sg), ... service objects are individuals
5316 (copy.copy(item0), inner_list0[1]) for inner_list0 in (
5317 # ([service, service], sg), ([service, service, ...], sg), ... services are sorted
5318 (sorted(sg1.members, key = lambda k: k.get_full_name()), sg1) for sg1 in
5319 # servicegroups, sorted by their servicegroup_name
5320 sorted([sg0 for sg0 in self.servicegroups.values() if sg0.members], key = lambda k: k.servicegroup_name)
5321 ) for item0 in inner_list0[0]
5323 ) if (without_filter or filter_stack(self.create_output(type_map, svc, [], filtercolumns)))
5325 else:
5326 # Now implemented. Why would one limit this anyway?
5327 pass
5328 elif table == 'servicesbyhostgroup':
5329 # We will use prefiltercolumns here for some serious speedup.
5330 # For example, if nagvis wants Filter: host_groups >= hgxy
5331 # we don't have to use the while list of hostgroups in
5332 # the innermost loop
5333 type_map = LiveStatus.out_map['Servicesbyhostgroup']
5334 # Filter: host_groups >= linux-servers
5335 # host_groups is a service attribute
5336 # We can get all services of all hosts of all hostgroups and filter at the end
5337 # But it would save a lot of time to already filter the hostgroups. This means host_groups must be hard-coded
5338 # Also host_name, but then we must filter the second step.
5339 # And a mixture host_groups/host_name with FilterAnd/Or? Must have several filter functions
5340 # This is still under construction. The code can be made simpler
5341 without_filter = len(filtercolumns) == 0
5342 if not limit:
5343 filtresult = [self.create_output(type_map, x, columns, filtercolumns) for x in (
5344 svc for svc in (
5345 setattr(svchgrp[0], 'hostgroup', svchgrp[1]) or svchgrp[0] for svchgrp in (
5346 # (service, hostgroup), (service, hostgroup), (service, hostgroup), ... service objects are individuals
5347 (copy.copy(item1), inner_list1[1]) for inner_list1 in (
5348 # ([service, service, ...], hostgroup), ([service, ...], hostgroup), ... flattened by host. only if a host has services. sorted by service_description
5349 (sorted(item0.services, key = lambda k: k.service_description), inner_list0[1]) for inner_list0 in (
5350 # ([host, host, ...], hostgroup), ([host, host, host, ...], hostgroup), ... sorted by host_name
5351 (sorted(hg1.members, key = lambda k: k.host_name), hg1) for hg1 in # ([host, host], hg), ([host], hg),... hostgroup.members->explode->sort
5352 # hostgroups, sorted by hostgroup_name
5353 sorted([hg0 for hg0 in self.hostgroups.values() if hg0.members], key = lambda k: k.hostgroup_name)
5354 ) for item0 in inner_list0[0] if item0.services
5355 ) for item1 in inner_list1[0]
5357 ) if (without_filter or filter_stack(self.create_output(type_map, svc, [], filtercolumns)))
5359 else:
5360 # Now implemented. Why would one limit this anyway?
5361 pass
5362 elif table == 'downtimes':
5363 type_map = LiveStatus.out_map['Downtime']
5364 need_filter = len(filtercolumns) > 0
5365 if len(filtercolumns) == 0:
5366 filtresult = [self.create_output(type_map, y, columns, filtercolumns) for y in reduce(list.__add__, [x.downtimes for x in self.services.values() + self.hosts.values() if len(x.downtimes) > 0], [])]
5367 else:
5368 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_stack(self.create_output(type_map, d, [], filtercolumns))]
5369 filtresult = [self.create_output(type_map, x, columns, filtercolumns) for x in prefiltresult]
5370 elif table == 'comments':
5371 type_map = LiveStatus.out_map['Comment']
5372 if len(filtercolumns) == 0:
5373 filtresult = [self.create_output(type_map, y, columns, filtercolumns) for y in reduce(list.__add__, [x.comments for x in self.services.values() + self.hosts.values() if len(x.comments) > 0], [])]
5374 else:
5375 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_stack(self.create_output(type_map, c, [], filtercolumns))]
5376 filtresult = [self.create_output(type_map, x, columns, filtercolumns) for x in prefiltresult]
5377 elif table == 'hostgroups':
5378 type_map = LiveStatus.out_map['Hostgroup']
5379 if len(filtercolumns) == 0:
5380 filtresult = [y for y in [self.create_output(type_map, x, columns, filtercolumns) for x in self.hostgroups.values()] if filter_stack(y)]
5381 else:
5382 prefiltresult = [x for x in self.hostgroups.values() if filter_stack(self.create_output(type_map, x, [], filtercolumns))]
5383 filtresult = [self.create_output(type_map, x, columns, filtercolumns) for x in prefiltresult]
5384 elif table == 'servicegroups':
5385 type_map = LiveStatus.out_map['Servicegroup']
5386 if len(filtercolumns) == 0:
5387 filtresult = [y for y in [self.create_output(type_map, x, columns, filtercolumns) for x in self.servicegroups.values()] if filter_stack(y)]
5388 else:
5389 prefiltresult = [x for x in self.servicegroups.values() if filter_stack(self.create_output(type_map, x, [], filtercolumns))]
5390 filtresult = [self.create_output(type_map, x, columns, filtercolumns) for x in prefiltresult]
5392 if stats_filter_stack.qsize() > 0:
5393 resultarr = {}
5394 if stats_group_by:
5395 # Break up filtresult and prepare resultarr
5396 # rseultarr is not a simple array (for a single result line)
5397 # It is a dict with the statsgroupyby: as key
5398 groupedresult = {}
5399 for elem in filtresult:
5400 if not elem[stats_group_by] in groupedresult:
5401 groupedresult[elem[stats_group_by]] = []
5402 groupedresult[elem[stats_group_by]].append(elem)
5403 for group in groupedresult:
5404 resultarr[group] = { stats_group_by : group }
5406 #The number of Stats: statements
5407 #For each statement there is one function on the stack
5408 maxidx = stats_filter_stack.qsize()
5409 for i in range(maxidx):
5410 #First, get a filter for the attributes mentioned in Stats: statements
5411 filtfunc = stats_filter_stack.get()
5412 #Then, postprocess (sum, max, min,...) the results
5413 postprocess = stats_postprocess_stack.get()
5414 #If we are not inversed (like >=2.6) we are like a stack
5415 if not self.inversed_stack_queue:
5416 ind = maxidx - i - 1
5417 else: # we take FIFO, so the order is the inversed!
5418 ind = i
5419 if stats_group_by:
5420 # Calc statistics over _all_ elements of groups
5421 # which share the same stats_filter_by
5422 for group in groupedresult:
5423 resultarr[group][ind] = postprocess(filter(filtfunc, groupedresult[group]))
5425 else:
5426 # Calc statistics over _all_ elements of filtresult
5427 resultarr[ind] = postprocess(filter(filtfunc, filtresult))
5428 if stats_group_by:
5429 for group in groupedresult:
5430 result.append(resultarr[group])
5431 else:
5432 # Without StatsGroupBy: we have only one line
5433 result = [resultarr]
5434 else:
5435 #Results are host/service/etc dicts with the requested attributes
5436 #Columns: = keys of the dicts
5437 result = filtresult
5438 elif table == 'contacts':
5439 type_map = LiveStatus.out_map['Contact']
5440 for c in self.contacts.values():
5441 result.append(self.create_output(type_map, c, columns, filtercolumns))
5442 elif table == 'commands':
5443 type_map = LiveStatus.out_map['Command']
5444 for c in self.commands.values():
5445 result.append(self.create_output(type_map, c, columns, filtercolumns))
5446 elif table == 'schedulers':
5447 type_map = LiveStatus.out_map['SchedulerLink']
5448 for s in self.schedulers.values():
5449 result.append(self.create_output(type_map, s, columns, filtercolumns))
5450 elif table == 'pollers':
5451 type_map = LiveStatus.out_map['PollerLink']
5452 for s in self.pollers.values():
5453 result.append(self.create_output(type_map, s, columns, filtercolumns))
5454 elif table == 'reactionners':
5455 type_map = LiveStatus.out_map['ReactionnerLink']
5456 for s in self.reactionners.values():
5457 result.append(self.create_output(type_map, s, columns, filtercolumns))
5458 elif table == 'brokers':
5459 type_map = LiveStatus.out_map['BrokerLink']
5460 for s in self.brokers.values():
5461 result.append(self.create_output(type_map, s, columns, filtercolumns))
5462 elif table == 'problems':
5463 type_map = LiveStatus.out_map['Problem']
5464 #We will crate a problems list first with all problems and source in it
5465 #TODO : create with filter
5466 problems = []
5467 for h in self.hosts.values():
5468 if h.is_problem:
5469 pb = Problem(h, h.impacts)
5470 problems.append(pb)
5471 for s in self.services.values():
5472 if s.is_problem:
5473 pb = Problem(s, s.impacts)
5474 problems.append(pb)
5475 #Then return
5476 for pb in problems:
5477 result.append(self.create_output(type_map, pb, columns, filtercolumns))
5478 elif table == 'status':
5479 type_map = LiveStatus.out_map['Config']
5480 for c in self.configs.values():
5481 result.append(self.create_output(type_map, c, columns, filtercolumns))
5482 elif table == 'columns':
5483 result.append({
5484 'description' : 'A description of the column' , 'name' : 'description' , 'table' : 'columns' , 'type' : 'string' })
5485 result.append({
5486 'description' : 'The name of the column within the table' , 'name' : 'name' , 'table' : 'columns' , 'type' : 'string' })
5487 result.append({
5488 'description' : 'The name of the table' , 'name' : 'table' , 'table' : 'columns' , 'type' : 'string' })
5489 result.append({
5490 'description' : 'The data type of the column (int, float, string, list)' , 'name' : 'type' , 'table' : 'columns' , 'type' : 'string' })
5491 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' }
5492 for obj in sorted(LiveStatus.out_map, key=lambda x: x):
5493 if obj in tablenames:
5494 for attr in LiveStatus.out_map[obj]:
5495 if 'description' in LiveStatus.out_map[obj][attr] and LiveStatus.out_map[obj][attr]['description']:
5496 result.append({ 'description' : LiveStatus.out_map[obj][attr]['description'], 'name' : attr, 'table' : tablenames[obj], 'type' : LiveStatus.out_map[obj][attr]['type'] })
5497 else:
5498 result.append({'description' : 'to_do_desc', 'name' : attr, 'table' : tablenames[obj], 'type' : LiveStatus.out_map[obj][attr]['type'] })
5500 #print "result is", result
5501 return result
5504 def get_live_data_log(self, table, columns, prefiltercolumns, filtercolumns, limit, filter_stack, sql_filter_stack):
5505 result = []
5506 if table == 'log':
5507 type_map = LiveStatus.out_map['Log']
5508 # we can apply the filterstack here as well. we have columns and filtercolumns.
5509 # the only additional step is to enrich log lines with host/service-attributes
5510 # a timerange can be useful for a faster preselection of lines
5511 filter_clause, filter_values = sql_filter_stack()
5512 c = self.dbconn.cursor()
5513 try:
5514 #print "sql:", 'SELECT * FROM logs WHERE %s' % (filter_clause)
5515 c.execute('SELECT * FROM logs WHERE %s' % filter_clause, filter_values)
5516 except sqlite3.Error, e:
5517 print "An error occurred:", e.args[0]
5518 prefiltresult = []
5519 dbresult = c.fetchall()
5520 # make a generator: fill in the missing columns in the logline and filter it with filtercolumns
5521 prefiltresult = (y for y in (x.fill(self.hosts, self.services, self.hostname_lookup_table, self.servicename_lookup_table, set(columns + filtercolumns)) for x in dbresult) if filter_stack(self.create_output(type_map, y, [], filtercolumns)))
5522 # add output columns
5523 filtresult = [self.create_output(type_map, x, columns, filtercolumns) for x in prefiltresult]
5524 result = filtresult
5525 pass
5526 # CREATE TABLE IF NOT EXISTS logs(logobject INT, attempt INT, class INT, command_name VARCHAR(64), comment VARCHAR(256), contact_name VARCHAR(64), host_name VARCHAR(64), lineno INT, message VARCHAR(512), options INT, plugin_output VARCHAR(256), service_description VARCHAR(64), state INT, state_type VARCHAR(10), time INT, type VARCHAR(64))
5528 #print "result is", result
5529 return result
5532 def format_live_data(self, result, columns, outputformat, columnheaders, separators, aliases):
5533 output = ''
5534 lines = []
5535 if outputformat == 'csv':
5536 if len(result) > 0:
5537 if columnheaders != 'off' or len(columns) == 0:
5538 if len(aliases) > 0:
5539 #This is for statements like "Stats: .... as alias_column
5540 lines.append(separators[1].join([aliases[col] for col in columns]))
5541 else:
5542 if (len(columns) == 0):
5543 # Show all available columns
5544 columns = sorted(result[0].keys())
5545 lines.append(separators[1].join(columns))
5546 for object in result:
5547 #construct one line of output for each object found
5548 l = []
5549 for x in [object[c] for c in columns]:
5550 if isinstance(x, list):
5551 l.append(separators[2].join(str(y) for y in x))
5552 else:
5553 l.append(str(x))
5554 lines.append(separators[1].join(l))
5555 else:
5556 if columnheaders == 'on':
5557 if len(aliases) > 0:
5558 lines.append(separators[1].join([aliases[col] for col in columns]))
5559 else:
5560 lines.append(separators[1].join(columns))
5561 return separators[0].join(lines)
5563 elif outputformat == 'json':
5564 if len(result) > 0:
5565 if columnheaders != 'off' or len(columns) == 0:
5566 if len(aliases) > 0:
5567 #This is for statements like "Stats: .... as alias_column
5568 lines.append([str(aliases[col]) for col in columns])
5569 else:
5570 if (len(columns) == 0):
5571 # Show all available columns
5572 columns = sorted(result[0].keys())
5573 lines.append(columns)
5574 for object in result:
5575 lines.append([object[c] for c in columns])
5576 else:
5577 if columnheaders == 'on':
5578 if len(aliases) > 0:
5579 lines.append([aliases[col] for col in columns])
5580 else:
5581 lines.append(columns)
5582 return json.dumps(lines, separators=(',', ':'))
5585 def make_filter(self, operator, attribute, reference):
5586 #The filters are closures.
5587 # Add parameter Class (Host, Service), lookup datatype (default string), convert reference
5588 def eq_filter(ref):
5589 return ref[attribute] == reference
5591 def eq_nocase_filter(ref):
5592 return ref[attribute].lower() == reference.lower()
5594 def ne_filter(ref):
5595 return ref[attribute] != reference
5597 def gt_filter(ref):
5598 return ref[attribute] > reference
5600 def ge_filter(ref):
5601 return ref[attribute] >= reference
5603 def lt_filter(ref):
5604 return ref[attribute] < reference
5606 def le_filter(ref):
5607 return ref[attribute] <= reference
5609 def contains_filter(ref):
5610 return reference in ref[attribute].split(',')
5612 def match_filter(ref):
5613 p = re.compile(reference)
5614 return p.search(ref[attribute])
5616 def match_nocase_filter(ref):
5617 p = re.compile(reference, re.I)
5618 return p.search(ref[attribute])
5620 def ge_contains_filter(ref):
5621 if isinstance(ref[attribute], list):
5622 return reference in ref[attribute]
5623 else:
5624 return ref[attribute] >= reference
5626 def dummy_filter(ref):
5627 return True
5629 def count_postproc(ref):
5630 return len(ref)
5632 def extract_postproc(ref):
5633 return [float(obj[attribute]) for obj in ref]
5635 def sum_postproc(ref):
5636 return sum(float(obj[attribute]) for obj in ref)
5638 def max_postproc(ref):
5639 if ref != []:
5640 return max(float(obj[attribute]) for obj in ref)
5641 return 0
5643 def min_postproc(ref):
5644 if ref != []:
5645 return min(float(obj[attribute]) for obj in ref)
5646 return 0
5648 def avg_postproc(ref):
5649 if ref != []:
5650 return sum(float(obj[attribute]) for obj in ref) / len(ref)
5651 return 0
5653 def std_postproc(ref):
5654 return 0
5656 ##print "check operator", operator
5657 if operator == '=':
5658 return eq_filter
5659 elif operator == '!=':
5660 return ne_filter
5661 elif operator == '>':
5662 return gt_filter
5663 elif operator == '>=':
5664 return ge_contains_filter
5665 elif operator == '<':
5666 return gt_filter
5667 elif operator == '<=':
5668 return le_filter
5669 elif operator == '=~':
5670 return eq_nocase_filter
5671 elif operator == '~':
5672 return match_filter
5673 elif operator == '~~':
5674 return match_nocase_filter
5675 elif operator == 'dummy':
5676 return dummy_filter
5677 elif operator == 'sum':
5678 return sum_postproc
5679 elif operator == 'max':
5680 return max_postproc
5681 elif operator == 'min':
5682 return min_postproc
5683 elif operator == 'avg':
5684 return avg_postproc
5685 elif operator == 'std':
5686 return std_postproc
5687 elif operator == 'count':
5688 # postprocess for stats
5689 return count_postproc
5690 elif operator == 'extract':
5691 # postprocess for max,min,...
5692 return extract_postproc
5693 else:
5694 raise "wrong operation", operator
5697 def get_filter_stack(self, filter_stack):
5698 if filter_stack.qsize() == 0:
5699 return lambda x : True
5700 else:
5701 return filter_stack.get()
5702 pass
5705 def and_filter_stack(self, num, filter_stack):
5706 filters = []
5707 for i in range(int(num)):
5708 filters.append(filter_stack.get())
5709 # Take from the stack:
5710 # List of functions taking parameter ref
5711 # Make a combined anded function
5712 # Put it on the stack
5713 def and_filter(ref):
5714 myfilters = filters
5715 failed = False
5716 for filter in myfilters:
5717 if not filter(ref):
5718 failed = True
5719 break
5720 else:
5721 pass
5722 return not failed
5723 filter_stack.put(and_filter)
5724 return filter_stack
5727 def or_filter_stack(self, num, filter_stack):
5728 filters = []
5729 for i in range(int(num)):
5730 filters.append(filter_stack.get())
5731 # Take from the stack:
5732 # List of functions taking parameter ref
5733 # Make a combined ored function
5734 # Put it on the stack
5735 def or_filter(ref):
5736 myfilters = filters
5737 failed = True
5738 for filter in myfilters:
5739 if filter(ref):
5740 failed = False
5741 break
5742 else:
5743 pass
5744 return not failed
5745 filter_stack.put(or_filter)
5746 return filter_stack
5749 def make_sql_filter(self, operator, attribute, reference):
5750 #The filters are closures.
5751 # Add parameter Class (Host, Service), lookup datatype (default string), convert reference
5752 def eq_filter():
5753 if reference == '':
5754 return ['%s IS NULL' % attribute, ()]
5755 else:
5756 return ['%s = ?' % attribute, (reference, )]
5757 def ne_filter():
5758 if reference == '':
5759 return ['%s IS NOT NULL' % attribute, ()]
5760 else:
5761 return ['%s != ?' % attribute, (reference, )]
5762 def ge_filter():
5763 return ['%s >= ?' % attribute, (reference, )]
5764 def le_filter():
5765 return ['%s <= ?' % attribute, (reference, )]
5766 def match_filter():
5767 return ['%s LIKE ?' % attribute, ('%'+reference+'%', )]
5768 if operator == '=':
5769 return eq_filter
5770 if operator == '>=':
5771 return ge_filter
5772 if operator == '<=':
5773 return le_filter
5774 if operator == '!=':
5775 return ne_filter
5776 if operator == '~':
5777 return match_filter
5780 def get_sql_filter_stack(self, filter_stack):
5781 if filter_stack.qsize() == 0:
5782 return ["1 = ?", 1]
5783 else:
5784 return filter_stack.get()
5785 pass
5788 def and_sql_filter_stack(self, num, filter_stack):
5789 filters = []
5790 for i in range(int(num)):
5791 filters.append(filter_stack.get())
5792 # Take from the stack:
5793 # List of functions returning [a where clause with ?, a tuple with the values for ?]
5794 # Combine the clauses with "and", merge the value tuples
5795 # Put a new function on the stack (returns anded clause and merged values)
5796 and_clause = '(' + (' AND ').join([ x()[0] for x in filters ]) + ')'
5797 and_values = reduce(lambda x, y: x+y, [ x()[1] for x in filters ])
5798 filter_stack.put(lambda : [and_clause, and_values])
5799 return filter_stack
5802 def or_sql_filter_stack(self, num, filter_stack):
5803 filters = []
5804 for i in range(int(num)):
5805 filters.append(filter_stack.get())
5806 and_clause = '(' + (' OR ').join([ x()[0] for x in filters ]) + ')'
5807 and_values = reduce(lambda x, y: x+y, [ x()[1] for x in filters ])
5808 filter_stack.put(lambda : [and_clause, and_values])
5809 return filter_stack
5812 def handle_request(self, data):
5813 #Dirty hack to change the output of get_full_name for services
5814 #for cvs and json
5815 global get_full_name
5816 title = ''
5817 content = ''
5818 response = ''
5819 columns = []
5820 filtercolumns = []
5821 prefiltercolumns = []
5822 responseheader = 'off'
5823 outputformat = 'csv'
5824 keepalive = 'off'
5825 limit = None
5827 #So set first this format in out global function
5828 get_full_name.outputformat = outputformat
5830 columnheaders = 'off'
5831 stats_group_by = False
5832 aliases = []
5833 extcmd = False
5834 print "REQUEST", data
5835 # Set the default values for the separators
5836 separators = LiveStatus.separators
5837 # Initialize the stacks which are needed for the Filter: and Stats:
5838 # filter- and count-operations
5839 filter_stack = Queue.LifoQueue()
5840 sql_filter_stack = Queue.LifoQueue()
5841 stats_filter_stack = Queue.LifoQueue()
5842 stats_postprocess_stack = Queue.LifoQueue()
5843 for line in data.splitlines():
5844 line = line.strip()
5845 if line.find('GET ') != -1:
5846 # Get the name of the base table
5847 cmd, table = line.split(' ', 1)
5848 elif line.find('Columns: ') != -1:
5849 # Get the names of the desired columns
5850 p = re.compile(r'\s+')
5851 cmd, columns = p.split(line, 1)
5852 columns = p.split(columns)
5853 columnheaders = 'off'
5854 elif line.find('ResponseHeader:') != -1:
5855 cmd, responseheader = line.split(':', 1)
5856 #strip the responseheader because a can be here
5857 responseheader = responseheader.strip()
5858 print "responseheader", responseheader
5859 elif line.find('OutputFormat:') != -1:
5860 cmd, outputformat = line.split(':', 1)
5861 #Maybe we have a space before it
5862 outputformat = outputformat.strip()
5863 print "Output format:", outputformat
5864 get_full_name.outputformat = outputformat
5865 elif line.find('KeepAlive:') != -1:
5866 cmd, keepalive = line.split(':', 1)
5867 keepalive = keepalive.strip()
5868 elif line.find('ColumnHeaders:') != -1:
5869 cmd, columnheaders = line.split(':', 1)
5870 columnheaders = columnheaders.strip()
5871 elif line.find('Limit:') != -1:
5872 cmd, limit = line.split(':', 1)
5873 limit = int(limit.strip())
5874 elif line.find('Filter:') != -1:
5875 try:
5876 cmd, attribute, operator, reference = line.split(' ', 3)
5877 except:
5878 cmd, attribute, operator = line.split(' ', 3)
5879 reference = ''
5880 if operator in ['=', '!=', '>', '>=', '<', '<=', '=~', '~', '~~']:
5881 # Put a function on top of the filter_stack which implements
5882 # the desired operation
5883 filtercolumns.append(attribute)
5884 prefiltercolumns.append(attribute)
5885 # reference is now datatype string. The referring object attribute on the other hand
5886 # may be an integer. (current_attempt for example)
5887 # So for the filter to work correctly (the two values compared must be
5888 # of the same type), we need to convert the reference to the desired type
5889 converter = self.find_converter(table, attribute)
5890 if converter:
5891 reference = converter(reference)
5892 filter_stack.put(self.make_filter(operator, attribute, reference))
5893 if table == 'log':
5894 if attribute == 'time':
5895 sql_filter_stack.put(self.make_sql_filter(operator, attribute, reference))
5896 else:
5897 print "illegal operation", operator
5898 pass # illegal operation
5899 elif line.find('And: ', 0, 5) != -1:
5900 cmd, andnum = line.split(' ', 1)
5901 # Take the last andnum functions from the stack
5902 # Construct a new function which makes a logical and
5903 # Put the function back onto the stack
5904 filter_stack = self.and_filter_stack(andnum, filter_stack)
5905 elif line.find('Or: ', 0, 4) != -1:
5906 cmd, ornum = line.split(' ', 1)
5907 # Take the last ornum functions from the stack
5908 # Construct a new function which makes a logical or
5909 # Put the function back onto the stack
5910 filter_stack = self.or_filter_stack(ornum, filter_stack)
5911 elif line.find('StatsGroupBy: ') != -1:
5912 cmd, stats_group_by = line.split(' ', 1)
5913 filtercolumns.append(stats_group_by)
5914 elif line.find('Stats: ') != -1:
5915 try:
5916 cmd, attribute, operator, reference = line.split(' ', 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 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 = line.split(' ', 3)
5927 if attribute in ['sum', 'min', 'max', 'avg', 'std']:
5928 attribute, operator = operator, attribute
5929 reference = ''
5930 if operator in ['=', '!=', '>', '>=']:
5931 filtercolumns.append(attribute)
5932 converter = self.find_converter(table, attribute)
5933 if converter:
5934 reference = converter(reference)
5935 stats_filter_stack.put(self.make_filter(operator, attribute, reference))
5936 stats_postprocess_stack.put(self.make_filter('count', attribute, None))
5937 elif operator in ['sum', 'min', 'max', 'avg', 'std']:
5938 columns.append(attribute)
5939 stats_filter_stack.put(self.make_filter('dummy', attribute, None))
5940 stats_postprocess_stack.put(self.make_filter(operator, attribute, None))
5941 else:
5942 print "illegal operation", operator
5943 pass # illegal operation
5945 elif line.find('StatsAnd: ') != -1:
5946 cmd, andnum = line.split(' ', 1)
5947 stats_filter_stack = self.and_filter_stack(andnum, stats_filter_stack)
5948 elif line.find('StatsOr: ') != -1:
5949 cmd, ornum = line.split(' ', 1)
5950 stats_filter_stack = self.or_filter_stack(ornum, stats_filter_stack)
5951 elif line.find('Separators: ') != -1:
5952 # check Class.attribute exists
5953 cmd, sep1, sep2, sep3, sep4 = line.split(' ', 5)
5954 separators = map(lambda x: chr(int(x)), [sep1, sep2, sep3, sep4])
5955 elif line.find('COMMAND') != -1:
5956 cmd, extcmd = line.split(' ', 1)
5957 else:
5958 # This line is not valid or not implemented
5959 print "Received a line of input which i can't handle : '%s'" % line
5960 pass
5961 #External command are send back to broker
5962 if extcmd:
5963 print "Managing an external command", extcmd
5964 e = ExternalCommand(extcmd)
5965 self.return_queue.put(e)
5966 #command_file = self.configs[0].command_file
5967 #if os.path.exists(command_file):
5968 # try:
5969 # fifo = os.open(command_file, os.O_NONBLOCK|os.O_WRONLY)
5970 # os.write(fifo, extcmd)
5971 # os.close(fifo)
5972 # except:
5973 # print "Unable to open/write the external command pipe"
5974 return '\n', keepalive
5975 else:
5976 # make filtercolumns unique
5977 filtercolumns = list(set(filtercolumns))
5978 if filter_stack.qsize() > 1:
5979 #If we have Filter: statements but no FilterAnd/Or statements
5980 #Make one big filter where the single filters are anded
5981 filter_stack = self.and_filter_stack(filter_stack.qsize(), filter_stack)
5982 try:
5983 #Get the function which implements the Filter: statements
5984 simplefilter_stack = self.get_filter_stack(filter_stack)
5985 if table == 'log':
5986 if sql_filter_stack.qsize() > 1:
5987 sql_filter_stack = self.and_sql_filter_stack(sql_filter_stack.qsize(), sql_filter_stack)
5988 sql_simplefilter_stack = self.get_sql_filter_stack(sql_filter_stack)
5989 result = self.get_live_data_log(table, columns, prefiltercolumns, filtercolumns, limit, simplefilter_stack, sql_simplefilter_stack)
5990 else:
5991 #Get the function which implements the Stats: statements
5992 stats = stats_filter_stack.qsize()
5993 #Apply the filters on the broker's host/service/etc elements
5994 result = self.get_live_data(table, columns, prefiltercolumns, filtercolumns, limit, simplefilter_stack, stats_filter_stack, stats_postprocess_stack, stats_group_by)
5995 if stats > 0:
5996 columns = range(stats)
5997 if stats_group_by:
5998 columns.insert(0, stats_group_by)
5999 print "all my columns", columns
6000 if len(aliases) == 0:
6001 #If there were Stats: staments without "as", show no column headers at all
6002 columnheaders = 'off'
6003 else:
6004 columnheaders = 'on'
6006 #Now bring the retrieved information to a form which can be sent back to the client
6007 response = self.format_live_data(result, columns, outputformat, columnheaders, separators, aliases) + "\n"
6008 except Exception, e:
6009 import traceback
6010 print "REQUEST produces an exception", data
6011 print "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
6012 print e
6013 traceback.print_exc(32)
6014 print "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
6017 if responseheader == 'fixed16':
6018 statuscode = 200
6019 responselength = len(response) # no error
6020 response = '%3d %11d\n' % (statuscode, responselength) + response
6023 print "REQUEST", data
6024 print "RESPONSE\n%s\n" % response
6025 return response, keepalive
6027 def row_factory(self, cursor, row):
6028 return Logline(cursor, row)