diff --git a/doc/6-object-types.md b/doc/6-object-types.md index 90567c543..fd650a611 100644 --- a/doc/6-object-types.md +++ b/doc/6-object-types.md @@ -658,31 +658,6 @@ Configuration Attributes: enable_perfdata |**Optional.** Whether performance data processing is globally enabled. Defaults to true. vars |**Optional.** A dictionary containing custom attributes that are available globally. -## IcingaStatusWriter - -> **Note** -> -> This feature was deprecated in 2.4 and will be removed in future releases. - -The IcingaStatusWriter feature periodically dumps the current status -and performance data from Icinga 2 and all registered features into -a defined JSON file. - -Example: - - object IcingaStatusWriter "status" { - status_path = LocalStateDir + "/cache/icinga2/status.json" - update_interval = 15s - } - -Configuration Attributes: - - Name |Description - --------------------------|-------------------------- - status\_path |**Optional.** Path to cluster status file. Defaults to LocalStateDir + "/cache/icinga2/status.json" - update\_interval |**Optional.** The interval in which the status files are updated. Defaults to 15 seconds. - - ## IdoMySqlConnection IDO database adapter for MySQL. diff --git a/etc/icinga2/features-available/icingastatus.conf b/etc/icinga2/features-available/icingastatus.conf deleted file mode 100644 index 579227305..000000000 --- a/etc/icinga2/features-available/icingastatus.conf +++ /dev/null @@ -1,10 +0,0 @@ -/** - * The IcingaStatusWriter feature periodically dumps the - * current status and performance data from Icinga 2 and - * all registered features into a defined JSON file. - */ - -/* NOTE: This feature was deprecated in 2.4 and will be removed in future releases. */ - -object IcingaStatusWriter "icinga-status" { } - diff --git a/lib/icinga/CMakeLists.txt b/lib/icinga/CMakeLists.txt index e48f21482..fa30fdc46 100644 --- a/lib/icinga/CMakeLists.txt +++ b/lib/icinga/CMakeLists.txt @@ -27,7 +27,6 @@ mkclass_target(hostgroup.ti hostgroup.tcpp hostgroup.thpp) mkclass_target(host.ti host.tcpp host.thpp) mkclass_target(icingaapplication.ti icingaapplication.tcpp icingaapplication.thpp) mkclass_target(customvarobject.ti customvarobject.tcpp customvarobject.thpp) -mkclass_target(icingastatuswriter.ti icingastatuswriter.tcpp icingastatuswriter.thpp) mkclass_target(notificationcommand.ti notificationcommand.tcpp notificationcommand.thpp) mkclass_target(notification.ti notification.tcpp notification.thpp) mkclass_target(perfdatavalue.ti perfdatavalue.tcpp perfdatavalue.thpp) @@ -44,7 +43,7 @@ set(icinga_SOURCES cib.cpp clusterevents.cpp command.cpp command.thpp comment.cpp comment.thpp compatutility.cpp dependency.cpp dependency.thpp dependency-apply.cpp downtime.cpp downtime.thpp eventcommand.cpp eventcommand.thpp externalcommandprocessor.cpp host.cpp host.thpp hostgroup.cpp hostgroup.thpp icingaapplication.cpp icingaapplication.thpp - customvarobject.cpp customvarobject.thpp icingastatuswriter.cpp icingastatuswriter.thpp + customvarobject.cpp customvarobject.thpp legacytimeperiod.cpp macroprocessor.cpp notificationcommand.cpp notificationcommand.thpp notification.cpp notification.thpp notification-apply.cpp objectutils.cpp perfdatavalue.cpp perfdatavalue.thpp pluginutility.cpp scheduleddowntime.cpp scheduleddowntime.thpp scheduleddowntime-apply.cpp service-apply.cpp checkable-check.cpp checkable-comment.cpp diff --git a/lib/icinga/icingastatuswriter.cpp b/lib/icinga/icingastatuswriter.cpp deleted file mode 100644 index 069dab852..000000000 --- a/lib/icinga/icingastatuswriter.cpp +++ /dev/null @@ -1,174 +0,0 @@ -/****************************************************************************** - * Icinga 2 * - * Copyright (C) 2012-2015 Icinga Development Team (http://www.icinga.org) * - * * - * This program is free software; you can redistribute it and/or * - * modify it under the terms of the GNU General Public License * - * as published by the Free Software Foundation; either version 2 * - * of the License, or (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program; if not, write to the Free Software Foundation * - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. * - ******************************************************************************/ - -#include "icinga/icingastatuswriter.hpp" -#include "icinga/icingastatuswriter.tcpp" -#include "icinga/cib.hpp" -#include "base/configtype.hpp" -#include "base/logger.hpp" -#include "base/exception.hpp" -#include "base/application.hpp" -#include "base/statsfunction.hpp" -#include "base/json.hpp" -#include -#include -#include - -using namespace icinga; - -REGISTER_TYPE(IcingaStatusWriter); - -REGISTER_STATSFUNCTION(IcingaStatusWriter, &IcingaStatusWriter::StatsFunc); - -void IcingaStatusWriter::StatsFunc(const Dictionary::Ptr& status, const Array::Ptr& perfdata) -{ - Dictionary::Ptr nodes = new Dictionary(); - - BOOST_FOREACH(const IcingaStatusWriter::Ptr& icingastatuswriter, ConfigType::GetObjectsByType()) { - nodes->Set(icingastatuswriter->GetName(), 1); //add more stats - } - - status->Set("icingastatuswriter", nodes); -} - -/** - * Hint: The reason why we're using "\n" rather than std::endl is because - * std::endl also _flushes_ the output stream which severely degrades - * performance (see http://gcc.gnu.org/onlinedocs/libstdc++/manual/bk01pt11ch25s02.html). - */ - -/** - * Starts the component. - */ -void IcingaStatusWriter::Start(bool runtimeCreated) -{ - ObjectImpl::Start(runtimeCreated); - - /* TODO: remove in versions > 2.4 */ - Log(LogWarning, "IcingaStatusWriter", "This feature was deprecated in 2.4 and will be removed in future Icinga 2 releases."); - - m_StatusTimer = new Timer(); - m_StatusTimer->SetInterval(GetUpdateInterval()); - m_StatusTimer->OnTimerExpired.connect(boost::bind(&IcingaStatusWriter::StatusTimerHandler, this)); - m_StatusTimer->Start(); - m_StatusTimer->Reschedule(0); -} - -Dictionary::Ptr IcingaStatusWriter::GetStatusData(void) -{ - Dictionary::Ptr bag = new Dictionary(); - - /* features */ - std::pair stats = CIB::GetFeatureStats(); - - bag->Set("feature_status", stats.first); - bag->Set("feature_perfdata", stats.second); - - /* icinga stats */ - Dictionary::Ptr icinga_stats = new Dictionary(); - - double interval = Utility::GetTime() - Application::GetStartTime(); - - if (interval > 60) - interval = 60; - - icinga_stats->Set("active_host_checks", CIB::GetActiveHostChecksStatistics(interval) / interval); - icinga_stats->Set("passive_host_checks", CIB::GetPassiveHostChecksStatistics(interval) / interval); - icinga_stats->Set("active_host_checks_1min", CIB::GetActiveHostChecksStatistics(60)); - icinga_stats->Set("passive_host_checks_1min", CIB::GetPassiveHostChecksStatistics(60)); - icinga_stats->Set("active_host_checks_5min", CIB::GetActiveHostChecksStatistics(60 * 5)); - icinga_stats->Set("passive_host_checks_5min", CIB::GetPassiveHostChecksStatistics(60 * 5)); - icinga_stats->Set("active_host_checks_15min", CIB::GetActiveHostChecksStatistics(60 * 15)); - icinga_stats->Set("passive_host_checks_15min", CIB::GetPassiveHostChecksStatistics(60 * 15)); - - icinga_stats->Set("active_service_checks", CIB::GetActiveServiceChecksStatistics(interval) / interval); - icinga_stats->Set("passive_service_checks", CIB::GetPassiveServiceChecksStatistics(interval) / interval); - icinga_stats->Set("active_service_checks_1min", CIB::GetActiveServiceChecksStatistics(60)); - icinga_stats->Set("passive_service_checks_1min", CIB::GetPassiveServiceChecksStatistics(60)); - icinga_stats->Set("active_service_checks_5min", CIB::GetActiveServiceChecksStatistics(60 * 5)); - icinga_stats->Set("passive_service_checks_5min", CIB::GetPassiveServiceChecksStatistics(60 * 5)); - icinga_stats->Set("active_service_checks_15min", CIB::GetActiveServiceChecksStatistics(60 * 15)); - icinga_stats->Set("passive_service_checks_15min", CIB::GetPassiveServiceChecksStatistics(60 * 15)); - - CheckableCheckStatistics scs = CIB::CalculateServiceCheckStats(); - - icinga_stats->Set("min_latency", scs.min_latency); - icinga_stats->Set("max_latency", scs.max_latency); - icinga_stats->Set("avg_latency", scs.avg_latency); - icinga_stats->Set("min_execution_time", scs.min_latency); - icinga_stats->Set("max_execution_time", scs.max_latency); - icinga_stats->Set("avg_execution_time", scs.avg_execution_time); - - ServiceStatistics ss = CIB::CalculateServiceStats(); - - icinga_stats->Set("num_services_ok", ss.services_ok); - icinga_stats->Set("num_services_warning", ss.services_warning); - icinga_stats->Set("num_services_critical", ss.services_critical); - icinga_stats->Set("num_services_unknown", ss.services_unknown); - icinga_stats->Set("num_services_pending", ss.services_pending); - icinga_stats->Set("num_services_unreachable", ss.services_unreachable); - icinga_stats->Set("num_services_flapping", ss.services_flapping); - icinga_stats->Set("num_services_in_downtime", ss.services_in_downtime); - icinga_stats->Set("num_services_acknowledged", ss.services_acknowledged); - - HostStatistics hs = CIB::CalculateHostStats(); - - icinga_stats->Set("num_hosts_up", hs.hosts_up); - icinga_stats->Set("num_hosts_down", hs.hosts_down); - icinga_stats->Set("num_hosts_unreachable", hs.hosts_unreachable); - icinga_stats->Set("num_hosts_flapping", hs.hosts_flapping); - icinga_stats->Set("num_hosts_in_downtime", hs.hosts_in_downtime); - icinga_stats->Set("num_hosts_acknowledged", hs.hosts_acknowledged); - - bag->Set("icinga_status", icinga_stats); - - return bag; -} - - -void IcingaStatusWriter::StatusTimerHandler(void) -{ - Log(LogNotice, "IcingaStatusWriter", "Writing status.json file"); - - String statuspath = GetStatusPath(); - String statuspathtmp = statuspath + ".tmp"; /* XXX make this a global definition */ - - std::ofstream statusfp; - statusfp.open(statuspathtmp.CStr(), std::ofstream::out | std::ofstream::trunc); - - statusfp << std::fixed; - - statusfp << JsonEncode(GetStatusData()); - - statusfp.close(); - -#ifdef _WIN32 - _unlink(statuspath.CStr()); -#endif /* _WIN32 */ - - if (rename(statuspathtmp.CStr(), statuspath.CStr()) < 0) { - BOOST_THROW_EXCEPTION(posix_error() - << boost::errinfo_api_function("rename") - << boost::errinfo_errno(errno) - << boost::errinfo_file_name(statuspathtmp)); - } - - Log(LogNotice, "IcingaStatusWriter", "Finished writing status.json file"); -} - diff --git a/lib/icinga/icingastatuswriter.hpp b/lib/icinga/icingastatuswriter.hpp deleted file mode 100644 index 90b1704b8..000000000 --- a/lib/icinga/icingastatuswriter.hpp +++ /dev/null @@ -1,51 +0,0 @@ -/****************************************************************************** - * Icinga 2 * - * Copyright (C) 2012-2015 Icinga Development Team (http://www.icinga.org) * - * * - * This program is free software; you can redistribute it and/or * - * modify it under the terms of the GNU General Public License * - * as published by the Free Software Foundation; either version 2 * - * of the License, or (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program; if not, write to the Free Software Foundation * - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. * - ******************************************************************************/ - -#ifndef ICINGASTATUSWRITER_H -#define ICINGASTATUSWRITER_H - -#include "icinga/icingastatuswriter.thpp" -#include "base/timer.hpp" - -namespace icinga -{ - -/** - * @ingroup compat - */ -class IcingaStatusWriter : public ObjectImpl -{ -public: - DECLARE_OBJECT(IcingaStatusWriter); - DECLARE_OBJECTNAME(IcingaStatusWriter); - - static void StatsFunc(const Dictionary::Ptr& status, const Array::Ptr& perfdata); - static Dictionary::Ptr GetStatusData(void); - -protected: - virtual void Start(bool runtimeCreated) override; - -private: - Timer::Ptr m_StatusTimer; - void StatusTimerHandler(void); -}; - -} - -#endif /* ICINGASTATUSWRITER_H */ diff --git a/lib/icinga/icingastatuswriter.ti b/lib/icinga/icingastatuswriter.ti deleted file mode 100644 index 1421dcce7..000000000 --- a/lib/icinga/icingastatuswriter.ti +++ /dev/null @@ -1,38 +0,0 @@ -/****************************************************************************** - * Icinga 2 * - * Copyright (C) 2012-2015 Icinga Development Team (http://www.icinga.org) * - * * - * This program is free software; you can redistribute it and/or * - * modify it under the terms of the GNU General Public License * - * as published by the Free Software Foundation; either version 2 * - * of the License, or (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program; if not, write to the Free Software Foundation * - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. * - ******************************************************************************/ - -#include "icinga/customvarobject.hpp" -#include "base/application.hpp" - -library icinga; - -namespace icinga -{ - -class IcingaStatusWriter : ConfigObject -{ - [config] String status_path { - default {{{ return Application::GetLocalStateDir() + "/cache/icinga2/status.json"; }}} - }; - [config] double update_interval { - default {{{ return 15; }}} - }; -}; - -} diff --git a/tools/syntax/nano/icinga2.nanorc b/tools/syntax/nano/icinga2.nanorc index 144cab3c8..9d0203709 100644 --- a/tools/syntax/nano/icinga2.nanorc +++ b/tools/syntax/nano/icinga2.nanorc @@ -10,7 +10,7 @@ icolor brightgreen "object[ \t]+(timeperiod|scheduleddowntime|dependency|perfd icolor brightgreen "object[ \t]+(graphitewriter|idomysqlconnection|idomysqlconnection)" icolor brightgreen "object[ \t]+(livestatuslistener|statusdatawriter|externalcommandlistener)" icolor brightgreen "object[ \t]+(compatlogger|checkresultreader|checkcomponent|notificationcomponent)" -icolor brightgreen "object[ \t]+(filelogger|sysloglogger|icingastatuswriter|apilistener|endpoint|zone)" +icolor brightgreen "object[ \t]+(filelogger|sysloglogger|apilistener|endpoint|zone)" ## apply def icolor brightgreen "apply[ \t]+(Service|Dependency|Notification|ScheduledDowntime)" diff --git a/tools/syntax/vim/syntax/icinga2.vim b/tools/syntax/vim/syntax/icinga2.vim index 0d41467d2..146e5bab9 100644 --- a/tools/syntax/vim/syntax/icinga2.vim +++ b/tools/syntax/vim/syntax/icinga2.vim @@ -51,7 +51,7 @@ syn match icinga2Objdef "object[ \t]\+\(timeperiod\|scheduleddowntime\|depende syn match icinga2ObjDef "object[ \t]\+\(graphitewriter\|idomysqlconnection\|idomysqlconnection\)" syn match icinga2ObjDef "object[ \t]\+\(livestatuslistener\|statusdatawriter\|externalcommandlistener\)" syn match icinga2ObjDef "object[ \t]\+\(compatlogger\|checkresultreader\|checkcomponent\|notificationcomponent\)" -syn match icinga2ObjDef "object[ \t]\+\(filelogger\|sysloglogger\|icingastatuswriter\|icingaapplication\|apilistener\|apiuser\|endpoint\|zone\)" +syn match icinga2ObjDef "object[ \t]\+\(filelogger\|sysloglogger\|icingaapplication\|apilistener\|apiuser\|endpoint\|zone\)" " apply def