From 85f564f2b4c580bc151d05559e6ed0614919da8a Mon Sep 17 00:00:00 2001 From: Christian Muck Date: Mon, 4 Jun 2012 09:08:52 +0200 Subject: [GDLT-90] Implemented systemd watchdog concept in dlt-system Signed-off-by: Christian Muck --- CMakeLists.txt | 23 +++- cmake/dlt_version.h.cmake | 24 ++++ src/CMakeLists.txt | 28 +++-- src/daemon/dlt-daemon.c | 14 +-- src/examples/dlt-example-filetransfer.c | 41 +++---- src/shared/dlt_common.c | 4 +- src/system/CMakeLists.txt | 8 +- src/system/dlt-system-options.c | 2 +- src/system/dlt-system-process-handling.c | 4 + src/system/dlt-system-watchdog.c | 197 +++++++++++++++++++++++++++++++ src/system/dlt-system.c | 26 +++- src/system/dlt-system.conf | 6 +- src/system/dlt-system.h | 3 + systemd/CMakeLists.txt | 40 +++++-- systemd/dlt-adaptor-udp.service.cmake | 28 +++++ systemd/dlt-example-user.service.cmake | 25 ++++ systemd/dlt-receive.service.cmake | 26 ++++ systemd/dlt-syslog.service.cmake | 25 ---- systemd/dlt-system.service.cmake | 31 +++++ systemd/dlt.service.cmake | 10 +- 20 files changed, 475 insertions(+), 90 deletions(-) create mode 100644 src/system/dlt-system-watchdog.c create mode 100644 systemd/dlt-adaptor-udp.service.cmake create mode 100644 systemd/dlt-example-user.service.cmake create mode 100644 systemd/dlt-receive.service.cmake delete mode 100755 systemd/dlt-syslog.service.cmake create mode 100755 systemd/dlt-system.service.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index eba6689..fc4de91 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,6 +19,7 @@ project( automotive-dlt ) mark_as_advanced( CMAKE_BACKWARDS_COMPATIBILITY) set( CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS TRUE ) +set( CMAKE_INSTALL_PREFIX "/usr" ) # Set version parameters set( DLT_MAJOR_VERSION 2) @@ -50,16 +51,20 @@ endif(NOT CMAKE_BUILD_TYPE) # Set of indiviual options option(BUILD_SHARED_LIBS "Set to OFF to build static libraries" ON ) -option(WITH_DLT_SHM_ENABLE "Set to ON to use shared memory as IPC - experimental" OFF ) +option(WITH_SYSTEMD "Set to ON to create unit files and systemd check on dlt-daemon startup" ON ) +option(WITH_SYSTEMD_WATCHDOG "Set to ON to use the systemd watchdog in dlt-daemon" ON) option(WITH_DOC "Set to ON to build documentation target" OFF ) -option(WITH_MAN "Set to ON to build man pages" OFF ) +option(WITH_MAN "Set to ON to build man pages" ON ) option(WITH_CHECK_CONFIG_FILE "Set to ON to create a configure file of CheckIncludeFiles and CheckFunctionExists " OFF ) option(WITH_TESTSCRIPTS "Set to ON to run CMakeLists.txt in testscripts" OFF ) -option(WITH_SYSTEMD "Set to ON to create unit files and systemd check on dlt-daemon startup" OFF ) -option(WITH_SYSTEMD_WATCHDOG "Set to ON to use the systemd watchdog in dlt-daemon" ON) option(WITH_GPROF "Set -pg to compile flags" OFF ) option(WITH_DLTTEST "Set to ON to build with modifications to test User-Daemon communication with corrupt messages" OFF) - +option(WITH_DLT_SHM_ENABLE "EXPERIMENTAL! Set to ON to use shared memory as IPC. EXPERIMENTAL!" OFF ) +option(WTIH_DLT_ADAPTOR "Set ton ON to build src/adaptor binaries" ON) +option(WITH_DLT_CONSOLE "Set ton ON to build src/console binaries" ON) +option(WITH_DLT_EXAMPLES "Set ton ON to build src/examples binaries" ON) +option(WITH_DLT_SYSTEM "Set ton ON to build src/system binaries" ON) +option(WITH_DLT_TESTS "Set ton ON to build src/test binaries" ON) # RPM settings set( GENIVI_RPM_RELEASE "1")#${DLT_REVISION}") set( LICENSE "Mozilla Public License Version 2.0" ) @@ -91,6 +96,7 @@ if(WITH_GPROF) endif(WITH_GPROF) add_definitions( "-Wall" ) +add_definitions( "-Wextra" ) configure_file(${CMAKE_SOURCE_DIR}/${PROJECT_NAME}.spec.in ${PROJECT_BINARY_DIR}/${PROJECT_NAME}.spec) configure_file(${CMAKE_SOURCE_DIR}/${PROJECT_NAME}.pc.in ${PROJECT_BINARY_DIR}/${PROJECT_NAME}.pc @ONLY) @@ -124,11 +130,16 @@ message( STATUS "WITH_SYSTEMD = ${WITH_SYSTEMD}" ) message( STATUS "WITH_SYSTEMD_WATCHDOG = ${WITH_SYSTEMD_WATCHDOG}" ) message( STATUS "WITH_DOC = ${WITH_DOC}" ) message( STATUS "WITH_MAN = ${WITH_MAN}" ) +message( STATUS "WTIH_DLT_ADAPTOR = ${WTIH_DLT_ADAPTOR}") +message( STATUS "WITH_DLT_CONSOLE = ${WITH_DLT_CONSOLE}") +message( STATUS "WITH_DLT_EXAMPLES = ${WITH_DLT_EXAMPLES}") +message( STATUS "WITH_DLT_SYSTEM = ${WITH_DLT_SYSTEM}") +message( STATUS "WITH_DLT_TESTS = ${WITH_DLT_TESTS}") message( STATUS "WITH_DLT_SHM_ENABLE = ${WITH_DLT_SHM_ENABLE}" ) +message( STATUS "WITH_DLTTEST = ${WITH_DLTTEST}" ) message( STATUS "WITH_CHECK_CONFIG_FILE = ${WITH_CHECK_CONFIG_FILE}" ) message( STATUS "WITH_TESTSCRIPTS = ${WITH_TESTSCRIPTS}" ) message( STATUS "WITH_GPROF = ${WITH_GPROF}" ) -message( STATUS "WITH_DLTTEST = ${WITH_DLTTEST}" ) message( STATUS "BUILD_SHARED_LIBS = ${BUILD_SHARED_LIBS}" ) message( STATUS "CMAKE_INSTALL_PREFIX = ${CMAKE_INSTALL_PREFIX}" ) message( STATUS "CMAKE_BUILD_TYPE = ${CMAKE_BUILD_TYPE}" ) diff --git a/cmake/dlt_version.h.cmake b/cmake/dlt_version.h.cmake index 949bf9e..ba94983 100755 --- a/cmake/dlt_version.h.cmake +++ b/cmake/dlt_version.h.cmake @@ -9,4 +9,28 @@ #define _DLT_PACKAGE_PATCH_LEVEL "@DLT_PATCH_LEVEL@" #define _DLT_PACKAGE_REVISION "@DLT_REVISION@" +#ifdef DLT_SYSTEMD_ENABLE +#define _DLT_SYSTEMD_ENABLE "+SYSTEMD" +#else +#define _DLT_SYSTEMD_ENABLE "-SYSTEMD" +#endif + +#ifdef DLT_SYSTEMD_WATCHDOG_ENABLE +#define _DLT_SYSTEMD_WATCHDOG_ENABLE "+SYSTEMD_WATCHDOG" +#else +#define _DLT_SYSTEMD_WATCHDOG_ENABLE "-SYSTEMD_WATCHDOG" +#endif + +#ifdef DLT_TEST_ENABLE +#define _DLT_TEST_ENABLE "+TEST" +#else +#define _DLT_TEST_ENABLE "-TEST" +#endif + +#ifdef DLT_SHM_ENABLE +#define _DLT_SHM_ENABLE "+SHM" +#else +#define _DLT_SHM_ENABLE "-SHM" +#endif + #endif diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index e7b84c0..a288381 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -14,11 +14,25 @@ # @licence end@ ######## -ADD_SUBDIRECTORY( lib ) -ADD_SUBDIRECTORY( console ) -ADD_SUBDIRECTORY( daemon ) -ADD_SUBDIRECTORY( examples ) -ADD_SUBDIRECTORY( adaptor ) -ADD_SUBDIRECTORY( tests ) -ADD_SUBDIRECTORY( system ) +add_subdirectory( lib ) +add_subdirectory( daemon ) +if( WITH_DLT_CONSOLE ) + add_subdirectory( console ) +endif( WITH_DLT_CONSOLE ) + +if( WITH_DLT_EXAMPLES ) + add_subdirectory( examples ) +endif( WITH_DLT_EXAMPLES ) + +if( WTIH_DLT_ADAPTOR ) + add_subdirectory( adaptor ) +endif( WTIH_DLT_ADAPTOR ) + +if( WITH_DLT_TESTS ) + add_subdirectory( tests ) +endif( WITH_DLT_TESTS ) + +if( WITH_DLT_SYSTEM ) + add_subdirectory( system ) +endif( WITH_DLT_SYSTEM ) diff --git a/src/daemon/dlt-daemon.c b/src/daemon/dlt-daemon.c index 9ef5c6c..57a3d02 100644 --- a/src/daemon/dlt-daemon.c +++ b/src/daemon/dlt-daemon.c @@ -86,12 +86,7 @@ #include "dlt-daemon.h" #include "dlt-daemon_cfg.h" -#if defined(DLT_SYSTEMD_ENABLE) - #if defined(DLT_SYSTEMD_WATCHDOG_ENABLE) - #include - #include - #endif - +#if defined(DLT_SYSTEMD_WATCHDOG_ENABLE) || defined(DLT_SYSTEMD_ENABLE) #include "sd-daemon.h" #endif @@ -119,8 +114,13 @@ static pthread_t dlt_daemon_systemd_watchdog_thread_handle; */ void usage() { + char version[DLT_DAEMON_TEXTBUFSIZE]; + dlt_get_version(version); + + //printf("DLT logging daemon %s %s\n", _DLT_PACKAGE_VERSION, _DLT_PACKAGE_VERSION_STATE); + //printf("Compile options: %s %s %s %s",_DLT_SYSTEMD_ENABLE, _DLT_SYSTEMD_WATCHDOG_ENABLE, _DLT_TEST_ENABLE, _DLT_SHM_ENABLE); + printf(version); printf("Usage: dlt-daemon [options]\n"); - printf("DLT logging daemon %s\n", _DLT_PACKAGE_REVISION); printf("Options:\n"); printf(" -d Daemonize\n"); printf(" -h Usage\n"); diff --git a/src/examples/dlt-example-filetransfer.c b/src/examples/dlt-example-filetransfer.c index adbe85b..b1d3e1a 100644 --- a/src/examples/dlt-example-filetransfer.c +++ b/src/examples/dlt-example-filetransfer.c @@ -82,11 +82,9 @@ void usage() dlt_get_version(version); - printf("Usage: dlt-example-filetransfer [options] \n"); - printf("Filetransfer example"); + printf("Usage: dlt-example-filetransfer [options] absolute-path-to-file\n"); + printf("Simple filetransfer example"); printf("%s \n", version); - printf("Command:\n"); - printf("-f file - File to transfer (absolute path)\n"); printf("Options:\n"); printf("-a apid - Set application id to apid (default: FLTR)\n"); printf("-c ctid - Set context id to ctid (default: FLTR)\n"); @@ -108,10 +106,10 @@ int main(int argc, char* argv[]) char ctid[DLT_ID_SIZE]; //char version[255]; - + int index; int dflag = 0; int iflag = 0; - char *fvalue = 0; + char *file = 0; char *tvalue = 0; dlt_set_id(apid, FLTR_APP); @@ -131,11 +129,6 @@ int main(int argc, char* argv[]) iflag = 1; break; } - case 'f': - { - fvalue = optarg; - break; - } case 't': { tvalue = optarg; @@ -158,7 +151,7 @@ int main(int argc, char* argv[]) } case '?': { - if (optopt == 'a' || optopt == 'c' || optopt == 'f' || optopt == 't') + if (optopt == 'a' || optopt == 'c' || optopt == 't') { fprintf (stderr, "Option -%c requires an argument.\n", optopt); } @@ -177,6 +170,20 @@ int main(int argc, char* argv[]) } } + for (index = optind; index < argc; index++) + { + file = argv[index]; + } + + if (file == 0) + { + /* no message, show usage and terminate */ + fprintf(stderr,"ERROR: No absolute path to file specified\n"); + usage(); + return -1; + } + + if (tvalue) { timeout = atoi(tvalue); @@ -186,12 +193,6 @@ int main(int argc, char* argv[]) timeout = TIMEOUT; } - if (!fvalue) - { - usage(); - return -1; - } - //Register the application at the dlt-daemon dltResult = DLT_REGISTER_APP(apid,FLTR_APP_DESC); @@ -202,10 +203,10 @@ int main(int argc, char* argv[]) if( dltResult == 0 ){ if( iflag ) { - dlt_user_log_file_infoAbout(&fileContext,fvalue); + dlt_user_log_file_infoAbout(&fileContext,file); } - if( dlt_user_log_file_complete(&fileContext,fvalue,dflag,timeout) < 0 ) + if( dlt_user_log_file_complete(&fileContext,file,dflag,timeout) < 0 ) { printf("File couldn't be transferred. Please check the dlt log messages.\n"); } diff --git a/src/shared/dlt_common.c b/src/shared/dlt_common.c index 896a047..69d601b 100755 --- a/src/shared/dlt_common.c +++ b/src/shared/dlt_common.c @@ -3046,8 +3046,8 @@ speed_t dlt_convert_serial_speed(int baudrate) void dlt_get_version(char *buf) { - sprintf(buf,"DLT Package Version: %s %s, Package Revision: %s, build on %s %s\n", - _DLT_PACKAGE_VERSION, _DLT_PACKAGE_VERSION_STATE, _DLT_PACKAGE_REVISION, __DATE__ , __TIME__ ); + sprintf(buf,"DLT Package Version: %s %s, Package Revision: %s, build on %s %s\n%s %s %s %s\n", + _DLT_PACKAGE_VERSION, _DLT_PACKAGE_VERSION_STATE, _DLT_PACKAGE_REVISION, __DATE__ , __TIME__,_DLT_SYSTEMD_ENABLE,_DLT_SYSTEMD_WATCHDOG_ENABLE,_DLT_TEST_ENABLE,_DLT_SHM_ENABLE ); } void dlt_get_major_version(char *buf) diff --git a/src/system/CMakeLists.txt b/src/system/CMakeLists.txt index be8e1c9..87c9c6f 100644 --- a/src/system/CMakeLists.txt +++ b/src/system/CMakeLists.txt @@ -14,10 +14,14 @@ # @licence end@ ######## +if(WITH_SYSTEMD_WATCHDOG OR WITH_SYSTEMD) + message( STATUS "Added ${systemd_SRCS} to dlt-system") +endif(WITH_SYSTEMD_WATCHDOG OR WITH_SYSTEMD) + set(dlt_system_SRCS dlt-system dlt-system-options dlt-system-process-handling dlt-system-filetransfer dlt-system-logfile dlt-system-processes dlt-system-shell - dlt-system-syslog) -add_executable(dlt-system ${dlt_system_SRCS}) + dlt-system-syslog dlt-system-watchdog) +add_executable(dlt-system ${dlt_system_SRCS} ${systemd_SRCS}) target_link_libraries(dlt-system dlt z) set_target_properties(dlt-system PROPERTIES LINKER_LANGUAGE C) diff --git a/src/system/dlt-system-options.c b/src/system/dlt-system-options.c index 98de12d..65951a2 100644 --- a/src/system/dlt-system-options.c +++ b/src/system/dlt-system-options.c @@ -65,7 +65,7 @@ void usage(char *prog_name) dlt_get_version(version); printf("Usage: %s [options]\n", prog_name); - printf("Application to transfer system information, logs and files.\n"); + printf("Application to forward syslog messages to DLT, transfer system information, logs and files.\n"); printf("%s\n", version); printf("Options:\n"); printf(" -d Daemonize. Detach from terminal and run in background.\n"); diff --git a/src/system/dlt-system-process-handling.c b/src/system/dlt-system-process-handling.c index 3837d35..2fd07fc 100644 --- a/src/system/dlt-system-process-handling.c +++ b/src/system/dlt-system-process-handling.c @@ -109,6 +109,10 @@ void start_threads(DltSystemConfiguration *config) threads.threads[i] = 0; } +#if defined(DLT_SYSTEMD_WATCHDOG_ENABLE) + start_systemd_watchdog(config); +#endif + init_shell(); if(config->LogFile.Enable) diff --git a/src/system/dlt-system-watchdog.c b/src/system/dlt-system-watchdog.c new file mode 100644 index 0000000..c764978 --- /dev/null +++ b/src/system/dlt-system-watchdog.c @@ -0,0 +1,197 @@ +/** + * @licence app begin@ + * Copyright (C) 2012 BMW AG + * + * This file is part of GENIVI Project Dlt - Diagnostic Log and Trace console apps. + * + * Contributions are licensed to the GENIVI Alliance under one or more + * Contribution License Agreements. + * + * \copyright + * This Source Code Form is subject to the terms of the + * Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with + * this file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * + * \author Lassi Marttala BMW 2012 + * + * \file dlt-system-logfile.c + * For further information see http://www.genivi.org/. + * @licence end@ + */ + +/******************************************************************************* +** ** +** SRC-MODULE: dlt-system-watchdog.c ** +** ** +** TARGET : linux ** +** ** +** PROJECT : DLT ** +** ** +** AUTHOR : Christian Muck ** +** Alexander Wenzel Alexander.AW.Wenzel@bmw.de ** +** ** +** PURPOSE : ** +** ** +** REMARKS : ** +** ** +** PLATFORM DEPENDANT [yes/no]: yes ** +** ** +** TO BE CHANGED BY USER [yes/no]: no ** +** ** +*******************************************************************************/ +#include +#include +#include +#include +#include "dlt.h" +#include "sd-daemon.h" +#include "dlt-system.h" + +DLT_DECLARE_CONTEXT(watchdogContext) +DLT_IMPORT_CONTEXT(dltsystem) + +extern DltSystemThreads threads; + +typedef struct +{ + int timer_fd; + unsigned long long wakeups_missed; +} PeriodicData; + +void wait_period (PeriodicData *info) +{ + unsigned long long missed; + + read (info->timer_fd, &missed, sizeof (missed)); + + if (missed > 0) + { + info->wakeups_missed += (missed - 1); + } +} + +int make_periodic(unsigned int period, PeriodicData *info) +{ + unsigned int ns; + unsigned int sec; + int fd; + struct itimerspec itval; + + if (info==0) + { + DLT_LOG(watchdogContext, DLT_LOG_ERROR, + DLT_STRING("Invalid function parameters used for function make_periodic.\n")); + return -1; + } + + /* Create the timer */ + fd = timerfd_create (CLOCK_MONOTONIC, 0); + + info->wakeups_missed = 0; + info->timer_fd = fd; + + if (fd == -1) + { + DLT_LOG(watchdogContext, DLT_LOG_ERROR, + DLT_STRING("Can't create timer filedescriptor.\n")); + return -1; + } + + /* Make the timer periodic */ + sec = period/1000000; + ns = (period - (sec * 1000000)) * 1000; + itval.it_interval.tv_sec = sec; + itval.it_interval.tv_nsec = ns; + itval.it_value.tv_sec = sec; + itval.it_value.tv_nsec = ns; + + return timerfd_settime (fd, 0, &itval, NULL); +} + +void watchdog_thread(void *v_conf) +{ + char str[512]; + char *watchdogUSec; + unsigned int watchdogTimeoutSeconds; + unsigned int notifiyPeriodNSec; + PeriodicData info; + + DLT_REGISTER_CONTEXT(watchdogContext, "DOG","dlt system watchdog context."); + + sleep(1); + + DLT_LOG(watchdogContext, DLT_LOG_INFO,DLT_STRING("Watchdog thread started.\n")); + + if (v_conf==0) + { + DLT_LOG(watchdogContext, DLT_LOG_ERROR, + DLT_STRING("Invalid function parameters used for function watchdog_thread.\n")); + return; + } + + + watchdogUSec = getenv("WATCHDOG_USEC"); + + if(watchdogUSec) + { + DLT_LOG(watchdogContext, DLT_LOG_DEBUG,DLT_STRING("watchdogusec: "),DLT_STRING(watchdogUSec)); + + watchdogTimeoutSeconds = atoi(watchdogUSec); + + if( watchdogTimeoutSeconds > 0 ){ + + // Calculate half of WATCHDOG_USEC in ns for timer tick + notifiyPeriodNSec = watchdogTimeoutSeconds / 2 ; + + sprintf(str,"systemd watchdog timeout: %i nsec - timer will be initialized: %i nsec\n", watchdogTimeoutSeconds, notifiyPeriodNSec ); + DLT_LOG(watchdogContext, DLT_LOG_DEBUG,DLT_STRING(str)); + + if (make_periodic (notifiyPeriodNSec, &info) < 0 ) + { + DLT_LOG(watchdogContext, DLT_LOG_ERROR,DLT_STRING("Could not initialize systemd watchdog timer\n")); + return; + } + + while (1) + { + if(sd_notify(0, "WATCHDOG=1") < 0) + { + DLT_LOG(watchdogContext, DLT_LOG_ERROR,DLT_STRING("Could not reset systemd watchdog\n")); + } + + DLT_LOG(watchdogContext, DLT_LOG_DEBUG,DLT_STRING("systemd watchdog waited periodic\n")); + + /* Wait for next period */ + wait_period(&info); + } + } + else + { + sprintf(str,"systemd watchdog timeout incorrect: %i\n", watchdogTimeoutSeconds); + DLT_LOG(watchdogContext, DLT_LOG_DEBUG,DLT_STRING(str)); + } + } + else + { + DLT_LOG(watchdogContext, DLT_LOG_ERROR,DLT_STRING("systemd watchdog timeout (WATCHDOG_USEC) is null\n")); + } + +} + +void start_systemd_watchdog(DltSystemConfiguration *conf) +{ + DLT_LOG(dltsystem, DLT_LOG_DEBUG,DLT_STRING("Creating thread for systemd watchdog\n")); + + static pthread_attr_t t_attr; + static pthread_t pt; + + if (pthread_create(&pt, &t_attr, (void *)watchdog_thread, conf) == 0) + { + threads.threads[threads.count++] = pt; + } + else + { + DLT_LOG(dltsystem, DLT_LOG_ERROR,DLT_STRING("Could not create thread for systemd watchdog\n")); + } +} diff --git a/src/system/dlt-system.c b/src/system/dlt-system.c index 6e1d22e..93e0873 100644 --- a/src/system/dlt-system.c +++ b/src/system/dlt-system.c @@ -48,12 +48,19 @@ #include #include +#if defined(DLT_SYSTEMD_WATCHDOG_ENABLE) || defined(DLT_SYSTEMD_ENABLE) +#include "sd-daemon.h" +#endif + DLT_DECLARE_CONTEXT(dltsystem) int main(int argc, char* argv[]) { DltSystemCliOptions options; DltSystemConfiguration config; +#if defined(DLT_SYSTEMD_WATCHDOG_ENABLE) || defined(DLT_SYSTEMD_ENABLE) + int ret; +#endif if(read_command_line(&options, argc, argv) < 0) { @@ -68,7 +75,24 @@ int main(int argc, char* argv[]) } DLT_REGISTER_APP(config.ApplicationId, "DLT System Manager"); DLT_REGISTER_CONTEXT(dltsystem,"MGR", "Context of main dlt system manager"); - sleep(1); + +#if defined(DLT_SYSTEMD_WATCHDOG_ENABLE) || defined(DLT_SYSTEMD_ENABLE) + ret = sd_booted(); + + if(ret == 0){ + DLT_LOG(dltsystem, DLT_LOG_INFO, DLT_STRING("system not booted with systemd!\n")); + } + else if(ret < 0) + { + DLT_LOG(dltsystem, DLT_LOG_ERROR, DLT_STRING("sd_booted failed!\n")); + return -1; + } + else + { + DLT_LOG(dltsystem, DLT_LOG_INFO, DLT_STRING("system booted with systemd\n")); + } +#endif + DLT_LOG(dltsystem, DLT_LOG_DEBUG, DLT_STRING("Configuration loaded.")); if(options.Daemonize > 0) diff --git a/src/system/dlt-system.conf b/src/system/dlt-system.conf index cc8dc75..ee237a2 100644 --- a/src/system/dlt-system.conf +++ b/src/system/dlt-system.conf @@ -26,7 +26,7 @@ SyslogPort = 47111 ######################################################################## # Enable the Filetransfer (Default: 0) -FiletransferEnable = 1 +FiletransferEnable = 0 # The Context Id of the filetransfer (Default: FILE) FiletransferContextId = FILE @@ -73,7 +73,7 @@ FiletransferCompressionLevel = 5 ######################################################################## # Enable the logging of files (Default: 0) -LogFileEnable = 1 +LogFileEnable = 0 # Log different files # Mode: 0 = off, 1 = startup only, 2 = regular @@ -132,7 +132,7 @@ LogFileContextId = STAT ######################################################################## # Enable the logging of processes (Default: 0) -LogProcessesEnable = 1 +LogProcessesEnable = 0 # The Context Id of the kernel version (Default: PROC) LogProcessesContextId = PROC diff --git a/src/system/dlt-system.h b/src/system/dlt-system.h index fd741dc..f949aea 100644 --- a/src/system/dlt-system.h +++ b/src/system/dlt-system.h @@ -167,5 +167,8 @@ void start_filetransfer(DltSystemConfiguration *conf); void start_logfile(DltSystemConfiguration *conf); void start_logprocess(DltSystemConfiguration *conf); +#if defined(DLT_SYSTEMD_WATCHDOG_ENABLE) +void start_systemd_watchdog(DltSystemConfiguration *conf); +#endif #endif /* DLT_SYSTEM_H_ */ diff --git a/systemd/CMakeLists.txt b/systemd/CMakeLists.txt index 7411364..d01c1ef 100644 --- a/systemd/CMakeLists.txt +++ b/systemd/CMakeLists.txt @@ -15,26 +15,46 @@ ######## if(WITH_SYSTEMD) + set(SYSTEMD_CONFIGURATIONS_FILES_DIR "/lib/systemd/system" ) if(WITH_SYSTEMD_WATCHDOG) set( DLT_WatchdogSec 2 ) - message( STATUS "The systemd watchdog is enabled for DLT daemon - timeout is set to ${DLT_WatchdogSec} seconds") + message( STATUS "The systemd watchdog is enabled - timeout is set to ${DLT_WatchdogSec} seconds") else(WITH_SYSTEMD_WATCHDOG) set( DLT_WatchdogSec 0 ) - message( STATUS "The systemd watchdog is disabled for DLT daemon") + message( STATUS "The systemd watchdog is disabled") endif(WITH_SYSTEMD_WATCHDOG) configure_file(${CMAKE_SOURCE_DIR}/systemd/dlt.service.cmake ${PROJECT_BINARY_DIR}/systemd/dlt.service) - install(FILES ${PROJECT_BINARY_DIR}/systemd/dlt.service DESTINATION ${SYSTEMD_CONFIGURATIONS_FILES_DIR} ) message( STATUS "Configured systemd unit file:dlt.service" ) - set( DLT_SYSLOG_APPID "SYS" ) - set( DLT_SYSLOG_CTID "LOG" ) - set( DLT_SYSLOG_PORT 4712 ) - message(STATUS "DLT-syslog configuration: APPID:${DLT_SYSLOG_APPID} CTID:${DLT_SYSLOG_CTID} PORT:${DLT_SYSLOG_PORT}" ) - configure_file(${CMAKE_SOURCE_DIR}/systemd/dlt-syslog.service.cmake ${PROJECT_BINARY_DIR}/systemd/dlt-syslog.service) - install(FILES ${PROJECT_BINARY_DIR}/systemd/dlt-syslog.service DESTINATION ${SYSTEMD_CONFIGURATIONS_FILES_DIR} ) - message( STATUS "Configured systemd unit file:dlt-syslog.service" ) + configure_file(${CMAKE_SOURCE_DIR}/systemd/dlt-system.service.cmake ${PROJECT_BINARY_DIR}/systemd/dlt-system.service) + message( STATUS "Configured systemd unit file:dlt-system.service" ) + + configure_file(${CMAKE_SOURCE_DIR}/systemd/dlt-receive.service.cmake ${PROJECT_BINARY_DIR}/systemd/dlt-receive.service) + message( STATUS "Configured systemd unit file:dlt-receive.service" ) + + configure_file(${CMAKE_SOURCE_DIR}/systemd/dlt-example-user.service.cmake ${PROJECT_BINARY_DIR}/systemd/dlt-example-user.service) + message( STATUS "Configured systemd unit file:dlt-example-user.service" ) + + set( DLT_ADAPTOR_UDP_APPID "DUDP" ) + set( DLT_ADAPTOR_UDP_CTID "DCTI" ) + set( DLT_ADAPTOR_UDP_PORT 4712 ) + configure_file(${CMAKE_SOURCE_DIR}/systemd/dlt-adaptor-udp.service.cmake ${PROJECT_BINARY_DIR}/systemd/dlt-adaptor-udp.service) + message( STATUS "Configured systemd unit file:dlt-adaptor-udp.service" ) + message(STATUS "DLT adaptor udp configuration: APPID=${DLT_ADAPTOR_UDP_APPID} CTID=${DLT_ADAPTOR_UDP_CTID} PORT=${DLT_ADAPTOR_UDP_PORT}" ) + + if(EXISTS ${SYSTEMD_CONFIGURATIONS_FILES_DIR}) + install(FILES ${PROJECT_BINARY_DIR}/systemd/dlt.service DESTINATION ${SYSTEMD_CONFIGURATIONS_FILES_DIR} ) + install(FILES ${PROJECT_BINARY_DIR}/systemd/dlt-system.service DESTINATION ${SYSTEMD_CONFIGURATIONS_FILES_DIR} ) + install(FILES ${PROJECT_BINARY_DIR}/systemd/dlt-receive.service DESTINATION ${SYSTEMD_CONFIGURATIONS_FILES_DIR} ) + install(FILES ${PROJECT_BINARY_DIR}/systemd/dlt-example-user.service DESTINATION ${SYSTEMD_CONFIGURATIONS_FILES_DIR} ) + install(FILES ${PROJECT_BINARY_DIR}/systemd/dlt-adaptor-udp.service DESTINATION ${SYSTEMD_CONFIGURATIONS_FILES_DIR} ) + message(STATUS "Unit files will be installed to ${SYSTEMD_CONFIGURATIONS_FILES_DIR} after make install" ) + else(EXISTS ${SYSTEMD_CONFIGURATIONS_FILES_DIR}) + message(STATUS "Unit files will not be installed to ${SYSTEMD_CONFIGURATIONS_FILES_DIR} after make install") + endif(EXISTS ${SYSTEMD_CONFIGURATIONS_FILES_DIR}) + endif(WITH_SYSTEMD) \ No newline at end of file diff --git a/systemd/dlt-adaptor-udp.service.cmake b/systemd/dlt-adaptor-udp.service.cmake new file mode 100644 index 0000000..0c39637 --- /dev/null +++ b/systemd/dlt-adaptor-udp.service.cmake @@ -0,0 +1,28 @@ +####### +# Dlt - Diagnostic Log and Trace +# @licence make begin@ +# +# Copyright (C) 2011-2012, BMW AG - Alexander Wenzel +# +# Contributions are licensed to the GENIVI Alliance under one or more +# Contribution License Agreements. +# +# This Source Code Form is subject to the terms of the +# Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with +# this file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +# @licence end@ +######## + +[Unit] +Description=GENIVI DLT adaptor stdin. Adaptor for forwarding received UDP messages to DLT daemon. +Wants=dlt.service + +[Service] +Type=Simple +User=genivi +ExecStart=@CMAKE_INSTALL_PREFIX@/bin/dlt-adaptor-udp -a @DLT_ADAPTOR_UDP_APPID@ -c @DLT_ADAPTOR_UDP_CTID@ -p @DLT_ADAPTOR_UDP_PORT@ +LimitCORE=infinity + +[Install] +WantedBy=multi-user.target \ No newline at end of file diff --git a/systemd/dlt-example-user.service.cmake b/systemd/dlt-example-user.service.cmake new file mode 100644 index 0000000..3652292 --- /dev/null +++ b/systemd/dlt-example-user.service.cmake @@ -0,0 +1,25 @@ +####### +# Dlt - Diagnostic Log and Trace +# @licence make begin@ +# +# Copyright (C) 2011-2012, BMW AG - Alexander Wenzel +# +# Contributions are licensed to the GENIVI Alliance under one or more +# Contribution License Agreements. +# +# This Source Code Form is subject to the terms of the +# Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with +# this file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +# @licence end@ +######## + +[Unit] +Description=GENIVI DLT example user. Generate DLT messages and store them to file or send them to daemon. +Wants=dlt.service + +[Service] +Type=Simple +User=genivi +ExecStart=@CMAKE_INSTALL_PREFIX@/bin/dlt-example-user "Hallo from GENIVI DLT example user application" +LimitCORE=infinity \ No newline at end of file diff --git a/systemd/dlt-receive.service.cmake b/systemd/dlt-receive.service.cmake new file mode 100644 index 0000000..b92c8b2 --- /dev/null +++ b/systemd/dlt-receive.service.cmake @@ -0,0 +1,26 @@ +####### +# Dlt - Diagnostic Log and Trace +# @licence make begin@ +# +# Copyright (C) 2011-2012, BMW AG - Alexander Wenzel +# +# Contributions are licensed to the GENIVI Alliance under one or more +# Contribution License Agreements. +# +# This Source Code Form is subject to the terms of the +# Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with +# this file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +# @licence end@ +######## + +[Unit] +Description=GENIVI DLT receive. Receive DLT messages from DLT daemon and print or store the messages. +Documentation=man:dlt-receive(1) +Wants=dlt.service + +[Service] +Type=Simple +User=genivi +ExecStart=@CMAKE_INSTALL_PREFIX@/bin/dlt-receive -o /tmp/dlt_receive_log.dlt localhost +LimitCORE=infinity \ No newline at end of file diff --git a/systemd/dlt-syslog.service.cmake b/systemd/dlt-syslog.service.cmake deleted file mode 100755 index a962841..0000000 --- a/systemd/dlt-syslog.service.cmake +++ /dev/null @@ -1,25 +0,0 @@ -####### -# Dlt - Diagnostic Log and Trace -# @licence make begin@ -# -# Copyright (C) 2011-2012, BMW AG - Alexander Wenzel -# -# Contributions are licensed to the GENIVI Alliance under one or more -# Contribution License Agreements. -# -# This Source Code Form is subject to the terms of the -# Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with -# this file, You can obtain one at http://mozilla.org/MPL/2.0/. -# -# @licence end@ -######## - -[Unit] -Description=DLT Syslog Adapter - -[Service] -ExecStart=@CMAKE_INSTALL_PREFIX@/bin/dlt-adaptor-udp -a @DLT_SYSLOG_APPID@ -c @DLT_SYSLOG_CTID@ -p @DLT_SYSLOG_PORT@ -# Restart=always - -[Install] -WantedBy=basic.target diff --git a/systemd/dlt-system.service.cmake b/systemd/dlt-system.service.cmake new file mode 100755 index 0000000..fc30f74 --- /dev/null +++ b/systemd/dlt-system.service.cmake @@ -0,0 +1,31 @@ +####### +# Dlt - Diagnostic Log and Trace +# @licence make begin@ +# +# Copyright (C) 2011-2012, BMW AG - Alexander Wenzel +# +# Contributions are licensed to the GENIVI Alliance under one or more +# Contribution License Agreements. +# +# This Source Code Form is subject to the terms of the +# Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with +# this file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +# @licence end@ +######## + +[Unit] +Description=GENIVI DLT system. Application to forward syslog messages to DLT, transfer system information, logs and files. +Documentation=man:dlt-system(1) man:dlt-system.conf(5) +Wants=dlt.service + +[Service] +Type=Simple +User=genivi +ExecStart=@CMAKE_INSTALL_PREFIX@/bin/dlt-system +WatchdogSec=@DLT_WatchdogSec@ +NotifyAccess=main +LimitCORE=infinity + +[Install] +WantedBy=basic.target \ No newline at end of file diff --git a/systemd/dlt.service.cmake b/systemd/dlt.service.cmake index 43cb319..22279c4 100755 --- a/systemd/dlt.service.cmake +++ b/systemd/dlt.service.cmake @@ -15,18 +15,16 @@ ######## [Unit] -Description=GENIVI DLT -Documentation=dlt-daemon(1) dlt.conf(5) +Description=GENIVI DLT logging daemon +Documentation=man:dlt-daemon(1) man:dlt.conf(5) [Service] Type=Simple User=genivi -#ExecStartPre=rm /tmp/dlt ExecStart=@CMAKE_INSTALL_PREFIX@/bin/dlt-daemon WatchdogSec=@DLT_WatchdogSec@ NotifyAccess=main -#RestartSec=2 -#Restart=always +LimitCORE=infinity [Install] -WantedBy=multi-user.target +WantedBy=basic.target -- cgit v1.2.1