return value;
}
+
+void ConfigObject::SetTemporary(bool value)
+{
+ GetProperties()->SetProperty("__temporary", value ? 1 : 0);
+}
+
+bool ConfigObject::IsTemporary(void) const
+{
+ bool value = false;
+ GetProperties()->GetProperty("__temporary", &value);
+ return value;
+}
+
void ConfigObject::SetAbstract(bool value)
{
GetProperties()->SetProperty("__abstract", value ? 1 : 0);
void SetLocal(bool value);
bool IsLocal(void) const;
+ void SetTemporary(bool value);
+ bool IsTemporary(void) const;
+
void SetAbstract(bool value);
bool IsAbstract(void) const;
{
if (!OnError.empty()) {
Event::Ptr ev = boost::make_shared<Event>();
- ev->OnEventDelivered.connect(boost::bind(boost::ref(OnError), GetSelf(), ex));
+ ev->OnEventDelivered.connect(boost::bind(boost::ref(OnError), GetSelf(), runtime_error(ex.what())));
Event::Post(ev);
CloseInternal(false);
SUBDIRS = \
checker \
+ compat \
configfile \
configrpc \
delegation \
m_CheckerEndpoint->RegisterTopicHandler("checker::ClearServices",
boost::bind(&CheckerComponent::ClearServicesRequestHandler, this, _2, _3));
m_CheckerEndpoint->RegisterPublication("checker::CheckResult");
- GetEndpointManager()->RegisterEndpoint(m_CheckerEndpoint);
+ EndpointManager::GetInstance()->RegisterEndpoint(m_CheckerEndpoint);
m_CheckTimer = boost::make_shared<Timer>();
m_CheckTimer->SetInterval(5);
void CheckerComponent::Stop(void)
{
- EndpointManager::Ptr mgr = GetEndpointManager();
+ EndpointManager::Ptr mgr = EndpointManager::GetInstance();
if (mgr)
mgr->UnregisterEndpoint(m_CheckerEndpoint);
/* update service state */
service.ApplyCheckResult(result);
+ /* figure out when the next check is for this service */
+ service.UpdateNextCheck();
+
+ /* remove the service from the list of pending services */
+ m_PendingServices.erase(service.GetConfigObject());
+ m_Services.push(service);
+
RequestMessage rm;
rm.SetMethod("checker::CheckResult");
params.SetProperty("state", static_cast<long>(service.GetState()));
params.SetProperty("state_type", static_cast<long>(service.GetStateType()));
params.SetProperty("current_attempt", static_cast<long>(service.GetCurrentCheckAttempt()));
+ params.SetProperty("next_check", static_cast<long>(service.GetNextCheck()));
params.SetProperty("result", result.GetDictionary());
rm.SetParams(params);
- GetEndpointManager()->SendMulticastMessage(m_CheckerEndpoint, rm);
-
- service.SetNextCheck(now + service.GetCheckInterval());
- m_PendingServices.erase(service.GetConfigObject());
- m_Services.push(service);
+ EndpointManager::GetInstance()->SendMulticastMessage(m_CheckerEndpoint, rm);
}
if (min_latency > 5) {
MessagePart result;
rm.SetResult(result);
- GetEndpointManager()->SendUnicastMessage(m_CheckerEndpoint, sender, rm);
+ EndpointManager::GetInstance()->SendUnicastMessage(m_CheckerEndpoint, sender, rm);
}
}
/**
* @ingroup checker
*/
-class CheckerComponent : public IcingaComponent
+class CheckerComponent : public Component
{
public:
typedef shared_ptr<CheckerComponent> Ptr;
--- /dev/null
+## Process this file with automake to produce Makefile.in
+
+pkglib_LTLIBRARIES = \
+ compat.la
+
+compat_la_SOURCES = \
+ compatcomponent.cpp \
+ compatcomponent.h \
+ i2-compat.h
+
+compat_la_CPPFLAGS = \
+ $(BOOST_CPPFLAGS) \
+ -I${top_srcdir}/base \
+ -I${top_srcdir}/jsonrpc \
+ -I${top_srcdir}/icinga
+
+compat_la_LDFLAGS = \
+ $(BOOST_LDFLAGS) \
+ -module \
+ -no-undefined \
+ @RELEASE_INFO@ \
+ @VERSION_INFO@
+
+compat_la_LIBADD = \
+ ${top_builddir}/base/libbase.la \
+ ${top_builddir}/jsonrpc/libjsonrpc.la \
+ ${top_builddir}/icinga/libicinga.la
--- /dev/null
+/******************************************************************************
+ * Icinga 2 *
+ * Copyright (C) 2012 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 "i2-compat.h"
+
+using namespace icinga;
+
+/**
+ * Returns the name of the component.
+ *
+ * @returns The name.
+ */
+string CompatComponent::GetName(void) const
+{
+ return "compat";
+}
+
+/**
+ * Starts the component.
+ */
+void CompatComponent::Start(void)
+{
+ m_StatusTimer = boost::make_shared<Timer>();
+ m_StatusTimer->SetInterval(15);
+ m_StatusTimer->OnTimerExpired.connect(boost::bind(&CompatComponent::StatusTimerHandler, this));
+ m_StatusTimer->Start();
+
+ CIB::RequireInformation(CIB_ProgramStatus);
+ CIB::RequireInformation(CIB_ServiceStatus);
+}
+
+/**
+ * Stops the component.
+ */
+void CompatComponent::Stop(void)
+{
+}
+
+void CompatComponent::DumpHostStatus(ofstream& fp, Host host)
+{
+ fp << "hoststatus {" << endl
+ << "\t" << "host_name=" << host.GetName() << endl
+ << "\t" << "has_been_checked=1" << endl
+ << "\t" << "should_be_scheduled=1" << endl
+ << "\t" << "check_execution_time=0" << endl
+ << "\t" << "check_latency=0" << endl
+ << "\t" << "current_state=0" << endl
+ << "\t" << "last_check=" << time(NULL) << endl
+ << "\t" << "next_check=" << time(NULL) << endl
+ << "\t" << "current_attempt=1" << endl
+ << "\t" << "max_attempts=1" << endl
+ << "\t" << "active_checks_enabled=1" << endl
+ << "\t" << "passive_checks_enabled=1" << endl
+ << "\t" << "}" << endl
+ << endl;
+}
+
+void CompatComponent::DumpHostObject(ofstream& fp, Host host)
+{
+ fp << "define host {" << endl
+ << "\t" << "host_name" << "\t" << host.GetName() << endl
+ << "\t" << "hostgroups" << "\t" << "all-hosts" << endl
+ << "\t" << "check_interval" << "\t" << 1 << endl
+ << "\t" << "retry_interval" << "\t" << 1 << endl
+ << "\t" << "max_check_attempts" << "\t" << 1 << endl
+ << "\t" << "active_checks_enabled" << "\t" << 1 << endl
+ << "\t" << "passive_checks_enabled" << "\t" << 1 << endl
+ << "\t" << "}" << endl
+ << endl;
+}
+
+void CompatComponent::DumpServiceStatus(ofstream& fp, Service service)
+{
+ Dictionary::Ptr cr;
+ cr = service.GetLastCheckResult();
+
+ string plugin_output;
+ long start_time = -1, end_time = -1;
+ if (cr) {
+ cr->GetProperty("output", &plugin_output);
+ cr->GetProperty("start_time", &start_time);
+ cr->GetProperty("end_time", &end_time);
+ }
+
+ fp << "servicestatus {" << endl
+ << "\t" << "host_name=" << service.GetHost().GetName() << endl
+ << "\t" << "service_description=" << service.GetDisplayName() << endl
+ << "\t" << "check_interval=" << service.GetCheckInterval() / 60.0 << endl
+ << "\t" << "retry_interval=" << service.GetRetryInterval() / 60.0 << endl
+ << "\t" << "has_been_checked=" << (end_time == -1 ? 0 : 1) << endl
+ << "\t" << "should_be_scheduled=1" << endl
+ << "\t" << "check_execution_time=" << end_time - start_time << endl
+ << "\t" << "check_latency=0" << endl
+ << "\t" << "current_state=" << service.GetState() << endl
+ << "\t" << "plugin_output=" << plugin_output << endl
+ << "\t" << "last_check=" << start_time << endl
+ << "\t" << "next_check=" << service.GetNextCheck() << endl
+ << "\t" << "current_attempt=" << service.GetCurrentCheckAttempt() << endl
+ << "\t" << "max_attempts=" << service.GetMaxCheckAttempts() << endl
+ << "\t" << "last_state_change=" << service.GetLastStateChange() << endl
+ << "\t" << "last_hard_state_change=" << service.GetLastHardStateChange() << endl
+ << "\t" << "last_update=" << time(NULL) << endl
+ << "\t" << "active_checks_enabled=1" << endl
+ << "\t" << "passive_checks_enabled=1" << endl
+ << "\t" << "}" << endl
+ << endl;
+}
+
+void CompatComponent::DumpServiceObject(ofstream& fp, Service service)
+{
+ fp << "define service {" << endl
+ << "\t" << "host_name" << "\t" << service.GetHost().GetName() << endl
+ << "\t" << "service_description" << "\t" << service.GetDisplayName() << endl
+ << "\t" << "check_command" << "\t" << "check_i2" << endl
+ << "\t" << "check_interval" << "\t" << service.GetCheckInterval() / 60.0 << endl
+ << "\t" << "retry_interval" << "\t" << service.GetRetryInterval() / 60.0 << endl
+ << "\t" << "max_check_attempts" << "\t" << 1 << endl
+ << "\t" << "active_checks_enabled" << "\t" << 1 << endl
+ << "\t" << "passive_checks_enabled" << "\t" << 1 << endl
+ << "\t" << "}" << endl
+ << endl;
+}
+
+/**
+ * Periodically writes the status.dat and objects.cache files.
+ */
+void CompatComponent::StatusTimerHandler(void)
+{
+ ofstream statusfp;
+ statusfp.open("status.dat.tmp", ofstream::out | ofstream::trunc);
+
+ statusfp << "# Icinga status file" << endl
+ << "# This file is auto-generated. Do not modify this file." << endl
+ << endl;
+
+ statusfp << "info {" << endl
+ << "\t" << "created=" << time(NULL) << endl
+ << "\t" << "version=2.0" << endl
+ << "\t" << "}" << endl
+ << endl;
+
+ ofstream objectfp;
+ objectfp.open("objects.cache.tmp", ofstream::out | ofstream::trunc);
+
+ objectfp << "# Icinga object cache file" << endl
+ << "# This file is auto-generated. Do not modify this file." << endl
+ << endl;
+
+ objectfp << "define hostgroup {" << endl
+ << "\t" << "hostgroup_name" << "\t" << "all-hosts" << endl;
+
+ ConfigObject::TMap::Range range;
+ range = ConfigObject::GetObjects("host");
+
+ ConfigObject::TMap::Iterator it;
+
+ if (range.first != range.second) {
+ objectfp << "\t" << "members" << "\t";
+ for (it = range.first; it != range.second; it++) {
+ Host host(it->second);
+
+ objectfp << host.GetName();
+
+ if (distance(it, range.second) != 1)
+ objectfp << ",";
+ }
+ objectfp << endl;
+ }
+
+ objectfp << "\t" << "}" << endl
+ << endl;
+
+ for (it = range.first; it != range.second; it++) {
+ DumpHostStatus(statusfp, it->second);
+ DumpHostObject(objectfp, it->second);
+ }
+
+ range = ConfigObject::GetObjects("service");
+
+ for (it = range.first; it != range.second; it++) {
+ DumpServiceStatus(statusfp, it->second);
+ DumpServiceObject(objectfp, it->second);
+ }
+
+ statusfp.close();
+ rename("status.dat.tmp", "status.dat");
+
+ objectfp.close();
+ rename("objects.cache.tmp", "objects.cache");
+}
+
+EXPORT_COMPONENT(compat, CompatComponent);
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
******************************************************************************/
-#include "i2-icinga.h"
+#ifndef COMPATCOMPONENT_H
+#define COMPATCOMPONENT_H
-using namespace icinga;
-
-IcingaApplication::Ptr IcingaComponent::GetIcingaApplication(void) const
+namespace icinga
{
- Application::Ptr application = Application::GetInstance();
- return static_pointer_cast<IcingaApplication>(application);
-}
-EndpointManager::Ptr IcingaComponent::GetEndpointManager(void) const
+/**
+ * @ingroup compat
+ */
+class CompatComponent : public Component
{
- IcingaApplication::Ptr app = GetIcingaApplication();
+public:
+ virtual string GetName(void) const;
+ virtual void Start(void);
+ virtual void Stop(void);
+
+private:
+ Timer::Ptr m_StatusTimer;
- if (!app)
- return EndpointManager::Ptr();
+ void DumpHostStatus(ofstream& fp, Host host);
+ void DumpHostObject(ofstream& fp, Host host);
+
+ void DumpServiceStatus(ofstream& fp, Service service);
+ void DumpServiceObject(ofstream& fp, Service service);
+
+ void StatusTimerHandler(void);
+};
- return app->GetEndpointManager();
}
+
+#endif /* COMPATCOMPONENT_H */
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
******************************************************************************/
-#ifndef ICINGACOMPONENT_H
-#define ICINGACOMPONENT_H
-
-namespace icinga
-{
+#ifndef I2COMPAT_H
+#define I2COMPAT_H
/**
- * A component that can be loaded into the Icinga application at run-time.
+ * @defgroup compat Compat component
*
- * @ingroup icinga
+ * The compat component implements compatibility functionality for Icinga 1.x.
*/
-class I2_ICINGA_API IcingaComponent : public Component
-{
-protected:
- IcingaApplication::Ptr GetIcingaApplication(void) const;
- EndpointManager::Ptr GetEndpointManager(void) const;
-};
-}
+#include <i2-base.h>
+#include <i2-jsonrpc.h>
+#include <i2-icinga.h>
+
+#include <fstream>
+
+using std::ofstream;
+using std::endl;
+
+#include "compatcomponent.h"
-#endif /* ICINGACOMPONENT_H */
+#endif /* I2COMPAT_H */
void ConfigRpcComponent::Start(void)
{
- EndpointManager::Ptr endpointManager = GetEndpointManager();
+ EndpointManager::Ptr endpointManager = EndpointManager::GetInstance();
m_ConfigRpcEndpoint = boost::make_shared<VirtualEndpoint>();
void ConfigRpcComponent::Stop(void)
{
- EndpointManager::Ptr mgr = GetEndpointManager();
+ EndpointManager::Ptr mgr = EndpointManager::GetInstance();
if (mgr)
mgr->UnregisterEndpoint(m_ConfigRpcEndpoint);
RequestMessage request;
request.SetMethod("config::FetchObjects");
- GetEndpointManager()->SendUnicastMessage(m_ConfigRpcEndpoint, endpoint, request);
+ EndpointManager::GetInstance()->SendUnicastMessage(m_ConfigRpcEndpoint, endpoint, request);
}
RequestMessage ConfigRpcComponent::MakeObjectMessage(const ConfigObject::Ptr& object, string method, bool includeProperties)
RequestMessage request = MakeObjectMessage(object, "config::ObjectCreated", true);
- GetEndpointManager()->SendUnicastMessage(m_ConfigRpcEndpoint, sender, request);
+ EndpointManager::GetInstance()->SendUnicastMessage(m_ConfigRpcEndpoint, sender, request);
}
}
if (!ShouldReplicateObject(object))
return;
- GetEndpointManager()->SendMulticastMessage(m_ConfigRpcEndpoint,
+ EndpointManager::GetInstance()->SendMulticastMessage(m_ConfigRpcEndpoint,
MakeObjectMessage(object, "config::ObjectCreated", true));
}
if (!ShouldReplicateObject(object))
return;
- GetEndpointManager()->SendMulticastMessage(m_ConfigRpcEndpoint,
+ EndpointManager::GetInstance()->SendMulticastMessage(m_ConfigRpcEndpoint,
MakeObjectMessage(object, "config::ObjectRemoved", false));
}
/**
* @ingroup configrpc
*/
-class ConfigRpcComponent : public IcingaComponent
+class ConfigRpcComponent : public Component
{
public:
virtual string GetName(void) const;
m_DelegationEndpoint = boost::make_shared<VirtualEndpoint>();
m_DelegationEndpoint->RegisterPublication("checker::AssignService");
m_DelegationEndpoint->RegisterPublication("checker::ClearServices");
- m_DelegationEndpoint->RegisterSubscription("checker::CheckResult");
- GetEndpointManager()->RegisterEndpoint(m_DelegationEndpoint);
+ m_DelegationEndpoint->RegisterTopicHandler("checker::CheckResult",
+ boost::bind(&DelegationComponent::CheckResultRequestHandler, this, _2, _3));
+ m_DelegationEndpoint->RegisterPublication("delegation::ServiceStatus");
+ EndpointManager::GetInstance()->RegisterEndpoint(m_DelegationEndpoint);
- GetEndpointManager()->OnNewEndpoint.connect(bind(&DelegationComponent::NewEndpointHandler, this, _2));
+ EndpointManager::GetInstance()->OnNewEndpoint.connect(bind(&DelegationComponent::NewEndpointHandler, this, _2));
}
void DelegationComponent::Stop(void)
{
- EndpointManager::Ptr mgr = GetEndpointManager();
+ EndpointManager::Ptr mgr = EndpointManager::GetInstance();
if (mgr)
mgr->UnregisterEndpoint(m_DelegationEndpoint);
Application::Log(LogDebug, "delegation", "Trying to delegate service '" + service.GetName() + "'");
- GetEndpointManager()->SendUnicastMessage(m_DelegationEndpoint, checker, request);
+ EndpointManager::GetInstance()->SendUnicastMessage(m_DelegationEndpoint, checker, request);
}
void DelegationComponent::ClearServices(const Endpoint::Ptr& checker)
MessagePart params;
request.SetParams(params);
- GetEndpointManager()->SendUnicastMessage(m_DelegationEndpoint, checker, request);
+ EndpointManager::GetInstance()->SendUnicastMessage(m_DelegationEndpoint, checker, request);
+}
+
+bool DelegationComponent::IsEndpointChecker(const Endpoint::Ptr& endpoint)
+{
+ return (endpoint->HasSubscription("checker::AssignService"));
}
vector<Endpoint::Ptr> DelegationComponent::GetCheckerCandidates(const Service& service) const
vector<Endpoint::Ptr> candidates;
EndpointManager::Iterator it;
- for (it = GetEndpointManager()->Begin(); it != GetEndpointManager()->End(); it++) {
+ for (it = EndpointManager::GetInstance()->Begin(); it != EndpointManager::GetInstance()->End(); it++) {
Endpoint::Ptr endpoint = it->second;
/* ignore disconnected endpoints */
continue;
/* ignore endpoints that aren't running the checker component */
- if (!endpoint->HasSubscription("checker::AssignService"))
+ if (!IsEndpointChecker(endpoint))
+ continue;
+
+ /* ignore endpoints that aren't allowed to check this service */
+ if (!service.IsAllowedChecker(it->first))
continue;
candidates.push_back(endpoint);
}
void DelegationComponent::SessionEstablishedHandler(const Endpoint::Ptr& endpoint)
{
+ /* ignore this endpoint if it's not a checker */
+ if (!IsEndpointChecker(endpoint))
+ return;
+
stringstream msgbuf;
msgbuf << "Clearing assigned services for endpoint '" << endpoint->GetIdentity() << "'";
Application::Log(LogInformation, "delegation", msgbuf.str());
map<Endpoint::Ptr, int> histogram;
EndpointManager::Iterator eit;
- for (eit = GetEndpointManager()->Begin(); eit != GetEndpointManager()->End(); eit++)
+ for (eit = EndpointManager::GetInstance()->Begin(); eit != EndpointManager::GetInstance()->End(); eit++)
histogram[eit->second] = 0;
vector<Service> services;
if (checker.empty())
continue;
- Endpoint::Ptr endpoint = GetEndpointManager()->GetEndpointByIdentity(checker);
+ Endpoint::Ptr endpoint = EndpointManager::GetInstance()->GetEndpointByIdentity(checker);
if (!endpoint)
continue;
Endpoint::Ptr oldEndpoint;
if (!checker.empty())
- oldEndpoint = GetEndpointManager()->GetEndpointByIdentity(checker);
+ oldEndpoint = EndpointManager::GetInstance()->GetEndpointByIdentity(checker);
vector<Endpoint::Ptr> candidates = GetCheckerCandidates(service);
for (sit = services.begin(); sit != services.end(); sit++) {
string checker = sit->GetChecker();
- Endpoint::Ptr endpoint = GetEndpointManager()->GetEndpointByIdentity(checker);
+ Endpoint::Ptr endpoint = EndpointManager::GetInstance()->GetEndpointByIdentity(checker);
if (!endpoint)
continue;
Application::Log(LogInformation, "delegation", msgbuf.str());
}
+void DelegationComponent::CheckResultRequestHandler(const Endpoint::Ptr& sender, const RequestMessage& request)
+{
+ MessagePart params;
+ if (!request.GetParams(¶ms))
+ return;
+
+ string svcname;
+ if (!params.GetProperty("service", &svcname))
+ return;
+
+ Service service = Service::GetByName(svcname);
+
+ /* validate that this is an authentic check result */
+ if (!service.IsAllowedChecker(sender->GetIdentity()))
+ return;
+
+ /* TODO: send state update for dependant services */
+
+ /* send state update */
+ RequestMessage rm;
+ rm.SetMethod("delegation::ServiceStatus");
+ rm.SetParams(params);
+ EndpointManager::GetInstance()->SendMulticastMessage(m_DelegationEndpoint, rm);
+}
+
EXPORT_COMPONENT(delegation, DelegationComponent);
/**
* @ingroup delegation
*/
-class DelegationComponent : public IcingaComponent
+class DelegationComponent : public Component
{
public:
virtual string GetName(void) const;
void AssignService(const Endpoint::Ptr& checker, const Service& service);
void ClearServices(const Endpoint::Ptr& checker);
+
+ static bool IsEndpointChecker(const Endpoint::Ptr& endpoint);
+
+ void CheckResultRequestHandler(const Endpoint::Ptr& sender, const RequestMessage& request);
};
}
*/
string DemoComponent::GetName(void) const
{
- return "democomponent";
+ return "demo";
}
/**
m_DemoEndpoint->RegisterTopicHandler("demo::HelloWorld",
boost::bind(&DemoComponent::HelloWorldRequestHandler, this, _2, _3));
m_DemoEndpoint->RegisterPublication("demo::HelloWorld");
- GetEndpointManager()->RegisterEndpoint(m_DemoEndpoint);
+ EndpointManager::GetInstance()->RegisterEndpoint(m_DemoEndpoint);
m_DemoTimer = boost::make_shared<Timer>();
m_DemoTimer->SetInterval(5);
*/
void DemoComponent::Stop(void)
{
- IcingaApplication::Ptr app = GetIcingaApplication();
+ EndpointManager::Ptr endpointManager = EndpointManager::GetInstance();
- if (app) {
- EndpointManager::Ptr endpointManager = app->GetEndpointManager();
+ if (endpointManager)
endpointManager->UnregisterEndpoint(m_DemoEndpoint);
- }
}
/**
RequestMessage request;
request.SetMethod("demo::HelloWorld");
- EndpointManager::Ptr endpointManager = GetIcingaApplication()->GetEndpointManager();
- endpointManager->SendMulticastMessage(m_DemoEndpoint, request);
+ EndpointManager::GetInstance()->SendMulticastMessage(m_DemoEndpoint, request);
}
/**
/**
* @ingroup demo
*/
-class DemoComponent : public IcingaComponent
+class DemoComponent : public Component
{
public:
virtual string GetName(void) const;
m_DiscoveryEndpoint->RegisterTopicHandler("discovery::Welcome",
boost::bind(&DiscoveryComponent::WelcomeMessageHandler, this, _2, _3));
- GetEndpointManager()->ForEachEndpoint(boost::bind(&DiscoveryComponent::NewEndpointHandler, this, _2));
- GetEndpointManager()->OnNewEndpoint.connect(boost::bind(&DiscoveryComponent::NewEndpointHandler, this, _2));
+ EndpointManager::GetInstance()->ForEachEndpoint(boost::bind(&DiscoveryComponent::NewEndpointHandler, this, _2));
+ EndpointManager::GetInstance()->OnNewEndpoint.connect(boost::bind(&DiscoveryComponent::NewEndpointHandler, this, _2));
- GetEndpointManager()->RegisterEndpoint(m_DiscoveryEndpoint);
+ EndpointManager::GetInstance()->RegisterEndpoint(m_DiscoveryEndpoint);
/* create the reconnect timer */
m_DiscoveryTimer = boost::make_shared<Timer>();
*/
void DiscoveryComponent::Stop(void)
{
- EndpointManager::Ptr mgr = GetEndpointManager();
+ EndpointManager::Ptr mgr = EndpointManager::GetInstance();
if (mgr)
mgr->UnregisterEndpoint(m_DiscoveryEndpoint);
Application::Log(LogWarning, "discovery", "Detected duplicate identity:" + other->GetIdentity() + " - Disconnecting old endpoint.");
other->Stop();
- GetEndpointManager()->UnregisterEndpoint(other);
+ EndpointManager::GetInstance()->UnregisterEndpoint(other);
}
}
string identity = endpoint->GetIdentity();
- if (identity == GetEndpointManager()->GetIdentity()) {
+ if (identity == EndpointManager::GetInstance()->GetIdentity()) {
Application::Log(LogWarning, "discovery", "Detected loop-back connection - Disconnecting endpoint.");
endpoint->Stop();
- GetEndpointManager()->UnregisterEndpoint(endpoint);
+ EndpointManager::GetInstance()->UnregisterEndpoint(endpoint);
return;
}
- GetEndpointManager()->ForEachEndpoint(boost::bind(&DiscoveryComponent::CheckExistingEndpoint, this, endpoint, _2));
+ EndpointManager::GetInstance()->ForEachEndpoint(boost::bind(&DiscoveryComponent::CheckExistingEndpoint, this, endpoint, _2));
// we assume the other component _always_ wants
// discovery::RegisterComponent messages from us
// send a discovery::RegisterComponent message, if the
// other component is a broker this makes sure
// the broker knows about our message types
- SendDiscoveryMessage("discovery::RegisterComponent", GetEndpointManager()->GetIdentity(), endpoint);
+ SendDiscoveryMessage("discovery::RegisterComponent", EndpointManager::GetInstance()->GetIdentity(), endpoint);
map<string, ComponentDiscoveryInfo::Ptr>::iterator ic;
endpoint->RegisterSubscription("discovery::NewComponent");
// send discovery::NewComponent message for ourselves
- SendDiscoveryMessage("discovery::NewComponent", GetEndpointManager()->GetIdentity(), endpoint);
+ SendDiscoveryMessage("discovery::NewComponent", EndpointManager::GetInstance()->GetIdentity(), endpoint);
// send discovery::NewComponent messages for all components
// we know about
*/
bool DiscoveryComponent::GetComponentDiscoveryInfo(string component, ComponentDiscoveryInfo::Ptr *info) const
{
- if (component == GetEndpointManager()->GetIdentity()) {
+ if (component == EndpointManager::GetInstance()->GetIdentity()) {
/* Build fake discovery info for ourselves */
*info = boost::make_shared<ComponentDiscoveryInfo>();
- GetEndpointManager()->ForEachEndpoint(boost::bind(&DiscoveryComponent::DiscoveryEndpointHandler, this, _2, *info));
+ EndpointManager::GetInstance()->ForEachEndpoint(boost::bind(&DiscoveryComponent::DiscoveryEndpointHandler, this, _2, *info));
(*info)->LastSeen = 0;
- (*info)->Node = GetIcingaApplication()->GetNode();
- (*info)->Service = GetIcingaApplication()->GetService();
+ (*info)->Node = IcingaApplication::GetInstance()->GetNode();
+ (*info)->Service = IcingaApplication::GetInstance()->GetService();
return true;
}
endpoint->RegisterSubscription("discovery::Welcome");
RequestMessage request;
request.SetMethod("discovery::Welcome");
- GetEndpointManager()->SendUnicastMessage(m_DiscoveryEndpoint, endpoint, request);
+ EndpointManager::GetInstance()->SendUnicastMessage(m_DiscoveryEndpoint, endpoint, request);
endpoint->SetSentWelcome(true);
params.SetPublications(publications);
if (recipient)
- GetEndpointManager()->SendUnicastMessage(m_DiscoveryEndpoint, recipient, request);
+ EndpointManager::GetInstance()->SendUnicastMessage(m_DiscoveryEndpoint, recipient, request);
else
- GetEndpointManager()->SendMulticastMessage(m_DiscoveryEndpoint, request);
+ EndpointManager::GetInstance()->SendMulticastMessage(m_DiscoveryEndpoint, request);
}
bool DiscoveryComponent::HasMessagePermission(const Dictionary::Ptr& roles, const string& messageType, const string& message)
void DiscoveryComponent::ProcessDiscoveryMessage(const string& identity, const DiscoveryMessage& message, bool trusted)
{
/* ignore discovery messages that are about ourselves */
- if (identity == GetEndpointManager()->GetIdentity())
+ if (identity == EndpointManager::GetInstance()->GetIdentity())
return;
ComponentDiscoveryInfo::Ptr info = boost::make_shared<ComponentDiscoveryInfo>();
}
}
- Endpoint::Ptr endpoint = GetEndpointManager()->GetEndpointByIdentity(identity);
+ Endpoint::Ptr endpoint = EndpointManager::GetInstance()->GetEndpointByIdentity(identity);
MessagePart publications;
if (message.GetPublications(&publications)) {
*/
void DiscoveryComponent::DiscoveryTimerHandler(void)
{
- EndpointManager::Ptr endpointManager = GetEndpointManager();
+ EndpointManager::Ptr endpointManager = EndpointManager::GetInstance();
time_t now;
time(&now);
i++;
/* there's no need to reconnect to ourself */
- if (identity == GetEndpointManager()->GetIdentity())
+ if (identity == EndpointManager::GetInstance()->GetIdentity())
continue;
/* for explicitly-configured upstream endpoints
/**
* @ingroup discovery
*/
-class DiscoveryComponent : public IcingaComponent
+class DiscoveryComponent : public Component
{
public:
virtual string GetName(void) const;
base/Makefile
components/Makefile
components/checker/Makefile
+components/compat/Makefile
components/configfile/Makefile
components/configrpc/Makefile
components/delegation/Makefile
*yy_cp = '\0'; \
yyg->yy_c_buf_p = yy_cp;
-#define YY_NUM_RULES 23
-#define YY_END_OF_BUFFER 24
+#define YY_NUM_RULES 24
+#define YY_END_OF_BUFFER 25
/* This struct is not used in this scanner,
but its presence is necessary. */
struct yy_trans_info
flex_int32_t yy_verify;
flex_int32_t yy_nxt;
};
-static yyconst flex_int16_t yy_accept[72] =
+static yyconst flex_int16_t yy_accept[81] =
{ 0,
- 0, 0, 0, 0, 24, 22, 21, 21, 22, 22,
- 22, 22, 22, 22, 9, 10, 7, 7, 7, 7,
- 7, 7, 17, 18, 21, 0, 20, 13, 11, 12,
- 15, 0, 14, 9, 7, 7, 7, 7, 7, 7,
- 17, 16, 8, 19, 7, 7, 7, 7, 7, 7,
- 7, 7, 7, 7, 6, 7, 7, 7, 7, 2,
- 7, 7, 7, 7, 3, 7, 4, 7, 1, 5,
- 0
+ 0, 0, 0, 0, 25, 23, 22, 22, 23, 23,
+ 23, 23, 23, 23, 10, 11, 8, 8, 8, 8,
+ 8, 8, 8, 18, 19, 22, 0, 21, 14, 12,
+ 13, 16, 0, 15, 10, 8, 8, 8, 8, 8,
+ 8, 8, 18, 17, 9, 20, 8, 8, 8, 8,
+ 8, 8, 8, 8, 8, 8, 8, 7, 8, 8,
+ 8, 8, 8, 2, 8, 8, 8, 8, 8, 4,
+ 8, 8, 5, 8, 8, 1, 6, 8, 3, 0
} ;
static yyconst flex_int32_t yy_ec[256] =
12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
1, 1, 1, 1, 12, 1, 13, 14, 15, 16,
- 17, 12, 12, 18, 19, 20, 12, 21, 12, 22,
- 23, 12, 12, 24, 25, 26, 27, 12, 12, 12,
- 12, 12, 1, 1, 1, 1, 1, 1, 1, 1,
+ 17, 12, 12, 18, 19, 20, 12, 21, 22, 23,
+ 24, 25, 12, 26, 27, 28, 29, 12, 12, 12,
+ 30, 12, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1
} ;
-static yyconst flex_int32_t yy_meta[28] =
+static yyconst flex_int32_t yy_meta[31] =
{ 0,
1, 1, 2, 3, 1, 4, 1, 5, 1, 5,
1, 5, 5, 5, 5, 5, 5, 5, 5, 5,
- 5, 5, 5, 5, 5, 5, 5
+ 5, 5, 5, 5, 5, 5, 5, 5, 5, 5
} ;
-static yyconst flex_int16_t yy_base[78] =
+static yyconst flex_int16_t yy_base[87] =
{ 0,
- 0, 0, 93, 92, 97, 100, 26, 28, 0, 0,
- 85, 84, 83, 26, 83, 100, 0, 78, 69, 67,
- 62, 74, 0, 78, 31, 82, 0, 100, 100, 100,
- 100, 0, 100, 75, 0, 59, 21, 68, 61, 61,
- 0, 100, 100, 0, 54, 58, 61, 64, 55, 58,
- 50, 46, 48, 50, 0, 55, 56, 52, 48, 0,
- 40, 50, 44, 32, 0, 25, 0, 22, 0, 0,
- 100, 39, 44, 49, 33, 54, 59
+ 0, 0, 104, 103, 108, 111, 29, 31, 0, 0,
+ 96, 95, 94, 29, 94, 111, 0, 89, 79, 77,
+ 71, 85, 81, 0, 88, 34, 92, 0, 111, 111,
+ 111, 111, 0, 111, 85, 0, 67, 24, 78, 71,
+ 71, 68, 0, 111, 111, 0, 61, 67, 70, 73,
+ 64, 67, 58, 56, 52, 54, 58, 0, 63, 53,
+ 63, 59, 55, 0, 45, 46, 56, 53, 41, 0,
+ 55, 36, 0, 34, 28, 0, 0, 20, 0, 111,
+ 42, 47, 52, 36, 57, 62
} ;
-static yyconst flex_int16_t yy_def[78] =
+static yyconst flex_int16_t yy_def[87] =
{ 0,
- 71, 1, 72, 72, 71, 71, 71, 71, 73, 74,
- 71, 71, 71, 71, 71, 71, 75, 75, 75, 75,
- 75, 75, 76, 71, 71, 73, 74, 71, 71, 71,
- 71, 77, 71, 71, 75, 75, 75, 75, 75, 75,
- 76, 71, 71, 77, 75, 75, 75, 75, 75, 75,
- 75, 75, 75, 75, 75, 75, 75, 75, 75, 75,
- 75, 75, 75, 75, 75, 75, 75, 75, 75, 75,
- 0, 71, 71, 71, 71, 71, 71
+ 80, 1, 81, 81, 80, 80, 80, 80, 82, 83,
+ 80, 80, 80, 80, 80, 80, 84, 84, 84, 84,
+ 84, 84, 84, 85, 80, 80, 82, 83, 80, 80,
+ 80, 80, 86, 80, 80, 84, 84, 84, 84, 84,
+ 84, 84, 85, 80, 80, 86, 84, 84, 84, 84,
+ 84, 84, 84, 84, 84, 84, 84, 84, 84, 84,
+ 84, 84, 84, 84, 84, 84, 84, 84, 84, 84,
+ 84, 84, 84, 84, 84, 84, 84, 84, 84, 0,
+ 80, 80, 80, 80, 80, 80
} ;
-static yyconst flex_int16_t yy_nxt[128] =
+static yyconst flex_int16_t yy_nxt[142] =
{ 0,
6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
16, 17, 18, 17, 17, 17, 17, 17, 19, 17,
- 20, 21, 22, 17, 17, 17, 17, 25, 25, 25,
- 25, 31, 25, 25, 32, 46, 33, 35, 47, 23,
- 23, 23, 23, 23, 26, 26, 70, 26, 26, 27,
- 69, 27, 27, 27, 41, 41, 41, 68, 41, 44,
- 67, 44, 44, 44, 66, 65, 64, 63, 62, 61,
- 60, 59, 58, 57, 56, 55, 54, 53, 52, 51,
- 50, 49, 48, 45, 34, 43, 42, 40, 39, 38,
- 37, 36, 34, 30, 29, 28, 71, 24, 24, 5,
-
- 71, 71, 71, 71, 71, 71, 71, 71, 71, 71,
- 71, 71, 71, 71, 71, 71, 71, 71, 71, 71,
- 71, 71, 71, 71, 71, 71, 71
+ 20, 17, 21, 22, 17, 17, 17, 23, 17, 17,
+ 26, 26, 26, 26, 32, 26, 26, 33, 48, 34,
+ 36, 49, 24, 24, 24, 24, 24, 27, 27, 79,
+ 27, 27, 28, 78, 28, 28, 28, 43, 43, 43,
+ 77, 43, 46, 76, 46, 46, 46, 75, 74, 73,
+ 72, 71, 70, 69, 68, 67, 66, 65, 64, 63,
+ 62, 61, 60, 59, 58, 57, 56, 55, 54, 53,
+ 52, 51, 50, 47, 35, 45, 44, 42, 41, 40,
+
+ 39, 38, 37, 35, 31, 30, 29, 80, 25, 25,
+ 5, 80, 80, 80, 80, 80, 80, 80, 80, 80,
+ 80, 80, 80, 80, 80, 80, 80, 80, 80, 80,
+ 80, 80, 80, 80, 80, 80, 80, 80, 80, 80,
+ 80
} ;
-static yyconst flex_int16_t yy_chk[128] =
+static yyconst flex_int16_t yy_chk[142] =
{ 0,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 7, 7, 8,
- 8, 14, 25, 25, 14, 37, 14, 75, 37, 72,
- 72, 72, 72, 72, 73, 73, 68, 73, 73, 74,
- 66, 74, 74, 74, 76, 76, 76, 64, 76, 77,
- 63, 77, 77, 77, 62, 61, 59, 58, 57, 56,
- 54, 53, 52, 51, 50, 49, 48, 47, 46, 45,
- 40, 39, 38, 36, 34, 26, 24, 22, 21, 20,
- 19, 18, 15, 13, 12, 11, 5, 4, 3, 71,
-
- 71, 71, 71, 71, 71, 71, 71, 71, 71, 71,
- 71, 71, 71, 71, 71, 71, 71, 71, 71, 71,
- 71, 71, 71, 71, 71, 71, 71
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 7, 7, 8, 8, 14, 26, 26, 14, 38, 14,
+ 84, 38, 81, 81, 81, 81, 81, 82, 82, 78,
+ 82, 82, 83, 75, 83, 83, 83, 85, 85, 85,
+ 74, 85, 86, 72, 86, 86, 86, 71, 69, 68,
+ 67, 66, 65, 63, 62, 61, 60, 59, 57, 56,
+ 55, 54, 53, 52, 51, 50, 49, 48, 47, 42,
+ 41, 40, 39, 37, 35, 27, 25, 23, 22, 21,
+
+ 20, 19, 18, 15, 13, 12, 11, 5, 4, 3,
+ 80, 80, 80, 80, 80, 80, 80, 80, 80, 80,
+ 80, 80, 80, 80, 80, 80, 80, 80, 80, 80,
+ 80, 80, 80, 80, 80, 80, 80, 80, 80, 80,
+ 80
} ;
/* Table of booleans, true if rule could match eol. */
-static yyconst flex_int32_t yy_rule_can_match_eol[24] =
+static yyconst flex_int32_t yy_rule_can_match_eol[25] =
{ 0,
-0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0,
- 0, 1, 0, 0, };
+0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0,
+ 0, 0, 1, 0, 0, };
/* The intent behind this definition is that it'll catch
* any uses of REJECT which flex missed.
} while (0)
#define YY_NO_UNISTD_H 1
-#line 549 "config_lexer.cc"
+#line 555 "config_lexer.cc"
#define INITIAL 0
#define IN_C_COMMENT 1
#line 48 "config_lexer.ll"
-#line 798 "config_lexer.cc"
+#line 804 "config_lexer.cc"
yylval = yylval_param;
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
{
yy_current_state = (int) yy_def[yy_current_state];
- if ( yy_current_state >= 72 )
+ if ( yy_current_state >= 81 )
yy_c = yy_meta[(unsigned int) yy_c];
}
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
++yy_cp;
}
- while ( yy_current_state != 71 );
+ while ( yy_current_state != 80 );
yy_cp = yyg->yy_last_accepting_cpos;
yy_current_state = yyg->yy_last_accepting_state;
case 3:
YY_RULE_SETUP
#line 51 "config_lexer.ll"
-return T_OBJECT;
+return T_TEMPORARY;
YY_BREAK
case 4:
YY_RULE_SETUP
#line 52 "config_lexer.ll"
-return T_INCLUDE;
+return T_OBJECT;
YY_BREAK
case 5:
YY_RULE_SETUP
#line 53 "config_lexer.ll"
-return T_INHERITS;
+return T_INCLUDE;
YY_BREAK
case 6:
YY_RULE_SETUP
#line 54 "config_lexer.ll"
-return T_NULL;
+return T_INHERITS;
YY_BREAK
case 7:
YY_RULE_SETUP
#line 55 "config_lexer.ll"
-{ yylval->text = strdup(yytext); return T_IDENTIFIER; }
+return T_NULL;
YY_BREAK
case 8:
-/* rule 8 can match eol */
YY_RULE_SETUP
#line 56 "config_lexer.ll"
-{ yytext[yyleng-1] = '\0'; yylval->text = strdup(yytext + 1); return T_STRING; }
+{ yylval->text = strdup(yytext); return T_IDENTIFIER; }
YY_BREAK
case 9:
+/* rule 9 can match eol */
YY_RULE_SETUP
#line 57 "config_lexer.ll"
-{ yylval->num = atoi(yytext); return T_NUMBER; }
+{ yytext[yyleng-1] = '\0'; yylval->text = strdup(yytext + 1); return T_STRING; }
YY_BREAK
case 10:
YY_RULE_SETUP
#line 58 "config_lexer.ll"
-{ yylval->op = OperatorSet; return T_EQUAL; }
+{ yylval->num = atoi(yytext); return T_NUMBER; }
YY_BREAK
case 11:
YY_RULE_SETUP
#line 59 "config_lexer.ll"
-{ yylval->op = OperatorPlus; return T_PLUS_EQUAL; }
+{ yylval->op = OperatorSet; return T_EQUAL; }
YY_BREAK
case 12:
YY_RULE_SETUP
#line 60 "config_lexer.ll"
-{ yylval->op = OperatorMinus; return T_MINUS_EQUAL; }
+{ yylval->op = OperatorPlus; return T_PLUS_EQUAL; }
YY_BREAK
case 13:
YY_RULE_SETUP
#line 61 "config_lexer.ll"
-{ yylval->op = OperatorMultiply; return T_MULTIPLY_EQUAL; }
+{ yylval->op = OperatorMinus; return T_MINUS_EQUAL; }
YY_BREAK
case 14:
YY_RULE_SETUP
#line 62 "config_lexer.ll"
-{ yylval->op = OperatorDivide; return T_DIVIDE_EQUAL; }
+{ yylval->op = OperatorMultiply; return T_MULTIPLY_EQUAL; }
YY_BREAK
-
case 15:
YY_RULE_SETUP
-#line 65 "config_lexer.ll"
-BEGIN(IN_C_COMMENT);
+#line 63 "config_lexer.ll"
+{ yylval->op = OperatorDivide; return T_DIVIDE_EQUAL; }
YY_BREAK
-
case 16:
YY_RULE_SETUP
-#line 69 "config_lexer.ll"
-BEGIN(INITIAL);
+#line 66 "config_lexer.ll"
+BEGIN(IN_C_COMMENT);
YY_BREAK
+
+
case 17:
-/* rule 17 can match eol */
YY_RULE_SETUP
#line 70 "config_lexer.ll"
-/* ignore comment */
+BEGIN(INITIAL);
YY_BREAK
case 18:
+/* rule 18 can match eol */
YY_RULE_SETUP
#line 71 "config_lexer.ll"
-/* ignore star */
+/* ignore comment */
YY_BREAK
-
case 19:
YY_RULE_SETUP
-#line 74 "config_lexer.ll"
-/* ignore C++-style comments */
+#line 72 "config_lexer.ll"
+/* ignore star */
YY_BREAK
+
case 20:
YY_RULE_SETUP
#line 75 "config_lexer.ll"
-/* ignore shell-style comments */
+/* ignore C++-style comments */
YY_BREAK
case 21:
-/* rule 21 can match eol */
YY_RULE_SETUP
#line 76 "config_lexer.ll"
-/* ignore whitespace */
+/* ignore shell-style comments */
YY_BREAK
case 22:
+/* rule 22 can match eol */
YY_RULE_SETUP
-#line 78 "config_lexer.ll"
-return yytext[0];
+#line 77 "config_lexer.ll"
+/* ignore whitespace */
YY_BREAK
case 23:
YY_RULE_SETUP
#line 79 "config_lexer.ll"
+return yytext[0];
+ YY_BREAK
+case 24:
+YY_RULE_SETUP
+#line 80 "config_lexer.ll"
ECHO;
YY_BREAK
-#line 1015 "config_lexer.cc"
+#line 1026 "config_lexer.cc"
case YY_STATE_EOF(INITIAL):
case YY_STATE_EOF(IN_C_COMMENT):
yyterminate();
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
{
yy_current_state = (int) yy_def[yy_current_state];
- if ( yy_current_state >= 72 )
+ if ( yy_current_state >= 81 )
yy_c = yy_meta[(unsigned int) yy_c];
}
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
{
yy_current_state = (int) yy_def[yy_current_state];
- if ( yy_current_state >= 72 )
+ if ( yy_current_state >= 81 )
yy_c = yy_meta[(unsigned int) yy_c];
}
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
- yy_is_jam = (yy_current_state == 71);
+ yy_is_jam = (yy_current_state == 80);
return yy_is_jam ? 0 : yy_current_state;
}
#define YYTABLES_NAME "yytables"
-#line 79 "config_lexer.ll"
+#line 80 "config_lexer.ll"
%%
abstract return T_ABSTRACT;
local return T_LOCAL;
+temporary return T_TEMPORARY;
object return T_OBJECT;
include return T_INCLUDE;
inherits return T_INHERITS;
T_MULTIPLY_EQUAL = 265,
T_DIVIDE_EQUAL = 266,
T_ABSTRACT = 267,
- T_LOCAL = 268,
- T_OBJECT = 269,
- T_INCLUDE = 270,
- T_INHERITS = 271
+ T_TEMPORARY = 268,
+ T_LOCAL = 269,
+ T_OBJECT = 270,
+ T_INCLUDE = 271,
+ T_INHERITS = 272
};
#endif
/* Tokens. */
#define T_MULTIPLY_EQUAL 265
#define T_DIVIDE_EQUAL 266
#define T_ABSTRACT 267
-#define T_LOCAL 268
-#define T_OBJECT 269
-#define T_INCLUDE 270
-#define T_INHERITS 271
+#define T_TEMPORARY 268
+#define T_LOCAL 269
+#define T_OBJECT 270
+#define T_INCLUDE 271
+#define T_INHERITS 272
/* Line 293 of yacc.c */
-#line 183 "config_parser.cc"
+#line 185 "config_parser.cc"
} YYSTYPE;
# define YYSTYPE_IS_TRIVIAL 1
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
/* Copy the second part of user declarations. */
/* Line 343 of yacc.c */
-#line 66 "config_parser.yy"
+#line 67 "config_parser.yy"
int yylex(YYSTYPE *lvalp, YYLTYPE *llocp, void *scanner);
static vector<ConfigItem::Ptr> m_Objects;
static ConfigItem::Ptr m_Object;
static bool m_Abstract;
+static bool m_Temporary;
static bool m_Local;
static Dictionary::Ptr m_Array;
/* Line 343 of yacc.c */
-#line 246 "config_parser.cc"
+#line 249 "config_parser.cc"
#ifdef short
# undef short
#define YYLAST 47
/* YYNTOKENS -- Number of terminals. */
-#define YYNTOKENS 28
+#define YYNTOKENS 29
/* YYNNTS -- Number of nonterminals. */
#define YYNNTS 23
/* YYNRULES -- Number of rules. */
-#define YYNRULES 43
+#define YYNRULES 44
/* YYNRULES -- Number of states. */
-#define YYNSTATES 60
+#define YYNSTATES 61
/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
#define YYUNDEFTOK 2
-#define YYMAXUTOK 271
+#define YYMAXUTOK 272
#define YYTRANSLATE(YYX) \
((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 26, 27, 19, 17, 21, 18, 2, 20, 2, 2,
+ 27, 28, 20, 18, 22, 19, 2, 21, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 24, 2, 25, 2, 2, 2, 2, 2, 2,
+ 2, 25, 2, 26, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 22, 2, 23, 2, 2, 2, 2,
+ 2, 2, 2, 23, 2, 24, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
- 15, 16
+ 15, 16, 17
};
#if YYDEBUG
static const yytype_uint8 yyprhs[] =
{
0, 0, 3, 4, 7, 9, 11, 14, 15, 16,
- 25, 26, 29, 31, 33, 35, 39, 41, 42, 45,
- 46, 51, 52, 54, 58, 62, 69, 71, 73, 75,
- 77, 79, 81, 83, 85, 87, 89, 91, 93, 94,
- 99, 101, 102, 104
+ 25, 26, 29, 31, 33, 35, 37, 41, 43, 44,
+ 47, 48, 53, 54, 56, 60, 64, 71, 73, 75,
+ 77, 79, 81, 83, 85, 87, 89, 91, 93, 95,
+ 96, 101, 103, 104, 106
};
/* YYRHS -- A `-1'-separated list of the rules' RHS. */
static const yytype_int8 yyrhs[] =
{
- 29, 0, -1, -1, 29, 30, -1, 32, -1, 31,
- -1, 15, 3, -1, -1, -1, 33, 35, 14, 6,
- 3, 34, 39, 40, -1, -1, 35, 36, -1, 12,
- -1, 13, -1, 38, -1, 37, 21, 38, -1, 3,
- -1, -1, 16, 37, -1, -1, 22, 41, 42, 23,
- -1, -1, 43, -1, 43, 21, 42, -1, 6, 44,
- 46, -1, 6, 24, 3, 25, 44, 46, -1, 3,
- -1, 7, -1, 8, -1, 9, -1, 10, -1, 11,
- -1, 3, -1, 4, -1, 5, -1, 45, -1, 47,
- -1, 40, -1, -1, 26, 48, 50, 27, -1, 45,
- -1, -1, 49, -1, 49, 21, 50, -1
+ 30, 0, -1, -1, 30, 31, -1, 33, -1, 32,
+ -1, 16, 3, -1, -1, -1, 34, 36, 15, 6,
+ 3, 35, 40, 41, -1, -1, 36, 37, -1, 12,
+ -1, 13, -1, 14, -1, 39, -1, 38, 22, 39,
+ -1, 3, -1, -1, 17, 38, -1, -1, 23, 42,
+ 43, 24, -1, -1, 44, -1, 44, 22, 43, -1,
+ 6, 45, 47, -1, 6, 25, 3, 26, 45, 47,
+ -1, 3, -1, 7, -1, 8, -1, 9, -1, 10,
+ -1, 11, -1, 3, -1, 4, -1, 5, -1, 46,
+ -1, 48, -1, 41, -1, -1, 27, 49, 51, 28,
+ -1, 46, -1, -1, 50, -1, 50, 22, 51, -1
};
/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
static const yytype_uint16 yyrline[] =
{
- 0, 104, 104, 105, 108, 108, 111, 115, 120, 115,
- 150, 151, 154, 158, 164, 165, 168, 175, 176, 180,
- 179, 191, 192, 193, 196, 204, 218, 227, 228, 229,
- 230, 231, 237, 242, 246, 252, 253, 254, 261, 260,
- 272, 278, 280, 281
+ 0, 106, 106, 107, 110, 110, 113, 117, 122, 117,
+ 155, 156, 159, 163, 167, 173, 174, 177, 184, 185,
+ 189, 188, 200, 201, 202, 205, 213, 227, 236, 237,
+ 238, 239, 240, 246, 251, 255, 261, 262, 263, 270,
+ 269, 281, 287, 289, 290
};
#endif
{
"$end", "error", "$undefined", "T_STRING", "T_NUMBER", "T_NULL",
"T_IDENTIFIER", "T_EQUAL", "T_PLUS_EQUAL", "T_MINUS_EQUAL",
- "T_MULTIPLY_EQUAL", "T_DIVIDE_EQUAL", "T_ABSTRACT", "T_LOCAL",
- "T_OBJECT", "T_INCLUDE", "T_INHERITS", "'+'", "'-'", "'*'", "'/'", "','",
- "'{'", "'}'", "'['", "']'", "'('", "')'", "$accept", "statements",
- "statement", "include", "object", "$@1", "$@2", "attributes",
- "attribute", "inherits_list", "inherits_item", "inherits_specifier",
- "expressionlist", "$@3", "expressions", "expression", "operator",
- "simplevalue", "value", "tuple", "$@4", "tupleitem", "tupleitems", 0
+ "T_MULTIPLY_EQUAL", "T_DIVIDE_EQUAL", "T_ABSTRACT", "T_TEMPORARY",
+ "T_LOCAL", "T_OBJECT", "T_INCLUDE", "T_INHERITS", "'+'", "'-'", "'*'",
+ "'/'", "','", "'{'", "'}'", "'['", "']'", "'('", "')'", "$accept",
+ "statements", "statement", "include", "object", "$@1", "$@2",
+ "attributes", "attribute", "inherits_list", "inherits_item",
+ "inherits_specifier", "expressionlist", "$@3", "expressions",
+ "expression", "operator", "simplevalue", "value", "tuple", "$@4",
+ "tupleitem", "tupleitems", 0
};
#endif
static const yytype_uint16 yytoknum[] =
{
0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
- 265, 266, 267, 268, 269, 270, 271, 43, 45, 42,
- 47, 44, 123, 125, 91, 93, 40, 41
+ 265, 266, 267, 268, 269, 270, 271, 272, 43, 45,
+ 42, 47, 44, 123, 125, 91, 93, 40, 41
};
# endif
/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
static const yytype_uint8 yyr1[] =
{
- 0, 28, 29, 29, 30, 30, 31, 33, 34, 32,
- 35, 35, 36, 36, 37, 37, 38, 39, 39, 41,
- 40, 42, 42, 42, 43, 43, 43, 44, 44, 44,
- 44, 44, 45, 45, 45, 46, 46, 46, 48, 47,
- 49, 50, 50, 50
+ 0, 29, 30, 30, 31, 31, 32, 34, 35, 33,
+ 36, 36, 37, 37, 37, 38, 38, 39, 40, 40,
+ 42, 41, 43, 43, 43, 44, 44, 44, 45, 45,
+ 45, 45, 45, 46, 46, 46, 47, 47, 47, 49,
+ 48, 50, 51, 51, 51
};
/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
static const yytype_uint8 yyr2[] =
{
0, 2, 0, 2, 1, 1, 2, 0, 0, 8,
- 0, 2, 1, 1, 1, 3, 1, 0, 2, 0,
- 4, 0, 1, 3, 3, 6, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 0, 4,
- 1, 0, 1, 3
+ 0, 2, 1, 1, 1, 1, 3, 1, 0, 2,
+ 0, 4, 0, 1, 3, 3, 6, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 0,
+ 4, 1, 0, 1, 3
};
/* YYDEFACT[STATE-NAME] -- Default reduction number in state STATE-NUM.
static const yytype_uint8 yydefact[] =
{
2, 7, 1, 0, 3, 5, 4, 10, 6, 0,
- 12, 13, 0, 11, 0, 8, 17, 0, 0, 16,
- 18, 14, 19, 9, 0, 21, 15, 26, 0, 0,
- 22, 27, 28, 29, 30, 31, 0, 0, 20, 21,
- 0, 32, 33, 34, 38, 37, 35, 24, 36, 23,
- 0, 41, 0, 40, 42, 0, 25, 41, 39, 43
+ 12, 13, 14, 0, 11, 0, 8, 18, 0, 0,
+ 17, 19, 15, 20, 9, 0, 22, 16, 27, 0,
+ 0, 23, 28, 29, 30, 31, 32, 0, 0, 21,
+ 22, 0, 33, 34, 35, 39, 38, 36, 25, 37,
+ 24, 0, 42, 0, 41, 43, 0, 26, 42, 40,
+ 44
};
/* YYDEFGOTO[NTERM-NUM]. */
static const yytype_int8 yydefgoto[] =
{
- -1, 1, 4, 5, 6, 7, 16, 9, 13, 20,
- 21, 18, 45, 25, 29, 30, 37, 46, 47, 48,
- 51, 54, 55
+ -1, 1, 4, 5, 6, 7, 17, 9, 14, 21,
+ 22, 19, 46, 26, 30, 31, 38, 47, 48, 49,
+ 52, 55, 56
};
/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
STATE-NUM. */
-#define YYPACT_NINF -44
+#define YYPACT_NINF -45
static const yytype_int8 yypact[] =
{
- -44, 9, -44, 8, -44, -44, -44, -44, -44, 3,
- -44, -44, 6, -44, 15, -44, 5, 19, 11, -44,
- 13, -44, -44, -44, 19, 7, -44, -44, -4, 12,
- 16, -44, -44, -44, -44, -44, 33, -3, -44, 7,
- 14, -44, -44, -44, -44, -44, -44, -44, -44, -44,
- 18, 27, -3, -44, 17, 20, -44, 27, -44, -44
+ -45, 9, -45, 19, -45, -45, -45, -45, -45, -2,
+ -45, -45, -45, 25, -45, 27, -45, 15, 30, 11,
+ -45, 13, -45, -45, -45, 30, 20, -45, -45, -4,
+ 12, 16, -45, -45, -45, -45, -45, 34, -3, -45,
+ 20, 14, -45, -45, -45, -45, -45, -45, -45, -45,
+ -45, 8, 24, -3, -45, 17, 18, -45, 24, -45,
+ -45
};
/* YYPGOTO[NTERM-NUM]. */
static const yytype_int8 yypgoto[] =
{
- -44, -44, -44, -44, -44, -44, -44, -44, -44, -44,
- 21, -44, 22, -44, 2, -44, -8, -43, -9, -44,
- -44, -44, -13
+ -45, -45, -45, -45, -45, -45, -45, -45, -45, -45,
+ 22, -45, 23, -45, 1, -45, -8, -44, -9, -45,
+ -45, -45, -13
};
/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
#define YYTABLE_NINF -1
static const yytype_uint8 yytable[] =
{
- 41, 42, 43, 31, 32, 33, 34, 35, 53, 2,
- 27, 8, 14, 28, 53, 10, 11, 12, 15, 22,
- 36, 17, 19, 44, 3, 31, 32, 33, 34, 35,
- 41, 42, 43, 22, 24, 38, 40, 39, 57, 50,
- 23, 49, 52, 56, 59, 26, 0, 58
+ 42, 43, 44, 32, 33, 34, 35, 36, 54, 2,
+ 10, 11, 12, 13, 54, 32, 33, 34, 35, 36,
+ 23, 37, 8, 28, 45, 3, 29, 42, 43, 44,
+ 16, 15, 18, 20, 23, 25, 39, 41, 40, 58,
+ 51, 50, 24, 53, 57, 60, 59, 27
};
#define yypact_value_is_default(yystate) \
- ((yystate) == (-44))
+ ((yystate) == (-45))
#define yytable_value_is_error(yytable_value) \
YYID (0)
-static const yytype_int8 yycheck[] =
+static const yytype_uint8 yycheck[] =
{
- 3, 4, 5, 7, 8, 9, 10, 11, 51, 0,
- 3, 3, 6, 6, 57, 12, 13, 14, 3, 22,
- 24, 16, 3, 26, 15, 7, 8, 9, 10, 11,
- 3, 4, 5, 22, 21, 23, 3, 21, 21, 25,
- 18, 39, 50, 52, 57, 24, -1, 27
+ 3, 4, 5, 7, 8, 9, 10, 11, 52, 0,
+ 12, 13, 14, 15, 58, 7, 8, 9, 10, 11,
+ 23, 25, 3, 3, 27, 16, 6, 3, 4, 5,
+ 3, 6, 17, 3, 23, 22, 24, 3, 22, 22,
+ 26, 40, 19, 51, 53, 58, 28, 25
};
/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
symbol of state STATE-NUM. */
static const yytype_uint8 yystos[] =
{
- 0, 29, 0, 15, 30, 31, 32, 33, 3, 35,
- 12, 13, 14, 36, 6, 3, 34, 16, 39, 3,
- 37, 38, 22, 40, 21, 41, 38, 3, 6, 42,
- 43, 7, 8, 9, 10, 11, 24, 44, 23, 21,
- 3, 3, 4, 5, 26, 40, 45, 46, 47, 42,
- 25, 48, 44, 45, 49, 50, 46, 21, 27, 50
+ 0, 30, 0, 16, 31, 32, 33, 34, 3, 36,
+ 12, 13, 14, 15, 37, 6, 3, 35, 17, 40,
+ 3, 38, 39, 23, 41, 22, 42, 39, 3, 6,
+ 43, 44, 7, 8, 9, 10, 11, 25, 45, 24,
+ 22, 3, 3, 4, 5, 27, 41, 46, 47, 48,
+ 43, 26, 49, 45, 46, 50, 51, 47, 22, 28,
+ 51
};
#define yyerrok (yyerrstatus = 0)
case 7:
/* Line 1806 of yacc.c */
-#line 115 "config_parser.yy"
+#line 117 "config_parser.yy"
{
m_Abstract = false;
m_Local = false;
case 8:
/* Line 1806 of yacc.c */
-#line 120 "config_parser.yy"
+#line 122 "config_parser.yy"
{
m_Object = boost::make_shared<ConfigItem>((yyvsp[(4) - (5)].text), (yyvsp[(5) - (5)].text), yylloc);
free((yyvsp[(4) - (5)].text));
case 9:
/* Line 1806 of yacc.c */
-#line 126 "config_parser.yy"
+#line 128 "config_parser.yy"
{
Object::Ptr exprl_object = *(yyvsp[(8) - (8)].variant);
delete (yyvsp[(8) - (8)].variant);
Expression abstractexpr("__abstract", OperatorSet, m_Abstract ? 1 : 0, yylloc);
exprl->AddExpression(abstractexpr);
+ Expression tempexpr("__temporary", OperatorSet, m_Temporary ? 1 : 0, yylloc);
+ exprl->AddExpression(tempexpr);
+
Expression localexpr("__local", OperatorSet, m_Local ? 1 : 0, yylloc);
exprl->AddExpression(localexpr);
case 12:
/* Line 1806 of yacc.c */
-#line 155 "config_parser.yy"
+#line 160 "config_parser.yy"
{
m_Abstract = true;
}
case 13:
/* Line 1806 of yacc.c */
-#line 159 "config_parser.yy"
+#line 164 "config_parser.yy"
+ {
+ m_Temporary = true;
+ }
+ break;
+
+ case 14:
+
+/* Line 1806 of yacc.c */
+#line 168 "config_parser.yy"
{
m_Local = true;
}
break;
- case 16:
+ case 17:
/* Line 1806 of yacc.c */
-#line 169 "config_parser.yy"
+#line 178 "config_parser.yy"
{
m_Object->AddParent((yyvsp[(1) - (1)].text));
free((yyvsp[(1) - (1)].text));
}
break;
- case 19:
+ case 20:
/* Line 1806 of yacc.c */
-#line 180 "config_parser.yy"
+#line 189 "config_parser.yy"
{
m_ExpressionLists.push(boost::make_shared<ExpressionList>());
}
break;
- case 20:
+ case 21:
/* Line 1806 of yacc.c */
-#line 185 "config_parser.yy"
+#line 194 "config_parser.yy"
{
(yyval.variant) = new Variant(m_ExpressionLists.top());
m_ExpressionLists.pop();
}
break;
- case 24:
+ case 25:
/* Line 1806 of yacc.c */
-#line 197 "config_parser.yy"
+#line 206 "config_parser.yy"
{
Expression expr((yyvsp[(1) - (3)].text), (yyvsp[(2) - (3)].op), *(yyvsp[(3) - (3)].variant), yylloc);
free((yyvsp[(1) - (3)].text));
}
break;
- case 25:
+ case 26:
/* Line 1806 of yacc.c */
-#line 205 "config_parser.yy"
+#line 214 "config_parser.yy"
{
Expression subexpr((yyvsp[(3) - (6)].text), (yyvsp[(5) - (6)].op), *(yyvsp[(6) - (6)].variant), yylloc);
free((yyvsp[(3) - (6)].text));
}
break;
- case 26:
+ case 27:
/* Line 1806 of yacc.c */
-#line 219 "config_parser.yy"
+#line 228 "config_parser.yy"
{
Expression expr((yyvsp[(1) - (1)].text), OperatorSet, (yyvsp[(1) - (1)].text), yylloc);
free((yyvsp[(1) - (1)].text));
}
break;
- case 31:
+ case 32:
/* Line 1806 of yacc.c */
-#line 232 "config_parser.yy"
+#line 241 "config_parser.yy"
{
(yyval.op) = (yyvsp[(1) - (1)].op);
}
break;
- case 32:
+ case 33:
/* Line 1806 of yacc.c */
-#line 238 "config_parser.yy"
+#line 247 "config_parser.yy"
{
(yyval.variant) = new Variant((yyvsp[(1) - (1)].text));
free((yyvsp[(1) - (1)].text));
}
break;
- case 33:
+ case 34:
/* Line 1806 of yacc.c */
-#line 243 "config_parser.yy"
+#line 252 "config_parser.yy"
{
(yyval.variant) = new Variant((yyvsp[(1) - (1)].num));
}
break;
- case 34:
+ case 35:
/* Line 1806 of yacc.c */
-#line 247 "config_parser.yy"
+#line 256 "config_parser.yy"
{
(yyval.variant) = new Variant();
}
break;
- case 37:
+ case 38:
/* Line 1806 of yacc.c */
-#line 255 "config_parser.yy"
+#line 264 "config_parser.yy"
{
(yyval.variant) = (yyvsp[(1) - (1)].variant);
}
break;
- case 38:
+ case 39:
/* Line 1806 of yacc.c */
-#line 261 "config_parser.yy"
+#line 270 "config_parser.yy"
{
m_Array = boost::make_shared<Dictionary>();
}
break;
- case 39:
+ case 40:
/* Line 1806 of yacc.c */
-#line 266 "config_parser.yy"
+#line 275 "config_parser.yy"
{
(yyval.variant) = new Variant(m_Array);
m_Array.reset();
}
break;
- case 40:
+ case 41:
/* Line 1806 of yacc.c */
-#line 273 "config_parser.yy"
+#line 282 "config_parser.yy"
{
m_Array->AddUnnamedProperty(*(yyvsp[(1) - (1)].variant));
delete (yyvsp[(1) - (1)].variant);
/* Line 1806 of yacc.c */
-#line 1785 "config_parser.cc"
+#line 1804 "config_parser.cc"
default: break;
}
/* User semantic actions sometimes alter yychar, and that requires
/* Line 2067 of yacc.c */
-#line 283 "config_parser.yy"
+#line 292 "config_parser.yy"
T_MULTIPLY_EQUAL = 265,
T_DIVIDE_EQUAL = 266,
T_ABSTRACT = 267,
- T_LOCAL = 268,
- T_OBJECT = 269,
- T_INCLUDE = 270,
- T_INHERITS = 271
+ T_TEMPORARY = 268,
+ T_LOCAL = 269,
+ T_OBJECT = 270,
+ T_INCLUDE = 271,
+ T_INHERITS = 272
};
#endif
/* Tokens. */
#define T_MULTIPLY_EQUAL 265
#define T_DIVIDE_EQUAL 266
#define T_ABSTRACT 267
-#define T_LOCAL 268
-#define T_OBJECT 269
-#define T_INCLUDE 270
-#define T_INHERITS 271
+#define T_TEMPORARY 268
+#define T_LOCAL 269
+#define T_OBJECT 270
+#define T_INCLUDE 271
+#define T_INHERITS 272
/* Line 2068 of yacc.c */
-#line 126 "config_parser.h"
+#line 128 "config_parser.h"
} YYSTYPE;
# define YYSTYPE_IS_TRIVIAL 1
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
%token <op> T_MULTIPLY_EQUAL
%token <op> T_DIVIDE_EQUAL
%token T_ABSTRACT
+%token T_TEMPORARY
%token T_LOCAL
%token T_OBJECT
%token T_INCLUDE
static vector<ConfigItem::Ptr> m_Objects;
static ConfigItem::Ptr m_Object;
static bool m_Abstract;
+static bool m_Temporary;
static bool m_Local;
static Dictionary::Ptr m_Array;
Expression abstractexpr("__abstract", OperatorSet, m_Abstract ? 1 : 0, yylloc);
exprl->AddExpression(abstractexpr);
+ Expression tempexpr("__temporary", OperatorSet, m_Temporary ? 1 : 0, yylloc);
+ exprl->AddExpression(tempexpr);
+
Expression localexpr("__local", OperatorSet, m_Local ? 1 : 0, yylloc);
exprl->AddExpression(localexpr);
{
m_Abstract = true;
}
+ | T_TEMPORARY
+ {
+ m_Temporary = true;
+ }
| T_LOCAL
{
m_Local = true;
void ConfigItem::Unregister(void)
{
- // TODO: unregister associated ConfigObject
+ ConfigObject::Ptr dobj = m_ConfigObject.lock();
+
+ if (dobj)
+ dobj->Unregister();
GetAllObjects()->RemoveObject(GetSelf());
}
${top_builddir}/base/libbase.la \
${top_builddir}/icinga/libicinga.la \
-dlopen ${top_builddir}/components/checker/checker.la \
+ -dlopen ${top_builddir}/components/compat/compat.la \
-dlopen ${top_builddir}/components/configfile/configfile.la \
-dlopen ${top_builddir}/components/configrpc/configrpc.la \
-dlopen ${top_builddir}/components/delegation/delegation.la \
checkresult.h \
checktask.cpp \
checktask.h \
+ cib.cpp \
+ cib.h \
configobjectadapter.cpp \
configobjectadapter.h \
endpoint.cpp \
endpointmanager.h \
icingaapplication.cpp \
icingaapplication.h \
- icingacomponent.cpp \
- icingacomponent.h \
host.cpp \
host.h \
i2-icinga.h \
--- /dev/null
+#include "i2-icinga.h"
+
+using namespace icinga;
+
+int CIB::m_Types;
+VirtualEndpoint::Ptr CIB::m_Endpoint;
+
+void CIB::RequireInformation(InformationType types)
+{
+ m_Types |= types;
+}
+
+void CIB::Start(void)
+{
+ m_Endpoint = boost::make_shared<VirtualEndpoint>();
+ if (m_Types & CIB_ServiceStatus) {
+ m_Endpoint->RegisterTopicHandler("delegation::ServiceStatus",
+ boost::bind(&CIB::ServiceStatusRequestHandler, _2, _3));
+ }
+ EndpointManager::GetInstance()->RegisterEndpoint(m_Endpoint);
+}
+
+void CIB::ServiceStatusRequestHandler(const Endpoint::Ptr& sender, const RequestMessage& request)
+{
+ MessagePart params;
+ if (!request.GetParams(¶ms))
+ return;
+
+ string svcname;
+ if (!params.GetProperty("service", &svcname))
+ return;
+
+ Service service = Service::GetByName(svcname);
+
+ long nextCheck;
+ if (params.GetProperty("next_check", &nextCheck))
+ service.SetNextCheck(nextCheck);
+
+ long state, stateType;
+ if (params.GetProperty("state", &state) && params.GetProperty("state_type", &stateType)) {
+ long old_state, old_stateType;
+ old_state = service.GetState();
+ old_stateType = service.GetStateType();
+
+ if (state != old_state) {
+ time_t now;
+ time(&now);
+
+ service.SetLastStateChange(now);
+
+ if (old_stateType != stateType)
+ service.SetLastHardStateChange(now);
+ }
+
+ service.SetState(static_cast<ServiceState>(state));
+ service.SetStateType(static_cast<ServiceStateType>(stateType));
+ }
+
+ long attempt;
+ if (params.GetProperty("current_attempt", &attempt))
+ service.SetCurrentCheckAttempt(attempt);
+
+ Dictionary::Ptr cr;
+ if (params.GetProperty("result", &cr))
+ service.SetLastCheckResult(cr);
+}
+
--- /dev/null
+#ifndef CIB_H
+#define CIB_H
+
+namespace icinga
+{
+
+enum InformationType
+{
+ CIB_Configuration = 1<<0,
+ CIB_ProgramStatus = 1<<1,
+ CIB_ServiceStatus = 1<<2
+};
+
+class CIB
+{
+public:
+ static void RequireInformation(InformationType type);
+
+ static void Start(void);
+
+private:
+ static int m_Types;
+ static VirtualEndpoint::Ptr m_Endpoint;
+
+ static void ServiceStatusRequestHandler(const Endpoint::Ptr& sender, const RequestMessage& request);
+};
+
+}
+
+#endif /* CIB_H */
return m_Endpoints.end();
}
+EndpointManager::Ptr EndpointManager::GetInstance(void)
+{
+ static EndpointManager::Ptr instance;
+
+ if (!instance)
+ instance = boost::make_shared<EndpointManager>();
+
+ return instance;
+}
EndpointManager(void);
+ static EndpointManager::Ptr GetInstance(void);
+
void SetIdentity(string identity);
string GetIdentity(void) const;
#include "virtualendpoint.h"
#include "endpointmanager.h"
#include "icingaapplication.h"
-#include "icingacomponent.h"
#include "configobjectadapter.h"
#include "host.h"
#include "service.h"
+#include "cib.h"
+
#include "macroprocessor.h"
#include "checkresult.h"
#include "checktask.h"
return EXIT_FAILURE;
}
- m_EndpointManager = boost::make_shared<EndpointManager>();
-
string componentDirectory = GetExeDirectory() + "/../lib/icinga2";
AddComponentSearchDir(componentDirectory);
shared_ptr<X509> cert = Utility::GetX509Certificate(GetCertificateFile());
string identity = Utility::GetCertificateCN(cert);
Application::Log(LogInformation, "icinga", "My identity: " + identity);
- m_EndpointManager->SetIdentity(identity);
+ EndpointManager::GetInstance()->SetIdentity(identity);
shared_ptr<SSL_CTX> sslContext = Utility::MakeSSLContext(GetCertificateFile(), GetCertificateFile(), GetCAFile());
- m_EndpointManager->SetSSLContext(sslContext);
+ EndpointManager::GetInstance()->SetSSLContext(sslContext);
}
/* create the primary RPC listener */
string service = GetService();
if (!service.empty())
- GetEndpointManager()->AddListener(service);
+ EndpointManager::GetInstance()->AddListener(service);
+
+ CIB::RequireInformation(CIB_ServiceStatus);
+ CIB::Start();
RunEventLoop();
return EXIT_SUCCESS;
}
-/**
- * Retrieves Icinga's endpoint manager.
- *
- * @returns The endpoint manager.
- */
-EndpointManager::Ptr IcingaApplication::GetEndpointManager(void)
-{
- return m_EndpointManager;
-}
-
void IcingaApplication::NewComponentHandler(const ConfigObject::Ptr& object)
{
/* don't allow replicated config objects */
LoadComponent(path, object);
}
+IcingaApplication::Ptr IcingaApplication::GetInstance(void)
+{
+ return static_pointer_cast<IcingaApplication>(Application::GetInstance());
+}
+
void IcingaApplication::DeletedComponentHandler(const ConfigObject::Ptr& object)
{
Component::Ptr component = GetComponent(object->GetName());
int Main(const vector<string>& args);
- EndpointManager::Ptr GetEndpointManager(void);
+ static IcingaApplication::Ptr GetInstance(void);
string GetCertificateFile(void) const;
string GetCAFile(void) const;
string GetService(void) const;
private:
- EndpointManager::Ptr m_EndpointManager;
-
string m_CertificateFile;
string m_CAFile;
string m_Node;
return GetName();
}
+Service Service::GetByName(string name)
+{
+ ConfigObject::Ptr configObject = ConfigObject::GetObject("service", name);
+
+ if (!configObject)
+ throw invalid_argument("Service '" + name + "' does not exist.");
+
+ return configObject;
+}
+
Host Service::GetHost(void) const
{
string hostname;
long Service::GetRetryInterval(void) const
{
- long value = 60;
- GetConfigObject()->GetProperty("retry_interval", &value);
+ long value;
+ if (!GetConfigObject()->GetProperty("retry_interval", &value))
+ value = GetCheckInterval() / 5;
+
+ return value;
+}
+
+Dictionary::Ptr Service::GetDependencies(void) const
+{
+ Dictionary::Ptr value;
+ GetConfigObject()->GetProperty("dependencies", &value);
return value;
}
time_t Service::GetNextCheck(void)
{
- long value = -1;
- GetConfigObject()->GetTag("next_check", &value);
- if (value == -1) {
+ long value;
+ if (!GetConfigObject()->GetTag("next_check", &value)) {
value = time(NULL) + rand() % GetCheckInterval();
SetNextCheck(value);
}
return value;
}
+void Service::UpdateNextCheck(void)
+{
+ time_t now;
+ time(&now);
+
+ if (GetStateType() == StateTypeSoft)
+ SetNextCheck(now + GetRetryInterval());
+ else
+ SetNextCheck(now + GetCheckInterval());
+}
+
void Service::SetChecker(string checker)
{
GetConfigObject()->SetTag("checker", checker);
return static_cast<ServiceStateType>(value);
}
+void Service::SetLastCheckResult(const Dictionary::Ptr& result)
+{
+ GetConfigObject()->SetTag("last_result", result);
+}
+
+Dictionary::Ptr Service::GetLastCheckResult(void) const
+{
+ Dictionary::Ptr value;
+ GetConfigObject()->GetTag("last_result", &value);
+ return value;
+}
+
+void Service::SetLastStateChange(time_t ts)
+{
+ GetConfigObject()->SetTag("last_state_change", ts);
+}
+
+time_t Service::GetLastStateChange(void) const
+{
+ long value = 0;
+ GetConfigObject()->GetTag("last_state_change", &value);
+ return value;
+}
+
+void Service::SetLastHardStateChange(time_t ts)
+{
+ GetConfigObject()->SetTag("last_hard_state_change", ts);
+}
+
+time_t Service::GetLastHardStateChange(void) const
+{
+ long value = 0;
+ GetConfigObject()->GetTag("last_hard_state_change", &value);
+ return value;
+}
+
void Service::ApplyCheckResult(const CheckResult& cr)
{
long attempt = GetCurrentCheckAttempt();
SetState(cr.GetState());
}
+ServiceState Service::StateFromString(string state)
+{
+ /* TODO: make this thread-safe */
+ static map<string, ServiceState> stateLookup;
+
+ if (stateLookup.empty()) {
+ stateLookup["ok"] = StateOK;
+ stateLookup["warning"] = StateWarning;
+ stateLookup["critical"] = StateCritical;
+ stateLookup["unreachable"] = StateUnreachable;
+ stateLookup["uncheckable"] = StateUncheckable;
+ stateLookup["unknown"] = StateUnknown;
+ }
+
+ map<string, ServiceState>::iterator it;
+ it = stateLookup.find(state);
+
+ if (it == stateLookup.end())
+ return StateUnknown;
+ else
+ return it->second;
+}
+
+string Service::StateToString(ServiceState state)
+{
+ switch (state) {
+ case StateOK:
+ return "ok";
+ case StateWarning:
+ return "warning";
+ case StateCritical:
+ return "critical";
+ case StateUnreachable:
+ return "unreachable";
+ case StateUncheckable:
+ return "uncheckable";
+ case StateUnknown:
+ default:
+ return "unknown";
+ }
+}
+
+ServiceStateType Service::StateTypeFromString(string type)
+{
+ if (type == "soft")
+ return StateTypeSoft;
+ else
+ return StateTypeHard;
+}
+
+string Service::StateTypeToString(ServiceStateType type)
+{
+ if (type == StateTypeSoft)
+ return "soft";
+ else
+ return "hard";
+}
+
+bool Service::IsAllowedChecker(string checker) const
+{
+ /* TODO: check config */
+ return true;
+}
StateOK,
StateWarning,
StateCritical,
+ StateUnknown,
StateUnreachable,
StateUncheckable,
- StateUnknown
};
enum ServiceStateType
{
- StateTypeHard,
- StateTypeSoft
+ StateTypeSoft,
+ StateTypeHard
};
struct CheckResult;
: ConfigObjectAdapter(configObject)
{ }
+ static Service GetByName(string name);
+
string GetDisplayName(void) const;
Host GetHost(void) const;
Dictionary::Ptr GetMacros(void) const;
long GetMaxCheckAttempts(void) const;
long GetCheckInterval(void) const;
long GetRetryInterval(void) const;
+ Dictionary::Ptr GetDependencies(void) const;
void SetNextCheck(time_t nextCheck);
time_t GetNextCheck(void);
+ void UpdateNextCheck(void);
void SetChecker(string checker);
string GetChecker(void) const;
+ bool IsAllowedChecker(string checker) const;
+
void SetCurrentCheckAttempt(long attempt);
long GetCurrentCheckAttempt(void) const;
void SetStateType(ServiceStateType type);
ServiceStateType GetStateType(void) const;
+ void SetLastCheckResult(const Dictionary::Ptr& result);
+ Dictionary::Ptr GetLastCheckResult(void) const;
+
+ void SetLastStateChange(time_t ts);
+ time_t GetLastStateChange(void) const;
+
+ void SetLastHardStateChange(time_t ts);
+ time_t GetLastHardStateChange(void) const;
+
void ApplyCheckResult(const CheckResult& cr);
+
+ static ServiceState StateFromString(string state);
+ static string StateToString(ServiceState state);
+
+ static ServiceStateType StateTypeFromString(string state);
+ static string StateTypeToString(ServiceStateType state);
};
}