]> granicus.if.org Git - icinga2/commitdiff
Make sure timestamps are formatted as integers in macro strings
authorGunnar Beutner <gunnar.beutner@netways.de>
Tue, 21 Jun 2016 09:29:12 +0000 (11:29 +0200)
committerGunnar Beutner <gunnar.beutner@netways.de>
Tue, 21 Jun 2016 09:29:12 +0000 (11:29 +0200)
refs #11483

15 files changed:
lib/base/datetime.ti
lib/base/value.hpp
lib/icinga/checkable.ti
lib/icinga/checkresult.ti
lib/icinga/comment.ti
lib/icinga/downtime.ti
lib/icinga/host.cpp
lib/icinga/host.ti
lib/icinga/macroprocessor.cpp
lib/icinga/notification.ti
lib/icinga/service.cpp
lib/icinga/service.ti
lib/icinga/user.ti
lib/remote/apilistener.ti
lib/remote/endpoint.ti

index 2b6d178dc928b488ef7db8e6b2291d74a384c339..af79ed539f9df14c8de4da1624cb8972521fd2ca 100644 (file)
@@ -24,7 +24,7 @@ namespace icinga
 
 vararg_constructor class DateTime
 {
-       [state, no_storage] double value {
+       [state, no_storage] Timestamp value {
                get;
        };
 };
index 34fe7cbd6c1bbf775a963ab69fbd6dd7b9d34e15..96be16d9f77402c2af9eddf5aeb865e02564aeb0 100644 (file)
@@ -28,6 +28,8 @@
 namespace icinga
 {
 
+typedef double Timestamp;
+
 /**
  * The type of a Value.
  *
index f3621e8f70a6a23a176b27d7189bb41bcdf99d7f..e909af69239e7f17782460db773f1d82c1ca0f52 100644 (file)
@@ -98,7 +98,7 @@ abstract class Checkable : CustomVarObject
        [config] String icon_image;
        [config] String icon_image_alt;
 
-       [state] double next_check;
+       [state] Timestamp next_check;
        [state] int check_attempt {
                default {{{ return 1; }}}
        };
@@ -121,27 +121,27 @@ abstract class Checkable : CustomVarObject
                default {{{ return true; }}}
        };
        [state] CheckResult::Ptr last_check_result;
-       [state] double last_state_change {
+       [state] Timestamp last_state_change {
                default {{{ return Application::GetStartTime(); }}}
        };
-       [state] double last_hard_state_change {
+       [state] Timestamp last_hard_state_change {
                default {{{ return Application::GetStartTime(); }}}
        };
-       [state] double last_state_unreachable;
+       [state] Timestamp last_state_unreachable;
        [state] bool last_in_downtime;
        [state] bool force_next_check;
        [state] int acknowledgement (AcknowledgementRaw) {
                default {{{ return AcknowledgementNone; }}}
        };
-       [state] double acknowledgement_expiry;
+       [state] Timestamp acknowledgement_expiry;
        [state] bool force_next_notification;
        [state] int flapping_positive;
        [state] int flapping_negative;
-       [state] double flapping_last_change;
+       [state] Timestamp flapping_last_change;
        [no_storage, protected] bool flapping {
                get {{{ return false; }}}
        };
-       [no_storage] double last_check {
+       [no_storage] Timestamp last_check {
                get;
        };
 
index 43c985a004634e648d4cd379280399ffa20d18fe..4f67d7588ff3da4807bbcee712c58fd1c35778d6 100644 (file)
@@ -61,10 +61,10 @@ enum StateType
 
 class CheckResult
 {
-       [state] double schedule_start;
-       [state] double schedule_end;
-       [state] double execution_start;
-       [state] double execution_end;
+       [state] Timestamp schedule_start;
+       [state] Timestamp schedule_end;
+       [state] Timestamp execution_start;
+       [state] Timestamp execution_end;
 
        [state] Value command;
        [state] int exit_status;
index 94ad48ebb0bc76851e1c359b44db691813704cc7..412837f7c689ea3badd8a46fb56b2ad22c4f4d7c 100644 (file)
@@ -79,7 +79,7 @@ class Comment : ConfigObject < CommentNameComposer
                }}}
        };
 
-       [config] double entry_time {
+       [config] Timestamp entry_time {
                default {{{ return Utility::GetTime(); }}}
        };
        [config, enum] CommentType entry_type {
@@ -87,7 +87,7 @@ class Comment : ConfigObject < CommentNameComposer
        };
        [config, required] String author;
        [config, required] String text;
-       [config] double expire_time;
+       [config] Timestamp expire_time;
        [state] int legacy_id;
 };
 
index 29248cc160c9c1124524fa7e36df0962301ea5fe..bb2bd09581ff73319565091b582376fd6bb63113 100644 (file)
@@ -66,16 +66,16 @@ class Downtime : ConfigObject < DowntimeNameComposer
                }}}
        };
 
-       [config] double entry_time {
+       [config] Timestamp entry_time {
                default {{{ return Utility::GetTime(); }}}
        };
        [config, required] String author;
        [config, required] String comment;
-       [config] double start_time;
-       [config] double end_time;
-       [state] double trigger_time;
+       [config] Timestamp start_time;
+       [config] Timestamp end_time;
+       [state] Timestamp trigger_time;
        [config] bool fixed;
-       [config] double duration;
+       [config] Timestamp duration;
        [config] name(Downtime) triggered_by;
        [config] String scheduled_by;
        [state] Array::Ptr triggers {
index af6cab8e0cc593bfdbbe2ea74e7fa6996d3174d6..f3c907fcd4c442c175c3edad32a2e303aca3a60f 100644 (file)
@@ -252,7 +252,7 @@ bool Host::ResolveMacro(const String& macro, const CheckResult::Ptr&, Value *res
                *result = StateTypeToString(GetLastStateType());
                return true;
        } else if (macro == "last_state_change") {
-               *result = GetLastStateChange();
+               *result = static_cast<long>(GetLastStateChange());
                return true;
        } else if (macro == "downtime_depth") {
                *result = GetDowntimeDepth();
index a88b9561442820cebf3bb3f4521a071e8daa25fe..10a583e8cb2176dd6108423a6a0d44ca7c96be19 100644 (file)
@@ -52,8 +52,8 @@ class Host : Checkable
        [enum, no_storage] HostState last_hard_state {
                get;
        };
-       [state] double last_state_up;
-       [state] double last_state_down;
+       [state] Timestamp last_state_up;
+       [state] Timestamp last_state_down;
 };
 
 }
index 88c82209d20abafa391d9b3787d8284d9fe0bb77..11ab8338e02df539448a9cd7f9e83db81e2c61cc 100644 (file)
@@ -159,6 +159,11 @@ bool MacroProcessor::ResolveMacro(const String& macro, const ResolverList& resol
                                }
 
                                ref = object->GetField(field);
+
+                               Field fieldInfo = type->GetFieldInfo(field);
+
+                               if (strcmp(fieldInfo.TypeName, "Timestamp") == 0)
+                                       ref = static_cast<long>(ref);
                        }
                }
 
index 0d234c99a7cd8fc7f5a83855feb834563f2a27ab..f7ef8639c828539f8b6db0c54daa475f1e8e5377 100644 (file)
@@ -90,10 +90,10 @@ class Notification : CustomVarObject < NotificationNameComposer
                default {{{ return new Array(); }}}
        };
 
-       [state] double last_notification;
-       [state] double next_notification;
+       [state] Timestamp last_notification;
+       [state] Timestamp next_notification;
        [state] int notification_number;
-       [state] double last_problem_notification;
+       [state] Timestamp last_problem_notification;
 
        [config, navigation] name(Endpoint) command_endpoint (CommandEndpointRaw) {
                navigate {{{
index 80f166f7ec322236b954588f3567c599a4da71cf..1cb904f1784bc6a0574ad1cee0faa2e0b9dc236c 100644 (file)
@@ -207,7 +207,7 @@ bool Service::ResolveMacro(const String& macro, const CheckResult::Ptr& cr, Valu
                *result = StateTypeToString(GetLastStateType());
                return true;
        } else if (macro == "last_state_change") {
-               *result = GetLastStateChange();
+               *result = static_cast<long>(GetLastStateChange());
                return true;
        } else if (macro == "downtime_depth") {
                *result = GetDowntimeDepth();
index 67f2773049e1691cda574bc1a8a7e8f0fc6238bc..16b9f1a08247b1d44b6e19515496dc4e4b54a769 100644 (file)
@@ -74,10 +74,10 @@ class Service : Checkable < ServiceNameComposer
                        return GetLastHardStateRaw();
                }}}
        };
-       [state] double last_state_ok (LastStateOK);
-       [state] double last_state_warning;
-       [state] double last_state_critical;
-       [state] double last_state_unknown;
+       [state] Timestamp last_state_ok (LastStateOK);
+       [state] Timestamp last_state_warning;
+       [state] Timestamp last_state_critical;
+       [state] Timestamp last_state_unknown;
 };
 
 }
index 9df96113f028cc0248762c4da4f6cdec4b91bdc4..e7028ea784bdbf1a995cc2711eb510c94f3f80a2 100644 (file)
@@ -56,7 +56,7 @@ class User : CustomVarObject
                default {{{ return true; }}}
        };
 
-       [state] double last_notification;
+       [state] Timestamp last_notification;
 };
 
 }
index 82ed71c09e7d9e5dc442c688baad161d4e01ef43..34e235cce4810c4445d84502998d4f4319fa0a8f 100644 (file)
@@ -43,7 +43,7 @@ class ApiListener : ConfigObject
 
        [config] String ticket_salt;
 
-       [state, no_user_modify] double log_message_timestamp;
+       [state, no_user_modify] Timestamp log_message_timestamp;
 
        [no_user_modify] String identity;
 };
index 9eaccb92604e014a1c1bfbf1464702412d7f65e1..5253e13cabe260e9c1e31e734e0a1dbf688580f5 100644 (file)
@@ -34,8 +34,8 @@ class Endpoint : ConfigObject
                default {{{ return 86400; }}}
        };
 
-       [state] double local_log_position;
-       [state] double remote_log_position;
+       [state] Timestamp local_log_position;
+       [state] Timestamp remote_log_position;
 
        [no_user_modify] bool connecting;
        [no_user_modify] bool syncing;