Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Monitor implemented (not tested).

  • Loading branch information...
commit 99bc1314b48a819e562c63a6661a2d5ca05b6527 1 parent 54ef9ea
@daniperez authored
View
7 client/src/main/c++/CMakeLists.txt
@@ -78,6 +78,7 @@ set ( lib_SOURCES
build_log.cpp build_send.cpp build_cat.cpp
wait.cpp
config.cpp config_add.cpp config_use.cpp config_remove.cpp
+ monitor.cpp
)
add_library ( magritlib SHARED ${lib_SOURCES} )
target_link_libraries ( magritlib ${Boost_LIBRARIES} )
@@ -110,6 +111,12 @@ add_executable ( magrit-cat-build main.cpp )
target_link_libraries ( magrit-cat-build magritlib )
set_target_properties ( magrit-cat-build PROPERTIES COMPILE_DEFINITIONS "MAGRIT_BUILD_CAT" )
# -------------------------------------------------------------------
+# `---> magrit-monitor
+# -------------------------------------------------------------------
+add_executable ( magrit-monitor main.cpp )
+target_link_libraries ( magrit-monitor magritlib )
+set_target_properties ( magrit-monitor PROPERTIES COMPILE_DEFINITIONS "MAGRIT_MONITOR" )
+# -------------------------------------------------------------------
# `---> tests
# -------------------------------------------------------------------
enable_testing()
View
4 client/src/main/c++/main.cpp
@@ -27,6 +27,8 @@
#include "build_cat.hpp"
#elif MAGRIT_WAIT
#include "wait.hpp"
+#elif MAGRIT_MONITOR
+#include "monitor.hpp"
#else
#include "magrit.hpp"
#endif
@@ -47,6 +49,8 @@ int main ( int argc, char** argv )
magrit::build_cat ma ( nullptr );
#elif MAGRIT_WAIT
magrit::wait ma ( nullptr );
+ #elif MAGRIT_MONITOR
+ magrit::monitor ma ( nullptr );
#else
magrit::magrit ma;
#endif
View
43 client/src/main/c++/monitor.cpp
@@ -26,7 +26,14 @@
const char*
magrit::monitor::get_name() const
{
- return "monitor";
+ if ( is_executable() )
+ {
+ return "magrit-monitor";
+ }
+ else
+ {
+ return "monitor";
+ }
}
/////////////////////////////////////////////////////////////////////////
@@ -35,6 +42,40 @@ const char* magrit::monitor::get_description() const
return "<description to be written>";
}
+/////////////////////////////////////////////////////////////////////////
+void
+magrit::monitor::process_parsed_options
+(
+ const std::vector<std::string>& arguments,
+ const boost::program_options::variables_map& vm,
+ const std::vector<std::string>& unrecognized_arguments,
+ bool allow_zero_arguments
+)
+const
+{
+ if ( arguments.size() != 0 )
+ {
+ throw magrit::option_not_recognized ( "monitor doesn't accept any options" );
+ }
+ do_monitor ( get_magrit_port(), get_magrit_connection_info() );
+}
+/////////////////////////////////////////////////////////////////////////
+void
+magrit::monitor::do_monitor
+ ( int magrit_port, const std::string& magrit_conn_str )
+{
+ start_ssh_process
+ (
+ magrit_port,
+ magrit_conn_str,
+ std::vector < std::string > { "magrit", "monitor" },
+ bp_close(),
+ bp_inherit(),
+ bp_inherit(),
+ [](const std::string& line){},
+ true
+ );
+}
View
50 client/src/main/c++/monitor.hpp
@@ -26,20 +26,44 @@
namespace magrit
{
- struct monitor : public generic_command
+ class monitor : public generic_command
{
- monitor ( generic_command* previous_subcommand )
- : generic_command ( previous_subcommand ) {}
-
- /**
- * @see generic_command::get_name
- */
- const char* get_name() const override;
-
- /**
- * @see generic_command::get_description
- */
- const char* get_description() const override;
+ public:
+
+ monitor ( generic_command* previous_subcommand )
+ : generic_command ( previous_subcommand ) {}
+
+ /**
+ * @see generic_command::get_name
+ */
+ const char* get_name() const override;
+
+ /**
+ * @see generic_command::get_description
+ */
+ const char* get_description() const override;
+
+ /**
+ * Starts monitor command in the given server.
+ */
+ static
+ void do_monitor
+ ( int magrit_port, const std::string& magrit_conn_str );
+
+ protected:
+
+ /**
+ * @see generic_command::process_parsed_options
+ */
+ void
+ process_parsed_options
+ (
+ const std::vector<std::string>& arguments,
+ const boost::program_options::variables_map& vm,
+ const std::vector<std::string>& unrecognized_arguments,
+ bool allow_zero_arguments
+ )
+ const override;
};
}
#endif
Please sign in to comment.
Something went wrong with that request. Please try again.