From 73beb278cfe186d8e2173dc39e0b122cb08cd997 Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Thu, 25 Jul 2013 09:45:40 +0200 Subject: [PATCH] compat: Fix timestamps. --- components/compat/compatcomponent.cpp | 24 ++++++++++++------------ lib/base/value.cpp | 3 +++ 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/components/compat/compatcomponent.cpp b/components/compat/compatcomponent.cpp index f6605ad92..9f815cbef 100644 --- a/components/compat/compatcomponent.cpp +++ b/components/compat/compatcomponent.cpp @@ -437,17 +437,17 @@ void CompatComponent::DumpServiceStatusAttrs(std::ostream& fp, const Service::Pt << "\t" << "plugin_output=" << attrs->Get("plugin_output") << "\n" << "\t" << "long_plugin_output=" << attrs->Get("long_plugin_output") << "\n" << "\t" << "performance_data=" << attrs->Get("performance_data") << "\n" - << "\t" << "last_check=" << attrs->Get("last_check") << "\n" - << "\t" << "next_check=" << attrs->Get("next_check") << "\n" + << "\t" << "last_check=" << static_cast(attrs->Get("last_check")) << "\n" + << "\t" << "next_check=" << static_cast(attrs->Get("next_check")) << "\n" << "\t" << "current_attempt=" << attrs->Get("current_attempt") << "\n" << "\t" << "max_attempts=" << attrs->Get("max_attempts") << "\n" - << "\t" << "last_state_change=" << attrs->Get("last_state_change") << "\n" - << "\t" << "last_hard_state_change=" << attrs->Get("last_hard_state_change") << "\n" - << "\t" << "last_time_ok=" << attrs->Get("last_time_ok") << "\n" - << "\t" << "last_time_warn=" << attrs->Get("last_time_warn") << "\n" - << "\t" << "last_time_critical=" << attrs->Get("last_time_critical") << "\n" - << "\t" << "last_time_unknown=" << attrs->Get("last_time_unknown") << "\n" - << "\t" << "last_update=" << attrs->Get("last_update") << "\n" + << "\t" << "last_state_change=" << static_cast(attrs->Get("last_state_change")) << "\n" + << "\t" << "last_hard_state_change=" << static_cast(attrs->Get("last_hard_state_change")) << "\n" + << "\t" << "last_time_ok=" << static_cast(attrs->Get("last_time_ok")) << "\n" + << "\t" << "last_time_warn=" << static_cast(attrs->Get("last_time_warn")) << "\n" + << "\t" << "last_time_critical=" << static_cast(attrs->Get("last_time_critical")) << "\n" + << "\t" << "last_time_unknown=" << static_cast(attrs->Get("last_time_unknown")) << "\n" + << "\t" << "last_update=" << static_cast(attrs->Get("last_update")) << "\n" << "\t" << "notifications_enabled=" << attrs->Get("notifications_enabled") << "\n" << "\t" << "active_checks_enabled=" << attrs->Get("active_checks_enabled") << "\n" << "\t" << "passive_checks_enabled=" << attrs->Get("passive_checks_enabled") << "\n" @@ -458,8 +458,8 @@ void CompatComponent::DumpServiceStatusAttrs(std::ostream& fp, const Service::Pt << "\t" << "acknowledgement_type=" << attrs->Get("acknowledgement_type") << "\n" << "\t" << "acknowledgement_end_time=" << attrs->Get("acknowledgement_end_time") << "\n" << "\t" << "scheduled_downtime_depth=" << attrs->Get("scheduled_downtime_depth") << "\n" - << "\t" << "last_notification=" << attrs->Get("last_notification") << "\n" - << "\t" << "next_notification=" << attrs->Get("next_notification") << "\n" + << "\t" << "last_notification=" << static_cast(attrs->Get("last_notification")) << "\n" + << "\t" << "next_notification=" << static_cast(attrs->Get("next_notification")) << "\n" << "\t" << "current_notification_number=" << attrs->Get("current_notification_number") << "\n"; } @@ -616,7 +616,7 @@ void CompatComponent::StatusTimerHandler(void) statusfp << "programstatus {" << "\n" << "icinga_pid=" << Utility::GetPid() << "\n" << "\t" << "daemon_mode=1" << "\n" - << "\t" << "program_start=" << IcingaApplication::GetInstance()->GetStartTime() << "\n" + << "\t" << "program_start=" << static_cast(IcingaApplication::GetInstance()->GetStartTime()) << "\n" << "\t" << "active_service_checks_enabled=1" << "\n" << "\t" << "passive_service_checks_enabled=1" << "\n" << "\t" << "active_host_checks_enabled=1" << "\n" diff --git a/lib/base/value.cpp b/lib/base/value.cpp index 91a780820..409a21e08 100644 --- a/lib/base/value.cpp +++ b/lib/base/value.cpp @@ -97,6 +97,9 @@ Value::operator double(void) const if (value) return *value; + if (IsEmpty()) + return 0; + return boost::lexical_cast(m_Value); }