[GDLT-90] Implemented systemd watchdog concept in dlt-system
authorChristian Muck <christian.muck@bmw.de>
Mon, 4 Jun 2012 07:08:52 +0000 (09:08 +0200)
committerChristian Muck <christian.muck@bmw.de>
Wed, 13 Jun 2012 21:52:51 +0000 (23:52 +0200)
Signed-off-by: Christian Muck <christian.muck@bmw.de>
19 files changed:
CMakeLists.txt
cmake/dlt_version.h.cmake
src/CMakeLists.txt
src/daemon/dlt-daemon.c
src/examples/dlt-example-filetransfer.c
src/shared/dlt_common.c
src/system/CMakeLists.txt
src/system/dlt-system-options.c
src/system/dlt-system-process-handling.c
src/system/dlt-system-watchdog.c [new file with mode: 0644]
src/system/dlt-system.c
src/system/dlt-system.conf
src/system/dlt-system.h
systemd/CMakeLists.txt
systemd/dlt-adaptor-udp.service.cmake [new file with mode: 0644]
systemd/dlt-example-user.service.cmake [moved from systemd/dlt-syslog.service.cmake with 65% similarity, mode: 0644]
systemd/dlt-receive.service.cmake [new file with mode: 0644]
systemd/dlt-system.service.cmake [new file with mode: 0755]
systemd/dlt.service.cmake

index eba6689..fc4de91 100644 (file)
@@ -19,6 +19,7 @@ project( automotive-dlt )
 \r
 mark_as_advanced( CMAKE_BACKWARDS_COMPATIBILITY)\r
 set( CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS TRUE )\r
+set( CMAKE_INSTALL_PREFIX "/usr" )\r
 \r
 # Set version parameters\r
 set( DLT_MAJOR_VERSION 2)\r
@@ -50,16 +51,20 @@ endif(NOT CMAKE_BUILD_TYPE)
 \r
 # Set of indiviual options\r
 option(BUILD_SHARED_LIBS      "Set to OFF to build static libraries"                 ON  )\r
-option(WITH_DLT_SHM_ENABLE    "Set to ON to use shared memory as IPC - experimental"    OFF )\r
+option(WITH_SYSTEMD           "Set to ON to create unit files and systemd check on dlt-daemon startup"           ON )\r
+option(WITH_SYSTEMD_WATCHDOG  "Set to ON to use the systemd watchdog in dlt-daemon"      ON)\r
 option(WITH_DOC               "Set to ON to build documentation target"              OFF )\r
-option(WITH_MAN               "Set to ON to build man pages"             OFF )\r
+option(WITH_MAN               "Set to ON to build man pages"             ON )\r
 option(WITH_CHECK_CONFIG_FILE "Set to ON to create a configure file of CheckIncludeFiles and CheckFunctionExists " OFF )\r
 option(WITH_TESTSCRIPTS       "Set to ON to run CMakeLists.txt in testscripts"       OFF )\r
-option(WITH_SYSTEMD           "Set to ON to create unit files and systemd check on dlt-daemon startup"           OFF )\r
-option(WITH_SYSTEMD_WATCHDOG  "Set to ON to use the systemd watchdog in dlt-daemon"      ON)\r
 option(WITH_GPROF             "Set -pg to compile flags"                             OFF )\r
 option(WITH_DLTTEST                      "Set to ON to build with modifications to test User-Daemon communication with corrupt messages" OFF)\r
-\r
+option(WITH_DLT_SHM_ENABLE    "EXPERIMENTAL! Set to ON to use shared memory as IPC. EXPERIMENTAL!"    OFF )\r
+option(WTIH_DLT_ADAPTOR       "Set ton ON to build src/adaptor binaries" ON)\r
+option(WITH_DLT_CONSOLE       "Set ton ON to build src/console binaries" ON)\r
+option(WITH_DLT_EXAMPLES      "Set ton ON to build src/examples binaries" ON)\r
+option(WITH_DLT_SYSTEM        "Set ton ON to build src/system binaries" ON)\r
+option(WITH_DLT_TESTS         "Set ton ON to build src/test binaries" ON)\r
 # RPM settings\r
 set( GENIVI_RPM_RELEASE "1")#${DLT_REVISION}")\r
 set( LICENSE "Mozilla Public License Version 2.0" )\r
