[icinga-checkins] icinga.org: icingaweb2-module-director/feature-ddo-playground: Ddo\Host/ ServiceState: first sample implementations

git at icinga.org git at icinga.org
Tue Jun 21 12:22:28 CEST 2016


Module: icingaweb2-module-director
Branch: feature-ddo-playground
Commit: 15885a518711c23486c154924529c82b6aa220ef
URL:    https://git.icinga.org/?p=icingaweb2-module-director.git;a=commit;h=15885a518711c23486c154924529c82b6aa220ef

Author: Thomas Gelf <thomas at gelf.net>
Date:   Tue Jun 21 12:22:04 2016 +0200

Ddo\Host/ServiceState: first sample implementations

---

 library/Director/Ddo/HostState.php    |   32 ++++++++++++++++++++++++
 library/Director/Ddo/ServiceState.php |   43 +++++++++++++++++++++++++++++++++
 2 files changed, 75 insertions(+)

diff --git a/library/Director/Ddo/HostState.php b/library/Director/Ddo/HostState.php
new file mode 100644
index 0000000..466e0fe
--- /dev/null
+++ b/library/Director/Ddo/HostState.php
@@ -0,0 +1,32 @@
+<?php
+
+namespace Icinga\Module\Director\Ddo;
+
+class HostState extends DdoObject
+{
+    protected $table = 'ddo_host_state';
+
+    protected $keyName = 'checksum';
+
+    protected $defaultProperties = array(
+        // active ?
+        'checksum'              => null,
+        'host'                  => null,
+        'state'                 => null,
+        'state_type'            => null,
+        'hard_state'            => null,
+        'severity'              => null,
+        'acknowledged'          => null,
+        'in_downtime'           => null,
+        'last_update'           => null, // only on store if modified
+        'last_state_change'     => null,
+        'last_comment_checksum' => null,
+        'attempt'               => null,
+        'check_source_checksum' => null,
+    );
+
+    protected function getSortingState()
+    {
+        return self::$hostStateSortMap[$this->state];
+    }
+}
diff --git a/library/Director/Ddo/ServiceState.php b/library/Director/Ddo/ServiceState.php
new file mode 100644
index 0000000..bc5f3d8
--- /dev/null
+++ b/library/Director/Ddo/ServiceState.php
@@ -0,0 +1,43 @@
+<?php
+
+namespace Icinga\Module\Director\Ddo;
+
+class ServiceState extends DdoObject
+{
+    protected $table = 'ddo_service_state';
+
+    protected $keyName = 'checksum';
+
+    protected $defaultProperties = array(
+        // active ?
+        'checksum'              => null,
+        'host_checksum'         => null,
+        'host'                  => null,
+        'service'               => null,
+        'state'                 => null,
+        'state_type'            => null,
+        'hard_state'            => null,
+        'attempt'               => null,
+        'severity'              => null,
+        'acknowledged'          => null,
+        'in_downtime'           => null,
+        'last_update'           => null, // only on store if modified
+        'last_state_change'     => null,
+        'last_comment_checksum' => null,
+        'check_source_checksum' => null,
+    );
+
+    protected function calculateSeverity()
+    {
+        $sev = parent::calculateSeverity();
+
+        // TODO: add host state to the mix
+
+        return $sev;
+    }
+
+    protected function getSortingState()
+    {
+        return self::$serviceStateSortMap[$this->state];
+    }
+}



More information about the icinga-checkins mailing list