include(CheckSymbolExists)
include(CheckFunctionExists)
include(CheckLibraryExists)
+include(CheckIncludeFileCXX)
check_symbol_exists(__COUNTER__ "" HAVE_COUNTER_MACRO)
check_function_exists(pipe2 HAVE_PIPE2)
check_library_exists(dl dladdr "dlfcn.h" HAVE_DLADDR)
check_library_exists(execinfo backtrace_symbols "" HAVE_LIBEXECINFO)
+check_include_file_cxx(cxxabi.h HAVE_CXXABI_H)
if(HAVE_LIBEXECINFO)
set(HAVE_BACKTRACE_SYMBOLS TRUE)
{
Dictionary::Ptr nodes = make_shared<Dictionary>();
- BOOST_FOREACH(const CheckerComponent::Ptr& checker, DynamicType::GetObjects<CheckerComponent>()) {
+ BOOST_FOREACH(const CheckerComponent::Ptr& checker, DynamicType::GetObjectsByType<CheckerComponent>()) {
unsigned long idle = checker->GetIdleCheckables();
unsigned long pending = checker->GetPendingCheckables();
{
Dictionary::Ptr nodes = make_shared<Dictionary>();
- BOOST_FOREACH(const CheckResultReader::Ptr& checkresultreader, DynamicType::GetObjects<CheckResultReader>()) {
+ BOOST_FOREACH(const CheckResultReader::Ptr& checkresultreader, DynamicType::GetObjectsByType<CheckResultReader>()) {
nodes->Set(checkresultreader->GetName(), 1); //add more stats
}
{
Dictionary::Ptr nodes = make_shared<Dictionary>();
- BOOST_FOREACH(const CompatLogger::Ptr& compat_logger, DynamicType::GetObjects<CompatLogger>()) {
+ BOOST_FOREACH(const CompatLogger::Ptr& compat_logger, DynamicType::GetObjectsByType<CompatLogger>()) {
nodes->Set(compat_logger->GetName(), 1); //add more stats
}
WriteLine("LOG ROTATION: " + GetRotationMethod());
WriteLine("LOG VERSION: 2.0");
- BOOST_FOREACH(const Host::Ptr& host, DynamicType::GetObjects<Host>()) {
+ BOOST_FOREACH(const Host::Ptr& host, DynamicType::GetObjectsByType<Host>()) {
String output;
CheckResult::Ptr cr = host->GetLastCheckResult();
WriteLine(msgbuf.str());
}
- BOOST_FOREACH(const Service::Ptr& service, DynamicType::GetObjects<Service>()) {
+ BOOST_FOREACH(const Service::Ptr& service, DynamicType::GetObjectsByType<Service>()) {
Host::Ptr host = service->GetHost();
String output;
{
Dictionary::Ptr nodes = make_shared<Dictionary>();
- BOOST_FOREACH(const ExternalCommandListener::Ptr& externalcommandlistener, DynamicType::GetObjects<ExternalCommandListener>()) {
+ BOOST_FOREACH(const ExternalCommandListener::Ptr& externalcommandlistener, DynamicType::GetObjectsByType<ExternalCommandListener>()) {
nodes->Set(externalcommandlistener->GetName(), 1); //add more stats
}
{
Dictionary::Ptr nodes = make_shared<Dictionary>();
- BOOST_FOREACH(const StatusDataWriter::Ptr& statusdatawriter, DynamicType::GetObjects<StatusDataWriter>()) {
+ BOOST_FOREACH(const StatusDataWriter::Ptr& statusdatawriter, DynamicType::GetObjectsByType<StatusDataWriter>()) {
nodes->Set(statusdatawriter->GetName(), 1); //add more stats
}
"# This file is auto-generated. Do not modify this file." "\n"
"\n";
- BOOST_FOREACH(const Host::Ptr& host, DynamicType::GetObjects<Host>()) {
+ BOOST_FOREACH(const Host::Ptr& host, DynamicType::GetObjectsByType<Host>()) {
std::ostringstream tempobjectfp;
tempobjectfp << std::fixed;
DumpHostObject(tempobjectfp, host);
}
}
- BOOST_FOREACH(const HostGroup::Ptr& hg, DynamicType::GetObjects<HostGroup>()) {
+ BOOST_FOREACH(const HostGroup::Ptr& hg, DynamicType::GetObjectsByType<HostGroup>()) {
std::ostringstream tempobjectfp;
tempobjectfp << std::fixed;
objectfp << tempobjectfp.str();
}
- BOOST_FOREACH(const ServiceGroup::Ptr& sg, DynamicType::GetObjects<ServiceGroup>()) {
+ BOOST_FOREACH(const ServiceGroup::Ptr& sg, DynamicType::GetObjectsByType<ServiceGroup>()) {
std::ostringstream tempobjectfp;
tempobjectfp << std::fixed;
objectfp << tempobjectfp.str();
}
- BOOST_FOREACH(const User::Ptr& user, DynamicType::GetObjects<User>()) {
+ BOOST_FOREACH(const User::Ptr& user, DynamicType::GetObjectsByType<User>()) {
std::ostringstream tempobjectfp;
tempobjectfp << std::fixed;
objectfp << tempobjectfp.str();
}
- BOOST_FOREACH(const UserGroup::Ptr& ug, DynamicType::GetObjects<UserGroup>()) {
+ BOOST_FOREACH(const UserGroup::Ptr& ug, DynamicType::GetObjectsByType<UserGroup>()) {
std::ostringstream tempobjectfp;
tempobjectfp << std::fixed;
objectfp << tempobjectfp.str();
}
- BOOST_FOREACH(const Command::Ptr& command, DynamicType::GetObjects<CheckCommand>()) {
+ BOOST_FOREACH(const Command::Ptr& command, DynamicType::GetObjectsByType<CheckCommand>()) {
DumpCommand(objectfp, command);
}
- BOOST_FOREACH(const Command::Ptr& command, DynamicType::GetObjects<NotificationCommand>()) {
+ BOOST_FOREACH(const Command::Ptr& command, DynamicType::GetObjectsByType<NotificationCommand>()) {
DumpCommand(objectfp, command);
}
- BOOST_FOREACH(const Command::Ptr& command, DynamicType::GetObjects<EventCommand>()) {
+ BOOST_FOREACH(const Command::Ptr& command, DynamicType::GetObjectsByType<EventCommand>()) {
DumpCommand(objectfp, command);
}
- BOOST_FOREACH(const TimePeriod::Ptr& tp, DynamicType::GetObjects<TimePeriod>()) {
+ BOOST_FOREACH(const TimePeriod::Ptr& tp, DynamicType::GetObjectsByType<TimePeriod>()) {
DumpTimePeriod(objectfp, tp);
}
- BOOST_FOREACH(const Dependency::Ptr& dep, DynamicType::GetObjects<Dependency>()) {
+ BOOST_FOREACH(const Dependency::Ptr& dep, DynamicType::GetObjectsByType<Dependency>()) {
Checkable::Ptr parent = dep->GetParent();
if (!parent) {
statusfp << "\t" "}" "\n"
"\n";
- BOOST_FOREACH(const Host::Ptr& host, DynamicType::GetObjects<Host>()) {
+ BOOST_FOREACH(const Host::Ptr& host, DynamicType::GetObjectsByType<Host>()) {
std::ostringstream tempstatusfp;
tempstatusfp << std::fixed;
DumpHostStatus(tempstatusfp, host);
{
Dictionary::Ptr nodes = make_shared<Dictionary>();
- BOOST_FOREACH(const IdoMysqlConnection::Ptr& idomysqlconnection, DynamicType::GetObjects<IdoMysqlConnection>()) {
+ BOOST_FOREACH(const IdoMysqlConnection::Ptr& idomysqlconnection, DynamicType::GetObjectsByType<IdoMysqlConnection>()) {
size_t items = idomysqlconnection->m_QueryQueue.GetLength();
Dictionary::Ptr stats = make_shared<Dictionary>();
{
Dictionary::Ptr nodes = make_shared<Dictionary>();
- BOOST_FOREACH(const IdoPgsqlConnection::Ptr& idopgsqlconnection, DynamicType::GetObjects<IdoPgsqlConnection>()) {
+ BOOST_FOREACH(const IdoPgsqlConnection::Ptr& idopgsqlconnection, DynamicType::GetObjectsByType<IdoPgsqlConnection>()) {
size_t items = idopgsqlconnection->m_QueryQueue.GetLength();
Dictionary::Ptr stats = make_shared<Dictionary>();
void CommandsTable::FetchRows(const AddRowFunction& addRowFn)
{
- BOOST_FOREACH(const DynamicObject::Ptr& object, DynamicType::GetObjects<CheckCommand>()) {
+ BOOST_FOREACH(const DynamicObject::Ptr& object, DynamicType::GetObjectsByType<CheckCommand>()) {
addRowFn(object);
}
- BOOST_FOREACH(const DynamicObject::Ptr& object, DynamicType::GetObjects<EventCommand>()) {
+ BOOST_FOREACH(const DynamicObject::Ptr& object, DynamicType::GetObjectsByType<EventCommand>()) {
addRowFn(object);
}
- BOOST_FOREACH(const DynamicObject::Ptr& object, DynamicType::GetObjects<NotificationCommand>()) {
+ BOOST_FOREACH(const DynamicObject::Ptr& object, DynamicType::GetObjectsByType<NotificationCommand>()) {
addRowFn(object);
}
}
void CommentsTable::FetchRows(const AddRowFunction& addRowFn)
{
- BOOST_FOREACH(const Host::Ptr& host, DynamicType::GetObjects<Host>()) {
+ BOOST_FOREACH(const Host::Ptr& host, DynamicType::GetObjectsByType<Host>()) {
Dictionary::Ptr comments = host->GetComments();
ObjectLock olock(comments);
}
}
- BOOST_FOREACH(const Service::Ptr& service, DynamicType::GetObjects<Service>()) {
+ BOOST_FOREACH(const Service::Ptr& service, DynamicType::GetObjectsByType<Service>()) {
Dictionary::Ptr comments = service->GetComments();
ObjectLock olock(comments);
void ContactGroupsTable::FetchRows(const AddRowFunction& addRowFn)
{
- BOOST_FOREACH(const UserGroup::Ptr& ug, DynamicType::GetObjects<UserGroup>()) {
+ BOOST_FOREACH(const UserGroup::Ptr& ug, DynamicType::GetObjectsByType<UserGroup>()) {
addRowFn(ug);
}
}
void ContactsTable::FetchRows(const AddRowFunction& addRowFn)
{
- BOOST_FOREACH(const User::Ptr& user, DynamicType::GetObjects<User>()) {
+ BOOST_FOREACH(const User::Ptr& user, DynamicType::GetObjectsByType<User>()) {
addRowFn(user);
}
}
void DowntimesTable::FetchRows(const AddRowFunction& addRowFn)
{
- BOOST_FOREACH(const Service::Ptr& service, DynamicType::GetObjects<Service>()) {
+ BOOST_FOREACH(const Service::Ptr& service, DynamicType::GetObjectsByType<Service>()) {
Dictionary::Ptr downtimes = service->GetDowntimes();
ObjectLock olock(downtimes);
void EndpointsTable::FetchRows(const AddRowFunction& addRowFn)
{
- BOOST_FOREACH(const Endpoint::Ptr& endpoint, DynamicType::GetObjects<Endpoint>()) {
+ BOOST_FOREACH(const Endpoint::Ptr& endpoint, DynamicType::GetObjectsByType<Endpoint>()) {
addRowFn(endpoint);
}
}
void HostGroupsTable::FetchRows(const AddRowFunction& addRowFn)
{
- BOOST_FOREACH(const HostGroup::Ptr& hg, DynamicType::GetObjects<HostGroup>()) {
+ BOOST_FOREACH(const HostGroup::Ptr& hg, DynamicType::GetObjectsByType<HostGroup>()) {
addRowFn(hg);
}
}
void HostsTable::FetchRows(const AddRowFunction& addRowFn)
{
- BOOST_FOREACH(const Host::Ptr& host, DynamicType::GetObjects<Host>()) {
+ BOOST_FOREACH(const Host::Ptr& host, DynamicType::GetObjectsByType<Host>()) {
addRowFn(host);
}
}
{
Dictionary::Ptr nodes = make_shared<Dictionary>();
- BOOST_FOREACH(const LivestatusListener::Ptr& livestatuslistener, DynamicType::GetObjects<LivestatusListener>()) {
+ BOOST_FOREACH(const LivestatusListener::Ptr& livestatuslistener, DynamicType::GetObjectsByType<LivestatusListener>()) {
Dictionary::Ptr stats = make_shared<Dictionary>();
stats->Set("connections", l_Connections);
void ServiceGroupsTable::FetchRows(const AddRowFunction& addRowFn)
{
- BOOST_FOREACH(const ServiceGroup::Ptr& sg, DynamicType::GetObjects<ServiceGroup>()) {
+ BOOST_FOREACH(const ServiceGroup::Ptr& sg, DynamicType::GetObjectsByType<ServiceGroup>()) {
addRowFn(sg);
}
}
void ServicesTable::FetchRows(const AddRowFunction& addRowFn)
{
- BOOST_FOREACH(const Service::Ptr& service, DynamicType::GetObjects<Service>()) {
+ BOOST_FOREACH(const Service::Ptr& service, DynamicType::GetObjectsByType<Service>()) {
addRowFn(service);
}
}
Value StatusTable::NumHostsAccessor(const Value&)
{
- return std::distance(DynamicType::GetObjects<Host>().first, DynamicType::GetObjects<Host>().second);
+ return std::distance(DynamicType::GetObjectsByType<Host>().first, DynamicType::GetObjectsByType<Host>().second);
}
Value StatusTable::NumServicesAccessor(const Value&)
{
- return std::distance(DynamicType::GetObjects<Service>().first, DynamicType::GetObjects<Service>().second);
+ return std::distance(DynamicType::GetObjectsByType<Service>().first, DynamicType::GetObjectsByType<Service>().second);
}
Value StatusTable::ProgramVersionAccessor(const Value&)
void TimePeriodsTable::FetchRows(const AddRowFunction& addRowFn)
{
- BOOST_FOREACH(const TimePeriod::Ptr& tp, DynamicType::GetObjects<TimePeriod>()) {
+ BOOST_FOREACH(const TimePeriod::Ptr& tp, DynamicType::GetObjectsByType<TimePeriod>()) {
addRowFn(tp);
}
}
{
Dictionary::Ptr nodes = make_shared<Dictionary>();
- BOOST_FOREACH(const NotificationComponent::Ptr& notification_component, DynamicType::GetObjects<NotificationComponent>()) {
+ BOOST_FOREACH(const NotificationComponent::Ptr& notification_component, DynamicType::GetObjectsByType<NotificationComponent>()) {
nodes->Set(notification_component->GetName(), 1); //add more stats
}
{
double now = Utility::GetTime();
- BOOST_FOREACH(const Notification::Ptr& notification, DynamicType::GetObjects<Notification>()) {
+ BOOST_FOREACH(const Notification::Ptr& notification, DynamicType::GetObjectsByType<Notification>()) {
Checkable::Ptr checkable = notification->GetCheckable();
if (checkable->IsPaused() && GetEnableHA())
{
Dictionary::Ptr nodes = make_shared<Dictionary>();
- BOOST_FOREACH(const GraphiteWriter::Ptr& graphitewriter, DynamicType::GetObjects<GraphiteWriter>()) {
+ BOOST_FOREACH(const GraphiteWriter::Ptr& graphitewriter, DynamicType::GetObjectsByType<GraphiteWriter>()) {
nodes->Set(graphitewriter->GetName(), 1); //add more stats
}
{
Dictionary::Ptr nodes = make_shared<Dictionary>();
- BOOST_FOREACH(const PerfdataWriter::Ptr& perfdatawriter, DynamicType::GetObjects<PerfdataWriter>()) {
+ BOOST_FOREACH(const PerfdataWriter::Ptr& perfdatawriter, DynamicType::GetObjectsByType<PerfdataWriter>()) {
nodes->Set(perfdatawriter->GetName(), 1); //add more stats
}
#cmakedefine HAVE_VFORK
#cmakedefine HAVE_DLADDR
#cmakedefine HAVE_LIBEXECINFO
+#cmakedefine HAVE_CXXABI_H
#cmakedefine ICINGA2_UNITY_BUILD
inline int icinga_assert_fail(const char *expr, const char *file, int line)
{
fprintf(stderr, "%s:%d: assertion failed: %s\n", file, line, expr);
- abort();
+ std::abort();
#if !defined(__GNUC__) && !defined(_MSC_VER)
return 0;
std::pair<DynamicTypeIterator<DynamicObject>, DynamicTypeIterator<DynamicObject> > GetObjects(void);
template<typename T>
- static std::pair<DynamicTypeIterator<T>, DynamicTypeIterator<T> > GetObjects(void)
+ static std::pair<DynamicTypeIterator<T>, DynamicTypeIterator<T> > GetObjectsByType(void)
{
DynamicType::Ptr type = GetByName(T::GetTypeName());
return std::make_pair(
#include "base/exception.hpp"
#include <boost/thread/tss.hpp>
-#ifndef _MSC_VER
+#ifdef HAVE_CXXABI_H
# include <cxxabi.h>
-#endif /* _MSC_VER */
+#endif /* HAVE_CXXABI_H */
using namespace icinga;
static boost::thread_specific_ptr<StackTrace> l_LastExceptionStack;
static boost::thread_specific_ptr<ContextTrace> l_LastExceptionContext;
-#ifndef _MSC_VER
+#ifdef HAVE_CXXABI_H
# if __clang_major__ > 3 || (__clang_major__ == 3 && __clang_minor__ > 3)
# define TYPEINFO_TYPE std::type_info
# else
# define TYPEINFO_TYPE void
# endif
-#endif /* _MSC_VER */
-#if !defined(__GLIBCXX__) && !defined(_WIN32)
+# if !defined(__GLIBCXX__) && !defined(_WIN32)
static boost::thread_specific_ptr<void *> l_LastExceptionObj;
static boost::thread_specific_ptr<TYPEINFO_TYPE *> l_LastExceptionPvtInfo;
extern "C" void __cxa_throw(void *obj, TYPEINFO_TYPE *pvtinfo, void (*dest)(void *));
extern "C" void __cxa_rethrow_primary_exception(void* thrown_object);
-#endif /* !__GLIBCXX__ && !_WIN32 */
+# endif /* !__GLIBCXX__ && !_WIN32 */
+#endif /* HAVE_CXXABI_H */
void icinga::RethrowUncaughtException(void)
{
-#if defined(__GLIBCXX__) || defined(_WIN32)
+#if defined(__GLIBCXX__) || !defined(HAVE_CXXABI_H)
throw;
#else /* __GLIBCXX__ || _WIN32 */
__cxa_throw(*l_LastExceptionObj.get(), *l_LastExceptionPvtInfo.get(), *l_LastExceptionDest.get());
#endif /* __GLIBCXX__ || _WIN32 */
}
-#ifndef _MSC_VER
+#ifdef HAVE_CXXABI_H
extern "C"
void __cxa_throw(void *obj, TYPEINFO_TYPE *pvtinfo, void (*dest)(void *))
{
real_cxa_throw(obj, tinfo, dest);
}
-#endif /* _MSC_VER */
+#endif /* HAVE_CXXABI_H */
StackTrace *icinga::GetLastExceptionStack(void)
{
void FIFO::Optimize(void)
{
if (m_DataSize < m_Offset) {
- memcpy(m_Buffer, m_Buffer + m_Offset, m_DataSize);
+ std::memcpy(m_Buffer, m_Buffer + m_Offset, m_DataSize);
m_Offset = 0;
if (m_DataSize > 0)
count = m_DataSize;
if (buffer != NULL)
- memcpy(buffer, m_Buffer + m_Offset, count);
+ std::memcpy(buffer, m_Buffer + m_Offset, count);
m_DataSize -= count;
m_Offset += count;
void FIFO::Write(const void *buffer, size_t count)
{
ResizeBuffer(m_Offset + m_DataSize + count, false);
- memcpy(m_Buffer + m_Offset + m_DataSize, buffer, count);
+ std::memcpy(m_Buffer + m_Offset + m_DataSize, buffer, count);
m_DataSize += count;
}
{
Dictionary::Ptr nodes = make_shared<Dictionary>();
- BOOST_FOREACH(const FileLogger::Ptr& filelogger, DynamicType::GetObjects<FileLogger>()) {
+ BOOST_FOREACH(const FileLogger::Ptr& filelogger, DynamicType::GetObjectsByType<FileLogger>()) {
nodes->Set(filelogger->GetName(), 1); //add more stats
}
template<typename TR>
boost::function<TR (const std::vector<Value>& arguments)> WrapScriptFunction(TR (*function)(const std::vector<Value>&))
{
- return boost::bind(function, _1);
+ return boost::bind<TR>(function, _1);
}
inline boost::function<Value (const std::vector<Value>& arguments)> WrapScriptFunction(void (*function)(const std::vector<Value>&))
fp << "\t(" << i - ignoreFrames - 1 << ") " << message << std::endl;
}
- free(messages);
+ std::free(messages);
fp << std::endl;
# else /* HAVE_BACKTRACE_SYMBOLS */
{
Dictionary::Ptr nodes = make_shared<Dictionary>();
- BOOST_FOREACH(const SyslogLogger::Ptr& sysloglogger, DynamicType::GetObjects<SyslogLogger>()) {
+ BOOST_FOREACH(const SyslogLogger::Ptr& sysloglogger, DynamicType::GetObjectsByType<SyslogLogger>()) {
nodes->Set(sysloglogger->GetName(), 1); //add more stats
}
avg_latency = 0;
if (utilization < 60 || utilization > 80 || alive < 8) {
- double wthreads = ceil((utilization * alive) / 80.0);
+ double wthreads = std::ceil((utilization * alive) / 80.0);
int tthreads = wthreads - alive;
# include <pthread_np.h>
#endif /* __FreeBSD__ */
-#ifndef _MSC_VER
+#ifdef HAVE_CXXABI_H
# include <cxxabi.h>
-#endif /* _MSC_VER */
+#endif /* HAVE_CXXABI_H */
using namespace icinga;
{
String result = sym;
-#ifndef _MSC_VER
+#ifdef HAVE_CXXABI_H
int status;
char *realname = abi::__cxa_demangle(sym.CStr(), 0, 0, &status);
result = String(realname);
free(realname);
}
-#else /* _MSC_VER */
+#elif defined(_MSC_VER) /* HAVE_CXXABI_H */
CHAR output[256];
if (UnDecorateSymbolName(sym.CStr(), output, sizeof(output), UNDNAME_COMPLETE) > 0)
result = output;
+#else /* _MSC_VER */
+ /* We're pretty much out of options here. */
#endif /* _MSC_VER */
return result;
return result;
}
-String Utility::FormatDuration(int duration)
+String Utility::FormatDuration(double duration)
{
std::vector<String> tokens;
String result;
if (duration >= 86400) {
int days = duration / 86400;
tokens.push_back(Convert::ToString(days) + (days != 1 ? " days" : " day"));
- duration %= 86400;
+ duration = static_cast<int>(duration) % 86400;
}
if (duration >= 3600) {
int hours = duration / 3600;
tokens.push_back(Convert::ToString(hours) + (hours != 1 ? " hours" : " hour"));
- duration %= 3600;
+ duration = static_cast<int>(duration) % 3600;
}
if (duration >= 60) {
int minutes = duration / 60;
tokens.push_back(Convert::ToString(minutes) + (minutes != 1 ? " minutes" : " minute"));
- duration %= 60;
+ duration = static_cast<int>(duration) % 60;
}
if (duration >= 1) {
}
if (tokens.size() == 0) {
- int milliseconds = floor(duration * 1000);
+ int milliseconds = std::floor(duration * 1000);
if (milliseconds >= 1)
tokens.push_back(Convert::ToString(milliseconds) + (milliseconds != 1 ? " milliseconds" : " millisecond"));
else
static String NaturalJoin(const std::vector<String>& tokens);
- static String FormatDuration(int duration);
+ static String FormatDuration(double duration);
static String FormatDateTime(const char *format, double ts);
static String FormatErrorNumber(int code);
case ValueEmpty:
return String();
case ValueNumber:
- fractional = modf(boost::get<double>(m_Value), &integral);
+ fractional = std::modf(boost::get<double>(m_Value), &integral);
if (fractional != 0)
return boost::lexical_cast<std::string>(m_Value);
query3.WhereCriteria->Set("instance_id", 0); /* DbConnection class fills in real ID */
DbObject::OnQuery(query3);
- InsertRuntimeVariable("total_services", std::distance(DynamicType::GetObjects<Service>().first, DynamicType::GetObjects<Service>().second));
- InsertRuntimeVariable("total_scheduled_services", std::distance(DynamicType::GetObjects<Service>().first, DynamicType::GetObjects<Service>().second));
- InsertRuntimeVariable("total_hosts", std::distance(DynamicType::GetObjects<Host>().first, DynamicType::GetObjects<Host>().second));
- InsertRuntimeVariable("total_scheduled_hosts", std::distance(DynamicType::GetObjects<Host>().first, DynamicType::GetObjects<Host>().second));
+ InsertRuntimeVariable("total_services", std::distance(DynamicType::GetObjectsByType<Service>().first, DynamicType::GetObjectsByType<Service>().second));
+ InsertRuntimeVariable("total_scheduled_services", std::distance(DynamicType::GetObjectsByType<Service>().first, DynamicType::GetObjectsByType<Service>().second));
+ InsertRuntimeVariable("total_hosts", std::distance(DynamicType::GetObjectsByType<Host>().first, DynamicType::GetObjectsByType<Host>().second));
+ InsertRuntimeVariable("total_scheduled_hosts", std::distance(DynamicType::GetObjectsByType<Host>().first, DynamicType::GetObjectsByType<Host>().second));
Dictionary::Ptr vars = IcingaApplication::GetInstance()->GetVars();
Dictionary::Ptr repository = make_shared<Dictionary>();
- BOOST_FOREACH(const Host::Ptr& host, DynamicType::GetObjects<Host>()) {
+ BOOST_FOREACH(const Host::Ptr& host, DynamicType::GetObjectsByType<Host>()) {
Array::Ptr services = make_shared<Array>();
BOOST_FOREACH(const Service::Ptr& service, host->GetServices()) {
void Checkable::CommentsExpireTimerHandler(void)
{
- BOOST_FOREACH(const Host::Ptr& host, DynamicType::GetObjects<Host>()) {
+ BOOST_FOREACH(const Host::Ptr& host, DynamicType::GetObjectsByType<Host>()) {
host->RemoveExpiredComments();
}
- BOOST_FOREACH(const Service::Ptr& service, DynamicType::GetObjects<Service>()) {
+ BOOST_FOREACH(const Service::Ptr& service, DynamicType::GetObjectsByType<Service>()) {
service->RemoveExpiredComments();
}
}
void Checkable::DowntimesExpireTimerHandler(void)
{
- BOOST_FOREACH(const Host::Ptr& host, DynamicType::GetObjects<Host>()) {
+ BOOST_FOREACH(const Host::Ptr& host, DynamicType::GetObjectsByType<Host>()) {
host->RemoveExpiredDowntimes();
}
- BOOST_FOREACH(const Service::Ptr& service, DynamicType::GetObjects<Service>()) {
+ BOOST_FOREACH(const Service::Ptr& service, DynamicType::GetObjectsByType<Service>()) {
service->RemoveExpiredDowntimes();
}
}
double min_execution_time = -1, max_execution_time = 0, sum_execution_time = 0;
int count_execution_time = 0;
- BOOST_FOREACH(const Host::Ptr& host, DynamicType::GetObjects<Host>()) {
+ BOOST_FOREACH(const Host::Ptr& host, DynamicType::GetObjectsByType<Host>()) {
ObjectLock olock(host);
CheckResult::Ptr cr = host->GetLastCheckResult();
double min_execution_time = -1, max_execution_time = 0, sum_execution_time = 0;
int count_execution_time = 0;
- BOOST_FOREACH(const Service::Ptr& service, DynamicType::GetObjects<Service>()) {
+ BOOST_FOREACH(const Service::Ptr& service, DynamicType::GetObjectsByType<Service>()) {
ObjectLock olock(service);
CheckResult::Ptr cr = service->GetLastCheckResult();
{
ServiceStatistics ss = {0};
- BOOST_FOREACH(const Service::Ptr& service, DynamicType::GetObjects<Service>()) {
+ BOOST_FOREACH(const Service::Ptr& service, DynamicType::GetObjectsByType<Service>()) {
ObjectLock olock(service);
CheckResult::Ptr cr = service->GetLastCheckResult();
{
HostStatistics hs = {0};
- BOOST_FOREACH(const Host::Ptr& host, DynamicType::GetObjects<Host>()) {
+ BOOST_FOREACH(const Host::Ptr& host, DynamicType::GetObjectsByType<Host>()) {
ObjectLock olock(host);
if (host->IsReachable()) {
if (rule.GetTargetType() == "Host") {
apply_count = 0;
- BOOST_FOREACH(const Host::Ptr& host, DynamicType::GetObjects<Host>()) {
+ BOOST_FOREACH(const Host::Ptr& host, DynamicType::GetObjectsByType<Host>()) {
CONTEXT("Evaluating 'apply' rules for host '" + host->GetName() + "'");
if (EvaluateApplyRuleOne(host, rule))
} else if (rule.GetTargetType() == "Service") {
apply_count = 0;
- BOOST_FOREACH(const Service::Ptr& service, DynamicType::GetObjects<Service>()) {
+ BOOST_FOREACH(const Service::Ptr& service, DynamicType::GetObjectsByType<Service>()) {
CONTEXT("Evaluating 'apply' rules for Service '" + service->GetName() + "'");
if (EvaluateApplyRuleOne(service, rule))
void HostGroup::EvaluateObjectRule(const ObjectRule& rule)
{
- BOOST_FOREACH(const Host::Ptr& host, DynamicType::GetObjects<Host>()) {
+ BOOST_FOREACH(const Host::Ptr& host, DynamicType::GetObjectsByType<Host>()) {
CONTEXT("Evaluating group membership in '" + rule.GetName() + "' for host '" + host->GetName() + "'");
EvaluateObjectRuleOne(host, rule);
{
Dictionary::Ptr nodes = make_shared<Dictionary>();
- BOOST_FOREACH(const IcingaApplication::Ptr& icingaapplication, DynamicType::GetObjects<IcingaApplication>()) {
+ BOOST_FOREACH(const IcingaApplication::Ptr& icingaapplication, DynamicType::GetObjectsByType<IcingaApplication>()) {
Dictionary::Ptr stats = make_shared<Dictionary>();
stats->Set("node_name", icingaapplication->GetNodeName());
stats->Set("enable_notifications", icingaapplication->GetEnableNotifications());
{
Dictionary::Ptr nodes = make_shared<Dictionary>();
- BOOST_FOREACH(const IcingaStatusWriter::Ptr& icingastatuswriter, DynamicType::GetObjects<IcingaStatusWriter>()) {
+ BOOST_FOREACH(const IcingaStatusWriter::Ptr& icingastatuswriter, DynamicType::GetObjectsByType<IcingaStatusWriter>()) {
nodes->Set(icingastatuswriter->GetName(), 1); //add more stats
}
if (rule.GetTargetType() == "Host") {
apply_count = 0;
- BOOST_FOREACH(const Host::Ptr& host, DynamicType::GetObjects<Host>()) {
+ BOOST_FOREACH(const Host::Ptr& host, DynamicType::GetObjectsByType<Host>()) {
CONTEXT("Evaluating 'apply' rules for host '" + host->GetName() + "'");
if (EvaluateApplyRuleOne(host, rule))
} else if (rule.GetTargetType() == "Service") {
apply_count = 0;
- BOOST_FOREACH(const Service::Ptr& service, DynamicType::GetObjects<Service>()) {
+ BOOST_FOREACH(const Service::Ptr& service, DynamicType::GetObjectsByType<Service>()) {
CONTEXT("Evaluating 'apply' rules for Service '" + service->GetName() + "'");
if (EvaluateApplyRuleOne(service, rule))
if (rule.GetTargetType() == "Host") {
apply_count = 0;
- BOOST_FOREACH(const Host::Ptr& host, DynamicType::GetObjects<Host>()) {
+ BOOST_FOREACH(const Host::Ptr& host, DynamicType::GetObjectsByType<Host>()) {
CONTEXT("Evaluating 'apply' rules for host '" + host->GetName() + "'");
if (EvaluateApplyRule(host, rule))
} else if (rule.GetTargetType() == "Service") {
apply_count = 0;
- BOOST_FOREACH(const Service::Ptr& service, DynamicType::GetObjects<Service>()) {
+ BOOST_FOREACH(const Service::Ptr& service, DynamicType::GetObjectsByType<Service>()) {
CONTEXT("Evaluating 'apply' rules for Service '" + service->GetName() + "'");
if(EvaluateApplyRule(service, rule))
void ScheduledDowntime::TimerProc(void)
{
- BOOST_FOREACH(const ScheduledDowntime::Ptr& sd, DynamicType::GetObjects<ScheduledDowntime>()) {
+ BOOST_FOREACH(const ScheduledDowntime::Ptr& sd, DynamicType::GetObjectsByType<ScheduledDowntime>()) {
sd->CreateNextDowntime();
}
}
{
int apply_count = 0;
- BOOST_FOREACH(const Host::Ptr& host, DynamicType::GetObjects<Host>()) {
+ BOOST_FOREACH(const Host::Ptr& host, DynamicType::GetObjectsByType<Host>()) {
CONTEXT("Evaluating 'apply' rules for host '" + host->GetName() + "'");
if (EvaluateApplyRuleOne(host, rule))
void ServiceGroup::EvaluateObjectRule(const ObjectRule& rule)
{
- BOOST_FOREACH(const Service::Ptr& service, DynamicType::GetObjects<Service>()) {
+ BOOST_FOREACH(const Service::Ptr& service, DynamicType::GetObjectsByType<Service>()) {
CONTEXT("Evaluating group membership in '" + rule.GetName() + "' for service '" + service->GetName() + "'");
EvaluateObjectRuleOne(service, rule);
{
double now = Utility::GetTime();
- BOOST_FOREACH(const TimePeriod::Ptr& tp, DynamicType::GetObjects<TimePeriod>()) {
+ BOOST_FOREACH(const TimePeriod::Ptr& tp, DynamicType::GetObjectsByType<TimePeriod>()) {
double valid_end;
{
void UserGroup::EvaluateObjectRule(const ObjectRule& rule)
{
- BOOST_FOREACH(const User::Ptr& user, DynamicType::GetObjects<User>()) {
+ BOOST_FOREACH(const User::Ptr& user, DynamicType::GetObjectsByType<User>()) {
CONTEXT("Evaluating group membership in '" + rule.GetName() + "' for user '" + user->GetName() + "'");
EvaluateObjectRuleOne(user, rule);
void ApiListener::SyncZoneDirs(void) const
{
- BOOST_FOREACH(const Zone::Ptr& zone, DynamicType::GetObjects<Zone>()) {
+ BOOST_FOREACH(const Zone::Ptr& zone, DynamicType::GetObjectsByType<Zone>()) {
if (!IsConfigMaster(zone))
continue;
String zonesDir = Application::GetLocalStateDir() + "/lib/icinga2/api/zones";
- BOOST_FOREACH(const Zone::Ptr& zone, DynamicType::GetObjects<Zone>()) {
+ BOOST_FOREACH(const Zone::Ptr& zone, DynamicType::GetObjectsByType<Zone>()) {
String zoneDir = zonesDir + "/" + zone->GetName();
if (!zone->IsChildOf(azone) && !zone->IsGlobal()) {
*/
void ApiListener::Start(void)
{
- if (std::distance(DynamicType::GetObjects<ApiListener>().first, DynamicType::GetObjects<ApiListener>().second) > 1) {
+ if (std::distance(DynamicType::GetObjectsByType<ApiListener>().first, DynamicType::GetObjectsByType<ApiListener>().second) > 1) {
Log(LogCritical, "ApiListener", "Only one ApiListener object is allowed.");
return;
}
ApiListener::Ptr ApiListener::GetInstance(void)
{
- BOOST_FOREACH(const ApiListener::Ptr& listener, DynamicType::GetObjects<ApiListener>())
+ BOOST_FOREACH(const ApiListener::Ptr& listener, DynamicType::GetObjectsByType<ApiListener>())
return listener;
return ApiListener::Ptr();
BOOST_FOREACH(int ts, files) {
bool need = false;
- BOOST_FOREACH(const Endpoint::Ptr& endpoint, DynamicType::GetObjects<Endpoint>()) {
+ BOOST_FOREACH(const Endpoint::Ptr& endpoint, DynamicType::GetObjectsByType<Endpoint>()) {
if (endpoint->GetName() == GetIdentity())
continue;
if (IsMaster()) {
Zone::Ptr my_zone = Zone::GetLocalZone();
- BOOST_FOREACH(const Zone::Ptr& zone, DynamicType::GetObjects<Zone>()) {
+ BOOST_FOREACH(const Zone::Ptr& zone, DynamicType::GetObjectsByType<Zone>()) {
/* only connect to endpoints in a) the same zone b) our parent zone c) immediate child zones */
if (my_zone != zone && my_zone != zone->GetParent() && zone != my_zone->GetParent())
continue;
}
}
- BOOST_FOREACH(const Endpoint::Ptr& endpoint, DynamicType::GetObjects<Endpoint>()) {
+ BOOST_FOREACH(const Endpoint::Ptr& endpoint, DynamicType::GetObjectsByType<Endpoint>()) {
if (!endpoint->IsConnected())
continue;
Log(LogNotice, "ApiListener", "Current zone master: " + master->GetName());
std::vector<String> names;
- BOOST_FOREACH(const Endpoint::Ptr& endpoint, DynamicType::GetObjects<Endpoint>())
+ BOOST_FOREACH(const Endpoint::Ptr& endpoint, DynamicType::GetObjectsByType<Endpoint>())
if (endpoint->IsConnected())
names.push_back(endpoint->GetName() + " (" + Convert::ToString(endpoint->GetClients().size()) + ")");
std::vector<Endpoint::Ptr> skippedEndpoints;
std::set<Zone::Ptr> finishedZones;
- BOOST_FOREACH(const Endpoint::Ptr& endpoint, DynamicType::GetObjects<Endpoint>()) {
+ BOOST_FOREACH(const Endpoint::Ptr& endpoint, DynamicType::GetObjectsByType<Endpoint>()) {
/* don't relay messages to ourselves or disconnected endpoints */
if (endpoint->GetName() == GetIdentity() || !endpoint->IsConnected())
continue;
Array::Ptr not_connected_endpoints = make_shared<Array>();
Array::Ptr connected_endpoints = make_shared<Array>();
- BOOST_FOREACH(const Endpoint::Ptr& endpoint, DynamicType::GetObjects<Endpoint>()) {
+ BOOST_FOREACH(const Endpoint::Ptr& endpoint, DynamicType::GetObjectsByType<Endpoint>()) {
if (endpoint->GetName() == GetIdentity())
continue;
{
DynamicObject::OnConfigLoaded();
- BOOST_FOREACH(const Zone::Ptr& zone, DynamicType::GetObjects<Zone>()) {
+ BOOST_FOREACH(const Zone::Ptr& zone, DynamicType::GetObjectsByType<Zone>()) {
const std::set<Endpoint::Ptr> members = zone->GetEndpoints();
if (members.empty())
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
-#ifdef __linux__
#include <alloca.h>
-#endif /* __linux */
#include <unistd.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
-#include <paths.h>
#include "execvpe.h"
#if !defined(_MSC_VER) && !defined(HAVE_EXECVPE)
scripts_argv (const char *file, char *const argv[], int argc, char **new_argv)
{
/* Construct an argument list for the shell. */
- new_argv[0] = (char *) _PATH_BSHELL;
+ new_argv[0] = (char *) "/bin/sh";
new_argv[1] = (char *) file;
while (argc > 1)
{
#include "classcompiler.hpp"
#include <iostream>
#include <vector>
+#include <cstring>
+
+using std::malloc;
+using std::free;
+using std::exit;
using namespace icinga;
std::cerr << "in " << locp->path << " at " << locp->first_line << ":" << locp->first_column << "-" << locp->last_line << ":" << locp->last_column << ": "
<< err
<< std::endl;
- exit(1);
+ std::exit(1);
}
int yyparse(ClassCompiler *context);
statement: include
{
context->HandleInclude($1, yylloc);
- free($1);
+ std::free($1);
}
| angle_include
{
context->HandleAngleInclude($1, yylloc);
- free($1);
+ std::free($1);
}
| class
{
| code
{
context->HandleCode($1, yylloc);
- free($1);
+ std::free($1);
}
;
namespace: T_NAMESPACE identifier '{'
{
context->HandleNamespaceBegin($2, yylloc);
- free($2);
+ std::free($2);
}
statements '}'
{
$$ = new Klass();
$$->Name = $3;
- free($3);
+ std::free($3);
if ($4) {
$$->Parent = $4;
- free($4);
+ std::free($4);
}
if ($5) {
$$->TypeBase = $5;
- free($5);
+ std::free($5);
}
$$->Attributes = $1;
field->Attributes = $1;
field->Type = $2;
- free($2);
+ std::free($2);
field->Name = $3;
- free($3);
+ std::free($3);
if ($4) {
field->AlternativeName = $4;
- free($4);
+ std::free($4);
}
std::vector<FieldAccessor>::const_iterator it;
field_accessor: T_FIELD_ACCESSOR_TYPE T_STRING
{
$$ = new FieldAccessor(static_cast<FieldAccessorType>($1), $2);
- free($2);
+ std::free($2);
}
;