@@ -91,6 +96,7 @@ if(WITH_GPROF)
 endif(WITH_GPROF)    \r
    \r
 add_definitions( "-Wall" )\r
+add_definitions( "-Wextra" )\r
 \r
 configure_file(${CMAKE_SOURCE_DIR}/${PROJECT_NAME}.spec.in ${PROJECT_BINARY_DIR}/${PROJECT_NAME}.spec)\r
 configure_file(${CMAKE_SOURCE_DIR}/${PROJECT_NAME}.pc.in ${PROJECT_BINARY_DIR}/${PROJECT_NAME}.pc @ONLY)\r
@@ -124,11 +130,16 @@ message( STATUS "WITH_SYSTEMD = ${WITH_SYSTEMD}" )
 message( STATUS "WITH_SYSTEMD_WATCHDOG = ${WITH_SYSTEMD_WATCHDOG}" )\r
 message( STATUS "WITH_DOC = ${WITH_DOC}" )\r
 message( STATUS "WITH_MAN = ${WITH_MAN}" )\r
+message( STATUS "WTIH_DLT_ADAPTOR = ${WTIH_DLT_ADAPTOR}")\r
+message( STATUS "WITH_DLT_CONSOLE = ${WITH_DLT_CONSOLE}")\r
+message( STATUS "WITH_DLT_EXAMPLES = ${WITH_DLT_EXAMPLES}")\r
+message( STATUS "WITH_DLT_SYSTEM = ${WITH_DLT_SYSTEM}")\r
+message( STATUS "WITH_DLT_TESTS = ${WITH_DLT_TESTS}")\r
 message( STATUS "WITH_DLT_SHM_ENABLE = ${WITH_DLT_SHM_ENABLE}" )\r
+message( STATUS "WITH_DLTTEST = ${WITH_DLTTEST}" )\r
 message( STATUS "WITH_CHECK_CONFIG_FILE = ${WITH_CHECK_CONFIG_FILE}" )\r
 message( STATUS "WITH_TESTSCRIPTS = ${WITH_TESTSCRIPTS}" )\r
 message( STATUS "WITH_GPROF = ${WITH_GPROF}" )\r
-message( STATUS "WITH_DLTTEST = ${WITH_DLTTEST}" )\r
 message( STATUS "BUILD_SHARED_LIBS = ${BUILD_SHARED_LIBS}" )\r
 message( STATUS "CMAKE_INSTALL_PREFIX = ${CMAKE_INSTALL_PREFIX}" )\r
 message( STATUS "CMAKE_BUILD_TYPE = ${CMAKE_BUILD_TYPE}" )\r
index 949bf9e..ba94983 100755 (executable)
@@ -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
index e7b84c0..a288381 100644 (file)
 # @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 )
index 9ef5c6c..57a3d02 100644 (file)
 #include "dlt-daemon.h"
 #include "dlt-daemon_cfg.h"
 
-#if defined(DLT_SYSTEMD_ENABLE)
-       #if defined(DLT_SYSTEMD_WATCHDOG_ENABLE)
-               #include <stdio.h>
-               #include <stdlib.h>
-       #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");
index adbe85b..b1d3e1a 100644 (file)
@@ -82,11 +82,9 @@ void usage()
 
        dlt_get_version(version);
 
-    printf("Usage: dlt-example-filetransfer [options] <command>\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");
                }
index 896a047..69d601b 100755 (executable)
@@ -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)
index be8e1c9..87c9c6f 100644 (file)
 # @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)
 
index 98de12d..65951a2 100644 (file)
@@ -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");
index 3837d35..2fd07fc 100644 (file)
@@ -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 (file)
index 0000000..c764978
--- /dev/null
@@ -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 <lassi.lm.marttala@partner.bmw.de> 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 <christian.muck@bmw.de>                                   **
+**              Alexander Wenzel Alexander.AW.Wenzel@bmw.de                   **
+**                                                                            **
+**  PURPOSE   :                                                               **
+**                                                                            **
+**  REMARKS   :                                                               **
+**                                                                            **
+**  PLATFORM DEPENDANT [yes/no]: yes                                          **
+**                                                                            **
+**  TO BE CHANGED BY USER [yes/no]: no                                        **
+**                                                                            **
+*******************************************************************************/
+#include <stdio.h>
+#include <stdlib.h>
+#include <pthread.h>
+#include <sys/timerfd.h>
+#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"));
+       }
+}
index 6e1d22e..93e0873 100644 (file)
 #include <errno.h>
 #include <signal.h>
 
