mirror of https://github.com/Icinga/icinga2.git
Make sure timestamps are formatted as integers in macro strings
refs #11483
This commit is contained in:
parent
b5a38f6707
commit
e3f1c1ec6f
|
@ -24,7 +24,7 @@ namespace icinga
|
|||
|
||||
vararg_constructor class DateTime
|
||||
{
|
||||
[state, no_storage] double value {
|
||||
[state, no_storage] Timestamp value {
|
||||
get;
|
||||
};
|
||||
};
|
||||
|
|
|
@ -28,6 +28,8 @@
|
|||
namespace icinga
|
||||
{
|
||||
|
||||
typedef double Timestamp;
|
||||
|
||||
/**
|
||||
* The type of a Value.
|
||||
*
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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 {{{
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -56,7 +56,7 @@ class User : CustomVarObject
|
|||
default {{{ return true; }}}
|
||||
};
|
||||
|
||||
[state] double last_notification;
|
||||
[state] Timestamp last_notification;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue