mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-28 16:14:09 +02:00
Clean up some parts of the code
This commit is contained in:
parent
c4d448efe5
commit
65bec9e904
@ -38,7 +38,7 @@ public:
|
|||||||
DECLARE_PTR_TYPEDEFS(CheckResultReader);
|
DECLARE_PTR_TYPEDEFS(CheckResultReader);
|
||||||
DECLARE_TYPENAME(CheckResultReader);
|
DECLARE_TYPENAME(CheckResultReader);
|
||||||
|
|
||||||
static Value StatsFunc(Dictionary::Ptr& status, Dictionary::Ptr& perfdata);
|
static Value StatsFunc(Dictionary::Ptr& status, Dictionary::Ptr& perfdata);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void Start(void);
|
virtual void Start(void);
|
||||||
|
@ -257,14 +257,14 @@ void CompatLogger::NotificationSentHandler(const Notification::Ptr& notification
|
|||||||
author_comment = author + ";" + comment_text;
|
author_comment = author + ";" + comment_text;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!cr)
|
if (!cr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
String output;
|
String output;
|
||||||
if (cr)
|
if (cr)
|
||||||
output = CompatUtility::GetCheckResultOutput(cr);
|
output = CompatUtility::GetCheckResultOutput(cr);
|
||||||
|
|
||||||
std::ostringstream msgbuf;
|
std::ostringstream msgbuf;
|
||||||
|
|
||||||
if (service) {
|
if (service) {
|
||||||
msgbuf << "SERVICE NOTIFICATION: "
|
msgbuf << "SERVICE NOTIFICATION: "
|
||||||
@ -277,22 +277,22 @@ void CompatLogger::NotificationSentHandler(const Notification::Ptr& notification
|
|||||||
<< author_comment
|
<< author_comment
|
||||||
<< "";
|
<< "";
|
||||||
} else {
|
} else {
|
||||||
msgbuf << "HOST NOTIFICATION: "
|
msgbuf << "HOST NOTIFICATION: "
|
||||||
<< user->GetName() << ";"
|
<< user->GetName() << ";"
|
||||||
<< host->GetName() << ";"
|
<< host->GetName() << ";"
|
||||||
<< notification_type_str << " "
|
<< notification_type_str << " "
|
||||||
<< "(" << (host->IsReachable() ? Host::StateToString(host->GetState()) : "UNREACHABLE") << ");"
|
<< "(" << (host->IsReachable() ? Host::StateToString(host->GetState()) : "UNREACHABLE") << ");"
|
||||||
<< command_name << ";"
|
<< command_name << ";"
|
||||||
<< output << ";"
|
<< output << ";"
|
||||||
<< author_comment
|
<< author_comment
|
||||||
<< "";
|
<< "";
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
ObjectLock oLock(this);
|
ObjectLock oLock(this);
|
||||||
WriteLine(msgbuf.str());
|
WriteLine(msgbuf.str());
|
||||||
Flush();
|
Flush();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -325,7 +325,7 @@ void CompatLogger::FlappingHandler(const Checkable::Ptr& checkable, FlappingStat
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::ostringstream msgbuf;
|
std::ostringstream msgbuf;
|
||||||
|
|
||||||
if (service) {
|
if (service) {
|
||||||
msgbuf << "SERVICE FLAPPING ALERT: "
|
msgbuf << "SERVICE FLAPPING ALERT: "
|
||||||
@ -335,32 +335,32 @@ void CompatLogger::FlappingHandler(const Checkable::Ptr& checkable, FlappingStat
|
|||||||
<< flapping_output
|
<< flapping_output
|
||||||
<< "";
|
<< "";
|
||||||
} else {
|
} else {
|
||||||
msgbuf << "HOST FLAPPING ALERT: "
|
msgbuf << "HOST FLAPPING ALERT: "
|
||||||
<< host->GetName() << ";"
|
<< host->GetName() << ";"
|
||||||
<< flapping_state_str << "; "
|
<< flapping_state_str << "; "
|
||||||
<< flapping_output
|
<< flapping_output
|
||||||
<< "";
|
<< "";
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
ObjectLock oLock(this);
|
ObjectLock oLock(this);
|
||||||
WriteLine(msgbuf.str());
|
WriteLine(msgbuf.str());
|
||||||
Flush();
|
Flush();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CompatLogger::ExternalCommandHandler(const String& command, const std::vector<String>& arguments)
|
void CompatLogger::ExternalCommandHandler(const String& command, const std::vector<String>& arguments)
|
||||||
{
|
{
|
||||||
std::ostringstream msgbuf;
|
std::ostringstream msgbuf;
|
||||||
msgbuf << "EXTERNAL COMMAND: "
|
msgbuf << "EXTERNAL COMMAND: "
|
||||||
<< command << ";"
|
<< command << ";"
|
||||||
<< boost::algorithm::join(arguments, ";")
|
<< boost::algorithm::join(arguments, ";")
|
||||||
<< "";
|
<< "";
|
||||||
|
|
||||||
{
|
{
|
||||||
ObjectLock oLock(this);
|
ObjectLock oLock(this);
|
||||||
WriteLine(msgbuf.str());
|
WriteLine(msgbuf.str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CompatLogger::EventCommandHandler(const Checkable::Ptr& checkable)
|
void CompatLogger::EventCommandHandler(const Checkable::Ptr& checkable)
|
||||||
@ -373,7 +373,7 @@ void CompatLogger::EventCommandHandler(const Checkable::Ptr& checkable)
|
|||||||
String event_command_name = event_command->GetName();
|
String event_command_name = event_command->GetName();
|
||||||
long current_attempt = checkable->GetCheckAttempt();
|
long current_attempt = checkable->GetCheckAttempt();
|
||||||
|
|
||||||
std::ostringstream msgbuf;
|
std::ostringstream msgbuf;
|
||||||
|
|
||||||
if (service) {
|
if (service) {
|
||||||
msgbuf << "SERVICE EVENT HANDLER: "
|
msgbuf << "SERVICE EVENT HANDLER: "
|
||||||
@ -385,7 +385,7 @@ void CompatLogger::EventCommandHandler(const Checkable::Ptr& checkable)
|
|||||||
<< event_command_name;
|
<< event_command_name;
|
||||||
} else {
|
} else {
|
||||||
msgbuf << "HOST EVENT HANDLER: "
|
msgbuf << "HOST EVENT HANDLER: "
|
||||||
<< host->GetName() << ";"
|
<< host->GetName() << ";"
|
||||||
<< (host->IsReachable() ? Host::StateToString(host->GetState()) : "UNREACHABLE") << ";"
|
<< (host->IsReachable() ? Host::StateToString(host->GetState()) : "UNREACHABLE") << ";"
|
||||||
<< Host::StateTypeToString(host->GetStateType()) << ";"
|
<< Host::StateTypeToString(host->GetStateType()) << ";"
|
||||||
<< current_attempt << ";"
|
<< current_attempt << ";"
|
||||||
@ -395,8 +395,8 @@ void CompatLogger::EventCommandHandler(const Checkable::Ptr& checkable)
|
|||||||
{
|
{
|
||||||
ObjectLock oLock(this);
|
ObjectLock oLock(this);
|
||||||
WriteLine(msgbuf.str());
|
WriteLine(msgbuf.str());
|
||||||
Flush();
|
Flush();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CompatLogger::WriteLine(const String& line)
|
void CompatLogger::WriteLine(const String& line)
|
||||||
|
@ -39,7 +39,7 @@ public:
|
|||||||
DECLARE_PTR_TYPEDEFS(CompatLogger);
|
DECLARE_PTR_TYPEDEFS(CompatLogger);
|
||||||
DECLARE_TYPENAME(CompatLogger);
|
DECLARE_TYPENAME(CompatLogger);
|
||||||
|
|
||||||
static Value StatsFunc(Dictionary::Ptr& status, Dictionary::Ptr& perfdata);
|
static Value StatsFunc(Dictionary::Ptr& status, Dictionary::Ptr& perfdata);
|
||||||
|
|
||||||
static void ValidateRotationMethod(const String& location, const Dictionary::Ptr& attrs);
|
static void ValidateRotationMethod(const String& location, const Dictionary::Ptr& attrs);
|
||||||
|
|
||||||
@ -52,8 +52,8 @@ private:
|
|||||||
|
|
||||||
void CheckResultHandler(const Checkable::Ptr& service, const CheckResult::Ptr& cr);
|
void CheckResultHandler(const Checkable::Ptr& service, const CheckResult::Ptr& cr);
|
||||||
void NotificationSentHandler(const Notification::Ptr& notification, const Checkable::Ptr& service,
|
void NotificationSentHandler(const Notification::Ptr& notification, const Checkable::Ptr& service,
|
||||||
const User::Ptr& user, NotificationType const& notification_type, CheckResult::Ptr const& cr,
|
const User::Ptr& user, NotificationType const& notification_type, CheckResult::Ptr const& cr,
|
||||||
const String& author, const String& comment_text, const String& command_name);
|
const String& author, const String& comment_text, const String& command_name);
|
||||||
void FlappingHandler(const Checkable::Ptr& service, FlappingState flapping_state);
|
void FlappingHandler(const Checkable::Ptr& service, FlappingState flapping_state);
|
||||||
void TriggerDowntimeHandler(const Checkable::Ptr& service, const Downtime::Ptr& downtime);
|
void TriggerDowntimeHandler(const Checkable::Ptr& service, const Downtime::Ptr& downtime);
|
||||||
void RemoveDowntimeHandler(const Checkable::Ptr& service, const Downtime::Ptr& downtime);
|
void RemoveDowntimeHandler(const Checkable::Ptr& service, const Downtime::Ptr& downtime);
|
||||||
|
@ -37,9 +37,9 @@ class ExternalCommandListener : public ObjectImpl<ExternalCommandListener>
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DECLARE_PTR_TYPEDEFS(ExternalCommandListener);
|
DECLARE_PTR_TYPEDEFS(ExternalCommandListener);
|
||||||
DECLARE_TYPENAME(ExternalCommandListener);
|
DECLARE_TYPENAME(ExternalCommandListener);
|
||||||
|
|
||||||
static Value StatsFunc(Dictionary::Ptr& status, Dictionary::Ptr& perfdata);
|
static Value StatsFunc(Dictionary::Ptr& status, Dictionary::Ptr& perfdata);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void Start(void);
|
virtual void Start(void);
|
||||||
@ -49,7 +49,7 @@ private:
|
|||||||
boost::thread m_CommandThread;
|
boost::thread m_CommandThread;
|
||||||
|
|
||||||
void CommandPipeThread(const String& commandPath);
|
void CommandPipeThread(const String& commandPath);
|
||||||
void ClientHandler(const String& commandPath, int fd);
|
void ClientHandler(const String& commandPath, int fd);
|
||||||
#endif /* _WIN32 */
|
#endif /* _WIN32 */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -236,7 +236,7 @@ void StatusDataWriter::DumpHostObject(std::ostream& fp, const Host::Ptr& host)
|
|||||||
"\t" "host_name" "\t" << host->GetName() << "\n";
|
"\t" "host_name" "\t" << host->GetName() << "\n";
|
||||||
if (!display_name.IsEmpty()) {
|
if (!display_name.IsEmpty()) {
|
||||||
fp << "\t" "display_name" "\t" << host->GetDisplayName() << "\n"
|
fp << "\t" "display_name" "\t" << host->GetDisplayName() << "\n"
|
||||||
"\t" "alias" "\t" << host->GetDisplayName() << "\n";
|
"\t" "alias" "\t" << host->GetDisplayName() << "\n";
|
||||||
}
|
}
|
||||||
if (!address.IsEmpty())
|
if (!address.IsEmpty())
|
||||||
fp << "\t" "address" "\t" << address << "\n";
|
fp << "\t" "address" "\t" << address << "\n";
|
||||||
@ -300,24 +300,24 @@ void StatusDataWriter::DumpHostObject(std::ostream& fp, const Host::Ptr& host)
|
|||||||
fp << "\t" "host_groups" "\t";
|
fp << "\t" "host_groups" "\t";
|
||||||
bool first = true;
|
bool first = true;
|
||||||
|
|
||||||
Array::Ptr groups = host->GetGroups();
|
Array::Ptr groups = host->GetGroups();
|
||||||
|
|
||||||
if (groups) {
|
if (groups) {
|
||||||
ObjectLock olock(groups);
|
ObjectLock olock(groups);
|
||||||
|
|
||||||
BOOST_FOREACH(const String& name, groups) {
|
BOOST_FOREACH(const String& name, groups) {
|
||||||
HostGroup::Ptr hg = HostGroup::GetByName(name);
|
HostGroup::Ptr hg = HostGroup::GetByName(name);
|
||||||
|
|
||||||
if (hg) {
|
if (hg) {
|
||||||
if (!first)
|
if (!first)
|
||||||
fp << ",";
|
fp << ",";
|
||||||
else
|
else
|
||||||
first = false;
|
first = false;
|
||||||
|
|
||||||
fp << hg->GetName();
|
fp << hg->GetName();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fp << "\n";
|
fp << "\n";
|
||||||
|
|
||||||
@ -344,7 +344,7 @@ void StatusDataWriter::DumpCheckableStatusAttrs(std::ostream& fp, const Checkabl
|
|||||||
|
|
||||||
if (cr) {
|
if (cr) {
|
||||||
fp << "\t" << "check_execution_time=" << Convert::ToString(Service::CalculateExecutionTime(cr)) << "\n"
|
fp << "\t" << "check_execution_time=" << Convert::ToString(Service::CalculateExecutionTime(cr)) << "\n"
|
||||||
"\t" "check_latency=" << Convert::ToString(Service::CalculateLatency(cr)) << "\n";
|
"\t" "check_latency=" << Convert::ToString(Service::CalculateLatency(cr)) << "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
Host::Ptr host;
|
Host::Ptr host;
|
||||||
@ -363,7 +363,7 @@ void StatusDataWriter::DumpCheckableStatusAttrs(std::ostream& fp, const Checkabl
|
|||||||
|
|
||||||
if (cr) {
|
if (cr) {
|
||||||
fp << "\t" << "check_source=" << cr->GetCheckSource() << "\n"
|
fp << "\t" << "check_source=" << cr->GetCheckSource() << "\n"
|
||||||
"\t" "last_check=" << static_cast<long>(cr->GetScheduleEnd()) << "\n";
|
"\t" "last_check=" << static_cast<long>(cr->GetScheduleEnd()) << "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
fp << "\t" << "next_check=" << static_cast<long>(checkable->GetNextCheck()) << "\n"
|
fp << "\t" << "next_check=" << static_cast<long>(checkable->GetNextCheck()) << "\n"
|
||||||
@ -446,13 +446,13 @@ void StatusDataWriter::DumpServiceObject(std::ostream& fp, const Service::Ptr& s
|
|||||||
if (eventcommand)
|
if (eventcommand)
|
||||||
fp << "\t" "event_handler" "\t" << CompatUtility::GetCommandName(eventcommand) << "\n";
|
fp << "\t" "event_handler" "\t" << CompatUtility::GetCommandName(eventcommand) << "\n";
|
||||||
|
|
||||||
fp << "\t" "contacts" "\t";
|
fp << "\t" "contacts" "\t";
|
||||||
DumpNameList(fp, CompatUtility::GetCheckableNotificationUsers(service));
|
DumpNameList(fp, CompatUtility::GetCheckableNotificationUsers(service));
|
||||||
fp << "\n";
|
fp << "\n";
|
||||||
|
|
||||||
fp << "\t" "contact_groups" "\t";
|
fp << "\t" "contact_groups" "\t";
|
||||||
DumpNameList(fp, CompatUtility::GetCheckableNotificationUserGroups(service));
|
DumpNameList(fp, CompatUtility::GetCheckableNotificationUserGroups(service));
|
||||||
fp << "\n";
|
fp << "\n";
|
||||||
|
|
||||||
String notes = service->GetNotes();
|
String notes = service->GetNotes();
|
||||||
String notes_url = service->GetNotesUrl();
|
String notes_url = service->GetNotesUrl();
|
||||||
@ -460,11 +460,11 @@ void StatusDataWriter::DumpServiceObject(std::ostream& fp, const Service::Ptr& s
|
|||||||
String icon_image = service->GetIconImage();
|
String icon_image = service->GetIconImage();
|
||||||
String icon_image_alt = service->GetIconImageAlt();
|
String icon_image_alt = service->GetIconImageAlt();
|
||||||
|
|
||||||
fp << "\t" "initial_state" "\t" "o" "\n"
|
fp << "\t" "initial_state" "\t" "o" "\n"
|
||||||
"\t" "low_flap_threshold" "\t" << service->GetFlappingThreshold() << "\n"
|
"\t" "low_flap_threshold" "\t" << service->GetFlappingThreshold() << "\n"
|
||||||
"\t" "high_flap_threshold" "\t" << service->GetFlappingThreshold() << "\n"
|
"\t" "high_flap_threshold" "\t" << service->GetFlappingThreshold() << "\n"
|
||||||
"\t" "process_perf_data" "\t" << CompatUtility::GetCheckableProcessPerformanceData(service) << "\n"
|
"\t" "process_perf_data" "\t" << CompatUtility::GetCheckableProcessPerformanceData(service) << "\n"
|
||||||
"\t" "check_freshness" << "\t" "1" "\n";
|
"\t" "check_freshness" << "\t" "1" "\n";
|
||||||
if (!notes.IsEmpty())
|
if (!notes.IsEmpty())
|
||||||
fp << "\t" "notes" "\t" << notes << "\n";
|
fp << "\t" "notes" "\t" << notes << "\n";
|
||||||
if (!notes_url.IsEmpty())
|
if (!notes_url.IsEmpty())
|
||||||
@ -480,24 +480,24 @@ void StatusDataWriter::DumpServiceObject(std::ostream& fp, const Service::Ptr& s
|
|||||||
fp << "\t" "service_groups" "\t";
|
fp << "\t" "service_groups" "\t";
|
||||||
bool first = true;
|
bool first = true;
|
||||||
|
|
||||||
Array::Ptr groups = service->GetGroups();
|
Array::Ptr groups = service->GetGroups();
|
||||||
|
|
||||||
if (groups) {
|
if (groups) {
|
||||||
ObjectLock olock(groups);
|
ObjectLock olock(groups);
|
||||||
|
|
||||||
BOOST_FOREACH(const String& name, groups) {
|
BOOST_FOREACH(const String& name, groups) {
|
||||||
ServiceGroup::Ptr sg = ServiceGroup::GetByName(name);
|
ServiceGroup::Ptr sg = ServiceGroup::GetByName(name);
|
||||||
|
|
||||||
if (sg) {
|
if (sg) {
|
||||||
if (!first)
|
if (!first)
|
||||||
fp << ",";
|
fp << ",";
|
||||||
else
|
else
|
||||||
first = false;
|
first = false;
|
||||||
|
|
||||||
fp << sg->GetName();
|
fp << sg->GetName();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fp << "\n";
|
fp << "\n";
|
||||||
|
|
||||||
@ -712,7 +712,7 @@ void StatusDataWriter::UpdateObjectsCache(void)
|
|||||||
Service::Ptr child_service;
|
Service::Ptr child_service;
|
||||||
tie(child_host, child_service) = GetHostService(child);
|
tie(child_host, child_service) = GetHostService(child);
|
||||||
|
|
||||||
int state_filter = dep->GetStateFilter();
|
int state_filter = dep->GetStateFilter();
|
||||||
std::vector<String> failure_criteria;
|
std::vector<String> failure_criteria;
|
||||||
if (state_filter & StateFilterOK || state_filter & StateFilterUp)
|
if (state_filter & StateFilterOK || state_filter & StateFilterUp)
|
||||||
failure_criteria.push_back("o");
|
failure_criteria.push_back("o");
|
||||||
|
@ -42,7 +42,7 @@ public:
|
|||||||
DECLARE_PTR_TYPEDEFS(IdoMysqlConnection);
|
DECLARE_PTR_TYPEDEFS(IdoMysqlConnection);
|
||||||
DECLARE_TYPENAME(IdoMysqlConnection);
|
DECLARE_TYPENAME(IdoMysqlConnection);
|
||||||
|
|
||||||
static Value StatsFunc(Dictionary::Ptr& status, Dictionary::Ptr& perfdata);
|
static Value StatsFunc(Dictionary::Ptr& status, Dictionary::Ptr& perfdata);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void Resume(void);
|
virtual void Resume(void);
|
||||||
|
@ -363,8 +363,8 @@ IdoPgsqlResult IdoPgsqlConnection::Query(const String& query)
|
|||||||
|
|
||||||
BOOST_THROW_EXCEPTION(
|
BOOST_THROW_EXCEPTION(
|
||||||
database_error()
|
database_error()
|
||||||
<< errinfo_message(message)
|
<< errinfo_message(message)
|
||||||
<< errinfo_database_query(query)
|
<< errinfo_database_query(query)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -384,8 +384,8 @@ IdoPgsqlResult IdoPgsqlConnection::Query(const String& query)
|
|||||||
|
|
||||||
BOOST_THROW_EXCEPTION(
|
BOOST_THROW_EXCEPTION(
|
||||||
database_error()
|
database_error()
|
||||||
<< errinfo_message(message)
|
<< errinfo_message(message)
|
||||||
<< errinfo_database_query(query)
|
<< errinfo_database_query(query)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,9 +40,9 @@ class IdoPgsqlConnection : public ObjectImpl<IdoPgsqlConnection>
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DECLARE_PTR_TYPEDEFS(IdoPgsqlConnection);
|
DECLARE_PTR_TYPEDEFS(IdoPgsqlConnection);
|
||||||
DECLARE_TYPENAME(IdoPgsqlConnection);
|
DECLARE_TYPENAME(IdoPgsqlConnection);
|
||||||
|
|
||||||
static Value StatsFunc(Dictionary::Ptr& status, Dictionary::Ptr& perfdata);
|
static Value StatsFunc(Dictionary::Ptr& status, Dictionary::Ptr& perfdata);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void Resume(void);
|
virtual void Resume(void);
|
||||||
@ -51,7 +51,7 @@ protected:
|
|||||||
virtual void ActivateObject(const DbObject::Ptr& dbobj);
|
virtual void ActivateObject(const DbObject::Ptr& dbobj);
|
||||||
virtual void DeactivateObject(const DbObject::Ptr& dbobj);
|
virtual void DeactivateObject(const DbObject::Ptr& dbobj);
|
||||||
virtual void ExecuteQuery(const DbQuery& query);
|
virtual void ExecuteQuery(const DbQuery& query);
|
||||||
virtual void CleanUpExecuteQuery(const String& table, const String& time_key, double time_value);
|
virtual void CleanUpExecuteQuery(const String& table, const String& time_key, double time_value);
|
||||||
virtual void FillIDCache(const DbType::Ptr& type);
|
virtual void FillIDCache(const DbType::Ptr& type);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -51,8 +51,8 @@ protected:
|
|||||||
static Value CustomVariableNamesAccessor(const Value& row);
|
static Value CustomVariableNamesAccessor(const Value& row);
|
||||||
static Value CustomVariableValuesAccessor(const Value& row);
|
static Value CustomVariableValuesAccessor(const Value& row);
|
||||||
static Value CustomVariablesAccessor(const Value& row);
|
static Value CustomVariablesAccessor(const Value& row);
|
||||||
static Value ModifiedAttributesAccessor(const Value& row);
|
static Value ModifiedAttributesAccessor(const Value& row);
|
||||||
static Value ModifiedAttributesListAccessor(const Value& row);
|
static Value ModifiedAttributesListAccessor(const Value& row);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -47,9 +47,9 @@ protected:
|
|||||||
virtual void FetchRows(const AddRowFunction& addRowFn);
|
virtual void FetchRows(const AddRowFunction& addRowFn);
|
||||||
|
|
||||||
static Value NameAccessor(const Value& row);
|
static Value NameAccessor(const Value& row);
|
||||||
static Value IdentityAccessor(const Value& row);
|
static Value IdentityAccessor(const Value& row);
|
||||||
static Value NodeAccessor(const Value& row);
|
static Value NodeAccessor(const Value& row);
|
||||||
static Value IsConnectedAccessor(const Value& row);
|
static Value IsConnectedAccessor(const Value& row);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,7 @@ namespace icinga
|
|||||||
class HistoryTable : public Table
|
class HistoryTable : public Table
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual void UpdateLogEntries(const Dictionary::Ptr& bag, int line_count, int lineno, const AddRowFunction& addRowFn);
|
virtual void UpdateLogEntries(const Dictionary::Ptr& bag, int line_count, int lineno, const AddRowFunction& addRowFn);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -584,7 +584,7 @@ Value HostsTable::CurrentNotificationNumberAccessor(const Value& row)
|
|||||||
if (!host)
|
if (!host)
|
||||||
return Empty;
|
return Empty;
|
||||||
|
|
||||||
return CompatUtility::GetCheckableNotificationNotificationNumber(host);
|
return CompatUtility::GetCheckableNotificationNotificationNumber(host);
|
||||||
}
|
}
|
||||||
|
|
||||||
Value HostsTable::TotalServicesAccessor(const Value& row)
|
Value HostsTable::TotalServicesAccessor(const Value& row)
|
||||||
|
@ -62,7 +62,7 @@ protected:
|
|||||||
static Value ActionUrlAccessor(const Value& row);
|
static Value ActionUrlAccessor(const Value& row);
|
||||||
static Value ActionUrlExpandedAccessor(const Value& row);
|
static Value ActionUrlExpandedAccessor(const Value& row);
|
||||||
static Value PluginOutputAccessor(const Value& row);
|
static Value PluginOutputAccessor(const Value& row);
|
||||||
static Value PerfDataAccessor(const Value& row);
|
static Value PerfDataAccessor(const Value& row);
|
||||||
static Value IconImageAccessor(const Value& row);
|
static Value IconImageAccessor(const Value& row);
|
||||||
static Value IconImageExpandedAccessor(const Value& row);
|
static Value IconImageExpandedAccessor(const Value& row);
|
||||||
static Value IconImageAltAccessor(const Value& row);
|
static Value IconImageAltAccessor(const Value& row);
|
||||||
@ -141,8 +141,8 @@ protected:
|
|||||||
static Value ServicesAccessor(const Value& row);
|
static Value ServicesAccessor(const Value& row);
|
||||||
static Value ServicesWithStateAccessor(const Value& row);
|
static Value ServicesWithStateAccessor(const Value& row);
|
||||||
static Value ServicesWithInfoAccessor(const Value& row);
|
static Value ServicesWithInfoAccessor(const Value& row);
|
||||||
static Value CheckSourceAccessor(const Value& row);
|
static Value CheckSourceAccessor(const Value& row);
|
||||||
static Value IsReachableAccessor(const Value& row);
|
static Value IsReachableAccessor(const Value& row);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -26,5 +26,5 @@
|
|||||||
%attribute %string "bind_host",
|
%attribute %string "bind_host",
|
||||||
%attribute %string "bind_port",
|
%attribute %string "bind_port",
|
||||||
|
|
||||||
%attribute %string "compat_log_path",
|
%attribute %string "compat_log_path",
|
||||||
}
|
}
|
||||||
|
@ -37,9 +37,9 @@ class LivestatusListener : public ObjectImpl<LivestatusListener>
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DECLARE_PTR_TYPEDEFS(LivestatusListener);
|
DECLARE_PTR_TYPEDEFS(LivestatusListener);
|
||||||
DECLARE_TYPENAME(LivestatusListener);
|
DECLARE_TYPENAME(LivestatusListener);
|
||||||
|
|
||||||
static Value StatsFunc(Dictionary::Ptr& status, Dictionary::Ptr& perfdata);
|
static Value StatsFunc(Dictionary::Ptr& status, Dictionary::Ptr& perfdata);
|
||||||
|
|
||||||
static int GetClientsConnected(void);
|
static int GetClientsConnected(void);
|
||||||
static int GetConnections(void);
|
static int GetConnections(void);
|
||||||
|
@ -120,27 +120,27 @@ void LivestatusLogUtility::CreateLogCache(std::map<time_t, String> index, Histor
|
|||||||
|
|
||||||
Dictionary::Ptr LivestatusLogUtility::GetAttributes(const String& text)
|
Dictionary::Ptr LivestatusLogUtility::GetAttributes(const String& text)
|
||||||
{
|
{
|
||||||
Dictionary::Ptr bag = make_shared<Dictionary>();
|
Dictionary::Ptr bag = make_shared<Dictionary>();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* [1379025342] SERVICE NOTIFICATION: contactname;hostname;servicedesc;WARNING;true;foo output
|
* [1379025342] SERVICE NOTIFICATION: contactname;hostname;servicedesc;WARNING;true;foo output
|
||||||
*/
|
*/
|
||||||
unsigned long time = atoi(text.SubStr(1, 11).CStr());
|
unsigned long time = atoi(text.SubStr(1, 11).CStr());
|
||||||
|
|
||||||
Log(LogDebug, "LivestatusLogUtility", "Processing log line: '" + text + "'.");
|
Log(LogDebug, "LivestatusLogUtility", "Processing log line: '" + text + "'.");
|
||||||
bag->Set("time", time);
|
bag->Set("time", time);
|
||||||
|
|
||||||
size_t colon = text.FindFirstOf(':');
|
size_t colon = text.FindFirstOf(':');
|
||||||
size_t colon_offset = colon - 13;
|
size_t colon_offset = colon - 13;
|
||||||
|
|
||||||
String type = String(text.SubStr(13, colon_offset));
|
String type = String(text.SubStr(13, colon_offset));
|
||||||
String options = String(text.SubStr(colon + 1));
|
String options = String(text.SubStr(colon + 1));
|
||||||
|
|
||||||
type.Trim();
|
type.Trim();
|
||||||
options.Trim();
|
options.Trim();
|
||||||
|
|
||||||
bag->Set("type", type);
|
bag->Set("type", type);
|
||||||
bag->Set("options", options);
|
bag->Set("options", options);
|
||||||
|
|
||||||
std::vector<String> tokens;
|
std::vector<String> tokens;
|
||||||
boost::algorithm::split(tokens, options, boost::is_any_of(";"));
|
boost::algorithm::split(tokens, options, boost::is_any_of(";"));
|
||||||
@ -260,7 +260,7 @@ Dictionary::Ptr LivestatusLogUtility::GetAttributes(const String& text)
|
|||||||
bag->Set("contact_name", tokens[0]);
|
bag->Set("contact_name", tokens[0]);
|
||||||
bag->Set("host_name", tokens[1]);
|
bag->Set("host_name", tokens[1]);
|
||||||
bag->Set("state_type", tokens[2].CStr());
|
bag->Set("state_type", tokens[2].CStr());
|
||||||
bag->Set("state", Service::StateFromString(tokens[3]));
|
bag->Set("state", Service::StateFromString(tokens[3]));
|
||||||
bag->Set("command_name", tokens[4]);
|
bag->Set("command_name", tokens[4]);
|
||||||
bag->Set("plugin_output", tokens[5]);
|
bag->Set("plugin_output", tokens[5]);
|
||||||
|
|
||||||
@ -274,9 +274,9 @@ Dictionary::Ptr LivestatusLogUtility::GetAttributes(const String& text)
|
|||||||
|
|
||||||
bag->Set("contact_name", tokens[0]);
|
bag->Set("contact_name", tokens[0]);
|
||||||
bag->Set("host_name", tokens[1]);
|
bag->Set("host_name", tokens[1]);
|
||||||
bag->Set("service_description", tokens[2]);
|
bag->Set("service_description", tokens[2]);
|
||||||
bag->Set("state_type", tokens[3].CStr());
|
bag->Set("state_type", tokens[3].CStr());
|
||||||
bag->Set("state", Service::StateFromString(tokens[4]));
|
bag->Set("state", Service::StateFromString(tokens[4]));
|
||||||
bag->Set("command_name", tokens[5]);
|
bag->Set("command_name", tokens[5]);
|
||||||
bag->Set("plugin_output", tokens[6]);
|
bag->Set("plugin_output", tokens[6]);
|
||||||
|
|
||||||
@ -292,41 +292,41 @@ Dictionary::Ptr LivestatusLogUtility::GetAttributes(const String& text)
|
|||||||
bag->Set("state", Host::StateFromString(tokens[1]));
|
bag->Set("state", Host::StateFromString(tokens[1]));
|
||||||
bag->Set("plugin_output", tokens[2]);
|
bag->Set("plugin_output", tokens[2]);
|
||||||
|
|
||||||
bag->Set("log_class", LogEntryClassPassive);
|
bag->Set("log_class", LogEntryClassPassive);
|
||||||
|
|
||||||
return bag;
|
return bag;
|
||||||
} else if (type.Contains("PASSIVE SERVICE CHECK")) {
|
} else if (type.Contains("PASSIVE SERVICE CHECK")) {
|
||||||
if (tokens.size() < 4)
|
if (tokens.size() < 4)
|
||||||
return bag;
|
return bag;
|
||||||
|
|
||||||
bag->Set("host_name", tokens[0]);
|
bag->Set("host_name", tokens[0]);
|
||||||
bag->Set("service_description", tokens[1]);
|
bag->Set("service_description", tokens[1]);
|
||||||
bag->Set("state", Host::StateFromString(tokens[2]));
|
bag->Set("state", Host::StateFromString(tokens[2]));
|
||||||
bag->Set("plugin_output", tokens[3]);
|
bag->Set("plugin_output", tokens[3]);
|
||||||
|
|
||||||
bag->Set("log_class", LogEntryClassPassive);
|
bag->Set("log_class", LogEntryClassPassive);
|
||||||
|
|
||||||
return bag;
|
return bag;
|
||||||
} else if (type.Contains("EXTERNAL COMMAND")) {
|
} else if (type.Contains("EXTERNAL COMMAND")) {
|
||||||
bag->Set("log_class", LogEntryClassCommand);
|
bag->Set("log_class", LogEntryClassCommand);
|
||||||
/* string processing not implemented in 1.x */
|
/* string processing not implemented in 1.x */
|
||||||
|
|
||||||
return bag;
|
return bag;
|
||||||
} else if (type.Contains("LOG VERSION")) {
|
} else if (type.Contains("LOG VERSION")) {
|
||||||
bag->Set("log_class", LogEntryClassProgram);
|
bag->Set("log_class", LogEntryClassProgram);
|
||||||
bag->Set("log_type", LogEntryTypeVersion);
|
bag->Set("log_type", LogEntryTypeVersion);
|
||||||
|
|
||||||
return bag;
|
return bag;
|
||||||
} else if (type.Contains("logging initial states")) {
|
} else if (type.Contains("logging initial states")) {
|
||||||
bag->Set("log_class", LogEntryClassProgram);
|
bag->Set("log_class", LogEntryClassProgram);
|
||||||
bag->Set("log_type", LogEntryTypeInitialStates);
|
bag->Set("log_type", LogEntryTypeInitialStates);
|
||||||
|
|
||||||
return bag;
|
return bag;
|
||||||
} else if (type.Contains("starting... (PID=")) {
|
} else if (type.Contains("starting... (PID=")) {
|
||||||
bag->Set("log_class", LogEntryClassProgram);
|
bag->Set("log_class", LogEntryClassProgram);
|
||||||
bag->Set("log_type", LogEntryTypeProgramStarting);
|
bag->Set("log_type", LogEntryTypeProgramStarting);
|
||||||
|
|
||||||
return bag;
|
return bag;
|
||||||
}
|
}
|
||||||
/* program */
|
/* program */
|
||||||
else if (type.Contains("restarting...") ||
|
else if (type.Contains("restarting...") ||
|
||||||
@ -336,8 +336,8 @@ Dictionary::Ptr LivestatusLogUtility::GetAttributes(const String& text)
|
|||||||
type.Contains("standby mode...")) {
|
type.Contains("standby mode...")) {
|
||||||
bag->Set("log_class", LogEntryClassProgram);
|
bag->Set("log_class", LogEntryClassProgram);
|
||||||
|
|
||||||
return bag;
|
return bag;
|
||||||
}
|
}
|
||||||
|
|
||||||
return bag;
|
return bag;
|
||||||
}
|
}
|
||||||
|
@ -44,15 +44,15 @@ public:
|
|||||||
virtual String GetName(void) const;
|
virtual String GetName(void) const;
|
||||||
virtual String GetPrefix(void) const;
|
virtual String GetPrefix(void) const;
|
||||||
|
|
||||||
void UpdateLogEntries(const Dictionary::Ptr& log_entry_attrs, int line_count, int lineno, const AddRowFunction& addRowFn);
|
void UpdateLogEntries(const Dictionary::Ptr& log_entry_attrs, int line_count, int lineno, const AddRowFunction& addRowFn);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void FetchRows(const AddRowFunction& addRowFn);
|
virtual void FetchRows(const AddRowFunction& addRowFn);
|
||||||
|
|
||||||
static Object::Ptr HostAccessor(const Value& row, const Column::ObjectAccessor& parentObjectAccessor);
|
static Object::Ptr HostAccessor(const Value& row, const Column::ObjectAccessor& parentObjectAccessor);
|
||||||
static Object::Ptr ServiceAccessor(const Value& row, const Column::ObjectAccessor& parentObjectAccessor);
|
static Object::Ptr ServiceAccessor(const Value& row, const Column::ObjectAccessor& parentObjectAccessor);
|
||||||
static Object::Ptr ContactAccessor(const Value& row, const Column::ObjectAccessor& parentObjectAccessor);
|
static Object::Ptr ContactAccessor(const Value& row, const Column::ObjectAccessor& parentObjectAccessor);
|
||||||
static Object::Ptr CommandAccessor(const Value& row, const Column::ObjectAccessor& parentObjectAccessor);
|
static Object::Ptr CommandAccessor(const Value& row, const Column::ObjectAccessor& parentObjectAccessor);
|
||||||
|
|
||||||
static Value TimeAccessor(const Value& row);
|
static Value TimeAccessor(const Value& row);
|
||||||
static Value LinenoAccessor(const Value& row);
|
static Value LinenoAccessor(const Value& row);
|
||||||
@ -71,11 +71,11 @@ protected:
|
|||||||
static Value CommandNameAccessor(const Value& row);
|
static Value CommandNameAccessor(const Value& row);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::map<time_t, String> m_LogFileIndex;
|
std::map<time_t, String> m_LogFileIndex;
|
||||||
std::map<time_t, Dictionary::Ptr> m_RowsCache;
|
std::map<time_t, Dictionary::Ptr> m_RowsCache;
|
||||||
time_t m_TimeFrom;
|
time_t m_TimeFrom;
|
||||||
time_t m_TimeUntil;
|
time_t m_TimeUntil;
|
||||||
String m_CompatLogPath;
|
String m_CompatLogPath;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -519,7 +519,7 @@ Value ServicesTable::NoMoreNotificationsAccessor(const Value& row)
|
|||||||
if (!service)
|
if (!service)
|
||||||
return Empty;
|
return Empty;
|
||||||
|
|
||||||
return CompatUtility::GetCheckableNoMoreNotifications(service);
|
return CompatUtility::GetCheckableNoMoreNotifications(service);
|
||||||
}
|
}
|
||||||
|
|
||||||
Value ServicesTable::LastTimeOkAccessor(const Value& row)
|
Value ServicesTable::LastTimeOkAccessor(const Value& row)
|
||||||
|
@ -95,7 +95,7 @@ protected:
|
|||||||
static Value AcceptPassiveChecksAccessor(const Value& row);
|
static Value AcceptPassiveChecksAccessor(const Value& row);
|
||||||
static Value EventHandlerEnabledAccessor(const Value& row);
|
static Value EventHandlerEnabledAccessor(const Value& row);
|
||||||
static Value NotificationsEnabledAccessor(const Value& row);
|
static Value NotificationsEnabledAccessor(const Value& row);
|
||||||
static Value ProcessPerformanceDataAccessor(const Value& row);
|
static Value ProcessPerformanceDataAccessor(const Value& row);
|
||||||
static Value ActiveChecksEnabledAccessor(const Value& row);
|
static Value ActiveChecksEnabledAccessor(const Value& row);
|
||||||
static Value CheckOptionsAccessor(const Value& row);
|
static Value CheckOptionsAccessor(const Value& row);
|
||||||
static Value FlapDetectionEnabledAccessor(const Value& row);
|
static Value FlapDetectionEnabledAccessor(const Value& row);
|
||||||
@ -124,8 +124,8 @@ protected:
|
|||||||
static Value CustomVariablesAccessor(const Value& row);
|
static Value CustomVariablesAccessor(const Value& row);
|
||||||
static Value GroupsAccessor(const Value& row);
|
static Value GroupsAccessor(const Value& row);
|
||||||
static Value ContactGroupsAccessor(const Value& row);
|
static Value ContactGroupsAccessor(const Value& row);
|
||||||
static Value CheckSourceAccessor(const Value& row);
|
static Value CheckSourceAccessor(const Value& row);
|
||||||
static Value IsReachableAccessor(const Value& row);
|
static Value IsReachableAccessor(const Value& row);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -50,8 +50,8 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
virtual void FetchRows(const AddRowFunction& addRowFn);
|
virtual void FetchRows(const AddRowFunction& addRowFn);
|
||||||
|
|
||||||
static Object::Ptr HostAccessor(const Value& row, const Column::ObjectAccessor& parentObjectAccessor);
|
static Object::Ptr HostAccessor(const Value& row, const Column::ObjectAccessor& parentObjectAccessor);
|
||||||
static Object::Ptr ServiceAccessor(const Value& row, const Column::ObjectAccessor& parentObjectAccessor);
|
static Object::Ptr ServiceAccessor(const Value& row, const Column::ObjectAccessor& parentObjectAccessor);
|
||||||
|
|
||||||
static Value TimeAccessor(const Value& row);
|
static Value TimeAccessor(const Value& row);
|
||||||
static Value LinenoAccessor(const Value& row);
|
static Value LinenoAccessor(const Value& row);
|
||||||
@ -81,11 +81,11 @@ protected:
|
|||||||
static Value DurationPartUnmonitoredAccessor(const Value& row);
|
static Value DurationPartUnmonitoredAccessor(const Value& row);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::map<time_t, String> m_LogFileIndex;
|
std::map<time_t, String> m_LogFileIndex;
|
||||||
std::map<Checkable::Ptr, Array::Ptr> m_CheckablesCache;
|
std::map<Checkable::Ptr, Array::Ptr> m_CheckablesCache;
|
||||||
time_t m_TimeFrom;
|
time_t m_TimeFrom;
|
||||||
time_t m_TimeUntil;
|
time_t m_TimeUntil;
|
||||||
String m_CompatLogPath;
|
String m_CompatLogPath;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -48,10 +48,10 @@ protected:
|
|||||||
|
|
||||||
static Value ConnectionsAccessor(const Value& row);
|
static Value ConnectionsAccessor(const Value& row);
|
||||||
static Value ConnectionsRateAccessor(const Value& row);
|
static Value ConnectionsRateAccessor(const Value& row);
|
||||||
static Value ServiceChecksAccessor(const Value& row);
|
static Value ServiceChecksAccessor(const Value& row);
|
||||||
static Value ServiceChecksRateAccessor(const Value& row);
|
static Value ServiceChecksRateAccessor(const Value& row);
|
||||||
static Value HostChecksAccessor(const Value& row);
|
static Value HostChecksAccessor(const Value& row);
|
||||||
static Value HostChecksRateAccessor(const Value& row);
|
static Value HostChecksRateAccessor(const Value& row);
|
||||||
static Value ExternalCommandsAccessor(const Value& row);
|
static Value ExternalCommandsAccessor(const Value& row);
|
||||||
static Value ExternalCommandsRateAccessor(const Value& row);
|
static Value ExternalCommandsRateAccessor(const Value& row);
|
||||||
static Value NagiosPidAccessor(const Value& row);
|
static Value NagiosPidAccessor(const Value& row);
|
||||||
@ -60,7 +60,7 @@ protected:
|
|||||||
static Value ExecuteHostChecksAccessor(const Value& row);
|
static Value ExecuteHostChecksAccessor(const Value& row);
|
||||||
static Value EnableEventHandlersAccessor(const Value& row);
|
static Value EnableEventHandlersAccessor(const Value& row);
|
||||||
static Value EnableFlapDetectionAccessor(const Value& row);
|
static Value EnableFlapDetectionAccessor(const Value& row);
|
||||||
static Value ProcessPerformanceDataAccessor(const Value& row);
|
static Value ProcessPerformanceDataAccessor(const Value& row);
|
||||||
static Value ProgramStartAccessor(const Value& row);
|
static Value ProgramStartAccessor(const Value& row);
|
||||||
static Value NumHostsAccessor(const Value& row);
|
static Value NumHostsAccessor(const Value& row);
|
||||||
static Value NumServicesAccessor(const Value& row);
|
static Value NumServicesAccessor(const Value& row);
|
||||||
|
@ -35,9 +35,9 @@ class NotificationComponent : public ObjectImpl<NotificationComponent>
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DECLARE_PTR_TYPEDEFS(NotificationComponent);
|
DECLARE_PTR_TYPEDEFS(NotificationComponent);
|
||||||
DECLARE_TYPENAME(NotificationComponent);
|
DECLARE_TYPENAME(NotificationComponent);
|
||||||
|
|
||||||
static Value StatsFunc(Dictionary::Ptr& status, Dictionary::Ptr& perfdata);
|
static Value StatsFunc(Dictionary::Ptr& status, Dictionary::Ptr& perfdata);
|
||||||
|
|
||||||
virtual void Start(void);
|
virtual void Start(void);
|
||||||
|
|
||||||
|
@ -41,20 +41,20 @@ public:
|
|||||||
DECLARE_PTR_TYPEDEFS(GraphiteWriter);
|
DECLARE_PTR_TYPEDEFS(GraphiteWriter);
|
||||||
DECLARE_TYPENAME(GraphiteWriter);
|
DECLARE_TYPENAME(GraphiteWriter);
|
||||||
|
|
||||||
static Value StatsFunc(Dictionary::Ptr& status, Dictionary::Ptr& perfdata);
|
static Value StatsFunc(Dictionary::Ptr& status, Dictionary::Ptr& perfdata);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void Start(void);
|
virtual void Start(void);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Stream::Ptr m_Stream;
|
Stream::Ptr m_Stream;
|
||||||
|
|
||||||
Timer::Ptr m_ReconnectTimer;
|
Timer::Ptr m_ReconnectTimer;
|
||||||
|
|
||||||
void CheckResultHandler(const Checkable::Ptr& checkable, const CheckResult::Ptr& cr);
|
void CheckResultHandler(const Checkable::Ptr& checkable, const CheckResult::Ptr& cr);
|
||||||
void SendMetric(const String& prefix, const String& name, double value);
|
void SendMetric(const String& prefix, const String& name, double value);
|
||||||
void SendPerfdata(const String& prefix, const CheckResult::Ptr& cr);
|
void SendPerfdata(const String& prefix, const CheckResult::Ptr& cr);
|
||||||
static void SanitizeMetric(String& str);
|
static void SanitizeMetric(String& str);
|
||||||
|
|
||||||
void ReconnectTimerHandler(void);
|
void ReconnectTimerHandler(void);
|
||||||
};
|
};
|
||||||
|
@ -28,6 +28,6 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
%type GraphiteWriter {
|
%type GraphiteWriter {
|
||||||
%attribute %string "host",
|
%attribute %string "host",
|
||||||
%attribute %string "port",
|
%attribute %string "port",
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,7 @@ public:
|
|||||||
DECLARE_PTR_TYPEDEFS(PerfdataWriter);
|
DECLARE_PTR_TYPEDEFS(PerfdataWriter);
|
||||||
DECLARE_TYPENAME(PerfdataWriter);
|
DECLARE_TYPENAME(PerfdataWriter);
|
||||||
|
|
||||||
static Value StatsFunc(Dictionary::Ptr& status, Dictionary::Ptr& perfdata);
|
static Value StatsFunc(Dictionary::Ptr& status, Dictionary::Ptr& perfdata);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void Start(void);
|
virtual void Start(void);
|
||||||
@ -52,7 +52,7 @@ private:
|
|||||||
void RotationTimerHandler(void);
|
void RotationTimerHandler(void);
|
||||||
|
|
||||||
std::ofstream m_ServiceOutputFile;
|
std::ofstream m_ServiceOutputFile;
|
||||||
std::ofstream m_HostOutputFile;
|
std::ofstream m_HostOutputFile;
|
||||||
void RotateFile(std::ofstream& output, const String& temp_path, const String& perfdata_path);
|
void RotateFile(std::ofstream& output, const String& temp_path, const String& perfdata_path);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -35,9 +35,9 @@ class I2_BASE_API FileLogger : public ObjectImpl<FileLogger>
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DECLARE_PTR_TYPEDEFS(FileLogger);
|
DECLARE_PTR_TYPEDEFS(FileLogger);
|
||||||
DECLARE_TYPENAME(FileLogger);
|
DECLARE_TYPENAME(FileLogger);
|
||||||
|
|
||||||
static Value StatsFunc(Dictionary::Ptr& status, Dictionary::Ptr& perfdata);
|
static Value StatsFunc(Dictionary::Ptr& status, Dictionary::Ptr& perfdata);
|
||||||
|
|
||||||
virtual void Start(void);
|
virtual void Start(void);
|
||||||
|
|
||||||
|
@ -136,7 +136,7 @@ void StackTrace::Print(std::ostream& fp, int ignoreFrames) const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fp << "\t(" << i - ignoreFrames - 1 << ") " << message << std::endl;
|
fp << "\t(" << i - ignoreFrames - 1 << ") " << message << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
free(messages);
|
free(messages);
|
||||||
|
@ -45,7 +45,7 @@ public:
|
|||||||
void BindStream(std::ostream *stream, bool ownsStream);
|
void BindStream(std::ostream *stream, bool ownsStream);
|
||||||
|
|
||||||
static void ProcessLogEntry(std::ostream& stream, bool tty, const LogEntry& entry);
|
static void ProcessLogEntry(std::ostream& stream, bool tty, const LogEntry& entry);
|
||||||
static bool IsTty(std::ostream& stream);
|
static bool IsTty(std::ostream& stream);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void ProcessLogEntry(const LogEntry& entry);
|
virtual void ProcessLogEntry(const LogEntry& entry);
|
||||||
|
@ -36,9 +36,9 @@ class I2_BASE_API SyslogLogger : public ObjectImpl<SyslogLogger>
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DECLARE_PTR_TYPEDEFS(SyslogLogger);
|
DECLARE_PTR_TYPEDEFS(SyslogLogger);
|
||||||
DECLARE_TYPENAME(SyslogLogger);
|
DECLARE_TYPENAME(SyslogLogger);
|
||||||
|
|
||||||
static Value StatsFunc(Dictionary::Ptr& status, Dictionary::Ptr& perfdata);
|
static Value StatsFunc(Dictionary::Ptr& status, Dictionary::Ptr& perfdata);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void ProcessLogEntry(const LogEntry& entry);
|
virtual void ProcessLogEntry(const LogEntry& entry);
|
||||||
|
@ -47,17 +47,17 @@ typedef boost::error_info<struct errinfo_openssl_error_, int> errinfo_openssl_er
|
|||||||
|
|
||||||
inline std::string to_string(const errinfo_openssl_error& e)
|
inline std::string to_string(const errinfo_openssl_error& e)
|
||||||
{
|
{
|
||||||
std::ostringstream tmp;
|
std::ostringstream tmp;
|
||||||
int code = e.value();
|
int code = e.value();
|
||||||
char errbuf[120];
|
char errbuf[120];
|
||||||
|
|
||||||
const char *message = ERR_error_string(code, errbuf);
|
const char *message = ERR_error_string(code, errbuf);
|
||||||
|
|
||||||
if (message == NULL)
|
if (message == NULL)
|
||||||
message = "Unknown error.";
|
message = "Unknown error.";
|
||||||
|
|
||||||
tmp << code << ", \"" << message << "\"";
|
tmp << code << ", \"" << message << "\"";
|
||||||
return tmp.str();
|
return tmp.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -777,22 +777,22 @@ String Utility::FormatErrorNumber(int code) {
|
|||||||
std::ostringstream msgbuf;
|
std::ostringstream msgbuf;
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
char *message;
|
char *message;
|
||||||
String result = "Unknown error.";
|
String result = "Unknown error.";
|
||||||
|
|
||||||
DWORD rc = FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
|
DWORD rc = FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
|
||||||
FORMAT_MESSAGE_FROM_SYSTEM, NULL, code, 0, (char *)&message,
|
FORMAT_MESSAGE_FROM_SYSTEM, NULL, code, 0, (char *)&message,
|
||||||
0, NULL);
|
0, NULL);
|
||||||
|
|
||||||
if (rc != 0) {
|
if (rc != 0) {
|
||||||
result = String(message);
|
result = String(message);
|
||||||
LocalFree(message);
|
LocalFree(message);
|
||||||
|
|
||||||
/* remove trailing new-line characters */
|
/* remove trailing new-line characters */
|
||||||
boost::algorithm::trim_right(result);
|
boost::algorithm::trim_right(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
msgbuf << code << ", \"" << result << "\"";
|
msgbuf << code << ", \"" << result << "\"";
|
||||||
#else
|
#else
|
||||||
msgbuf << strerror(code);
|
msgbuf << strerror(code);
|
||||||
#endif
|
#endif
|
||||||
|
@ -54,7 +54,7 @@ public:
|
|||||||
static ConfigCompilerContext *GetInstance(void);
|
static ConfigCompilerContext *GetInstance(void);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<ConfigCompilerMessage> m_Messages;
|
std::vector<ConfigCompilerMessage> m_Messages;
|
||||||
|
|
||||||
mutable boost::mutex m_Mutex;
|
mutable boost::mutex m_Mutex;
|
||||||
};
|
};
|
||||||
|
@ -42,7 +42,7 @@ public:
|
|||||||
virtual Dictionary::Ptr GetStatusFields(void) const;
|
virtual Dictionary::Ptr GetStatusFields(void) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void OnConfigUpdate(void);
|
virtual void OnConfigUpdate(void);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -18,31 +18,31 @@
|
|||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
%type DbConnection {
|
%type DbConnection {
|
||||||
%validator "ValidateFailoverTimeout"
|
%validator "ValidateFailoverTimeout"
|
||||||
|
|
||||||
%attribute %string "table_prefix",
|
%attribute %string "table_prefix",
|
||||||
|
|
||||||
%attribute %dictionary "cleanup" {
|
%attribute %dictionary "cleanup" {
|
||||||
%attribute %number "acknowledgements_age",
|
%attribute %number "acknowledgements_age",
|
||||||
%attribute %number "commenthistory_age",
|
%attribute %number "commenthistory_age",
|
||||||
%attribute %number "contactnotifications_age",
|
%attribute %number "contactnotifications_age",
|
||||||
%attribute %number "contactnotificationmethods_age",
|
%attribute %number "contactnotificationmethods_age",
|
||||||
%attribute %number "downtimehistory_age",
|
%attribute %number "downtimehistory_age",
|
||||||
%attribute %number "eventhandlers_age",
|
%attribute %number "eventhandlers_age",
|
||||||
%attribute %number "externalcommands_age",
|
%attribute %number "externalcommands_age",
|
||||||
%attribute %number "flappinghistory_age",
|
%attribute %number "flappinghistory_age",
|
||||||
%attribute %number "hostchecks_age",
|
%attribute %number "hostchecks_age",
|
||||||
%attribute %number "logentries_age",
|
%attribute %number "logentries_age",
|
||||||
%attribute %number "notifications_age",
|
%attribute %number "notifications_age",
|
||||||
%attribute %number "processevents_age",
|
%attribute %number "processevents_age",
|
||||||
%attribute %number "statehistory_age",
|
%attribute %number "statehistory_age",
|
||||||
%attribute %number "servicechecks_age",
|
%attribute %number "servicechecks_age",
|
||||||
%attribute %number "systemcommands_age",
|
%attribute %number "systemcommands_age",
|
||||||
},
|
},
|
||||||
|
|
||||||
%attribute %number "categories",
|
%attribute %number "categories",
|
||||||
|
|
||||||
%attribute %number "enable_ha",
|
%attribute %number "enable_ha",
|
||||||
|
|
||||||
%attribute %number "failover_timeout",
|
%attribute %number "failover_timeout",
|
||||||
}
|
}
|
||||||
|
@ -419,9 +419,8 @@ void DbConnection::ValidateFailoverTimeout(const String& location, const Diction
|
|||||||
if (!attrs->Contains("failover_timeout"))
|
if (!attrs->Contains("failover_timeout"))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Value failover_timeout = attrs->Get("failover_timeout");
|
if (attrs->Get("failover_timeout") < 60) {
|
||||||
if (failover_timeout < 60) {
|
ConfigCompilerContext::GetInstance()->AddMessage(true, "Validation failed for " +
|
||||||
ConfigCompilerContext::GetInstance()->AddMessage(true, "Validation failed for " +
|
location + ": Failover timeout minimum is 60s.");
|
||||||
location + ": Failover timeout minimum is 60s.");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -63,10 +63,10 @@ public:
|
|||||||
void SetStatusUpdate(const DbObject::Ptr& dbobj, bool hasupdate);
|
void SetStatusUpdate(const DbObject::Ptr& dbobj, bool hasupdate);
|
||||||
bool GetStatusUpdate(const DbObject::Ptr& dbobj) const;
|
bool GetStatusUpdate(const DbObject::Ptr& dbobj) const;
|
||||||
|
|
||||||
static void ValidateFailoverTimeout(const String& location, const Dictionary::Ptr& attrs);
|
static void ValidateFailoverTimeout(const String& location, const Dictionary::Ptr& attrs);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void OnConfigLoaded(void);
|
virtual void OnConfigLoaded(void);
|
||||||
virtual void Start(void);
|
virtual void Start(void);
|
||||||
virtual void Resume(void);
|
virtual void Resume(void);
|
||||||
virtual void Pause(void);
|
virtual void Pause(void);
|
||||||
@ -85,7 +85,7 @@ protected:
|
|||||||
private:
|
private:
|
||||||
std::map<DbObject::Ptr, DbReference> m_ObjectIDs;
|
std::map<DbObject::Ptr, DbReference> m_ObjectIDs;
|
||||||
std::map<std::pair<DbType::Ptr, DbReference>, DbReference> m_InsertIDs;
|
std::map<std::pair<DbType::Ptr, DbReference>, DbReference> m_InsertIDs;
|
||||||
std::map<CustomVarObject::Ptr, DbReference> m_NotificationInsertIDs;
|
std::map<CustomVarObject::Ptr, DbReference> m_NotificationInsertIDs;
|
||||||
std::set<DbObject::Ptr> m_ActiveObjects;
|
std::set<DbObject::Ptr> m_ActiveObjects;
|
||||||
std::set<DbObject::Ptr> m_ConfigUpdates;
|
std::set<DbObject::Ptr> m_ConfigUpdates;
|
||||||
std::set<DbObject::Ptr> m_StatusUpdates;
|
std::set<DbObject::Ptr> m_StatusUpdates;
|
||||||
|
@ -1087,18 +1087,18 @@ void DbEvents::AddFlappingLogHistory(const Checkable::Ptr& checkable, FlappingSt
|
|||||||
std::ostringstream msgbuf;
|
std::ostringstream msgbuf;
|
||||||
|
|
||||||
if (service) {
|
if (service) {
|
||||||
msgbuf << "SERVICE FLAPPING ALERT: "
|
msgbuf << "SERVICE FLAPPING ALERT: "
|
||||||
<< host->GetName() << ";"
|
<< host->GetName() << ";"
|
||||||
<< service->GetShortName() << ";"
|
<< service->GetShortName() << ";"
|
||||||
<< flapping_state_str << "; "
|
<< flapping_state_str << "; "
|
||||||
<< flapping_output
|
<< flapping_output
|
||||||
<< "";
|
<< "";
|
||||||
} else {
|
} else {
|
||||||
msgbuf << "HOST FLAPPING ALERT: "
|
msgbuf << "HOST FLAPPING ALERT: "
|
||||||
<< host->GetName() << ";"
|
<< host->GetName() << ";"
|
||||||
<< flapping_state_str << "; "
|
<< flapping_state_str << "; "
|
||||||
<< flapping_output
|
<< flapping_output
|
||||||
<< "";
|
<< "";
|
||||||
}
|
}
|
||||||
|
|
||||||
AddLogHistory(checkable, msgbuf.str(), LogEntryTypeInfoMessage);
|
AddLogHistory(checkable, msgbuf.str(), LogEntryTypeInfoMessage);
|
||||||
|
@ -71,16 +71,16 @@ public:
|
|||||||
static void StaticInitialize(void);
|
static void StaticInitialize(void);
|
||||||
|
|
||||||
static void AddCommentByType(const DynamicObject::Ptr& object, const Comment::Ptr& comment, bool historical);
|
static void AddCommentByType(const DynamicObject::Ptr& object, const Comment::Ptr& comment, bool historical);
|
||||||
static void AddComments(const Checkable::Ptr& checkable);
|
static void AddComments(const Checkable::Ptr& checkable);
|
||||||
static void RemoveComments(const Checkable::Ptr& checkable);
|
static void RemoveComments(const Checkable::Ptr& checkable);
|
||||||
|
|
||||||
static void AddDowntimeByType(const Checkable::Ptr& checkable, const Downtime::Ptr& downtime, bool historical);
|
static void AddDowntimeByType(const Checkable::Ptr& checkable, const Downtime::Ptr& downtime, bool historical);
|
||||||
static void AddDowntimes(const Checkable::Ptr& checkable);
|
static void AddDowntimes(const Checkable::Ptr& checkable);
|
||||||
static void RemoveDowntimes(const Checkable::Ptr& checkable);
|
static void RemoveDowntimes(const Checkable::Ptr& checkable);
|
||||||
|
|
||||||
static void AddLogHistory(const Checkable::Ptr& checkable, String buffer, LogEntryType type);
|
static void AddLogHistory(const Checkable::Ptr& checkable, String buffer, LogEntryType type);
|
||||||
|
|
||||||
/* Status */
|
/* Status */
|
||||||
static void NextCheckChangedHandler(const Checkable::Ptr& checkable, double nextCheck);
|
static void NextCheckChangedHandler(const Checkable::Ptr& checkable, double nextCheck);
|
||||||
static void FlappingChangedHandler(const Checkable::Ptr& checkable, FlappingState state);
|
static void FlappingChangedHandler(const Checkable::Ptr& checkable, FlappingState state);
|
||||||
static void LastNotificationChangedHandler(const Notification::Ptr& notification, const Checkable::Ptr& checkable);
|
static void LastNotificationChangedHandler(const Notification::Ptr& notification, const Checkable::Ptr& checkable);
|
||||||
@ -102,34 +102,34 @@ public:
|
|||||||
static void RemoveAcknowledgement(const Checkable::Ptr& checkable);
|
static void RemoveAcknowledgement(const Checkable::Ptr& checkable);
|
||||||
static void AddAcknowledgementInternal(const Checkable::Ptr& checkable, AcknowledgementType type, bool add);
|
static void AddAcknowledgementInternal(const Checkable::Ptr& checkable, AcknowledgementType type, bool add);
|
||||||
|
|
||||||
/* comment, downtime, acknowledgement history */
|
/* comment, downtime, acknowledgement history */
|
||||||
static void AddCommentHistory(const Checkable::Ptr& checkable, const Comment::Ptr& comment);
|
static void AddCommentHistory(const Checkable::Ptr& checkable, const Comment::Ptr& comment);
|
||||||
static void AddDowntimeHistory(const Checkable::Ptr& checkable, const Downtime::Ptr& downtime);
|
static void AddDowntimeHistory(const Checkable::Ptr& checkable, const Downtime::Ptr& downtime);
|
||||||
static void AddAcknowledgementHistory(const Checkable::Ptr& checkable, const String& author, const String& comment,
|
static void AddAcknowledgementHistory(const Checkable::Ptr& checkable, const String& author, const String& comment,
|
||||||
AcknowledgementType type, double expiry);
|
AcknowledgementType type, double expiry);
|
||||||
|
|
||||||
/* notification & contactnotification history */
|
/* notification & contactnotification history */
|
||||||
static void AddNotificationHistory(const Notification::Ptr& notification, const Checkable::Ptr& checkable,
|
static void AddNotificationHistory(const Notification::Ptr& notification, const Checkable::Ptr& checkable,
|
||||||
const std::set<User::Ptr>& users, NotificationType type, const CheckResult::Ptr& cr, const String& author,
|
const std::set<User::Ptr>& users, NotificationType type, const CheckResult::Ptr& cr, const String& author,
|
||||||
const String& text);
|
const String& text);
|
||||||
|
|
||||||
/* statehistory */
|
/* statehistory */
|
||||||
static void AddStateChangeHistory(const Checkable::Ptr& checkable, const CheckResult::Ptr& cr, StateType type);
|
static void AddStateChangeHistory(const Checkable::Ptr& checkable, const CheckResult::Ptr& cr, StateType type);
|
||||||
|
|
||||||
/* logentries */
|
/* logentries */
|
||||||
static void AddCheckResultLogHistory(const Checkable::Ptr& checkable, const CheckResult::Ptr &cr);
|
static void AddCheckResultLogHistory(const Checkable::Ptr& checkable, const CheckResult::Ptr &cr);
|
||||||
static void AddTriggerDowntimeLogHistory(const Checkable::Ptr& checkable, const Downtime::Ptr& downtime);
|
static void AddTriggerDowntimeLogHistory(const Checkable::Ptr& checkable, const Downtime::Ptr& downtime);
|
||||||
static void AddRemoveDowntimeLogHistory(const Checkable::Ptr& checkable, const Downtime::Ptr& downtime);
|
static void AddRemoveDowntimeLogHistory(const Checkable::Ptr& checkable, const Downtime::Ptr& downtime);
|
||||||
static void AddNotificationSentLogHistory(const Notification::Ptr& notification, const Checkable::Ptr& checkable,
|
static void AddNotificationSentLogHistory(const Notification::Ptr& notification, const Checkable::Ptr& checkable,
|
||||||
const User::Ptr& user, NotificationType notification_type, const CheckResult::Ptr& cr, const String& author,
|
const User::Ptr& user, NotificationType notification_type, const CheckResult::Ptr& cr, const String& author,
|
||||||
const String& comment_text);
|
const String& comment_text);
|
||||||
static void AddFlappingLogHistory(const Checkable::Ptr& checkable, FlappingState flapping_state);
|
static void AddFlappingLogHistory(const Checkable::Ptr& checkable, FlappingState flapping_state);
|
||||||
|
|
||||||
/* other history */
|
/* other history */
|
||||||
static void AddFlappingHistory(const Checkable::Ptr& checkable, FlappingState flapping_state);
|
static void AddFlappingHistory(const Checkable::Ptr& checkable, FlappingState flapping_state);
|
||||||
static void AddServiceCheckHistory(const Checkable::Ptr& checkable, const CheckResult::Ptr &cr);
|
static void AddServiceCheckHistory(const Checkable::Ptr& checkable, const CheckResult::Ptr &cr);
|
||||||
static void AddEventHandlerHistory(const Checkable::Ptr& checkable);
|
static void AddEventHandlerHistory(const Checkable::Ptr& checkable);
|
||||||
static void AddExternalCommandHistory(double time, const String& command, const std::vector<String>& arguments);
|
static void AddExternalCommandHistory(double time, const String& command, const std::vector<String>& arguments);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DbEvents(void);
|
DbEvents(void);
|
||||||
|
@ -39,17 +39,17 @@ public:
|
|||||||
|
|
||||||
EndpointDbObject(const shared_ptr<DbType>& type, const String& name1, const String& name2);
|
EndpointDbObject(const shared_ptr<DbType>& type, const String& name1, const String& name2);
|
||||||
|
|
||||||
static void StaticInitialize(void);
|
static void StaticInitialize(void);
|
||||||
|
|
||||||
virtual Dictionary::Ptr GetConfigFields(void) const;
|
virtual Dictionary::Ptr GetConfigFields(void) const;
|
||||||
virtual Dictionary::Ptr GetStatusFields(void) const;
|
virtual Dictionary::Ptr GetStatusFields(void) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void OnConfigUpdate(void);
|
virtual void OnConfigUpdate(void);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static void UpdateConnectedStatus(const Endpoint::Ptr& endpoint);
|
static void UpdateConnectedStatus(const Endpoint::Ptr& endpoint);
|
||||||
static int EndpointIsConnected(const Endpoint::Ptr& endpoint);
|
static int EndpointIsConnected(const Endpoint::Ptr& endpoint);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -41,7 +41,7 @@ public:
|
|||||||
virtual Dictionary::Ptr GetConfigFields(void) const;
|
virtual Dictionary::Ptr GetConfigFields(void) const;
|
||||||
virtual Dictionary::Ptr GetStatusFields(void) const;
|
virtual Dictionary::Ptr GetStatusFields(void) const;
|
||||||
|
|
||||||
virtual void OnConfigUpdate(void);
|
virtual void OnConfigUpdate(void);
|
||||||
|
|
||||||
virtual bool IsStatusAttribute(const String& attribute) const;
|
virtual bool IsStatusAttribute(const String& attribute) const;
|
||||||
};
|
};
|
||||||
|
@ -190,7 +190,7 @@ public:
|
|||||||
|
|
||||||
static void RemoveDowntime(const String& id, bool cancelled, const MessageOrigin& origin = MessageOrigin());
|
static void RemoveDowntime(const String& id, bool cancelled, const MessageOrigin& origin = MessageOrigin());
|
||||||
|
|
||||||
void TriggerDowntimes(void);
|
void TriggerDowntimes(void);
|
||||||
static void TriggerDowntime(const String& id);
|
static void TriggerDowntime(const String& id);
|
||||||
|
|
||||||
static String GetDowntimeIDFromLegacyID(int id);
|
static String GetDowntimeIDFromLegacyID(int id);
|
||||||
|
@ -37,25 +37,25 @@ struct CheckableCheckStatistics {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct ServiceStatistics {
|
struct ServiceStatistics {
|
||||||
double services_ok;
|
double services_ok;
|
||||||
double services_warning;
|
double services_warning;
|
||||||
double services_critical;
|
double services_critical;
|
||||||
double services_unknown;
|
double services_unknown;
|
||||||
double services_pending;
|
double services_pending;
|
||||||
double services_unreachable;
|
double services_unreachable;
|
||||||
double services_flapping;
|
double services_flapping;
|
||||||
double services_in_downtime;
|
double services_in_downtime;
|
||||||
double services_acknowledged;
|
double services_acknowledged;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct HostStatistics {
|
struct HostStatistics {
|
||||||
double hosts_up;
|
double hosts_up;
|
||||||
double hosts_down;
|
double hosts_down;
|
||||||
double hosts_unreachable;
|
double hosts_unreachable;
|
||||||
double hosts_pending;
|
double hosts_pending;
|
||||||
double hosts_flapping;
|
double hosts_flapping;
|
||||||
double hosts_in_downtime;
|
double hosts_in_downtime;
|
||||||
double hosts_acknowledged;
|
double hosts_acknowledged;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -79,12 +79,12 @@ public:
|
|||||||
static void UpdatePassiveServiceChecksStatistics(long tv, int num);
|
static void UpdatePassiveServiceChecksStatistics(long tv, int num);
|
||||||
static int GetPassiveServiceChecksStatistics(long timespan);
|
static int GetPassiveServiceChecksStatistics(long timespan);
|
||||||
|
|
||||||
static CheckableCheckStatistics CalculateHostCheckStats(void);
|
static CheckableCheckStatistics CalculateHostCheckStats(void);
|
||||||
static CheckableCheckStatistics CalculateServiceCheckStats(void);
|
static CheckableCheckStatistics CalculateServiceCheckStats(void);
|
||||||
static HostStatistics CalculateHostStats(void);
|
static HostStatistics CalculateHostStats(void);
|
||||||
static ServiceStatistics CalculateServiceStats(void);
|
static ServiceStatistics CalculateServiceStats(void);
|
||||||
|
|
||||||
static std::pair<Dictionary::Ptr, Dictionary::Ptr> GetFeatureStats(void);
|
static std::pair<Dictionary::Ptr, Dictionary::Ptr> GetFeatureStats(void);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CIB(void);
|
CIB(void);
|
||||||
|
@ -314,8 +314,8 @@ int CompatUtility::GetCheckableIsAcknowledged(const Checkable::Ptr& checkable)
|
|||||||
|
|
||||||
int CompatUtility::GetCheckableNoMoreNotifications(const Checkable::Ptr& checkable)
|
int CompatUtility::GetCheckableNoMoreNotifications(const Checkable::Ptr& checkable)
|
||||||
{
|
{
|
||||||
if (CompatUtility::GetCheckableNotificationNotificationInterval(checkable) == 0 && !checkable->GetVolatile())
|
if (CompatUtility::GetCheckableNotificationNotificationInterval(checkable) == 0 && !checkable->GetVolatile())
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -49,7 +49,7 @@ public:
|
|||||||
static int GetHostNotifyOnUnreachable(const Host::Ptr& host);
|
static int GetHostNotifyOnUnreachable(const Host::Ptr& host);
|
||||||
|
|
||||||
/* service */
|
/* service */
|
||||||
static String GetCheckableCommandArgs(const Checkable::Ptr& checkable);
|
static String GetCheckableCommandArgs(const Checkable::Ptr& checkable);
|
||||||
static int GetCheckableCheckType(const Checkable::Ptr& checkable);
|
static int GetCheckableCheckType(const Checkable::Ptr& checkable);
|
||||||
static double GetCheckableCheckInterval(const Checkable::Ptr& checkable);
|
static double GetCheckableCheckInterval(const Checkable::Ptr& checkable);
|
||||||
static double GetCheckableRetryInterval(const Checkable::Ptr& checkable);
|
static double GetCheckableRetryInterval(const Checkable::Ptr& checkable);
|
||||||
@ -62,7 +62,7 @@ public:
|
|||||||
static int GetCheckableEventHandlerEnabled(const Checkable::Ptr& checkable);
|
static int GetCheckableEventHandlerEnabled(const Checkable::Ptr& checkable);
|
||||||
static int GetCheckableFlapDetectionEnabled(const Checkable::Ptr& checkable);
|
static int GetCheckableFlapDetectionEnabled(const Checkable::Ptr& checkable);
|
||||||
static int GetCheckableIsFlapping(const Checkable::Ptr& checkable);
|
static int GetCheckableIsFlapping(const Checkable::Ptr& checkable);
|
||||||
static int GetCheckableIsReachable(const Checkable::Ptr& checkable);
|
static int GetCheckableIsReachable(const Checkable::Ptr& checkable);
|
||||||
static String GetCheckablePercentStateChange(const Checkable::Ptr& checkable);
|
static String GetCheckablePercentStateChange(const Checkable::Ptr& checkable);
|
||||||
static int GetCheckableProcessPerformanceData(const Checkable::Ptr& checkable);
|
static int GetCheckableProcessPerformanceData(const Checkable::Ptr& checkable);
|
||||||
|
|
||||||
|
@ -127,10 +127,10 @@ private:
|
|||||||
static void ChangeSvcModattr(double time, const std::vector<String>& arguments);
|
static void ChangeSvcModattr(double time, const std::vector<String>& arguments);
|
||||||
static void ChangeHostModattr(double time, const std::vector<String>& arguments);
|
static void ChangeHostModattr(double time, const std::vector<String>& arguments);
|
||||||
|
|
||||||
static void ChangeUserModattr(double time, const std::vector<String>& arguments);
|
static void ChangeUserModattr(double time, const std::vector<String>& arguments);
|
||||||
static void ChangeCheckcommandModattr(double time, const std::vector<String>& arguments);
|
static void ChangeCheckcommandModattr(double time, const std::vector<String>& arguments);
|
||||||
static void ChangeEventcommandModattr(double time, const std::vector<String>& arguments);
|
static void ChangeEventcommandModattr(double time, const std::vector<String>& arguments);
|
||||||
static void ChangeNotificationcommandModattr(double time, const std::vector<String>& arguments);
|
static void ChangeNotificationcommandModattr(double time, const std::vector<String>& arguments);
|
||||||
|
|
||||||
static void ChangeNormalSvcCheckInterval(double time, const std::vector<String>& arguments);
|
static void ChangeNormalSvcCheckInterval(double time, const std::vector<String>& arguments);
|
||||||
static void ChangeNormalHostCheckInterval(double time, const std::vector<String>& arguments);
|
static void ChangeNormalHostCheckInterval(double time, const std::vector<String>& arguments);
|
||||||
@ -148,12 +148,12 @@ private:
|
|||||||
static void ChangeMaxSvcCheckAttempts(double time, const std::vector<String>& arguments);
|
static void ChangeMaxSvcCheckAttempts(double time, const std::vector<String>& arguments);
|
||||||
static void ChangeHostCheckTimeperiod(double time, const std::vector<String>& arguments);
|
static void ChangeHostCheckTimeperiod(double time, const std::vector<String>& arguments);
|
||||||
static void ChangeSvcCheckTimeperiod(double time, const std::vector<String>& arguments);
|
static void ChangeSvcCheckTimeperiod(double time, const std::vector<String>& arguments);
|
||||||
static void ChangeCustomHostVar(double time, const std::vector<String>& arguments);
|
static void ChangeCustomHostVar(double time, const std::vector<String>& arguments);
|
||||||
static void ChangeCustomSvcVar(double time, const std::vector<String>& arguments);
|
static void ChangeCustomSvcVar(double time, const std::vector<String>& arguments);
|
||||||
static void ChangeCustomUserVar(double time, const std::vector<String>& arguments);
|
static void ChangeCustomUserVar(double time, const std::vector<String>& arguments);
|
||||||
static void ChangeCustomCheckcommandVar(double time, const std::vector<String>& arguments);
|
static void ChangeCustomCheckcommandVar(double time, const std::vector<String>& arguments);
|
||||||
static void ChangeCustomEventcommandVar(double time, const std::vector<String>& arguments);
|
static void ChangeCustomEventcommandVar(double time, const std::vector<String>& arguments);
|
||||||
static void ChangeCustomNotificationcommandVar(double time, const std::vector<String>& arguments);
|
static void ChangeCustomNotificationcommandVar(double time, const std::vector<String>& arguments);
|
||||||
|
|
||||||
static void EnableHostgroupHostNotifications(double time, const std::vector<String>& arguments);
|
static void EnableHostgroupHostNotifications(double time, const std::vector<String>& arguments);
|
||||||
static void EnableHostgroupSvcNotifications(double time, const std::vector<String>& arguments);
|
static void EnableHostgroupSvcNotifications(double time, const std::vector<String>& arguments);
|
||||||
@ -165,8 +165,8 @@ private:
|
|||||||
static void DisableServicegroupSvcNotifications(double time, const std::vector<String>& arguments);
|
static void DisableServicegroupSvcNotifications(double time, const std::vector<String>& arguments);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static void ChangeCommandModattrInternal(const Command::Ptr& command, int mod_attr);
|
static void ChangeCommandModattrInternal(const Command::Ptr& command, int mod_attr);
|
||||||
static void ChangeCustomCommandVarInternal(const Command::Ptr& command, const String& name, const Value& value);
|
static void ChangeCustomCommandVarInternal(const Command::Ptr& command, const String& name, const Value& value);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -34,10 +34,10 @@ INITIALIZE_ONCE(&HostGroup::RegisterObjectRuleHandler);
|
|||||||
|
|
||||||
void HostGroup::RegisterObjectRuleHandler(void)
|
void HostGroup::RegisterObjectRuleHandler(void)
|
||||||
{
|
{
|
||||||
ObjectRule::RegisterType("HostGroup", &HostGroup::EvaluateObjectRules);
|
ObjectRule::RegisterType("HostGroup", &HostGroup::EvaluateObjectRules);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HostGroup::EvaluateObjectRuleOne(const Host::Ptr host, const ObjectRule& rule)
|
bool HostGroup::EvaluateObjectRuleOne(const Host::Ptr& host, const ObjectRule& rule)
|
||||||
{
|
{
|
||||||
DebugInfo di = rule.GetDebugInfo();
|
DebugInfo di = rule.GetDebugInfo();
|
||||||
|
|
||||||
|
@ -44,17 +44,17 @@ public:
|
|||||||
void AddMember(const Host::Ptr& host);
|
void AddMember(const Host::Ptr& host);
|
||||||
void RemoveMember(const Host::Ptr& host);
|
void RemoveMember(const Host::Ptr& host);
|
||||||
|
|
||||||
bool ResolveGroupMembership(Host::Ptr const& host, bool add = true, int rstack = 0);
|
bool ResolveGroupMembership(const Host::Ptr& host, bool add = true, int rstack = 0);
|
||||||
|
|
||||||
static void RegisterObjectRuleHandler(void);
|
static void RegisterObjectRuleHandler(void);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
mutable boost::mutex m_HostGroupMutex;
|
mutable boost::mutex m_HostGroupMutex;
|
||||||
std::set<Host::Ptr> m_Members;
|
std::set<Host::Ptr> m_Members;
|
||||||
|
|
||||||
static bool EvaluateObjectRuleOne(const Host::Ptr host, const ObjectRule& rule);
|
static bool EvaluateObjectRuleOne(const Host::Ptr& host, const ObjectRule& rule);
|
||||||
static void EvaluateObjectRule(const ObjectRule& rule);
|
static void EvaluateObjectRule(const ObjectRule& rule);
|
||||||
static void EvaluateObjectRules(const std::vector<ObjectRule>& rules);
|
static void EvaluateObjectRules(const std::vector<ObjectRule>& rules);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -21,8 +21,8 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
%type IcingaStatusWriter {
|
%type IcingaStatusWriter {
|
||||||
%attribute %string "status_path",
|
%attribute %string "status_path",
|
||||||
%attribute %number "update_interval"
|
%attribute %number "update_interval"
|
||||||
}
|
}
|
||||||
|
|
||||||
%type Checkable {
|
%type Checkable {
|
||||||
|
@ -42,13 +42,13 @@ public:
|
|||||||
|
|
||||||
int Main(void);
|
int Main(void);
|
||||||
|
|
||||||
static Value StatsFunc(Dictionary::Ptr& status, Dictionary::Ptr& perfdata);
|
static Value StatsFunc(Dictionary::Ptr& status, Dictionary::Ptr& perfdata);
|
||||||
|
|
||||||
static IcingaApplication::Ptr GetInstance(void);
|
static IcingaApplication::Ptr GetInstance(void);
|
||||||
|
|
||||||
String GetPidPath(void) const;
|
String GetPidPath(void) const;
|
||||||
Dictionary::Ptr GetVars(void) const;
|
Dictionary::Ptr GetVars(void) const;
|
||||||
String GetNodeName(void) const;
|
String GetNodeName(void) const;
|
||||||
|
|
||||||
virtual bool ResolveMacro(const String& macro, const CheckResult::Ptr& cr, String *result) const;
|
virtual bool ResolveMacro(const String& macro, const CheckResult::Ptr& cr, String *result) const;
|
||||||
|
|
||||||
|
@ -143,29 +143,29 @@ void IcingaStatusWriter::StatusTimerHandler(void)
|
|||||||
{
|
{
|
||||||
Log(LogNotice, "IcingaStatusWriter", "Writing status.json file");
|
Log(LogNotice, "IcingaStatusWriter", "Writing status.json file");
|
||||||
|
|
||||||
String statuspath = GetStatusPath();
|
String statuspath = GetStatusPath();
|
||||||
String statuspathtmp = statuspath + ".tmp"; /* XXX make this a global definition */
|
String statuspathtmp = statuspath + ".tmp"; /* XXX make this a global definition */
|
||||||
|
|
||||||
std::ofstream statusfp;
|
std::ofstream statusfp;
|
||||||
statusfp.open(statuspathtmp.CStr(), std::ofstream::out | std::ofstream::trunc);
|
statusfp.open(statuspathtmp.CStr(), std::ofstream::out | std::ofstream::trunc);
|
||||||
|
|
||||||
statusfp << std::fixed;
|
statusfp << std::fixed;
|
||||||
|
|
||||||
statusfp << JsonSerialize(GetStatusData());
|
statusfp << JsonSerialize(GetStatusData());
|
||||||
|
|
||||||
statusfp.close();
|
statusfp.close();
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
_unlink(statuspath.CStr());
|
_unlink(statuspath.CStr());
|
||||||
#endif /* _WIN32 */
|
#endif /* _WIN32 */
|
||||||
|
|
||||||
if (rename(statuspathtmp.CStr(), statuspath.CStr()) < 0) {
|
if (rename(statuspathtmp.CStr(), statuspath.CStr()) < 0) {
|
||||||
BOOST_THROW_EXCEPTION(posix_error()
|
BOOST_THROW_EXCEPTION(posix_error()
|
||||||
<< boost::errinfo_api_function("rename")
|
<< boost::errinfo_api_function("rename")
|
||||||
<< boost::errinfo_errno(errno)
|
<< boost::errinfo_errno(errno)
|
||||||
<< boost::errinfo_file_name(statuspathtmp));
|
<< boost::errinfo_file_name(statuspathtmp));
|
||||||
}
|
}
|
||||||
|
|
||||||
Log(LogNotice, "IcingaStatusWriter", "Finished writing status.json file");
|
Log(LogNotice, "IcingaStatusWriter", "Finished writing status.json file");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,10 +34,10 @@ INITIALIZE_ONCE(&ServiceGroup::RegisterObjectRuleHandler);
|
|||||||
|
|
||||||
void ServiceGroup::RegisterObjectRuleHandler(void)
|
void ServiceGroup::RegisterObjectRuleHandler(void)
|
||||||
{
|
{
|
||||||
ObjectRule::RegisterType("ServiceGroup", &ServiceGroup::EvaluateObjectRules);
|
ObjectRule::RegisterType("ServiceGroup", &ServiceGroup::EvaluateObjectRules);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ServiceGroup::EvaluateObjectRuleOne(const Service::Ptr service, const ObjectRule& rule)
|
bool ServiceGroup::EvaluateObjectRuleOne(const Service::Ptr& service, const ObjectRule& rule)
|
||||||
{
|
{
|
||||||
DebugInfo di = rule.GetDebugInfo();
|
DebugInfo di = rule.GetDebugInfo();
|
||||||
|
|
||||||
|
@ -44,17 +44,17 @@ public:
|
|||||||
void AddMember(const Service::Ptr& service);
|
void AddMember(const Service::Ptr& service);
|
||||||
void RemoveMember(const Service::Ptr& service);
|
void RemoveMember(const Service::Ptr& service);
|
||||||
|
|
||||||
bool ResolveGroupMembership(Service::Ptr const& service, bool add = true, int rstack = 0);
|
bool ResolveGroupMembership(const Service::Ptr& service, bool add = true, int rstack = 0);
|
||||||
|
|
||||||
static void RegisterObjectRuleHandler(void);
|
static void RegisterObjectRuleHandler(void);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
mutable boost::mutex m_ServiceGroupMutex;
|
mutable boost::mutex m_ServiceGroupMutex;
|
||||||
std::set<Service::Ptr> m_Members;
|
std::set<Service::Ptr> m_Members;
|
||||||
|
|
||||||
static bool EvaluateObjectRuleOne(const Service::Ptr service, const ObjectRule& rule);
|
static bool EvaluateObjectRuleOne(const Service::Ptr& service, const ObjectRule& rule);
|
||||||
static void EvaluateObjectRule(const ObjectRule& rule);
|
static void EvaluateObjectRule(const ObjectRule& rule);
|
||||||
static void EvaluateObjectRules(const std::vector<ObjectRule>& rules);
|
static void EvaluateObjectRules(const std::vector<ObjectRule>& rules);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -34,10 +34,10 @@ INITIALIZE_ONCE(&UserGroup::RegisterObjectRuleHandler);
|
|||||||
|
|
||||||
void UserGroup::RegisterObjectRuleHandler(void)
|
void UserGroup::RegisterObjectRuleHandler(void)
|
||||||
{
|
{
|
||||||
ObjectRule::RegisterType("UserGroup", &UserGroup::EvaluateObjectRules);
|
ObjectRule::RegisterType("UserGroup", &UserGroup::EvaluateObjectRules);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool UserGroup::EvaluateObjectRuleOne(const User::Ptr user, const ObjectRule& rule)
|
bool UserGroup::EvaluateObjectRuleOne(const User::Ptr& user, const ObjectRule& rule)
|
||||||
{
|
{
|
||||||
DebugInfo di = rule.GetDebugInfo();
|
DebugInfo di = rule.GetDebugInfo();
|
||||||
|
|
||||||
|
@ -44,17 +44,17 @@ public:
|
|||||||
void AddMember(const User::Ptr& user);
|
void AddMember(const User::Ptr& user);
|
||||||
void RemoveMember(const User::Ptr& user);
|
void RemoveMember(const User::Ptr& user);
|
||||||
|
|
||||||
bool ResolveGroupMembership(User::Ptr const& user, bool add = true, int rstack = 0);
|
bool ResolveGroupMembership(const User::Ptr& user, bool add = true, int rstack = 0);
|
||||||
|
|
||||||
static void RegisterObjectRuleHandler(void);
|
static void RegisterObjectRuleHandler(void);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
mutable boost::mutex m_UserGroupMutex;
|
mutable boost::mutex m_UserGroupMutex;
|
||||||
std::set<User::Ptr> m_Members;
|
std::set<User::Ptr> m_Members;
|
||||||
|
|
||||||
static bool EvaluateObjectRuleOne(const User::Ptr user, const ObjectRule& rule);
|
static bool EvaluateObjectRuleOne(const User::Ptr& user, const ObjectRule& rule);
|
||||||
static void EvaluateObjectRule(const ObjectRule& rule);
|
static void EvaluateObjectRule(const ObjectRule& rule);
|
||||||
static void EvaluateObjectRules(const std::vector<ObjectRule>& rules);
|
static void EvaluateObjectRules(const std::vector<ObjectRule>& rules);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
ClusterCheckTask(void);
|
ClusterCheckTask(void);
|
||||||
static String FormatArray(const Array::Ptr& arr);
|
static String FormatArray(const Array::Ptr& arr);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
PluginEventTask(void);
|
PluginEventTask(void);
|
||||||
|
|
||||||
static void ProcessFinishedHandler(const Checkable::Ptr& checkable, const Value& command, const ProcessResult& pr);
|
static void ProcessFinishedHandler(const Checkable::Ptr& checkable, const Value& command, const ProcessResult& pr);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user