+#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)
index cc8dc75..ee237a2 100644 (file)
@@ -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
index fd741dc..f949aea 100644 (file)
@@ -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_ */
index 7411364..d01c1ef 100644 (file)
 ########
 
 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 (file)
index 0000000..0c39637
--- /dev/null
@@ -0,0 +1,28 @@
+#######
+# Dlt - Diagnostic Log and Trace
+# @licence make begin@
+#
+# Copyright (C) 2011-2012, BMW AG - Alexander Wenzel <alexander.aw.wenzel@bmw.de>
+# 
+# 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
old mode 100755 (executable)
new mode 100644 (file)
similarity index 65%
rename from systemd/dlt-syslog.service.cmake
rename to systemd/dlt-example-user.service.cmake
index a962841..3652292
@@ -1,25 +1,25 @@
-#######\r
-# Dlt - Diagnostic Log and Trace\r
-# @licence make begin@\r
-#\r
-# Copyright (C) 2011-2012, BMW AG - Alexander Wenzel <alexander.aw.wenzel@bmw.de>\r
-# \r
-# Contributions are licensed to the GENIVI Alliance under one or more\r
-# Contribution License Agreements.\r
-# \r
-# This Source Code Form is subject to the terms of the\r
-# Mozilla Public License, v. 2.0. If a  copy of the MPL was not distributed with\r
-# this file, You can obtain one at http://mozilla.org/MPL/2.0/.\r
-#\r
-# @licence end@\r
-########\r
-\r
-[Unit]\r
-Description=DLT Syslog Adapter\r
-\r
-[Service]\r
-ExecStart=@CMAKE_INSTALL_PREFIX@/bin/dlt-adaptor-udp -a @DLT_SYSLOG_APPID@ -c @DLT_SYSLOG_CTID@ -p @DLT_SYSLOG_PORT@\r
-# Restart=always\r
-\r
-[Install]\r
-WantedBy=basic.target\r
+#######
+# Dlt - Diagnostic Log and Trace
+# @licence make begin@
+#
+# Copyright (C) 2011-2012, BMW AG - Alexander Wenzel <alexander.aw.wenzel@bmw.de>
+# 
+# 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 (file)
index 0000000..b92c8b2
--- /dev/null
@@ -0,0 +1,26 @@
+#######
+# Dlt - Diagnostic Log and Trace
+# @licence make begin@
+#
+# Copyright (C) 2011-2012, BMW AG - Alexander Wenzel <alexander.aw.wenzel@bmw.de>
+# 
+# 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-system.service.cmake b/systemd/dlt-system.service.cmake
new file mode 100755 (executable)
index 0000000..fc30f74
--- /dev/null
@@ -0,0 +1,31 @@
+#######\r
+# Dlt - Diagnostic Log and Trace\r
+# @licence make begin@\r
+#\r
+# Copyright (C) 2011-2012, BMW AG - Alexander Wenzel <alexander.aw.wenzel@bmw.de>\r
+# \r
+# Contributions are licensed to the GENIVI Alliance under one or more\r
+# Contribution License Agreements.\r
+# \r
+# This Source Code Form is subject to the terms of the\r
+# Mozilla Public License, v. 2.0. If a  copy of the MPL was not distributed with\r
+# this file, You can obtain one at http://mozilla.org/MPL/2.0/.\r
+#\r
+# @licence end@\r
+########\r
+\r
+[Unit]\r
+Description=GENIVI DLT system. Application to forward syslog messages to DLT, transfer system information, logs and files.\r
+Documentation=man:dlt-system(1) man:dlt-system.conf(5)\r
+Wants=dlt.service\r
+\r
+[Service]\r
+Type=Simple\r
+User=genivi\r
+ExecStart=@CMAKE_INSTALL_PREFIX@/bin/dlt-system\r
+WatchdogSec=@DLT_WatchdogSec@\r
+NotifyAccess=main\r
+LimitCORE=infinity\r
+\r
+[Install]\r
+WantedBy=basic.target
\ No newline at end of file
index 43cb319..22279c4 100755 (executable)
 ########
 
 [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