summaryrefslogtreecommitdiffstats
path: root/library/Director/Objects/Extension/FlappingSupport.php
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--library/Director/Objects/Extension/FlappingSupport.php54
1 files changed, 54 insertions, 0 deletions
diff --git a/library/Director/Objects/Extension/FlappingSupport.php b/library/Director/Objects/Extension/FlappingSupport.php
new file mode 100644
index 0000000..a86f10d
--- /dev/null
+++ b/library/Director/Objects/Extension/FlappingSupport.php
@@ -0,0 +1,54 @@
+<?php
+
+namespace Icinga\Module\Director\Objects\Extension;
+
+use Icinga\Module\Director\IcingaConfig\IcingaConfigHelper as c;
+use Icinga\Module\Director\IcingaConfig\IcingaLegacyConfigHelper as c1;
+
+trait FlappingSupport
+{
+ /**
+ * @param $value
+ * @return string
+ * @codingStandardsIgnoreStart
+ */
+ protected function renderFlapping_threshold_high($value)
+ {
+ return $this->renderFlappingThreshold('flapping_threshold_high', $value);
+ }
+
+ /**
+ * @param $value
+ * @return string
+ */
+ protected function renderFlapping_threshold_low($value)
+ {
+ return $this->renderFlappingThreshold('flapping_threshold_low', $value);
+ }
+
+ protected function renderFlappingThreshold($key, $value)
+ {
+ return sprintf(
+ " try { // This setting is only available in Icinga >= 2.8.0\n"
+ . " %s"
+ . " } except { globals.directorWarnOnceForThresholds() }\n",
+ c::renderKeyValue($key, c::renderFloat($value))
+ );
+ }
+
+ protected function renderLegacyEnable_flapping($value)
+ {
+ return c1::renderKeyValue('flap_detection_enabled', c1::renderBoolean($value));
+ }
+
+ protected function renderLegacyFlapping_threshold_high($value)
+ {
+ return c1::renderKeyValue('high_flap_threshold', $value);
+ }
+
+ protected function renderLegacyFlapping_threshold_low($value)
+ {
+ // @codingStandardsIgnoreEnd
+ return c1::renderKeyValue('low_flap_threshold', $value);
+ }
+}