---
src/CMakeLists.txt | 6 ++-
src/log/matahari-log.cpp | 101 ++++++++++++++++++++++++++++++++++++++++++++++
src/schema.xml | 38 +++++++++++++++++
3 files changed, 144 insertions(+), 1 deletions(-)
create mode 100644 src/log/matahari-log.cpp
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 9664781..ee8906d 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -15,8 +15,9 @@ include_directories("${CMAKE_CURRENT_SOURCE_DIR}/include")
set(M_HOST "matahari-hostd")
set(M_NET "matahari-netd")
set(M_SRV "matahari-serviced")
+set(M_LOG "matahari-logd")
-set(DAEMONS ${M_HOST} ${M_NET} ${M_SRV})
+set(DAEMONS ${M_HOST} ${M_NET} ${M_SRV} ${M_LOG})
file(GLOB SCHEMAS "${CMAKE_CURRENT_SOURCE_DIR}/*.xml")
@@ -29,6 +30,7 @@ add_definitions(-DMATAHARI_BROKER="${MATAHARI_BROKER}")
set(SCHEMA_SOURCES
${CMAKE_CURRENT_BINARY_DIR}/qmf/com/redhat/matahari/Host.cpp
${CMAKE_CURRENT_BINARY_DIR}/qmf/com/redhat/matahari/Network.cpp
+ ${CMAKE_CURRENT_BINARY_DIR}/qmf/com/redhat/matahari/Logging.cpp
${CMAKE_CURRENT_BINARY_DIR}/qmf/com/redhat/matahari/Services.cpp
${CMAKE_CURRENT_BINARY_DIR}/qmf/com/redhat/matahari/Resources.cpp
${CMAKE_CURRENT_BINARY_DIR}/qmf/com/redhat/matahari/EventHeartbeat.cpp
@@ -61,6 +63,8 @@ add_executable(${M_NET} net/matahari-net.cpp ${SCHEMA_SOURCES}
${COMMON_SOURCE
add_executable(${M_SRV} service/matahari-srv.cpp ${SCHEMA_SOURCES} ${COMMON_SOURCES})
target_link_libraries(${M_HOST} msrv)
+add_executable(${M_LOG} log/matahari-log.cpp ${SCHEMA_SOURCES} ${COMMON_SOURCES})
+
foreach(daemon ${DAEMONS})
target_link_libraries(${daemon} mcommon)
if(WIN32)
diff --git a/src/log/matahari-log.cpp b/src/log/matahari-log.cpp
new file mode 100644
index 0000000..6b62ff4
--- /dev/null
+++ b/src/log/matahari-log.cpp
@@ -0,0 +1,101 @@
+/* matahari-log.cpp - Copyright (C) 2010 Red Hat, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA. A copy of the GNU General Public License is
+ * also available at
http://www.gnu.org/copyleft/gpl.html.
+ */
+
+#ifndef WIN32
+#include "config.h"
+#endif
+
+#include <string>
+#include <qpid/management/Manageable.h>
+#include <qpid/agent/ManagementAgent.h>
+#include "matahari/mh_agent.h"
+
+#include "qmf/com/redhat/matahari/Logging.h"
+#include "qmf/com/redhat/matahari/ArgsLoggingExtract_date_range.h"
+#include "qmf/com/redhat/matahari/ArgsLoggingExtract_pattern.h"
+#include "qmf/com/redhat/matahari/ArgsLoggingSystem_logfile.h"
+#include "qmf/com/redhat/matahari/ArgsLoggingTruncate_logfile.h"
+
+extern "C" {
+#include "matahari/logging.h"
+}
+
+class LogAgent : public MatahariAgent
+{
+ private:
+ ManagementAgent* _agent;
+ _qmf::Logging* _management_object;
+
+ public:
+ int setup(ManagementAgent* agent);
+ ManagementObject* GetManagementObject() const { return _management_object; }
+ status_t ManagementMethod(uint32_t method, Args& arguments, string&
text);
+};
+
+extern "C" {
+#include <stdlib.h>
+#include <string.h>
+};
+
+int
+main(int argc, char **argv)
+{
+ LogAgent agent;
+ int rc = agent.init(argc, argv);
+ while (rc == 0) {
+ qpid::sys::sleep(1);
+ }
+ return rc;
+}
+
+int
+LogAgent::setup(ManagementAgent* agent)
+{
+ this->_agent = agent;
+ this->_management_object = new _qmf::Logging(agent, this);
+ this->_management_object->set_hostname(get_hostname());
+
+ agent->addObject(this->_management_object);
+
+ return 0;
+}
+
+Manageable::status_t
+LogAgent::ManagementMethod(uint32_t method, Args& arguments, string& text)
+{
+ switch(method)
+ {
+ case _qmf::Logging::METHOD_EXTRACT_DATE_RANGE:
+
+ return Manageable::STATUS_OK;
+
+ case _qmf::Logging::METHOD_EXTRACT_PATTERN:
+
+ return Manageable::STATUS_OK;
+
+ case _qmf::Logging::METHOD_SYSTEM_LOGFILE:
+
+ return Manageable::STATUS_OK;
+
+ case _qmf::Logging::METHOD_TRUNCATE_LOGFILE:
+
+ return Manageable::STATUS_OK;
+
+ }
+ return Manageable::STATUS_NOT_IMPLEMENTED;
+}
diff --git a/src/schema.xml b/src/schema.xml
index ece5d0d..17b4110 100644
--- a/src/schema.xml
+++ b/src/schema.xml
@@ -239,4 +239,42 @@
</method-->
</class>
+ <class name="Logging">
+ <property name="hostname" type="sstr" access="RO"
desc="Hostname" index="y"/>
+
+ <method name="extract_date_range">
+ <arg name="filename" dir="I" type="lstr"
/>
+ <arg name="start" dir="I" type="absTime"
/>
+ <arg name="end" dir="I" type="absTime"
/>
+ <arg name="lines" dir="O" type="list"
/>
+ </method>
+ <method name="extract_pattern">
+ <arg name="filename" dir="I" type="lstr"
/>
+ <arg name="regex_list" dir="I" type="list"
/>
+ <arg name="lines" dir="O" type="list"
/>
+ </method>
+ <!-- What is the point of search_* methods?
+ output is list of tupples:
+ { filename (String), last_modified (Integer) }
+
https://fedorahosted.org/matahari/wiki/LoggingAPIs
+ It's not part of Ricci API which is used as justification
+
http://sources.redhat.com/cluster/conga/ricci_api/logging_api.html
+ method name="search_content">
+ <arg name="paths" dir="I" type="list"
/>
+ <arg name="regex" dir="I" type="sstr"
/>
+ <arg name="filenames" dir="O" type="list"
/>
+ </method>
+ method name="search_name">
+ <arg name="paths" dir="I" type="list"
/>
+ <arg name="regex_list" dir="I" type="list"
/>
+ <arg name="filenames" dir="O" type="list"
/>
+ </method -->
+ <method name="system_logfile">
+ <arg name="filename" dir="O" type="lstr"
/>
+ </method>
+ <method name="truncate_logfile">
+ <arg name="rc" dir="O" type="uint32" />
+ </method>
+ </class>
+
</schema>
--
1.7.2.3