]> granicus.if.org Git - icinga2/commitdiff
Livestatus: Add servive_checks(_rate) columns to status table.
authorMichael Friedrich <michael.friedrich@netways.de>
Thu, 7 Nov 2013 16:29:45 +0000 (17:29 +0100)
committerMichael Friedrich <michael.friedrich@netways.de>
Thu, 7 Nov 2013 16:29:45 +0000 (17:29 +0100)
Refs #4655
Refs #2762

components/livestatus/query.cpp
components/livestatus/query.h
components/livestatus/statustable.cpp
components/livestatus/statustable.h

index de43a20762dbba018b027519e344832f17c61f07..c768d22ff0d17e4042fd9408c94306d4cdf19788 100644 (file)
@@ -47,7 +47,7 @@ using namespace livestatus;
 static int l_ExternalCommands = 0;
 static boost::mutex l_QueryMutex;
 
-Query::Query(const std::vector<String>& lines, const String& log_path)
+Query::Query(const std::vector<String>& lines, const String& compat_log_path)
        : m_KeepAlive(false), m_OutputFormat("csv"), m_ColumnHeaders(true), m_Limit(-1),
          m_LogTimeFrom(0), m_LogTimeUntil(static_cast<long>(Utility::GetTime()))
 {
@@ -64,7 +64,7 @@ Query::Query(const std::vector<String>& lines, const String& log_path)
        }
        Log(LogDebug, "livestatus", msg);
 
-       m_CompatLogPath = log_path;
+       m_CompatLogPath = compat_log_path;
 
        /* default separators */
        m_Separators.push_back("\n");
index adb3bd5e399bf908213f24160ceab86f141f188d..d7cdbb02ba0ce5186de582194adc991c727ca044 100644 (file)
@@ -47,7 +47,7 @@ class Query : public Object
 public:
        DECLARE_PTR_TYPEDEFS(Query);
 
-       Query(const std::vector<String>& lines, const String& log_path);
+       Query(const std::vector<String>& lines, const String& compat_log_path);
 
        bool Execute(const Stream::Ptr& stream);
 
index 36824e117ff842bf2f1a0075a41606b734048cdf..eed18ec6b17e0fea4421c588176fd2def78bc251 100644 (file)
@@ -47,8 +47,8 @@ void StatusTable::AddColumns(Table *table, const String& prefix,
        table->AddColumn(prefix + "connections", Column(&StatusTable::ConnectionsAccessor, objectAccessor));
        table->AddColumn(prefix + "connections_rate", Column(&StatusTable::ConnectionsRateAccessor, objectAccessor));
 
-       table->AddColumn(prefix + "service_checks", Column(&Table::ZeroAccessor, objectAccessor));
-       table->AddColumn(prefix + "service_checks_rate", Column(&Table::ZeroAccessor, objectAccessor));
+       table->AddColumn(prefix + "service_checks", Column(&StatusTable::ServiceChecksAccessor, objectAccessor));
+       table->AddColumn(prefix + "service_checks_rate", Column(&StatusTable::ServiceChecksRateAccessor, objectAccessor));
 
        table->AddColumn(prefix + "host_checks", Column(&Table::ZeroAccessor, objectAccessor));
        table->AddColumn(prefix + "host_checks_rate", Column(&Table::ZeroAccessor, objectAccessor));
@@ -122,6 +122,18 @@ Value StatusTable::ConnectionsRateAccessor(const Value& row)
        return (LivestatusListener::GetConnections() / (Utility::GetTime() - Application::GetStartTime()));
 }
 
+Value StatusTable::ServiceChecksAccessor(const Value& row)
+{
+       long timespan = static_cast<long>(Utility::GetTime() - Application::GetStartTime());
+       return CIB::GetActiveChecksStatistics(timespan);
+}
+
+Value StatusTable::ServiceChecksRateAccessor(const Value& row)
+{
+       long timespan = static_cast<long>(Utility::GetTime() - Application::GetStartTime());
+       return (CIB::GetActiveChecksStatistics(timespan) / (Utility::GetTime() - Application::GetStartTime()));
+}
+
 Value StatusTable::ExternalCommandsAccessor(const Value& row)
 {
        return Query::GetExternalCommands();
index b8584df55d3ad210002bb393acc03bf202b713c5..6d893d258c69ff0efab466ec096f580b2a084eca 100644 (file)
@@ -47,6 +47,8 @@ protected:
 
        static Value ConnectionsAccessor(const Value& row);
        static Value ConnectionsRateAccessor(const Value& row);
+        static Value ServiceChecksAccessor(const Value& row);
+        static Value ServiceChecksRateAccessor(const Value& row);
        static Value ExternalCommandsAccessor(const Value& row);
        static Value ExternalCommandsRateAccessor(const Value& row);
        static Value NagiosPidAccessor(const Value& row);