summaryrefslogtreecommitdiff
path: root/src/system/dlt-system-log.c
diff options
context:
space:
mode:
authorAlexander Wenzel <Alexander.AW.Wenzel@bmw.de>2011-10-05 15:00:04 +0200
committerAlexander Wenzel <Alexander.AW.Wenzel@bmw.de>2011-10-05 15:00:04 +0200
commitfbc90e0e3b7c6754cc426b183eeabea3e98359d8 (patch)
treef23203d80ae10237837f5541cd180585104b7694 /src/system/dlt-system-log.c
parent71a7aae2c7e3451293ad7e96b07efa5329e12b86 (diff)
downloadDLT-daemon-fbc90e0e3b7c6754cc426b183eeabea3e98359d8.tar.gz
Functionality log of processes from /proc added.
Diffstat (limited to 'src/system/dlt-system-log.c')
-rw-r--r--src/system/dlt-system-log.c53
1 files changed, 52 insertions, 1 deletions
diff --git a/src/system/dlt-system-log.c b/src/system/dlt-system-log.c
index 45ac901..de40176 100644
--- a/src/system/dlt-system-log.c
+++ b/src/system/dlt-system-log.c
@@ -2,6 +2,11 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+#include <dirent.h>
#include "dlt_common.h"
#include "dlt_user.h"
@@ -10,7 +15,7 @@
#include "dlt-system_cfg.h"
#include "dlt-system-log.h"
-void dlt_system_log_kernel_version(DltContext *context) {
+void dlt_system_log_kernel_version(DltSystemOptions *options,DltContext *context) {
FILE * pFile;
char buffer[1024];
int bytes;
@@ -29,3 +34,49 @@ void dlt_system_log_kernel_version(DltContext *context) {
}
}
}
+
+void dlt_system_log_processes(DltSystemOptions *options,DltContext *context) {
+ FILE * pFile;
+ struct dirent *dp;
+ char filename[256];
+ char buffer[1024];
+ int bytes;
+ int num;
+
+ /* 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') {
+ sprintf(filename,"/proc/%s/stat",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));
+ }
+ }
+ 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) {
+ for(num=0;num<bytes;num++) {
+ if(buffer[num]==0) {
+ buffer[num] = ' ';
+ }
+ }
+ buffer[bytes] = 0;
+ DLT_LOG(*context, DLT_LOG_INFO, DLT_INT(atoi(dp->d_name)), DLT_STRING(buffer));
+ }
+ }
+ }
+ }
+ closedir(dir);
+}