diff options
Diffstat (limited to 'src/system/dlt-system-log.c')
-rw-r--r-- | src/system/dlt-system-log.c | 53 |
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); +} |