summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlexander Wenzel <Alexander.AW.Wenzel@bmw.de>2011-10-14 14:42:05 +0200
committerAlexander Wenzel <Alexander.AW.Wenzel@bmw.de>2011-10-14 14:42:05 +0200
commit6b67e89b17b6c012023b6824ef1e967c3a858c52 (patch)
treea3d04e3610cb7c597bd5b28137be7d6c665cc414 /src
parenta0e2ed4fe47ac42f831e1c0c3524ba1b86ccdf71 (diff)
downloadDLT-daemon-6b67e89b17b6c012023b6824ef1e967c3a858c52.tar.gz
Improved file logging and added variable to enable each kind of system logging.
Diffstat (limited to 'src')
-rw-r--r--src/system/dlt-system-log.c176
-rw-r--r--src/system/dlt-system-log.h70
-rwxr-xr-xsrc/system/dlt-system.c201
-rw-r--r--src/system/dlt-system.conf73
-rw-r--r--src/system/dlt-system.h81
-rw-r--r--src/system/dlt-system_cfg.h70
6 files changed, 525 insertions, 146 deletions
diff --git a/src/system/dlt-system-log.c b/src/system/dlt-system-log.c
index 1a5f4bc..b785a2b 100644
--- a/src/system/dlt-system-log.c
+++ b/src/system/dlt-system-log.c
@@ -1,3 +1,73 @@
+/*
+ * Dlt system manager to Dlt
+ * @licence app begin@
+ *
+ * Copyright (C) 2011, BMW AG - Alexander Wenzel <alexander.wenzel@bmw.de>
+ *
+ * This program is free software; you can redistribute it and/or modify it under the terms of the
+ * GNU Lesser General Public License, version 2.1, as published by the Free Software Foundation.
+ * 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 Lesser General
+ * Public License, version 2.1, for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License, version 2.1, along
+ * with this program; if not, see <http://www.gnu.org/licenses/lgpl-2.1.html>.
+ *
+ * Note that the copyright holders assume that the GNU Lesser General Public License, version 2.1, may
+ * also be applicable to programs even in cases in which the program is not a library in the technical sense.
+ *
+ * Linking DLT statically or dynamically with other modules is making a combined work based on DLT. You may
+ * license such other modules under the GNU Lesser General Public License, version 2.1. If you do not want to
+ * license your linked modules under the GNU Lesser General Public License, version 2.1, you
+ * may use the program under the following exception.
+ *
+ * As a special exception, the copyright holders of DLT give you permission to combine DLT
+ * with software programs or libraries that are released under any license unless such a combination is not
+ * permitted by the license of such a software program or library. You may copy and distribute such a
+ * system following the terms of the GNU Lesser General Public License, version 2.1, including this
+ * special exception, for DLT and the licenses of the other code concerned.
+ *
+ * Note that people who make modified versions of DLT are not obligated to grant this special exception
+ * for their modified versions; it is their choice whether to do so. The GNU Lesser General Public License,
+ * version 2.1, gives permission to release a modified version without this exception; this exception
+ * also makes it possible to release a modified version which carries forward this exception.
+ *
+ * @licence end@
+ */
+
+/*******************************************************************************
+** **
+** SRC-MODULE: dlt-system-log.c **
+** **
+** TARGET : linux **
+** **
+** PROJECT : DLT **
+** **
+** AUTHOR : Alexander Wenzel Alexander.AW.Wenzel@bmw.de **
+** **
+** PURPOSE : **
+** **
+** REMARKS : **
+** **
+** PLATFORM DEPENDANT [yes/no]: yes **
+** **
+** TO BE CHANGED BY USER [yes/no]: no **
+** **
+*******************************************************************************/
+
+/*******************************************************************************
+** Author Identity **
+********************************************************************************
+** **
+** Initials Name Company **
+** -------- ------------------------- ---------------------------------- **
+** aw Alexander Wenzel BMW **
+*******************************************************************************/
+
+/*******************************************************************************
+** Revision Control History **
+*******************************************************************************/
+
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
@@ -32,6 +102,7 @@ void dlt_system_filetransfer_run(DltSystemOptions *options,DltSystemRuntime *run
time_t time_oldest = 0;
int transferResult;
int total_size, used_size;
+ DIR *dir;
if(runtime->filetransferRunning == 0) {
/* delete last transmitted file */
@@ -46,19 +117,36 @@ void dlt_system_filetransfer_run(DltSystemOptions *options,DltSystemRuntime *run
/* filetransfer not running, check directory */
filename[0] = 0;
- DIR *dir = opendir(options->FiletransferDirectory);
- while ((dp=readdir(dir)) != NULL) {
- if(strcmp(dp->d_name,".")!=0 && strcmp(dp->d_name,"..")!=0) {
- sprintf(filename,"%s/%s",options->FiletransferDirectory,dp->d_name);
- stat(filename,&status);
- if(time_oldest == 0 || status.st_mtime < time_oldest) {
- time_oldest = status.st_mtime;
- size_oldest = status.st_size;
- strcpy(runtime->filetransferFile,filename);
+ dir = opendir(options->FiletransferDirectory1);
+ if(dir > 0) {
+ while ((dp=readdir(dir)) != NULL) {
+ if(strcmp(dp->d_name,".")!=0 && strcmp(dp->d_name,"..")!=0) {
+ sprintf(filename,"%s/%s",options->FiletransferDirectory1,dp->d_name);
+ stat(filename,&status);
+ if(time_oldest == 0 || status.st_mtime < time_oldest) {
+ time_oldest = status.st_mtime;
+ size_oldest = status.st_size;
+ strcpy(runtime->filetransferFile,filename);
+ }
}
- }
- }
- closedir(dir);
+ }
+ closedir(dir);
+ }
+ dir = opendir(options->FiletransferDirectory2);
+ if(dir > 0) {
+ while ((dp=readdir(dir)) != NULL) {
+ if(strcmp(dp->d_name,".")!=0 && strcmp(dp->d_name,"..")!=0) {
+ sprintf(filename,"%s/%s",options->FiletransferDirectory2,dp->d_name);
+ stat(filename,&status);
+ if(time_oldest == 0 || status.st_mtime < time_oldest) {
+ time_oldest = status.st_mtime;
+ size_oldest = status.st_size;
+ strcpy(runtime->filetransferFile,filename);
+ }
+ }
+ }
+ closedir(dir);
+ }
/* start filetransfer if file exists */
if(runtime->filetransferFile[0]) {
@@ -125,19 +213,26 @@ void dlt_system_log_file(DltSystemOptions *options,DltContext *context,int num)
FILE * pFile;
char buffer[1024];
int bytes;
+ int seq = 1;
pFile = fopen(options->LogFileFilename[num],"r");
if(pFile>0)
{
- do {
+ while (!feof(pFile)) {
bytes = fread(buffer,1,sizeof(buffer)-1,pFile);
-
- if(bytes>0) {
+ if(bytes>=0)
buffer[bytes] = 0;
- DLT_LOG(*context, DLT_LOG_INFO, DLT_STRING(buffer));
+ else
+ buffer[0] = 0;
+
+ if(feof(pFile)) {
+ DLT_LOG(*context, DLT_LOG_INFO, DLT_INT(seq*-1), DLT_STRING(buffer));
+ }
+ else {
+ DLT_LOG(*context, DLT_LOG_INFO, DLT_INT(seq++), DLT_STRING(buffer));
}
- } while (bytes>0);
+ }
fclose(pFile);
}
}
@@ -152,36 +247,39 @@ void dlt_system_log_process(DltSystemOptions *options,DltContext *context,int nu
/* go through all dlt files in directory */
DIR *dir = opendir("/proc");
- while ((dp=readdir(dir)) != NULL) {
- if(dp->d_name[0]>'0' && dp->d_name[0]<'9') {
- buffer[0] = 0;
- sprintf(filename,"/proc/%s/cmdline",dp->d_name);
- pFile = fopen(filename,"r");
- if(pFile>0)
- {
- bytes = fread(buffer,1,sizeof(buffer)-1,pFile);
- fclose(pFile);
- }
- if((strcmp(options->LogProcessFilename[num],"*")==0) ||
- (strcmp(buffer,options->LogProcessName[num])==0) ) {
- found = 1;
- sprintf(filename,"/proc/%s/%s",dp->d_name,options->LogProcessFilename[num]);
+ if(dir>0) {
+ while ((dp=readdir(dir)) != NULL) {
+ if(dp->d_name[0]>'0' && dp->d_name[0]<'9') {
+ buffer[0] = 0;
+ sprintf(filename,"/proc/%s/cmdline",dp->d_name);
pFile = fopen(filename,"r");
if(pFile>0)
{
bytes = fread(buffer,1,sizeof(buffer)-1,pFile);
fclose(pFile);
-
- if(bytes>0) {
- buffer[bytes] = 0;
- DLT_LOG(*context, DLT_LOG_INFO, DLT_INT(atoi(dp->d_name)), DLT_STRING(buffer));
+ }
+ if((strcmp(options->LogProcessName[num],"*")==0) ||
+ (strcmp(buffer,options->LogProcessName[num])==0) ) {
+ found = 1;
+ sprintf(filename,"/proc/%s/%s",dp->d_name,options->LogProcessFilename[num]);
+ pFile = fopen(filename,"r");
+ if(pFile>0)
+ {
+ bytes = fread(buffer,1,sizeof(buffer)-1,pFile);
+ fclose(pFile);
+
+ if(bytes>0) {
+ buffer[bytes] = 0;
+ DLT_LOG(*context, DLT_LOG_INFO, DLT_INT(atoi(dp->d_name)),DLT_STRING(options->LogProcessFilename[num]), DLT_STRING(buffer));
+ }
}
+ if(strcmp(options->LogProcessName[num],"*")!=0)
+ break;
}
- break;
}
- }
- }
- closedir(dir);
+ }
+ closedir(dir);
+ }
if(!found) {
DLT_LOG(*context, DLT_LOG_INFO, DLT_STRING("Process"), DLT_STRING(options->LogProcessName[num]),DLT_STRING("not running!"));
diff --git a/src/system/dlt-system-log.h b/src/system/dlt-system-log.h
index 6eb8d62..e0ba49d 100644
--- a/src/system/dlt-system-log.h
+++ b/src/system/dlt-system-log.h
@@ -1,3 +1,73 @@
+/*
+ * Dlt system manager to Dlt
+ * @licence app begin@
+ *
+ * Copyright (C) 2011, BMW AG - Alexander Wenzel <alexander.wenzel@bmw.de>
+ *
+ * This program is free software; you can redistribute it and/or modify it under the terms of the
+ * GNU Lesser General Public License, version 2.1, as published by the Free Software Foundation.
+ * 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 Lesser General
+ * Public License, version 2.1, for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License, version 2.1, along
+ * with this program; if not, see <http://www.gnu.org/licenses/lgpl-2.1.html>.
+ *
+ * Note that the copyright holders assume that the GNU Lesser General Public License, version 2.1, may
+ * also be applicable to programs even in cases in which the program is not a library in the technical sense.
+ *
+ * Linking DLT statically or dynamically with other modules is making a combined work based on DLT. You may
+ * license such other modules under the GNU Lesser General Public License, version 2.1. If you do not want to
+ * license your linked modules under the GNU Lesser General Public License, version 2.1, you
+ * may use the program under the following exception.
+ *
+ * As a special exception, the copyright holders of DLT give you permission to combine DLT
+ * with software programs or libraries that are released under any license unless such a combination is not
+ * permitted by the license of such a software program or library. You may copy and distribute such a
+ * system following the terms of the GNU Lesser General Public License, version 2.1, including this
+ * special exception, for DLT and the licenses of the other code concerned.
+ *
+ * Note that people who make modified versions of DLT are not obligated to grant this special exception
+ * for their modified versions; it is their choice whether to do so. The GNU Lesser General Public License,
+ * version 2.1, gives permission to release a modified version without this exception; this exception
+ * also makes it possible to release a modified version which carries forward this exception.
+ *
+ * @licence end@
+ */
+
+/*******************************************************************************
+** **
+** SRC-MODULE: dlt-system-log.h **
+** **
+** TARGET : linux **
+** **
+** PROJECT : DLT **
+** **
+** AUTHOR : Alexander Wenzel Alexander.AW.Wenzel@bmw.de **
+** **
+** PURPOSE : **
+** **
+** REMARKS : **
+** **
+** PLATFORM DEPENDANT [yes/no]: yes **
+** **
+** TO BE CHANGED BY USER [yes/no]: no **
+** **
+*******************************************************************************/
+
+/*******************************************************************************
+** Author Identity **
+********************************************************************************
+** **
+** Initials Name Company **
+** -------- ------------------------- ---------------------------------- **
+** aw Alexander Wenzel BMW **
+*******************************************************************************/
+
+/*******************************************************************************
+** Revision Control History **
+*******************************************************************************/
+
#ifndef DLT_SYSTEM_LOG_H
#define DLT_SYSTEM_LOG_H
diff --git a/src/system/dlt-system.c b/src/system/dlt-system.c
index 2930a4a..6439d85 100755
--- a/src/system/dlt-system.c
+++ b/src/system/dlt-system.c
@@ -62,19 +62,12 @@
** Initials Name Company **
** -------- ------------------------- ---------------------------------- **
** aw Alexander Wenzel BMW **
-** mk Markus Klein Fraunhofer ESK **
*******************************************************************************/
/*******************************************************************************
** Revision Control History **
*******************************************************************************/
-/*
- * $LastChangedRevision: 1670 $
- * $LastChangedDate: 2011-04-08 15:12:06 +0200 (Fr, 08. Apr 2011) $
- * $LastChangedBy$
- */
-
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -106,12 +99,22 @@ void dlt_system_init_options(DltSystemOptions *options)
strncpy(options->ConfigurationFile,DEFAULT_CONFIGURATION_FILE,sizeof(options->ConfigurationFile));
strncpy(options->ApplicationId,DEFAULT_APPLICATION_ID,sizeof(options->ApplicationId));
+
+ /* Syslog Adapter */
+ options->SyslogEnable = 0;
strncpy(options->SyslogContextId,DEFAULT_SYSLOG_CONTEXT_ID,sizeof(options->SyslogContextId));
options->SyslogPort = DEFAULT_SYSLOG_PORT;
- strncpy(options->FiletransferDirectory,DEFAULT_FILETRANSFER_DIRECTORY,sizeof(options->FiletransferDirectory));
+
+ /* Filetransfer */
+ options->FiletransferEnable = 0;
strncpy(options->FiletransferContextId,DEFAULT_FILETRANSFER_CONTEXT_ID,sizeof(options->FiletransferContextId));
+ strncpy(options->FiletransferDirectory1,DEFAULT_FILETRANSFER_DIRECTORY,sizeof(options->FiletransferDirectory1));
+ options->FiletransferDirectory2[0]=0;
options->FiletransferTimeStartup = DEFAULT_FILETRANSFER_TIME_STARTUP;
options->FiletransferTimeDelay = DEFAULT_FILETRANSFER_TIME_DELAY;
+
+ /* Log file */
+ options->LogFileEnable = 0;
options->LogFileNumber = 0;
for(num=0;num<DLT_SYSTEM_LOG_FILE_MAX;num++) {
options->LogFileFilename[num][0]=0;
@@ -119,14 +122,18 @@ void dlt_system_init_options(DltSystemOptions *options)
options->LogFileContextId[num][0]=0;
options->LogFileTimeDelay[num]=0;
}
- options->LogProcessNumber = 0;
+
+ /* Log processes */
+ options->LogProcessesEnable = 0;
strncpy(options->LogProcessesContextId,DEFAULT_LOG_PROCESSES_CONTEXT_ID,sizeof(options->LogProcessesContextId));
+ options->LogProcessNumber = 0;
for(num=0;num<DLT_SYSTEM_LOG_PROCESSES_MAX;num++) {
options->LogProcessName[num][0]=0;
options->LogProcessFilename[num][0]=0;
options->LogProcessMode[num]=0;
options->LogProcessTimeDelay[num]=0;
}
+
}
int dlt_system_parse_options(DltSystemOptions *options,int argc, char* argv[])
@@ -216,6 +223,12 @@ int dlt_system_parse_configuration(DltSystemOptions *options)
strncpy(options->ApplicationId,value,sizeof(options->ApplicationId));
printf("Option: %s=%s\n",token,value);
}
+ /* Syslog Adapter */
+ else if(strcmp(token,"SyslogEnable")==0)
+ {
+ options->SyslogEnable = atoi(value);
+ printf("Option: %s=%s\n",token,value);
+ }
else if(strcmp(token,"SyslogContextId")==0)
{
strncpy(options->SyslogContextId,value,sizeof(options->SyslogContextId));
@@ -226,9 +239,20 @@ int dlt_system_parse_configuration(DltSystemOptions *options)
options->SyslogPort = atoi(value);
printf("Option: %s=%s\n",token,value);
}
- else if(strcmp(token,"FiletransferDirectory")==0)
+ /* Filetransfer */
+ else if(strcmp(token,"FiletransferEnable")==0)
{
- strncpy(options->FiletransferDirectory,value,sizeof(options->FiletransferDirectory));
+ options->FiletransferEnable = atoi(value);
+ printf("Option: %s=%s\n",token,value);
+ }
+ else if(strcmp(token,"FiletransferDirectory1")==0)
+ {
+ strncpy(options->FiletransferDirectory1,value,sizeof(options->FiletransferDirectory1));
+ printf("Option: %s=%s\n",token,value);
+ }
+ else if(strcmp(token,"FiletransferDirectory2")==0)
+ {
+ strncpy(options->FiletransferDirectory2,value,sizeof(options->FiletransferDirectory2));
printf("Option: %s=%s\n",token,value);
}
else if(strcmp(token,"FiletransferContextId")==0)
@@ -246,6 +270,12 @@ int dlt_system_parse_configuration(DltSystemOptions *options)
options->FiletransferTimeDelay = atoi(value);
printf("Option: %s=%s\n",token,value);
}
+ /* Log File */
+ else if(strcmp(token,"LogFileEnable")==0)
+ {
+ options->LogFileEnable = atoi(value);
+ printf("Option: %s=%s\n",token,value);
+ }
else if(strcmp(token,"LogFileFilename")==0)
{
strncpy(options->LogFileFilename[options->LogFileNumber],value,sizeof(options->LogFileFilename[options->LogFileNumber]));
@@ -268,6 +298,12 @@ int dlt_system_parse_configuration(DltSystemOptions *options)
if(options->LogFileNumber < (DLT_SYSTEM_LOG_FILE_MAX-1) )
options->LogFileNumber++;
}
+ /* Log processes */
+ else if(strcmp(token,"LogProcessesEnable")==0)
+ {
+ options->LogProcessesEnable = atoi(value);
+ printf("Option: %s=%s\n",token,value);
+ }
else if(strcmp(token,"LogProcessesContextId")==0)
{
strncpy(options->LogProcessesContextId,value,sizeof(options->LogProcessesContextId));
@@ -348,48 +384,51 @@ int main(int argc, char* argv[])
return -1;
}
- /* register application and contexts */
+ /* register application and contexts */
DLT_REGISTER_APP(options.ApplicationId,"DLT System Manager");
-
- DLT_REGISTER_CONTEXT(syslogContext,options.SyslogContextId,"SYSLOG Adapter");
-
- DLT_REGISTER_CONTEXT(processesContext,options.LogProcessesContextId,"Log Processes");
-
- if(options.FiletransferDirectory[0]!=0)
+ if(options.SyslogEnable)
+ DLT_REGISTER_CONTEXT(syslogContext,options.SyslogContextId,"SYSLOG Adapter");
+ if(options.FiletransferEnable)
DLT_REGISTER_CONTEXT(filetransferContext,options.FiletransferContextId,"Filetransfer");
-
- for(num=0;num<options.LogFileNumber;num++) {
- if(options.LogFileFilename[num][0]!=0)
- DLT_REGISTER_CONTEXT(logFileContext[num],options.LogFileContextId[num],options.LogFileFilename[num]);
- runtime.timeLogFileDelay[num]=0;
-
+ if(options.LogFileEnable) {
+ for(num=0;num<options.LogFileNumber;num++) {
+ if(options.LogFileFilename[num][0]!=0)
+ DLT_REGISTER_CONTEXT(logFileContext[num],options.LogFileContextId[num],options.LogFileFilename[num]);
+ runtime.timeLogFileDelay[num]=0;
+ }
}
-
- for(num=0;num<options.LogProcessNumber;num++) {
- runtime.timeLogProcessDelay[num]=0;
+ if(options.LogProcessesEnable) {
+ DLT_REGISTER_CONTEXT(processesContext,options.LogProcessesContextId,"Log Processes");
+ for(num=0;num<options.LogProcessNumber;num++) {
+ runtime.timeLogProcessDelay[num]=0;
+ }
}
/* create systemd socket */
- if ((sock = socket(AF_INET, SOCK_DGRAM, 0)) == -1)
- {
- perror("Socket");
- exit(1);
- }
- server_addr.sin_family = AF_INET;
- server_addr.sin_port = htons(options.SyslogPort);
- server_addr.sin_addr.s_addr = INADDR_ANY;
- bzero(&(server_addr.sin_zero), 8);
- if (bind(sock, (struct sockaddr *)&server_addr,
- sizeof(struct sockaddr)) == -1)
- {
- perror("Bind");
- return -1;
- }
- addr_len = sizeof(struct sockaddr);
+ if(options.SyslogEnable) {
+ if ((sock = socket(AF_INET, SOCK_DGRAM, 0)) == -1)
+ {
+ perror("Socket");
+ exit(1);
+ }
+ server_addr.sin_family = AF_INET;
+ server_addr.sin_port = htons(options.SyslogPort);
+ server_addr.sin_addr.s_addr = INADDR_ANY;
+ bzero(&(server_addr.sin_zero), 8);
+ if (bind(sock, (struct sockaddr *)&server_addr,
+ sizeof(struct sockaddr)) == -1)
+ {
+ perror("Bind");
+ return -1;
+ }
+ addr_len = sizeof(struct sockaddr);
+ }
/* Watch sockets to see when it has input. */
- FD_ZERO(&rfds);
- FD_SET(sock, &rfds);
+ FD_ZERO(&rfds);
+ if(options.SyslogEnable) {
+ FD_SET(sock, &rfds);
+ }
/* init timers */
lasttime = dlt_uptime();
@@ -397,7 +436,8 @@ int main(int argc, char* argv[])
runtime.timeFiletransferDelay = 0;
/* initialise filetransfer manager */
- dlt_system_filetransfer_init(&options,&runtime);
+ if(options.FiletransferEnable)
+ dlt_system_filetransfer_init(&options,&runtime);
while (1)
{
@@ -419,7 +459,7 @@ int main(int argc, char* argv[])
;//printf("No data within one seconds.\n");
/* call filtransfer even in shorter time schedule */
- if(runtime.filetransferRunning)
+ if(options.FiletransferEnable && runtime.filetransferRunning)
dlt_system_filetransfer_run(&options,&runtime,&filetransferContext);
if((dlt_uptime()-lasttime) >= 10000)
@@ -429,7 +469,7 @@ int main(int argc, char* argv[])
runtime.timeStartup++;
/* filetransfer manager */
- if(options.FiletransferDirectory[0]!=0) {
+ if(options.FiletransferEnable) {
if(runtime.timeStartup > options.FiletransferTimeStartup) {
if(runtime.timeFiletransferDelay>0) {
runtime.timeFiletransferDelay--;
@@ -441,30 +481,34 @@ int main(int argc, char* argv[])
}
/* log files */
- for(num=0;num<options.LogFileNumber;num++) {
- if(((options.LogFileMode[num] == DLT_SYSTEM_MODE_STARTUP) && firsttime) ||
- (options.LogFileMode[num] == DLT_SYSTEM_MODE_REGULAR) ) {
- if(runtime.timeLogFileDelay[num]<=0) {
- dlt_system_log_file(&options,&logFileContext[num],num);
- runtime.timeLogFileDelay[num]=options.LogFileTimeDelay[num]-1;
- }
- else {
- runtime.timeLogFileDelay[num]--;
- }
+ if(options.LogFileEnable) {
+ for(num=0;num<options.LogFileNumber;num++) {
+ if(((options.LogFileMode[num] == DLT_SYSTEM_MODE_STARTUP) && firsttime) ||
+ (options.LogFileMode[num] == DLT_SYSTEM_MODE_REGULAR) ) {
+ if(runtime.timeLogFileDelay[num]<=0) {
+ dlt_system_log_file(&options,&logFileContext[num],num);
+ runtime.timeLogFileDelay[num]=options.LogFileTimeDelay[num]-1;
+ }
+ else {
+ runtime.timeLogFileDelay[num]--;
+ }
+ }
}
}
/* log processes information */
- for(num=0;num<options.LogProcessNumber;num++) {
- if(((options.LogProcessMode[num] == DLT_SYSTEM_MODE_STARTUP) && firsttime) ||
- (options.LogProcessMode[num] == DLT_SYSTEM_MODE_REGULAR) ) {
- if(runtime.timeLogProcessDelay[num]<=0) {
- dlt_system_log_process(&options,&processesContext,num);
- runtime.timeLogProcessDelay[num]=options.LogProcessTimeDelay[num]-1;
- }
- else {
- runtime.timeLogProcessDelay[num]--;
- }
+ if(options.LogProcessesEnable) {
+ for(num=0;num<options.LogProcessNumber;num++) {
+ if(((options.LogProcessMode[num] == DLT_SYSTEM_MODE_STARTUP) && firsttime) ||
+ (options.LogProcessMode[num] == DLT_SYSTEM_MODE_REGULAR) ) {
+ if(runtime.timeLogProcessDelay[num]<=0) {
+ dlt_system_log_process(&options,&processesContext,num);
+ runtime.timeLogProcessDelay[num]=options.LogProcessTimeDelay[num]-1;
+ }
+ else {
+ runtime.timeLogProcessDelay[num]--;
+ }
+ }
}
}
@@ -472,7 +516,7 @@ int main(int argc, char* argv[])
}
/* check syslog adapter socket */
- if(FD_ISSET(sock, &rfds))
+ if(options.SyslogEnable && FD_ISSET(sock, &rfds))
{
bytes_read = 0;
@@ -500,17 +544,22 @@ int main(int argc, char* argv[])
}
}
- DLT_UNREGISTER_CONTEXT(processesContext);
-
- if(options.FiletransferDirectory[0]!=0)
+ if(options.SyslogEnable)
+ DLT_UNREGISTER_CONTEXT(syslogContext);
+
+ if(options.FiletransferEnable)
DLT_UNREGISTER_CONTEXT(filetransferContext);
- for(num=0;num<options.LogFileNumber;num++) {
- if(options.LogFileFilename[num][0]!=0)
- DLT_UNREGISTER_CONTEXT(logFileContext[num]);
+ if(options.LogFileEnable) {
+ for(num=0;num<options.LogFileNumber;num++) {
+ if(options.LogFileFilename[num][0]!=0)
+ DLT_UNREGISTER_CONTEXT(logFileContext[num]);
+ }
}
+
+ if(options.LogProcessesEnable)
+ DLT_UNREGISTER_CONTEXT(processesContext);
- DLT_UNREGISTER_CONTEXT(syslogContext);
DLT_UNREGISTER_APP();
return 0;
diff --git a/src/system/dlt-system.conf b/src/system/dlt-system.conf
index 53b1abd..1811fc3 100644
--- a/src/system/dlt-system.conf
+++ b/src/system/dlt-system.conf
@@ -12,6 +12,9 @@ ApplicationId = SYS
# Syslog Adapter configuration
########################################################################
+# Enable the Syslog Adapter (Default: 0)
+SyslogEnable = 1
+
# The Context Id of the syslog adapter (Default: SYSL)
SyslogContextId = SYSL
@@ -22,25 +25,32 @@ SyslogPort = 47111
# Filetransfer Manager
########################################################################
+# Enable the Filetransfer (Default: 0)
+FiletransferEnable = 1
+
# Directory which contains files to be transfered over DLT (Default: /tmp/filetransfer)
# Files are deleted after Filetransfer is finished and after TimeDelay expired
-FiletransferDirectory = /tmp/filetransfer
+FiletransferDirectory1 = /tmp/filetransfer
+FiletransferDirectory2 = /tmp/filetransfer2
# The Context Id of the filetransfer (Default: FILE)
FiletransferContextId = FILE
# Time after startup of dlt-system when first file is transfered (Default: 30)
# Time in seconds
-FiletransferTimeStartup = 5
+FiletransferTimeStartup = 30
# Time to wait when transfered file is deleted and next file transfer starts (Default: 10)
# Time in seconds
-FiletransferTimeDelay = 3
+FiletransferTimeDelay = 10
########################################################################
# Log short files, expecially from proc filesystem
########################################################################
+# Enable the logging of files (Default: 0)
+LogFileEnable = 1
+
# Log different files
# Mode: 0 = off, 1 = startup only, 2 = regular
# TimeDelay: If mode regular is set, time delay is the number of seconds for next sent
@@ -55,48 +65,51 @@ LogFileContextId = VER
LogFileFilename = /proc/version
LogFileMode = 1
LogFileTimeDelay = 3
-LogFileContextId = KVER
+LogFileContextId = VERK
# Log the file /proc/meminfo
-LogFileFilename = /proc/meminfo
-LogFileMode = 2
-LogFileTimeDelay = 5
-LogFileContextId = MEM
+# LogFileFilename = /proc/meminfo
+# LogFileMode = 2
+# LogFileTimeDelay = 5
+# LogFileContextId = MEM
# Log the file /proc/cpuinfo
-LogFileFilename = /proc/cpuinfo
-LogFileMode = 2
-LogFileTimeDelay = 5
-LogFileContextId = CPU
+# LogFileFilename = /proc/cpuinfo
+# LogFileMode = 2
+# LogFileTimeDelay = 5
+# LogFileContextId = CPU
# Log the file /proc/stat
LogFileFilename = /proc/stat
LogFileMode = 2
-LogFileTimeDelay = 5
+LogFileTimeDelay = 1
LogFileContextId = STAT
# Log the file /proc/modules
-LogFileFilename = /proc/modules
-LogFileMode = 2
-LogFileTimeDelay = 5
-LogFileContextId = MOD
+# LogFileFilename = /proc/modules
+# LogFileMode = 2
+# LogFileTimeDelay = 5
+# LogFileContextId = MOD
# Log the file /proc/ioports
-LogFileFilename = /proc/ioports
-LogFileMode = 1
-LogFileTimeDelay = 5
-LogFileContextId = IOP
+# LogFileFilename = /proc/ioports
+# LogFileMode = 1
+# LogFileTimeDelay = 5
+# LogFileContextId = IOP
# Log the file /proc/iomem
-LogFileFilename = /proc/iomem
-LogFileMode = 1
-LogFileTimeDelay = 5
-LogFileContextId = IOM
+# LogFileFilename = /proc/iomem
+# LogFileMode = 1
+# LogFileTimeDelay = 5
+# LogFileContextId = IOM
########################################################################
# Log Processes
########################################################################
+# Enable the logging of processes (Default: 0)
+LogProcessesEnable = 1
+
# The Context Id of the kernel version (Default: PROC)
LogProcessesContextId = PROC
@@ -108,11 +121,11 @@ LogProcessesContextId = PROC
LogProcessName = *
LogProcessFilename = stat
-LogProcessMode = 1
+LogProcessMode = 2
LogProcessTimeDelay = 5
-LogProcessName = ./dlt-daemon
-LogProcessFilename = stat
-LogProcessMode = 2
-LogProcessTimeDelay = 1
+# LogProcessName = dlt_viewer
+# LogProcessFilename = stat
+# LogProcessMode = 2
+# LogProcessTimeDelay = 1
diff --git a/src/system/dlt-system.h b/src/system/dlt-system.h
index d0005fd..1865060 100644
--- a/src/system/dlt-system.h
+++ b/src/system/dlt-system.h
@@ -1,3 +1,73 @@
+/*
+ * Dlt system manager to Dlt
+ * @licence app begin@
+ *
+ * Copyright (C) 2011, BMW AG - Alexander Wenzel <alexander.wenzel@bmw.de>
+ *
+ * This program is free software; you can redistribute it and/or modify it under the terms of the
+ * GNU Lesser General Public License, version 2.1, as published by the Free Software Foundation.
+ * 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 Lesser General
+ * Public License, version 2.1, for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License, version 2.1, along
+ * with this program; if not, see <http://www.gnu.org/licenses/lgpl-2.1.html>.
+ *
+ * Note that the copyright holders assume that the GNU Lesser General Public License, version 2.1, may
+ * also be applicable to programs even in cases in which the program is not a library in the technical sense.
+ *
+ * Linking DLT statically or dynamically with other modules is making a combined work based on DLT. You may
+ * license such other modules under the GNU Lesser General Public License, version 2.1. If you do not want to
+ * license your linked modules under the GNU Lesser General Public License, version 2.1, you
+ * may use the program under the following exception.
+ *
+ * As a special exception, the copyright holders of DLT give you permission to combine DLT
+ * with software programs or libraries that are released under any license unless such a combination is not
+ * permitted by the license of such a software program or library. You may copy and distribute such a
+ * system following the terms of the GNU Lesser General Public License, version 2.1, including this
+ * special exception, for DLT and the licenses of the other code concerned.
+ *
+ * Note that people who make modified versions of DLT are not obligated to grant this special exception
+ * for their modified versions; it is their choice whether to do so. The GNU Lesser General Public License,
+ * version 2.1, gives permission to release a modified version without this exception; this exception
+ * also makes it possible to release a modified version which carries forward this exception.
+ *
+ * @licence end@
+ */
+
+/*******************************************************************************
+** **
+** SRC-MODULE: dlt-system.h **
+** **
+** TARGET : linux **
+** **
+** PROJECT : DLT **
+** **
+** AUTHOR : Alexander Wenzel Alexander.AW.Wenzel@bmw.de **
+** **
+** PURPOSE : **
+** **
+** REMARKS : **
+** **
+** PLATFORM DEPENDANT [yes/no]: yes **
+** **
+** TO BE CHANGED BY USER [yes/no]: no **
+** **
+*******************************************************************************/
+
+/*******************************************************************************
+** Author Identity **
+********************************************************************************
+** **
+** Initials Name Company **
+** -------- ------------------------- ---------------------------------- **
+** aw Alexander Wenzel BMW **
+*******************************************************************************/
+
+/*******************************************************************************
+** Revision Control History **
+*******************************************************************************/
+
#ifndef DLT_SYSTEM_H
#define DLT_SYSTEM_H
@@ -11,17 +81,26 @@
typedef struct {
char ConfigurationFile[256];
char ApplicationId[256];
+
+ int SyslogEnable;
char SyslogContextId[256];
int SyslogPort;
- char FiletransferDirectory[256];
+
+ int FiletransferEnable;
+ char FiletransferDirectory1[256];
+ char FiletransferDirectory2[256];
char FiletransferContextId[256];
int FiletransferTimeStartup;
int FiletransferTimeDelay;
+
+ int LogFileEnable;
int LogFileNumber;
char LogFileFilename[DLT_SYSTEM_LOG_FILE_MAX][256];
int LogFileMode[DLT_SYSTEM_LOG_FILE_MAX];
int LogFileTimeDelay[DLT_SYSTEM_LOG_FILE_MAX];
char LogFileContextId[DLT_SYSTEM_LOG_FILE_MAX][256];
+
+ int LogProcessesEnable;
char LogProcessesContextId[256];
int LogProcessNumber;
char LogProcessName[DLT_SYSTEM_LOG_PROCESSES_MAX][256];
diff --git a/src/system/dlt-system_cfg.h b/src/system/dlt-system_cfg.h
index dbd6ce0..c90d28f 100644
--- a/src/system/dlt-system_cfg.h
+++ b/src/system/dlt-system_cfg.h
@@ -1,3 +1,73 @@
+/*
+ * Dlt system manager to Dlt
+ * @licence app begin@
+ *
+ * Copyright (C) 2011, BMW AG - Alexander Wenzel <alexander.wenzel@bmw.de>
+ *
+ * This program is free software; you can redistribute it and/or modify it under the terms of the
+ * GNU Lesser General Public License, version 2.1, as published by the Free Software Foundation.
+ * 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 Lesser General
+ * Public License, version 2.1, for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License, version 2.1, along
+ * with this program; if not, see <http://www.gnu.org/licenses/lgpl-2.1.html>.
+ *
+ * Note that the copyright holders assume that the GNU Lesser General Public License, version 2.1, may
+ * also be applicable to programs even in cases in which the program is not a library in the technical sense.
+ *
+ * Linking DLT statically or dynamically with other modules is making a combined work based on DLT. You may
+ * license such other modules under the GNU Lesser General Public License, version 2.1. If you do not want to
+ * license your linked modules under the GNU Lesser General Public License, version 2.1, you
+ * may use the program under the following exception.
+ *
+ * As a special exception, the copyright holders of DLT give you permission to combine DLT
+ * with software programs or libraries that are released under any license unless such a combination is not
+ * permitted by the license of such a software program or library. You may copy and distribute such a
+ * system following the terms of the GNU Lesser General Public License, version 2.1, including this
+ * special exception, for DLT and the licenses of the other code concerned.
+ *
+ * Note that people who make modified versions of DLT are not obligated to grant this special exception
+ * for their modified versions; it is their choice whether to do so. The GNU Lesser General Public License,
+ * version 2.1, gives permission to release a modified version without this exception; this exception
+ * also makes it possible to release a modified version which carries forward this exception.
+ *
+ * @licence end@
+ */
+
+/*******************************************************************************
+** **
+** SRC-MODULE: dlt-system_cfg.h **
+** **
+** TARGET : linux **
+** **
+** PROJECT : DLT **
+** **
+** AUTHOR : Alexander Wenzel Alexander.AW.Wenzel@bmw.de **
+** **
+** PURPOSE : **
+** **
+** REMARKS : **
+** **
+** PLATFORM DEPENDANT [yes/no]: yes **
+** **
+** TO BE CHANGED BY USER [yes/no]: no **
+** **
+*******************************************************************************/
+
+/*******************************************************************************
+** Author Identity **
+********************************************************************************
+** **
+** Initials Name Company **
+** -------- ------------------------- ---------------------------------- **
+** aw Alexander Wenzel BMW **
+*******************************************************************************/
+
+/*******************************************************************************
+** Revision Control History **
+*******************************************************************************/
+
#define DEFAULT_CONFIGURATION_FILE "/etc/dlt-system.conf"
#define DEFAULT_APPLICATION_ID "SYS"