2013-07-12 14:33:17 +02:00
|
|
|
<?php
|
2014-07-15 13:39:22 +02:00
|
|
|
// {{{ICINGA_LICENSE_HEADER}}}
|
|
|
|
// {{{ICINGA_LICENSE_HEADER}}}
|
2013-07-12 14:33:17 +02:00
|
|
|
|
2013-08-20 15:32:25 +02:00
|
|
|
namespace Icinga\Module\Monitoring\Object;
|
2013-07-12 14:33:17 +02:00
|
|
|
|
2014-09-12 10:17:46 +02:00
|
|
|
use Icinga\Module\Monitoring\Backend;
|
2013-07-12 14:33:17 +02:00
|
|
|
|
2014-09-12 10:17:46 +02:00
|
|
|
/**
|
|
|
|
* A Icinga host
|
|
|
|
*/
|
2014-09-04 13:07:03 +02:00
|
|
|
class Host extends MonitoredObject
|
2013-07-12 14:33:17 +02:00
|
|
|
{
|
2014-09-12 10:17:46 +02:00
|
|
|
/**
|
|
|
|
* Type of the Icinga host
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
public $type = self::TYPE_HOST;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Prefix of the Icinga host
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
2014-03-09 19:29:23 +01:00
|
|
|
public $prefix = 'host_';
|
2013-07-12 14:33:17 +02:00
|
|
|
|
2014-09-12 10:17:46 +02:00
|
|
|
/**
|
|
|
|
* Host name
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
protected $host;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a new host
|
|
|
|
*
|
|
|
|
* @param Backend $backend Backend to fetch host information from
|
|
|
|
* @param string $host Host name
|
|
|
|
*/
|
|
|
|
public function __construct(Backend $backend, $host)
|
2014-03-04 13:59:26 +01:00
|
|
|
{
|
2014-09-12 10:17:46 +02:00
|
|
|
parent::__construct($backend);
|
|
|
|
$this->host = $host;
|
2014-03-04 13:59:26 +01:00
|
|
|
}
|
2013-07-12 14:33:17 +02:00
|
|
|
|
2014-09-12 10:17:46 +02:00
|
|
|
/**
|
|
|
|
* Get the host name
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function getHost()
|
2013-07-12 14:33:17 +02:00
|
|
|
{
|
2014-09-12 10:17:46 +02:00
|
|
|
return $this->host;
|
2013-07-12 14:33:17 +02:00
|
|
|
}
|
2013-09-04 18:27:16 +02:00
|
|
|
|
2014-09-12 10:17:46 +02:00
|
|
|
/**
|
|
|
|
* Get the data view to fetch the host information from
|
|
|
|
*
|
|
|
|
* @return \Icinga\Module\Monitoring\DataView\HostStatus
|
|
|
|
*/
|
|
|
|
protected function getDataView()
|
2013-07-12 14:33:17 +02:00
|
|
|
{
|
2014-09-12 10:17:46 +02:00
|
|
|
return $this->backend->select()->from('hostStatus', array(
|
2014-05-21 00:19:26 +02:00
|
|
|
'host_name',
|
|
|
|
'host_alias',
|
|
|
|
'host_address',
|
|
|
|
'host_state',
|
|
|
|
'host_state_type',
|
|
|
|
'host_handled',
|
|
|
|
'host_in_downtime',
|
|
|
|
'host_acknowledged',
|
|
|
|
'host_last_state_change',
|
|
|
|
'host_last_notification',
|
|
|
|
'host_last_check',
|
|
|
|
'host_next_check',
|
|
|
|
'host_check_execution_time',
|
|
|
|
'host_check_latency',
|
|
|
|
'host_check_source',
|
|
|
|
'host_output',
|
|
|
|
'host_long_output',
|
|
|
|
'host_check_command',
|
|
|
|
'host_perfdata',
|
|
|
|
'host_passive_checks_enabled',
|
|
|
|
'host_passive_checks_enabled_changed',
|
|
|
|
'host_obsessing',
|
|
|
|
'host_obsessing_changed',
|
|
|
|
'host_notifications_enabled',
|
|
|
|
'host_notifications_enabled_changed',
|
|
|
|
'host_event_handler_enabled',
|
|
|
|
'host_event_handler_enabled_changed',
|
|
|
|
'host_flap_detection_enabled',
|
|
|
|
'host_flap_detection_enabled_changed',
|
|
|
|
'host_active_checks_enabled',
|
|
|
|
'host_active_checks_enabled_changed',
|
|
|
|
'host_current_check_attempt',
|
|
|
|
'host_max_check_attempts',
|
|
|
|
'host_current_notification_number',
|
|
|
|
'host_percent_state_change',
|
|
|
|
'host_is_flapping',
|
|
|
|
'host_action_url',
|
|
|
|
'host_notes_url',
|
|
|
|
'host_modified_host_attributes',
|
2014-09-05 19:05:13 +02:00
|
|
|
'host_problem',
|
2014-09-12 10:17:46 +02:00
|
|
|
'host_process_performance_data'
|
|
|
|
))
|
|
|
|
->where('host_name', $this->host);
|
2013-07-12 14:33:17 +02:00
|
|
|
}
|
|
|
|
}
|