From b2a53cb68658ec297d8b66f4c333a287bf70bc37 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jos=C3=A9=20Bollo?= Date: Sun, 27 Aug 2017 14:48:05 +0200 Subject: [PATCH] monitoring: Add option --monitoring MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Installs basic interface for monitoring and add the option --monitoring / -M to activate the alias /monitoring. This makes the page /monitoring/monitor.html available. Change-Id: Iebe0959f0a5e7c396fe7ce6862d0f9c883733824 Signed-off-by: José Bollo --- CMakeLists.txt | 14 ++++++++++++++ src/afb-config.c | 19 +++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5a8d2d2a..eb2d2d12 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -112,6 +112,20 @@ SET(link_libraries SET(binding_install_dir ${CMAKE_INSTALL_FULL_LIBDIR}/afb) +########################################################################### +# activates the monitoring by default +set(INCLUDE_MONITORING ON CACHE BOOL "Activates installation of monitoring") +if(INCLUDE_MONITORING) + add_definitions(-DWITH_MONITORING_OTPION) + INSTALL(DIRECTORY + ${CMAKE_CURRENT_SOURCE_DIR}/test/monitoring + DESTINATION + ${binding_install_dir} + ) +endif() + +########################################################################### + ADD_SUBDIRECTORY(src) ADD_SUBDIRECTORY(include) ADD_SUBDIRECTORY(bindings) diff --git a/src/afb-config.c b/src/afb-config.c index c22dbb5e..2a11458f 100644 --- a/src/afb-config.c +++ b/src/afb-config.c @@ -90,6 +90,9 @@ #define SET_TRACEEVT 'E' #define SET_EXEC 'e' #define DISPLAY_HELP 'h' +#if defined(WITH_MONITORING_OTPION) +#define SET_MONITORING 'M' +#endif #define SET_TCP_PORT 'p' #define SET_QUIET 'q' #define SET_RNDTOKEN 'r' @@ -103,6 +106,9 @@ const char shortopts[] = "c:D:E:ehp:qrT:t:u:Vvw:" +#if defined(WITH_MONITORING_OTPION) + "M" +#endif ; // Command line structure hold cli --command + help text @@ -167,6 +173,9 @@ static AFB_options cliOptions[] = { {SET_NO_HTTPD, 0, "no-httpd", "Forbids HTTP service"}, {SET_EXEC, 0, "exec", "Execute the remaining arguments"}, +#if defined(WITH_MONITORING_OTPION) + {SET_MONITORING, 0, "monitoring", "enable HTTP monitoring at /monitoring/monitor.html"}, +#endif {0, 0, NULL, NULL} /* *INDENT-ON* */ }; @@ -570,7 +579,12 @@ static void parse_arguments(int argc, char **argv, struct afb_config *config) case SET_RNDTOKEN: config->token = random_token(); + +#if defined(WITH_MONITORING_OTPION) + case SET_MONITORING: + config->monitoring = 1; break; +#endif case DISPLAY_VERSION: noarg(optc); @@ -635,6 +649,11 @@ static void config_set_default(struct afb_config *config) if (config->ldpaths == NULL && config->weak_ldpaths == NULL && !config->no_ldpaths) list_add(&config->ldpaths, BINDING_INSTALL_DIR); +#if defined(WITH_MONITORING_OTPION) + if (config->monitoring) + list_add(&config->aliases, strdup("/monitoring:"BINDING_INSTALL_DIR"/monitoring")); +#endif + // if no config dir create a default path from uploaddir if (config->console == NULL) { config->console = malloc(512); -- 2.16.6