diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/CMakeLists.txt | 6 | ||||
-rw-r--r-- | src/kpi/CMakeLists.txt (renamed from src/procfs/CMakeLists.txt) | 12 | ||||
-rw-r--r-- | src/kpi/dlt-kpi-common.c (renamed from src/procfs/dlt-procfs-common.c) | 10 | ||||
-rw-r--r-- | src/kpi/dlt-kpi-common.h (renamed from src/procfs/dlt-procfs-common.h) | 12 | ||||
-rw-r--r-- | src/kpi/dlt-kpi-interrupt.c (renamed from src/procfs/dlt-procfs-interrupt.c) | 32 | ||||
-rw-r--r-- | src/kpi/dlt-kpi-interrupt.h (renamed from src/procfs/dlt-procfs-interrupt.h) | 12 | ||||
-rw-r--r-- | src/kpi/dlt-kpi-options.c (renamed from src/procfs/dlt-procfs-options.c) | 30 | ||||
-rw-r--r-- | src/kpi/dlt-kpi-process-list.c (renamed from src/procfs/dlt-procfs-process-list.c) | 82 | ||||
-rw-r--r-- | src/kpi/dlt-kpi-process-list.h | 54 | ||||
-rw-r--r-- | src/kpi/dlt-kpi-process.c (renamed from src/procfs/dlt-procfs-process.c) | 125 | ||||
-rw-r--r-- | src/kpi/dlt-kpi-process.h | 56 | ||||
-rw-r--r-- | src/kpi/dlt-kpi.c (renamed from src/procfs/dlt-procfs.c) | 183 | ||||
-rw-r--r-- | src/kpi/dlt-kpi.conf (renamed from src/procfs/dlt-procfs.conf) | 2 | ||||
-rw-r--r-- | src/kpi/dlt-kpi.h (renamed from src/procfs/dlt-procfs.h) | 31 | ||||
-rw-r--r-- | src/procfs/dlt-procfs-process-list.h | 54 | ||||
-rw-r--r-- | src/procfs/dlt-procfs-process.h | 56 |
16 files changed, 386 insertions, 371 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index f30932a..1457578 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -47,6 +47,6 @@ if( WITH_DLT_COREDUMPHANDLER ) add_subdirectory( core_dump_handler ) endif( WITH_DLT_COREDUMPHANDLER ) -if( WITH_DLT_PROCFS ) - add_subdirectory( procfs ) -endif( WITH_DLT_PROCFS ) +if( WITH_DLT_KPI ) + add_subdirectory( kpi ) +endif( WITH_DLT_KPI ) diff --git a/src/procfs/CMakeLists.txt b/src/kpi/CMakeLists.txt index bbe3d49..721b612 100644 --- a/src/procfs/CMakeLists.txt +++ b/src/kpi/CMakeLists.txt @@ -15,15 +15,15 @@ # @licence end@ ####### -set (dlt_procfs_SRCS dlt-procfs.c dlt-procfs-options.c dlt-procfs-process.c dlt-procfs-process-list.c dlt-procfs-common.c dlt-procfs-interrupt.c) -add_executable (dlt-procfs ${dlt_procfs_SRCS}) -target_link_libraries (dlt-procfs dlt) -set_target_properties(dlt-procfs PROPERTIES LINKER_LANGUAGE C) +set (dlt_kpi_SRCS dlt-kpi.c dlt-kpi-options.c dlt-kpi-process.c dlt-kpi-process-list.c dlt-kpi-common.c dlt-kpi-interrupt.c) +add_executable (dlt-kpi ${dlt_kpi_SRCS}) +target_link_libraries (dlt-kpi dlt) +set_target_properties(dlt-kpi PROPERTIES LINKER_LANGUAGE C) -install(TARGETS dlt-procfs +install(TARGETS dlt-kpi RUNTIME DESTINATION bin COMPONENT base) -INSTALL(FILES dlt-procfs.conf +INSTALL(FILES dlt-kpi.conf DESTINATION ${CONFIGURATION_FILES_DIR} COMPONENT base) diff --git a/src/procfs/dlt-procfs-common.c b/src/kpi/dlt-kpi-common.c index c7e490d..c0c7767 100644 --- a/src/procfs/dlt-procfs-common.c +++ b/src/kpi/dlt-kpi-common.c @@ -21,15 +21,15 @@ * \copyright Copyright © 2011-2015 BMW AG. \n * License MPL-2.0: Mozilla Public License version 2.0 http://mozilla.org/MPL/2.0/. * - * \file dlt-procfs-common.c + * \file dlt-kpi-common.c */ -#include "dlt-procfs-common.h" +#include "dlt-kpi-common.h" -DltReturnValue dlt_procfs_read_file_compact(char *filename, char **target) +DltReturnValue dlt_kpi_read_file_compact(char *filename, char **target) { char buffer[BUFFER_SIZE]; - int ret = dlt_procfs_read_file(filename, buffer, BUFFER_SIZE); + int ret = dlt_kpi_read_file(filename, buffer, BUFFER_SIZE); if(ret < DLT_RETURN_OK) return ret; @@ -44,7 +44,7 @@ DltReturnValue dlt_procfs_read_file_compact(char *filename, char **target) return DLT_RETURN_OK; } -DltReturnValue dlt_procfs_read_file(char* filename, char* buffer, uint maxLength) +DltReturnValue dlt_kpi_read_file(char* filename, char* buffer, uint maxLength) { if(filename == NULL || buffer == NULL) { diff --git a/src/procfs/dlt-procfs-common.h b/src/kpi/dlt-kpi-common.h index ed7f096..4e220a8 100644 --- a/src/procfs/dlt-procfs-common.h +++ b/src/kpi/dlt-kpi-common.h @@ -21,11 +21,11 @@ * \copyright Copyright © 2011-2015 BMW AG. \n * License MPL-2.0: Mozilla Public License version 2.0 http://mozilla.org/MPL/2.0/. * - * \file dlt-procfs-common.h + * \file dlt-kpi-common.h */ -#ifndef SRC_PROCFS_DLT_PROCFS_COMMON_H_ -#define SRC_PROCFS_DLT_PROCFS_COMMON_H_ +#ifndef SRC_KPI_DLT_KPI_COMMON_H_ +#define SRC_KPI_DLT_KPI_COMMON_H_ #include <dlt_types.h> #include <stdio.h> @@ -34,7 +34,7 @@ #define BUFFER_SIZE 4096 -DltReturnValue dlt_procfs_read_file(char* filename, char* buffer, uint maxLength); -DltReturnValue dlt_procfs_read_file_compact(char *filename, char **target); +DltReturnValue dlt_kpi_read_file(char* filename, char* buffer, uint maxLength); +DltReturnValue dlt_kpi_read_file_compact(char *filename, char **target); -#endif /* SRC_PROCFS_DLT_PROCFS_COMMON_H_ */ +#endif /* SRC_KPI_DLT_KPI_COMMON_H_ */ diff --git a/src/procfs/dlt-procfs-interrupt.c b/src/kpi/dlt-kpi-interrupt.c index 10d8823..c193b70 100644 --- a/src/procfs/dlt-procfs-interrupt.c +++ b/src/kpi/dlt-kpi-interrupt.c @@ -21,16 +21,16 @@ * \copyright Copyright © 2011-2015 BMW AG. \n * License MPL-2.0: Mozilla Public License version 2.0 http://mozilla.org/MPL/2.0/. * - * \file dlt-procfs-interrupt.c + * \file dlt-kpi-interrupt.c */ -#include "dlt-procfs-interrupt.h" +#include "dlt-kpi-interrupt.h" -DltReturnValue dlt_procfs_log_interrupts(DltContext *ctx, DltLogLevelType log_level) +DltReturnValue dlt_kpi_log_interrupts(DltContext *ctx, DltLogLevelType log_level) { if(ctx == NULL) { - fprintf(stderr, "dlt_procfs_log_interrupts(): Nullpointer parameter\n"); + fprintf(stderr, "dlt_kpi_log_interrupts(): Nullpointer parameter\n"); return DLT_RETURN_WRONG_PARAMETER; } @@ -42,7 +42,7 @@ DltReturnValue dlt_procfs_log_interrupts(DltContext *ctx, DltLogLevelType log_le int head_line = 1, first_row = 1, cpu_count = 0, column = 0, buffer_offset = 0; DltReturnValue ret; - if((ret = dlt_procfs_read_file("/proc/interrupts", file_buffer, BUFFER_SIZE)) < DLT_RETURN_OK) return ret; + if((ret = dlt_kpi_read_file("/proc/interrupts", file_buffer, BUFFER_SIZE)) < DLT_RETURN_OK) return ret; token = strtok(file_buffer, delim); while(token != NULL) @@ -53,7 +53,7 @@ DltReturnValue dlt_procfs_log_interrupts(DltContext *ctx, DltLogLevelType log_le cpu_count++; else if(cpu_count <= 0) { - fprintf(stderr, "dlt_procfs_log_interrupts: Could not parse CPU count\n"); + fprintf(stderr, "dlt_kpi_log_interrupts: Could not parse CPU count\n"); return DLT_RETURN_ERROR; } else if(strcmp(token, "\n") == 0) @@ -83,7 +83,7 @@ DltReturnValue dlt_procfs_log_interrupts(DltContext *ctx, DltLogLevelType log_le long int interrupt_count = strtol(token, &check, 10); if(*check != '\0') { - fprintf(stderr, "dlt_procfs_log_interrupts: Could not parse interrupt count for CPU %d\n", column - 1); + fprintf(stderr, "dlt_kpi_log_interrupts: Could not parse interrupt count for CPU %d\n", column - 1); return DLT_RETURN_ERROR; } @@ -96,16 +96,19 @@ DltReturnValue dlt_procfs_log_interrupts(DltContext *ctx, DltLogLevelType log_le } } + // synchronization message + DLT_LOG(*ctx, log_level, DLT_STRING("IRQ"), DLT_STRING("BEG")); + DltContextData ctx_data; if((ret = dlt_user_log_write_start(ctx, &ctx_data, log_level)) < DLT_RETURN_OK) { - fprintf(stderr, "dlt_procfs_log_interrupts(): dlt_user_log_write_start() returned error\n"); + fprintf(stderr, "dlt_kpi_log_interrupts(): dlt_user_log_write_start() returned error\n"); return ret; } if((ret = dlt_user_log_write_string(&ctx_data, "IRQ")) < DLT_RETURN_OK) { - fprintf(stderr, "dlt_procfs_log_interrupts(): dlt_user_log_write_string() returned error\n"); + fprintf(stderr, "dlt_kpi_log_interrupts(): dlt_user_log_write_string() returned error\n"); return ret; } @@ -117,19 +120,19 @@ DltReturnValue dlt_procfs_log_interrupts(DltContext *ctx, DltLogLevelType log_le /* message buffer full, start new one */ if((ret = dlt_user_log_write_finish(&ctx_data)) < DLT_RETURN_OK) { - fprintf(stderr, "dlt_procfs_log_interrupts(): dlt_user_log_write_finish() returned error\n"); + fprintf(stderr, "dlt_kpi_log_interrupts(): dlt_user_log_write_finish() returned error\n"); return ret; } if((ret = dlt_user_log_write_start(ctx, &ctx_data, log_level)) < DLT_RETURN_OK) { - fprintf(stderr, "dlt_procfs_log_interrupts(): dlt_user_log_write_start() returned error\n"); + fprintf(stderr, "dlt_kpi_log_interrupts(): dlt_user_log_write_start() returned error\n"); return ret; } if((ret = dlt_user_log_write_string(&ctx_data, "IRQ")) < DLT_RETURN_OK) { - fprintf(stderr, "dlt_procfs_log_interrupts(): dlt_user_log_write_string() returned error\n"); + fprintf(stderr, "dlt_kpi_log_interrupts(): dlt_user_log_write_string() returned error\n"); return ret; } } @@ -139,9 +142,12 @@ DltReturnValue dlt_procfs_log_interrupts(DltContext *ctx, DltLogLevelType log_le if((ret = dlt_user_log_write_finish(&ctx_data)) < DLT_RETURN_OK) { - fprintf(stderr, "dlt_procfs_log_interrupts(): dlt_user_log_write_finish() returned error\n"); + fprintf(stderr, "dlt_kpi_log_interrupts(): dlt_user_log_write_finish() returned error\n"); return ret; } + // synchronization message + DLT_LOG(*ctx, log_level, DLT_STRING("IRQ"), DLT_STRING("END")); + return DLT_RETURN_OK; } diff --git a/src/procfs/dlt-procfs-interrupt.h b/src/kpi/dlt-kpi-interrupt.h index 48a3a6d..8b5dc4d 100644 --- a/src/procfs/dlt-procfs-interrupt.h +++ b/src/kpi/dlt-kpi-interrupt.h @@ -21,15 +21,15 @@ * \copyright Copyright © 2011-2015 BMW AG. \n * License MPL-2.0: Mozilla Public License version 2.0 http://mozilla.org/MPL/2.0/. * - * \file dlt-procfs-interrupt.h + * \file dlt-kpi-interrupt.h */ -#ifndef SRC_PROCFS_DLT_PROCFS_INTERRUPT_H_ -#define SRC_PROCFS_DLT_PROCFS_INTERRUPT_H_ +#ifndef SRC_KPI_DLT_KPI_INTERRUPT_H_ +#define SRC_KPI_DLT_KPI_INTERRUPT_H_ #include "dlt.h" -#include "dlt-procfs-common.h" +#include "dlt-kpi-common.h" -DltReturnValue dlt_procfs_log_interrupts(DltContext *ctx, DltLogLevelType log_level); +DltReturnValue dlt_kpi_log_interrupts(DltContext *ctx, DltLogLevelType log_level); -#endif /* SRC_PROCFS_DLT_PROCFS_INTERRUPT_H_ */ +#endif /* SRC_KPI_DLT_KPI_INTERRUPT_H_ */ diff --git a/src/procfs/dlt-procfs-options.c b/src/kpi/dlt-kpi-options.c index d2aa3af..dda36dc 100644 --- a/src/procfs/dlt-procfs-options.c +++ b/src/kpi/dlt-kpi-options.c @@ -21,10 +21,10 @@ * \copyright Copyright © 2011-2015 BMW AG. \n * License MPL-2.0: Mozilla Public License version 2.0 http://mozilla.org/MPL/2.0/. * - * \file dlt-procfs-options.c + * \file dlt-kpi-options.c */ -#include "dlt-procfs.h" +#include "dlt-kpi.h" /** * Print information how to use this program. @@ -47,26 +47,26 @@ void usage(char *prog_name) /** * Initialize command line options with default values. */ -void dlt_procfs_init_cli_options(DltProcfsOptions *options) +void dlt_kpi_init_cli_options(DltKpiOptions *options) { options->configurationFileName = DEFAULT_CONF_FILE; options->customConfigFile = 0; } -void dlt_procfs_free_cli_options(DltProcfsOptions *options) +void dlt_kpi_free_cli_options(DltKpiOptions *options) { if(options->customConfigFile) free(options->configurationFileName); } -DltReturnValue dlt_procfs_read_command_line(DltProcfsOptions *options, int argc, char **argv) +DltReturnValue dlt_kpi_read_command_line(DltKpiOptions *options, int argc, char **argv) { if(options == NULL) { - fprintf(stderr, "dlt_procfs_read_command_line(): Nullpointer parameter\n"); + fprintf(stderr, "dlt_kpi_read_command_line(): Nullpointer parameter\n"); return DLT_RETURN_WRONG_PARAMETER; } - dlt_procfs_init_cli_options(options); + dlt_kpi_init_cli_options(options); int opt; while((opt = getopt(argc, argv, "c:h")) != -1) @@ -104,7 +104,7 @@ DltReturnValue dlt_procfs_read_command_line(DltProcfsOptions *options, int argc, /** * Initialize configuration to default values. */ -void dlt_procfs_init_configuration(DltProcfsConfig *config) +void dlt_kpi_init_configuration(DltKpiConfig *config) { config->process_log_interval = 1000; config->irq_log_interval = 1000; @@ -114,7 +114,7 @@ void dlt_procfs_init_configuration(DltProcfsConfig *config) /** * Read options from the configuration file */ -DltReturnValue dlt_procfs_read_configuration_file(DltProcfsConfig *config, char *file_name) +DltReturnValue dlt_kpi_read_configuration_file(DltKpiConfig *config, char *file_name) { FILE *file; char *line, *token, *value, *pch, *strchk; @@ -126,7 +126,7 @@ DltReturnValue dlt_procfs_read_configuration_file(DltProcfsConfig *config, char return DLT_RETURN_WRONG_PARAMETER; } - dlt_procfs_init_configuration(config); + dlt_kpi_init_configuration(config); file = fopen(file_name, "r"); @@ -229,9 +229,9 @@ DltReturnValue dlt_procfs_read_configuration_file(DltProcfsConfig *config, char return DLT_RETURN_OK; } -DltReturnValue dlt_procfs_init(int argc, char **argv, DltProcfsConfig *config) +DltReturnValue dlt_kpi_init(int argc, char **argv, DltKpiConfig *config) { - DltProcfsOptions options; + DltKpiOptions options; DltReturnValue ret; @@ -241,19 +241,19 @@ DltReturnValue dlt_procfs_init(int argc, char **argv, DltProcfsConfig *config) return DLT_RETURN_WRONG_PARAMETER; } - if((ret = dlt_procfs_read_command_line(&options, argc, argv)) < DLT_RETURN_OK) + if((ret = dlt_kpi_read_command_line(&options, argc, argv)) < DLT_RETURN_OK) { fprintf(stderr, "Failed to read command line!"); return ret; } - if((ret = dlt_procfs_read_configuration_file(config, options.configurationFileName)) < DLT_RETURN_OK) + if((ret = dlt_kpi_read_configuration_file(config, options.configurationFileName)) < DLT_RETURN_OK) { fprintf(stderr, "Failed to read configuration file!"); return ret; } - dlt_procfs_free_cli_options(&options); + dlt_kpi_free_cli_options(&options); return DLT_RETURN_OK; } diff --git a/src/procfs/dlt-procfs-process-list.c b/src/kpi/dlt-kpi-process-list.c index 9c98bdc..7711498 100644 --- a/src/procfs/dlt-procfs-process-list.c +++ b/src/kpi/dlt-kpi-process-list.c @@ -21,31 +21,31 @@ * \copyright Copyright © 2011-2015 BMW AG. \n * License MPL-2.0: Mozilla Public License version 2.0 http://mozilla.org/MPL/2.0/. * - * \file dlt-procfs-process-list.c + * \file dlt-kpi-process-list.c */ -#include "dlt-procfs-process-list.h" +#include "dlt-kpi-process-list.h" -DltProcfsProcessList *dlt_procfs_create_process_list() +DltKpiProcessList *dlt_kpi_create_process_list() { - DltProcfsProcessList *new_list = malloc(sizeof(DltProcfsProcessList)); + DltKpiProcessList *new_list = malloc(sizeof(DltKpiProcessList)); if(new_list == NULL) { fprintf(stderr, "Cannot create process list, out of memory\n"); return NULL; } - memset(new_list, 0, sizeof(DltProcfsProcessList)); + memset(new_list, 0, sizeof(DltKpiProcessList)); new_list->start = new_list->cursor = NULL; return new_list; } -DltReturnValue dlt_procfs_free_process_list_soft(DltProcfsProcessList *list) +DltReturnValue dlt_kpi_free_process_list_soft(DltKpiProcessList *list) { if(list == NULL) { - fprintf(stderr, "dlt_procfs_free_process_list_soft: Nullpointer parameter\n"); + fprintf(stderr, "dlt_kpi_free_process_list_soft: Nullpointer parameter\n"); return DLT_RETURN_WRONG_PARAMETER; } @@ -54,43 +54,43 @@ DltReturnValue dlt_procfs_free_process_list_soft(DltProcfsProcessList *list) return DLT_RETURN_OK; } -DltReturnValue dlt_procfs_free_process_list(DltProcfsProcessList *list) +DltReturnValue dlt_kpi_free_process_list(DltKpiProcessList *list) { if(list == NULL) { - fprintf(stderr, "dlt_procfs_free_process_list: Nullpointer parameter\n"); + fprintf(stderr, "dlt_kpi_free_process_list: Nullpointer parameter\n"); return DLT_RETURN_WRONG_PARAMETER; } - DltProcfsProcess *tmp; + DltKpiProcess *tmp; list->cursor = list->start; while(list->cursor != NULL) { tmp = list->cursor->next; - dlt_procfs_free_process(list->cursor); + dlt_kpi_free_process(list->cursor); list->cursor = tmp; } - return dlt_procfs_free_process_list_soft(list); + return dlt_kpi_free_process_list_soft(list); } -DltProcfsProcess *dlt_procfs_get_process_at_cursor(DltProcfsProcessList *list) +DltKpiProcess *dlt_kpi_get_process_at_cursor(DltKpiProcessList *list) { if(list == NULL) { - fprintf(stderr, "dlt_procfs_get_process_at_cursor(): Nullpointer parameter\n"); + fprintf(stderr, "dlt_kpi_get_process_at_cursor(): Nullpointer parameter\n"); return NULL; } return list->cursor; } -DltReturnValue dlt_procfs_reset_cursor(DltProcfsProcessList *list) +DltReturnValue dlt_kpi_reset_cursor(DltKpiProcessList *list) { if(list == NULL) { - fprintf(stderr, "dlt_procfs_reset_cursor(): Nullpointer parameter\n"); + fprintf(stderr, "dlt_kpi_reset_cursor(): Nullpointer parameter\n"); return DLT_RETURN_WRONG_PARAMETER; } @@ -98,11 +98,11 @@ DltReturnValue dlt_procfs_reset_cursor(DltProcfsProcessList *list) return DLT_RETURN_OK; } -DltReturnValue dlt_procfs_set_cursor_at_end(DltProcfsProcessList *list) +DltReturnValue dlt_kpi_set_cursor_at_end(DltKpiProcessList *list) { if(list == NULL) { - fprintf(stderr, "dlt_procfs_set_cursor_at_end(): Nullpointer parameter\n"); + fprintf(stderr, "dlt_kpi_set_cursor_at_end(): Nullpointer parameter\n"); return DLT_RETURN_WRONG_PARAMETER; } @@ -111,16 +111,16 @@ DltReturnValue dlt_procfs_set_cursor_at_end(DltProcfsProcessList *list) return DLT_RETURN_OK; while(list->cursor->next != NULL) - dlt_procfs_increment_cursor(list); + dlt_kpi_increment_cursor(list); return DLT_RETURN_OK; } -DltReturnValue dlt_procfs_increment_cursor(DltProcfsProcessList *list) +DltReturnValue dlt_kpi_increment_cursor(DltKpiProcessList *list) { if(list == NULL) { - fprintf(stderr, "dlt_procfs_set_cursor_at_end(): Nullpointer parameter\n"); + fprintf(stderr, "dlt_kpi_set_cursor_at_end(): Nullpointer parameter\n"); return DLT_RETURN_WRONG_PARAMETER; } @@ -132,11 +132,11 @@ DltReturnValue dlt_procfs_increment_cursor(DltProcfsProcessList *list) return DLT_RETURN_OK; } -DltReturnValue dlt_procfs_decrement_cursor(DltProcfsProcessList *list) +DltReturnValue dlt_kpi_decrement_cursor(DltKpiProcessList *list) { if(list == NULL) { - fprintf(stderr, "dlt_procfs_set_cursor_at_end(): Nullpointer parameter\n"); + fprintf(stderr, "dlt_kpi_set_cursor_at_end(): Nullpointer parameter\n"); return DLT_RETURN_WRONG_PARAMETER; } @@ -148,11 +148,11 @@ DltReturnValue dlt_procfs_decrement_cursor(DltProcfsProcessList *list) return DLT_RETURN_OK; } -DltReturnValue dlt_procfs_add_process_at_start(DltProcfsProcessList *list, DltProcfsProcess *process) +DltReturnValue dlt_kpi_add_process_at_start(DltKpiProcessList *list, DltKpiProcess *process) { if(list == NULL || process == NULL) { - fprintf(stderr, "dlt_procfs_add_process_at_start(): Nullpointer parameter\n"); + fprintf(stderr, "dlt_kpi_add_process_at_start(): Nullpointer parameter\n"); return DLT_RETURN_WRONG_PARAMETER; } @@ -165,24 +165,24 @@ DltReturnValue dlt_procfs_add_process_at_start(DltProcfsProcessList *list, DltPr return DLT_RETURN_OK; } -DltReturnValue dlt_procfs_add_process_before_cursor(DltProcfsProcessList *list, DltProcfsProcess *process) +DltReturnValue dlt_kpi_add_process_before_cursor(DltKpiProcessList *list, DltKpiProcess *process) { if(list == NULL || process == NULL) { - fprintf(stderr, "dlt_procfs_add_process_before_cursor(): Nullpointer parameter\n"); + fprintf(stderr, "dlt_kpi_add_process_before_cursor(): Nullpointer parameter\n"); return DLT_RETURN_WRONG_PARAMETER; } if(list->start == NULL) // Empty list? { - DltReturnValue ret = dlt_procfs_add_process_at_start(list, process); + DltReturnValue ret = dlt_kpi_add_process_at_start(list, process); list->cursor = NULL; return ret; } else if(list->cursor == NULL) { - dlt_procfs_set_cursor_at_end(list); - DltReturnValue ret = dlt_procfs_add_process_after_cursor(list, process); + dlt_kpi_set_cursor_at_end(list); + DltReturnValue ret = dlt_kpi_add_process_after_cursor(list, process); list->cursor = NULL; return ret; } @@ -199,16 +199,16 @@ DltReturnValue dlt_procfs_add_process_before_cursor(DltProcfsProcessList *list, return DLT_RETURN_OK; } -DltReturnValue dlt_procfs_add_process_after_cursor(DltProcfsProcessList *list, DltProcfsProcess *process) +DltReturnValue dlt_kpi_add_process_after_cursor(DltKpiProcessList *list, DltKpiProcess *process) { if(list == NULL || process == NULL) { - fprintf(stderr, "dlt_procfs_add_process_after_cursor: Nullpointer parameter\n"); + fprintf(stderr, "dlt_kpi_add_process_after_cursor: Nullpointer parameter\n"); return DLT_RETURN_ERROR; } if(list->cursor == NULL) - return dlt_procfs_add_process_at_start(list, process); + return dlt_kpi_add_process_at_start(list, process); if(list->cursor->next != NULL) list->cursor->next->prev = process; @@ -220,11 +220,11 @@ DltReturnValue dlt_procfs_add_process_after_cursor(DltProcfsProcessList *list, D return DLT_RETURN_OK; } -DltReturnValue dlt_procfs_remove_process_at_cursor_soft(DltProcfsProcessList *list) +DltReturnValue dlt_kpi_remove_process_at_cursor_soft(DltKpiProcessList *list) { if(list == NULL) { - fprintf(stderr, "dlt_procfs_set_cursor_at_end(): Nullpointer parameter\n"); + fprintf(stderr, "dlt_kpi_set_cursor_at_end(): Nullpointer parameter\n"); return DLT_RETURN_WRONG_PARAMETER; } @@ -234,7 +234,7 @@ DltReturnValue dlt_procfs_remove_process_at_cursor_soft(DltProcfsProcessList *li return DLT_RETURN_ERROR; } - DltProcfsProcess *tmp = list->cursor; + DltKpiProcess *tmp = list->cursor; if(tmp->prev != NULL) { @@ -262,11 +262,11 @@ DltReturnValue dlt_procfs_remove_process_at_cursor_soft(DltProcfsProcessList *li return DLT_RETURN_OK; } -DltReturnValue dlt_procfs_remove_process_at_cursor(DltProcfsProcessList *list) +DltReturnValue dlt_kpi_remove_process_at_cursor(DltKpiProcessList *list) { if(list == NULL) { - fprintf(stderr, "dlt_procfs_set_cursor_at_end(): Nullpointer parameter\n"); + fprintf(stderr, "dlt_kpi_set_cursor_at_end(): Nullpointer parameter\n"); return DLT_RETURN_WRONG_PARAMETER; } @@ -276,12 +276,12 @@ DltReturnValue dlt_procfs_remove_process_at_cursor(DltProcfsProcessList *list) return DLT_RETURN_ERROR; } - DltProcfsProcess *tmp = list->cursor; - DltReturnValue ret = dlt_procfs_remove_process_at_cursor_soft(list); + DltKpiProcess *tmp = list->cursor; + DltReturnValue ret = dlt_kpi_remove_process_at_cursor_soft(list); if(ret < DLT_RETURN_OK) return ret; - dlt_procfs_free_process(tmp); + dlt_kpi_free_process(tmp); return DLT_RETURN_OK; } diff --git a/src/kpi/dlt-kpi-process-list.h b/src/kpi/dlt-kpi-process-list.h new file mode 100644 index 0000000..52eb11f --- /dev/null +++ b/src/kpi/dlt-kpi-process-list.h @@ -0,0 +1,54 @@ +/* + * @licence app begin@ + * SPDX license identifier: MPL-2.0 + * + * Copyright (C) 2011-2015, BMW AG + * + * This file is part of GENIVI Project DLT - Diagnostic Log and Trace. + * + * This Source Code Form is subject to the terms of the + * Mozilla Public License (MPL), 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/. + * + * For further information see http://www.genivi.org/. + * @licence end@ + */ + +/*! + * \author Sven Hassler <sven_hassler@mentor.com> + * + * \copyright Copyright © 2011-2015 BMW AG. \n + * License MPL-2.0: Mozilla Public License version 2.0 http://mozilla.org/MPL/2.0/. + * + * \file dlt-kpi-process-list.h + */ + +#ifndef SRC_KPI_DLT_KPI_PROCESS_LIST_H_ +#define SRC_KPI_DLT_KPI_PROCESS_LIST_H_ + +#include "dlt-kpi-process.h" +#include "dlt-kpi-common.h" + +typedef struct +{ + struct DltKpiProcess *start, *cursor; +} DltKpiProcessList; + +DltKpiProcessList *dlt_kpi_create_process_list(); +DltReturnValue dlt_kpi_free_process_list_soft(DltKpiProcessList *list); +DltReturnValue dlt_kpi_free_process_list(DltKpiProcessList *list); +DltKpiProcess *dlt_kpi_get_process_at_cursor(DltKpiProcessList *list); +DltReturnValue dlt_kpi_increment_cursor(DltKpiProcessList *list); +DltReturnValue dlt_kpi_decrement_cursor(DltKpiProcessList *list); +DltReturnValue dlt_kpi_reset_cursor(DltKpiProcessList *list); +DltReturnValue dlt_kpi_add_process_at_start(DltKpiProcessList *list, DltKpiProcess *process); +DltReturnValue dlt_kpi_add_process_before_cursor(DltKpiProcessList *list, DltKpiProcess *process); +DltReturnValue dlt_kpi_add_process_after_cursor(DltKpiProcessList *list, DltKpiProcess *process); +DltReturnValue dlt_kpi_remove_process_at_cursor_soft(DltKpiProcessList *list); +DltReturnValue dlt_kpi_remove_process_at_cursor(DltKpiProcessList *list); + +// DltReturnValue dlt_kpi_remove_process_after_cursor(DltKpiProcessList *list); +// DltReturnValue dlt_kpi_remove_first_process(DltKpiProcessList *list); + +#endif /* SRC_KPI_DLT_KPI_PROCESS_LIST_H_ */ diff --git a/src/procfs/dlt-procfs-process.c b/src/kpi/dlt-kpi-process.c index 7bb815f..d126551 100644 --- a/src/procfs/dlt-procfs-process.c +++ b/src/kpi/dlt-kpi-process.c @@ -21,26 +21,27 @@ * \copyright Copyright © 2011-2015 BMW AG. \n * License MPL-2.0: Mozilla Public License version 2.0 http://mozilla.org/MPL/2.0/. * - * \file dlt-procfs-process.c + * \file dlt-kpi-process.c */ -#include "dlt-procfs-process.h" +#include "dlt-kpi-process.h" + #include <pthread.h> #include <unistd.h> -DltReturnValue dlt_procfs_read_process_file_to_str(pid_t pid, char **target_str, char *subdir); -unsigned long int dlt_procfs_read_process_stat_to_ulong(pid_t pid, unsigned int index); -DltReturnValue dlt_procfs_read_process_stat_cmdline(pid_t pid, char **buffer); +DltReturnValue dlt_kpi_read_process_file_to_str(pid_t pid, char **target_str, char *subdir); +unsigned long int dlt_kpi_read_process_stat_to_ulong(pid_t pid, unsigned int index); +DltReturnValue dlt_kpi_read_process_stat_cmdline(pid_t pid, char **buffer); -DltReturnValue dlt_procfs_process_update_io_wait(DltProcfsProcess *process, unsigned long int time_dif_ms) +DltReturnValue dlt_kpi_process_update_io_wait(DltKpiProcess *process, unsigned long int time_dif_ms) { if(process == NULL) { - fprintf(stderr, "dlt_procfs_process_update_io_wait(): Nullpointer parameter\n"); + fprintf(stderr, "dlt_kpi_process_update_io_wait(): Nullpointer parameter\n"); return DLT_RETURN_WRONG_PARAMETER; } - unsigned long int total_io_wait = dlt_procfs_read_process_stat_to_ulong(process->pid, 42); + unsigned long int total_io_wait = dlt_kpi_read_process_stat_to_ulong(process->pid, 42); process->io_wait = (total_io_wait - process->last_io_wait) * 1000 / sysconf(_SC_CLK_TCK); // busy milliseconds since last update if(time_dif_ms > 0) @@ -51,16 +52,16 @@ DltReturnValue dlt_procfs_process_update_io_wait(DltProcfsProcess *process, unsi return DLT_RETURN_OK; } -DltReturnValue dlt_procfs_process_update_cpu_time(DltProcfsProcess *process, unsigned long int time_dif_ms) +DltReturnValue dlt_kpi_process_update_cpu_time(DltKpiProcess *process, unsigned long int time_dif_ms) { if(process == NULL) { - fprintf(stderr, "dlt_procfs_process_update_cpu_time(): Nullpointer parameter\n"); + fprintf(stderr, "dlt_kpi_process_update_cpu_time(): Nullpointer parameter\n"); return DLT_RETURN_WRONG_PARAMETER; } - unsigned long int utime = dlt_procfs_read_process_stat_to_ulong(process->pid, 14); - unsigned long int stime = dlt_procfs_read_process_stat_to_ulong(process->pid, 15); + unsigned long int utime = dlt_kpi_read_process_stat_to_ulong(process->pid, 14); + unsigned long int stime = dlt_kpi_read_process_stat_to_ulong(process->pid, 15); unsigned long total_cpu_time = utime + stime; @@ -73,24 +74,24 @@ DltReturnValue dlt_procfs_process_update_cpu_time(DltProcfsProcess *process, uns return DLT_RETURN_OK; } -DltReturnValue dlt_procfs_process_update_rss(DltProcfsProcess *process) +DltReturnValue dlt_kpi_process_update_rss(DltKpiProcess *process) { if(process == NULL) { - fprintf(stderr, "dlt_procfs_process_update_rss(): Nullpointer parameter\n"); + fprintf(stderr, "dlt_kpi_process_update_rss(): Nullpointer parameter\n"); return DLT_RETURN_WRONG_PARAMETER; } - process->rss = dlt_procfs_read_process_stat_to_ulong(process->pid, 24); + process->rss = dlt_kpi_read_process_stat_to_ulong(process->pid, 24); return DLT_RETURN_OK; } -DltReturnValue dlt_procfs_process_update_ctx_switches(DltProcfsProcess *process) +DltReturnValue dlt_kpi_process_update_ctx_switches(DltKpiProcess *process) { if(process == NULL) { - fprintf(stderr, "dlt_procfs_process_update_ctx_switches(): Nullpointer parameter\n"); + fprintf(stderr, "dlt_kpi_process_update_ctx_switches(): Nullpointer parameter\n"); return DLT_RETURN_WRONG_PARAMETER; } @@ -99,7 +100,7 @@ DltReturnValue dlt_procfs_process_update_ctx_switches(DltProcfsProcess *process) last_tok = NULL; DltReturnValue ret; - if((ret = dlt_procfs_read_process_file_to_str(process->pid, &buffer, "status")) < DLT_RETURN_OK) return ret; + if((ret = dlt_kpi_read_process_file_to_str(process->pid, &buffer, "status")) < DLT_RETURN_OK) return ret; process->ctx_switches = 0; @@ -131,11 +132,11 @@ DltReturnValue dlt_procfs_process_update_ctx_switches(DltProcfsProcess *process) return DLT_RETURN_OK; } -DltReturnValue dlt_procfs_process_update_io_bytes(DltProcfsProcess *process) +DltReturnValue dlt_kpi_process_update_io_bytes(DltKpiProcess *process) { if(process == NULL) { - fprintf(stderr, "dlt_procfs_process_update_io_bytes: Nullpointer parameter\n"); + fprintf(stderr, "dlt_kpi_process_update_io_bytes: Nullpointer parameter\n"); return DLT_RETURN_WRONG_PARAMETER; } @@ -144,7 +145,7 @@ DltReturnValue dlt_procfs_process_update_io_bytes(DltProcfsProcess *process) last_tok = NULL; DltReturnValue ret; - if((ret = dlt_procfs_read_process_file_to_str(process->pid, &buffer, "io")) < DLT_RETURN_OK) + if((ret = dlt_kpi_read_process_file_to_str(process->pid, &buffer, "io")) < DLT_RETURN_OK) return ret; process->io_bytes = 0; @@ -177,55 +178,55 @@ DltReturnValue dlt_procfs_process_update_io_bytes(DltProcfsProcess *process) return DLT_RETURN_OK; } -DltReturnValue dlt_procfs_update_process(DltProcfsProcess *process, unsigned long int time_dif_ms) +DltReturnValue dlt_kpi_update_process(DltKpiProcess *process, unsigned long int time_dif_ms) { - dlt_procfs_process_update_io_wait(process, time_dif_ms); - dlt_procfs_process_update_cpu_time(process, time_dif_ms); - dlt_procfs_process_update_rss(process); - dlt_procfs_process_update_ctx_switches(process); - dlt_procfs_process_update_io_bytes(process); + dlt_kpi_process_update_io_wait(process, time_dif_ms); + dlt_kpi_process_update_cpu_time(process, time_dif_ms); + dlt_kpi_process_update_rss(process); + dlt_kpi_process_update_ctx_switches(process); + dlt_kpi_process_update_io_bytes(process); return DLT_RETURN_OK; } -DltProcfsProcess *dlt_procfs_create_process(int pid) +DltKpiProcess *dlt_kpi_create_process(int pid) { - DltProcfsProcess *new_process = malloc(sizeof(DltProcfsProcess)); - memset(new_process, 0, sizeof(DltProcfsProcess)); + DltKpiProcess *new_process = malloc(sizeof(DltKpiProcess)); + memset(new_process, 0, sizeof(DltKpiProcess)); new_process->pid = pid; - new_process->ppid = (pid_t)dlt_procfs_read_process_stat_to_ulong(pid, 4); + new_process->ppid = (pid_t)dlt_kpi_read_process_stat_to_ulong(pid, 4); - dlt_procfs_read_process_file_to_str(pid, &(new_process->command_line), "cmdline"); + dlt_kpi_read_process_file_to_str(pid, &(new_process->command_line), "cmdline"); if(new_process->command_line != NULL) if(strlen(new_process->command_line) == 0) { free(new_process->command_line); - dlt_procfs_read_process_stat_cmdline(pid, &(new_process->command_line)); + dlt_kpi_read_process_stat_cmdline(pid, &(new_process->command_line)); } - dlt_procfs_update_process(new_process, 0); + dlt_kpi_update_process(new_process, 0); return new_process; } -DltProcfsProcess *dlt_procfs_clone_process(DltProcfsProcess *original) +DltKpiProcess *dlt_kpi_clone_process(DltKpiProcess *original) { if(original == NULL) { - fprintf(stderr, "dlt_procfs_clone_process: Nullpointer parameter\n"); + fprintf(stderr, "dlt_kpi_clone_process: Nullpointer parameter\n"); return NULL; } - // DltProcfsProcess *new_process = dlt_procfs_create_process(original->pid); - DltProcfsProcess *new_process = malloc(sizeof(DltProcfsProcess)); + // DltKpiProcess *new_process = dlt_kpi_create_process(original->pid); + DltKpiProcess *new_process = malloc(sizeof(DltKpiProcess)); if(new_process == NULL) { fprintf(stderr, "Out of memory\n"); return NULL; } - memcpy(new_process, original, sizeof(DltProcfsProcess)); + memcpy(new_process, original, sizeof(DltKpiProcess)); if(original->command_line != NULL) { @@ -245,11 +246,11 @@ DltProcfsProcess *dlt_procfs_clone_process(DltProcfsProcess *original) return new_process; } -DltReturnValue dlt_procfs_free_process(DltProcfsProcess *process) +DltReturnValue dlt_kpi_free_process(DltKpiProcess *process) { if(process == NULL) { - fprintf(stderr, "dlt_procfs_free_process: Nullpointer parameter\n"); + fprintf(stderr, "dlt_kpi_free_process: Nullpointer parameter\n"); return DLT_RETURN_WRONG_PARAMETER; } @@ -261,7 +262,7 @@ DltReturnValue dlt_procfs_free_process(DltProcfsProcess *process) return DLT_RETURN_OK; } -DltReturnValue dlt_procfs_print_process(DltProcfsProcess *process) +DltReturnValue dlt_kpi_print_process(DltKpiProcess *process) { if(process == NULL) { @@ -281,7 +282,7 @@ DltReturnValue dlt_procfs_print_process(DltProcfsProcess *process) return DLT_RETURN_OK; } -DltReturnValue dlt_procfs_read_process_file_to_str(pid_t pid, char **target_str, char *subdir) +DltReturnValue dlt_kpi_read_process_file_to_str(pid_t pid, char **target_str, char *subdir) { if(target_str == NULL) { @@ -306,19 +307,19 @@ DltReturnValue dlt_procfs_read_process_file_to_str(pid_t pid, char **target_str, char filename[BUFFER_SIZE]; snprintf(filename, BUFFER_SIZE, "/proc/%d/%s", pid, subdir); - return dlt_procfs_read_file_compact(filename, target_str); + return dlt_kpi_read_file_compact(filename, target_str); } -unsigned long int dlt_procfs_read_process_stat_to_ulong(pid_t pid, unsigned int index) +unsigned long int dlt_kpi_read_process_stat_to_ulong(pid_t pid, unsigned int index) { if(pid <= 0) { - fprintf(stderr, "dlt_procfs_read_process_stat_to_ulong(): Invalid PID\n"); + fprintf(stderr, "dlt_kpi_read_process_stat_to_ulong(): Invalid PID\n"); return 0; } char *buffer = NULL; - DltReturnValue tmp = dlt_procfs_read_process_file_to_str(pid, &buffer, "stat"); + DltReturnValue tmp = dlt_kpi_read_process_file_to_str(pid, &buffer, "stat"); if(tmp < DLT_RETURN_OK) { if(buffer != NULL) @@ -349,34 +350,34 @@ unsigned long int dlt_procfs_read_process_stat_to_ulong(pid_t pid, unsigned int ret = strtoul(tok, &check, 10); if(*check != '\0') { - fprintf(stderr, "dlt_procfs_read_process_stat_to_ulong(): Could not extract token\n"); + fprintf(stderr, "dlt_kpi_read_process_stat_to_ulong(): Could not extract token\n"); ret = 0; } } else - fprintf(stderr, "dlt_procfs_read_process_stat_to_ulong(): Index not found\n"); + fprintf(stderr, "dlt_kpi_read_process_stat_to_ulong(): Index not found\n"); free(buffer); return ret; } -DltReturnValue dlt_procfs_read_process_stat_cmdline(pid_t pid, char **buffer) +DltReturnValue dlt_kpi_read_process_stat_cmdline(pid_t pid, char **buffer) { if(pid <= 0) { - fprintf(stderr, "dlt_procfs_read_process_stat_cmdline(): Invalid PID\n"); + fprintf(stderr, "dlt_kpi_read_process_stat_cmdline(): Invalid PID\n"); return DLT_RETURN_WRONG_PARAMETER; } if(buffer == NULL) { - fprintf(stderr, "dlt_procfs_read_process_stat_cmdline(): Nullpointer parameter\n"); + fprintf(stderr, "dlt_kpi_read_process_stat_cmdline(): Nullpointer parameter\n"); return DLT_RETURN_WRONG_PARAMETER; } char *tmp_buffer = NULL; - DltReturnValue tmp = dlt_procfs_read_process_file_to_str(pid, &tmp_buffer, "stat"); + DltReturnValue tmp = dlt_kpi_read_process_file_to_str(pid, &tmp_buffer, "stat"); if(tmp < DLT_RETURN_OK) { if(tmp_buffer != NULL) @@ -405,7 +406,7 @@ DltReturnValue dlt_procfs_read_process_stat_cmdline(pid_t pid, char **buffer) } else { - fprintf(stderr, "dlt_procfs_read_process_stat_cmdline(): cmdline entry not found\n"); + fprintf(stderr, "dlt_kpi_read_process_stat_cmdline(): cmdline entry not found\n"); return DLT_RETURN_ERROR; } @@ -414,11 +415,11 @@ DltReturnValue dlt_procfs_read_process_stat_cmdline(pid_t pid, char **buffer) return DLT_RETURN_OK; } -DltReturnValue dlt_procfs_get_msg_process_update(DltProcfsProcess *process, char *buffer, int maxlen) +DltReturnValue dlt_kpi_get_msg_process_update(DltKpiProcess *process, char *buffer, int maxlen) { if(process == NULL || buffer == NULL) { - fprintf(stderr, "dlt_procfs_log_process_new(): Nullpointer parameter\n"); + fprintf(stderr, "dlt_kpi_log_process_new(): Nullpointer parameter\n"); return DLT_RETURN_WRONG_PARAMETER; } @@ -427,11 +428,11 @@ DltReturnValue dlt_procfs_get_msg_process_update(DltProcfsProcess *process, char return DLT_RETURN_OK; } -DltReturnValue dlt_procfs_get_msg_process_new(DltProcfsProcess *process, char *buffer, int maxlen) +DltReturnValue dlt_kpi_get_msg_process_new(DltKpiProcess *process, char *buffer, int maxlen) { if(process == NULL || buffer == NULL) { - fprintf(stderr, "dlt_procfs_log_process_new(): Nullpointer parameter\n"); + fprintf(stderr, "dlt_kpi_log_process_new(): Nullpointer parameter\n"); return DLT_RETURN_WRONG_PARAMETER; } @@ -440,11 +441,11 @@ DltReturnValue dlt_procfs_get_msg_process_new(DltProcfsProcess *process, char *b return DLT_RETURN_OK; } -DltReturnValue dlt_procfs_get_msg_process_stop(DltProcfsProcess *process, char *buffer, int maxlen) +DltReturnValue dlt_kpi_get_msg_process_stop(DltKpiProcess *process, char *buffer, int maxlen) { if(process == NULL || buffer == NULL) { - fprintf(stderr, "dlt_procfs_log_process_new(): Nullpointer parameter\n"); + fprintf(stderr, "dlt_kpi_log_process_new(): Nullpointer parameter\n"); return DLT_RETURN_WRONG_PARAMETER; } @@ -453,11 +454,11 @@ DltReturnValue dlt_procfs_get_msg_process_stop(DltProcfsProcess *process, char * return DLT_RETURN_OK; } -DltReturnValue dlt_procfs_get_msg_process_commandline(DltProcfsProcess *process, char *buffer, int maxlen) +DltReturnValue dlt_kpi_get_msg_process_commandline(DltKpiProcess *process, char *buffer, int maxlen) { if(process == NULL || buffer == NULL) { - fprintf(stderr, "dlt_procfs_log_process_new(): Nullpointer parameter\n"); + fprintf(stderr, "dlt_kpi_log_process_new(): Nullpointer parameter\n"); return DLT_RETURN_WRONG_PARAMETER; } diff --git a/src/kpi/dlt-kpi-process.h b/src/kpi/dlt-kpi-process.h new file mode 100644 index 0000000..50d5fbc --- /dev/null +++ b/src/kpi/dlt-kpi-process.h @@ -0,0 +1,56 @@ +/* + * @licence app begin@ + * SPDX license identifier: MPL-2.0 + * + * Copyright (C) 2011-2015, BMW AG + * + * This file is part of GENIVI Project DLT - Diagnostic Log and Trace. + * + * This Source Code Form is subject to the terms of the + * Mozilla Public License (MPL), 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/. + * + * For further information see http://www.genivi.org/. + * @licence end@ + */ + +/*! + * \author Sven Hassler <sven_hassler@mentor.com> + * + * \copyright Copyright © 2011-2015 BMW AG. \n + * License MPL-2.0: Mozilla Public License version 2.0 http://mozilla.org/MPL/2.0/. + * + * \file dlt-kpi-process.h + */ + +#ifndef SRC_KPI_DLT_KPI_PROCESS_H_ +#define SRC_KPI_DLT_KPI_PROCESS_H_ + +#include "dlt.h" +#include <stdlib.h> +#include "dlt-kpi-common.h" + +typedef struct DltKpiEventWatch DltKpiEventWatch; // forward declaration + +typedef struct DltKpiProcess +{ + pid_t pid, ppid; + char *command_line; + unsigned long int cpu_time, last_cpu_time, io_wait, last_io_wait, io_bytes; + long int rss, ctx_switches; + + struct DltKpiProcess *next, *prev; +} DltKpiProcess; + +DltKpiProcess *dlt_kpi_create_process(); +DltKpiProcess *dlt_kpi_clone_process(DltKpiProcess *original); +DltReturnValue dlt_kpi_free_process(DltKpiProcess *process); +DltReturnValue dlt_kpi_print_process(DltKpiProcess *process); +DltReturnValue dlt_kpi_update_process(DltKpiProcess *process, unsigned long int time_dif_ms); +DltReturnValue dlt_kpi_get_msg_process_new(DltKpiProcess *process, char *buffer, int maxlen); +DltReturnValue dlt_kpi_get_msg_process_stop(DltKpiProcess *process, char *buffer, int maxlen); +DltReturnValue dlt_kpi_get_msg_process_update(DltKpiProcess *process, char *buffer, int maxlen); +DltReturnValue dlt_kpi_get_msg_process_commandline(DltKpiProcess *process, char *buffer, int maxlen); + +#endif /* SRC_KPI_DLT_KPI_PROCESS_H_ */ diff --git a/src/procfs/dlt-procfs.c b/src/kpi/dlt-kpi.c index 4396c27..f315058 100644 --- a/src/procfs/dlt-procfs.c +++ b/src/kpi/dlt-kpi.c @@ -21,37 +21,38 @@ * \copyright Copyright © 2011-2015 BMW AG. \n * License MPL-2.0: Mozilla Public License version 2.0 http://mozilla.org/MPL/2.0/. * - * \file dlt-procfs.c + * \file dlt-kpi.c */ -#include "dlt-procfs.h" +#include "dlt-kpi.h" + #include <signal.h> #include <dirent.h> #include <time.h> #include <unistd.h> #include <pthread.h> -DLT_DECLARE_CONTEXT(procfs_ctx); +DLT_DECLARE_CONTEXT(kpi_ctx); -DltProcfsConfig config; +DltKpiConfig config; static volatile sig_atomic_t stop_loop = 0; -static DltProcfsProcessList *list, *new_process_list, *stopped_process_list, *update_process_list; +static DltKpiProcessList *list, *new_process_list, *stopped_process_list, *update_process_list; static struct timespec _tmp_time; static pthread_mutex_t process_list_mutex; -void dlt_procfs_stop_loops(int sig); -void dlt_procfs_init_sigterm_handler(); -DltReturnValue dlt_procfs_init_process_lists(); -DltReturnValue dlt_procfs_free_process_lists(); -void *dlt_procfs_start_process_thread(); -DltReturnValue dlt_procfs_process_loop(); -DltReturnValue dlt_procfs_update_process_list(DltProcfsProcessList *list, unsigned long int time_dif_ms); -void *dlt_procfs_start_irq_thread(); -DltReturnValue dlt_procfs_irq_loop(); -void *dlt_procfs_start_check_thread(); -DltReturnValue dlt_procfs_check_loop(); -DltReturnValue dlt_procfs_log_check_commandlines(); +void dlt_kpi_stop_loops(int sig); +void dlt_kpi_init_sigterm_handler(); +DltReturnValue dlt_kpi_init_process_lists(); +DltReturnValue dlt_kpi_free_process_lists(); +void *dlt_kpi_start_process_thread(); +DltReturnValue dlt_kpi_process_loop(); +DltReturnValue dlt_kpi_update_process_list(DltKpiProcessList *list, unsigned long int time_dif_ms); +void *dlt_kpi_start_irq_thread(); +DltReturnValue dlt_kpi_irq_loop(); +void *dlt_kpi_start_check_thread(); +DltReturnValue dlt_kpi_check_loop(); +DltReturnValue dlt_kpi_log_check_commandlines(); unsigned long int timespec_to_millis(struct timespec *time) { @@ -66,17 +67,17 @@ unsigned long int get_millis() int main(int argc, char **argv) { - printf("Launching dlt-procfs...\n"); + printf("Launching dlt-kpi...\n"); - if(dlt_procfs_init(argc, argv, &config) < DLT_RETURN_OK) + if(dlt_kpi_init(argc, argv, &config) < DLT_RETURN_OK) { fprintf(stderr, "Initialization error!\n"); return -1; } - dlt_procfs_init_sigterm_handler(); + dlt_kpi_init_sigterm_handler(); - if(dlt_procfs_init_process_lists() < DLT_RETURN_OK) + if(dlt_kpi_init_process_lists() < DLT_RETURN_OK) { fprintf(stderr, "Error occurred initializing process lists\n"); return -1; @@ -89,23 +90,23 @@ int main(int argc, char **argv) } DLT_REGISTER_APP("PROC", "/proc/-filesystem logger application"); - DLT_REGISTER_CONTEXT_LL_TS(procfs_ctx, "PROC", "/proc/-filesystem logger context", config.log_level, 0); + DLT_REGISTER_CONTEXT_LL_TS(kpi_ctx, "PROC", "/proc/-filesystem logger context", config.log_level, 1); pthread_t process_thread; pthread_t irq_thread; pthread_t check_thread; - if(pthread_create(&process_thread, NULL, &dlt_procfs_start_process_thread, NULL) != 0) + if(pthread_create(&process_thread, NULL, &dlt_kpi_start_process_thread, NULL) != 0) { fprintf(stderr, "Could not create thread\n"); return -1; } - if(pthread_create(&irq_thread, NULL, &dlt_procfs_start_irq_thread, NULL) != 0) + if(pthread_create(&irq_thread, NULL, &dlt_kpi_start_irq_thread, NULL) != 0) { fprintf(stderr, "Could not create thread\n"); return -1; } - if(pthread_create(&check_thread, NULL, &dlt_procfs_start_check_thread, NULL) != 0) + if(pthread_create(&check_thread, NULL, &dlt_kpi_start_check_thread, NULL) != 0) { fprintf(stderr, "Could not create thread\n"); return -1; @@ -115,73 +116,73 @@ int main(int argc, char **argv) pthread_join(irq_thread, NULL); pthread_join(check_thread, NULL); - DLT_UNREGISTER_CONTEXT(procfs_ctx); + DLT_UNREGISTER_CONTEXT(kpi_ctx); DLT_UNREGISTER_APP(); pthread_mutex_destroy(&process_list_mutex); - dlt_procfs_free_process_lists(); + dlt_kpi_free_process_lists(); printf("Done.\n"); } -void dlt_procfs_init_sigterm_handler() +void dlt_kpi_init_sigterm_handler() { struct sigaction action; memset(&action, 0, sizeof(struct sigaction)); - action.sa_handler = dlt_procfs_stop_loops; + action.sa_handler = dlt_kpi_stop_loops; sigaction(SIGTERM, &action, NULL); } -void dlt_procfs_stop_loops(int sig) +void dlt_kpi_stop_loops(int sig) { if(sig > -1) - fprintf(stderr, "dlt-procfs is now terminating due to signal %d...\n", sig); + fprintf(stderr, "dlt-kpi is now terminating due to signal %d...\n", sig); else - fprintf(stderr, "dlt-procfs is now terminating due to an error...\n"); + fprintf(stderr, "dlt-kpi is now terminating due to an error...\n"); stop_loop = 1; } -DltReturnValue dlt_procfs_init_process_lists() +DltReturnValue dlt_kpi_init_process_lists() { - if((list = dlt_procfs_create_process_list()) == NULL) return DLT_RETURN_ERROR; - if((new_process_list = dlt_procfs_create_process_list()) == NULL) return DLT_RETURN_ERROR; - if((stopped_process_list = dlt_procfs_create_process_list()) == NULL) return DLT_RETURN_ERROR; - if((update_process_list = dlt_procfs_create_process_list()) == NULL) return DLT_RETURN_ERROR; + if((list = dlt_kpi_create_process_list()) == NULL) return DLT_RETURN_ERROR; + if((new_process_list = dlt_kpi_create_process_list()) == NULL) return DLT_RETURN_ERROR; + if((stopped_process_list = dlt_kpi_create_process_list()) == NULL) return DLT_RETURN_ERROR; + if((update_process_list = dlt_kpi_create_process_list()) == NULL) return DLT_RETURN_ERROR; return DLT_RETURN_OK; } -DltReturnValue dlt_procfs_free_process_lists() +DltReturnValue dlt_kpi_free_process_lists() { DltReturnValue ret = DLT_RETURN_OK; - if(dlt_procfs_free_process_list(list) < DLT_RETURN_OK) + if(dlt_kpi_free_process_list(list) < DLT_RETURN_OK) ret = DLT_RETURN_ERROR; - if(dlt_procfs_free_process_list(new_process_list) < DLT_RETURN_OK) + if(dlt_kpi_free_process_list(new_process_list) < DLT_RETURN_OK) ret = DLT_RETURN_ERROR; - if(dlt_procfs_free_process_list(stopped_process_list) < DLT_RETURN_OK) + if(dlt_kpi_free_process_list(stopped_process_list) < DLT_RETURN_OK) ret = DLT_RETURN_ERROR; - if(dlt_procfs_free_process_list(update_process_list) < DLT_RETURN_OK) + if(dlt_kpi_free_process_list(update_process_list) < DLT_RETURN_OK) ret = DLT_RETURN_ERROR; return ret; } -void *dlt_procfs_start_process_thread() +void *dlt_kpi_start_process_thread() { - if(dlt_procfs_process_loop() < DLT_RETURN_OK) - dlt_procfs_stop_loops(-1); + if(dlt_kpi_process_loop() < DLT_RETURN_OK) + dlt_kpi_stop_loops(-1); return NULL; } -DltReturnValue dlt_procfs_process_loop() +DltReturnValue dlt_kpi_process_loop() { static unsigned long int old_millis, sleep_millis, dif_millis; @@ -189,7 +190,7 @@ DltReturnValue dlt_procfs_process_loop() while(!stop_loop) { - /*DltReturnValue ret = */ dlt_procfs_update_process_list(list, config.process_log_interval); + /*DltReturnValue ret = */ dlt_kpi_update_process_list(list, config.process_log_interval); //if(ret < DLT_RETURN_OK) // return ret; @@ -208,33 +209,36 @@ DltReturnValue dlt_procfs_process_loop() return DLT_RETURN_OK; } -DltReturnValue dlt_procfs_log_list(DltProcfsProcessList *list, DltReturnValue(*process_callback)(DltProcfsProcess*, char*, int), char *title, int delete_elements) +DltReturnValue dlt_kpi_log_list(DltKpiProcessList *list, DltReturnValue(*process_callback)(DltKpiProcess*, char*, int), char *title, int delete_elements) { if(list == NULL || process_callback == NULL || title == NULL) { - fprintf(stderr, "dlt_procfs_log_list(): Nullpointer parameter\n"); + fprintf(stderr, "dlt_kpi_log_list(): Nullpointer parameter\n"); return DLT_RETURN_WRONG_PARAMETER; } - dlt_procfs_reset_cursor(list); + dlt_kpi_reset_cursor(list); if(list->cursor == NULL) return DLT_RETURN_OK; // list empty; nothing to do + // Synchronization message + DLT_LOG(kpi_ctx, config.log_level, DLT_STRING(title), DLT_STRING("BEG")); + DltReturnValue ret; DltContextData data; char buffer[BUFFER_SIZE]; buffer[0] = '\0'; - if((ret = dlt_user_log_write_start(&procfs_ctx, &data, config.log_level)) < DLT_RETURN_OK) + if((ret = dlt_user_log_write_start(&kpi_ctx, &data, config.log_level)) < DLT_RETURN_OK) { - fprintf(stderr, "dlt_procfs_log_list(): dlt_user_log_write_start() returned error.\n"); + fprintf(stderr, "dlt_kpi_log_list(): dlt_user_log_write_start() returned error.\n"); return ret; } if((ret = dlt_user_log_write_string(&data, title)) < DLT_RETURN_OK) { - fprintf(stderr, "dlt_procfs_log_list(): dlt_user_log_write_string() returned error.\n"); + fprintf(stderr, "dlt_kpi_log_list(): dlt_user_log_write_string() returned error.\n"); return ret; } @@ -248,25 +252,25 @@ DltReturnValue dlt_procfs_log_list(DltProcfsProcessList *list, DltReturnValue(*p /* Log buffer full => Write log and start new one*/ if((ret = dlt_user_log_write_finish(&data)) < DLT_RETURN_OK) { - fprintf(stderr, "dlt_procfs_log_list(): dlt_user_log_write_finish() returned error.\n"); + fprintf(stderr, "dlt_kpi_log_list(): dlt_user_log_write_finish() returned error.\n"); return ret; } - if((ret = dlt_user_log_write_start(&procfs_ctx, &data, config.log_level)) < DLT_RETURN_OK) + if((ret = dlt_user_log_write_start(&kpi_ctx, &data, config.log_level)) < DLT_RETURN_OK) { - fprintf(stderr, "dlt_procfs_log_list(): dlt_user_log_write_start() returned error.\n"); + fprintf(stderr, "dlt_kpi_log_list(): dlt_user_log_write_start() returned error.\n"); return ret; } if((ret = dlt_user_log_write_string(&data, title)) < DLT_RETURN_OK) { - fprintf(stderr, "dlt_procfs_log_list(): dlt_user_log_write_string() returned error.\n"); + fprintf(stderr, "dlt_kpi_log_list(): dlt_user_log_write_string() returned error.\n"); return ret; } } else if(delete_elements) { - if((ret = dlt_procfs_remove_process_at_cursor(list)) < DLT_RETURN_OK) + if((ret = dlt_kpi_remove_process_at_cursor(list)) < DLT_RETURN_OK) return ret; } else @@ -278,14 +282,17 @@ DltReturnValue dlt_procfs_log_list(DltProcfsProcessList *list, DltReturnValue(*p if((ret = dlt_user_log_write_finish(&data)) < DLT_RETURN_OK) { - fprintf(stderr, "dlt_procfs_log_list(): dlt_user_log_write_finish() returned error.\n"); + fprintf(stderr, "dlt_kpi_log_list(): dlt_user_log_write_finish() returned error.\n"); return ret; } + // Synchronization message + DLT_LOG(kpi_ctx, config.log_level, DLT_STRING(title), DLT_STRING("END")); + return DLT_RETURN_OK; } -DltReturnValue dlt_procfs_update_process_list(DltProcfsProcessList *list, unsigned long int time_dif_ms) +DltReturnValue dlt_kpi_update_process_list(DltKpiProcessList *list, unsigned long int time_dif_ms) { static char *strchk; static DltReturnValue tmp_ret; @@ -294,7 +301,7 @@ DltReturnValue dlt_procfs_update_process_list(DltProcfsProcessList *list, unsign if(list == NULL) { - fprintf(stderr, "dlt_procfs_update_process_list(): Nullpointer parameter"); + fprintf(stderr, "dlt_kpi_update_process_list(): Nullpointer parameter"); return DLT_RETURN_WRONG_PARAMETER; } @@ -306,7 +313,7 @@ DltReturnValue dlt_procfs_update_process_list(DltProcfsProcessList *list, unsign } current_dir = readdir(proc_dir); - dlt_procfs_reset_cursor(list); + dlt_kpi_reset_cursor(list); int debug_process_count = 0; @@ -324,10 +331,10 @@ DltReturnValue dlt_procfs_update_process_list(DltProcfsProcessList *list, unsign if(list->cursor != NULL) while(list->cursor != NULL) { - if((tmp_ret = dlt_procfs_add_process_after_cursor(stopped_process_list, dlt_procfs_clone_process(list->cursor))) < DLT_RETURN_OK) + if((tmp_ret = dlt_kpi_add_process_after_cursor(stopped_process_list, dlt_kpi_clone_process(list->cursor))) < DLT_RETURN_OK) return tmp_ret; - dlt_procfs_remove_process_at_cursor(list); + dlt_kpi_remove_process_at_cursor(list); } break; @@ -344,17 +351,17 @@ DltReturnValue dlt_procfs_update_process_list(DltProcfsProcessList *list, unsign /* compare the /proc/-filesystem with our process-list */ if(list->cursor == NULL || current_dir_pid < list->cursor->pid) // New Process { - DltProcfsProcess *new_process = dlt_procfs_create_process(current_dir_pid); + DltKpiProcess *new_process = dlt_kpi_create_process(current_dir_pid); if(new_process == NULL) { fprintf(stderr, "Error: Could not create process (out of memory?)\n"); return DLT_RETURN_ERROR; } - if((tmp_ret = dlt_procfs_add_process_before_cursor(list, new_process)) < DLT_RETURN_OK) + if((tmp_ret = dlt_kpi_add_process_before_cursor(list, new_process)) < DLT_RETURN_OK) return tmp_ret; - if((tmp_ret = dlt_procfs_add_process_before_cursor(new_process_list, dlt_procfs_clone_process(new_process))) < DLT_RETURN_OK) + if((tmp_ret = dlt_kpi_add_process_before_cursor(new_process_list, dlt_kpi_clone_process(new_process))) < DLT_RETURN_OK) return tmp_ret; current_dir = readdir(proc_dir); // next process in proc-fs @@ -362,26 +369,26 @@ DltReturnValue dlt_procfs_update_process_list(DltProcfsProcessList *list, unsign } else if(current_dir_pid > list->cursor->pid) // Process ended { - if((tmp_ret = dlt_procfs_add_process_after_cursor(stopped_process_list, dlt_procfs_clone_process(list->cursor))) < DLT_RETURN_OK) + if((tmp_ret = dlt_kpi_add_process_after_cursor(stopped_process_list, dlt_kpi_clone_process(list->cursor))) < DLT_RETURN_OK) return tmp_ret; - if((tmp_ret = dlt_procfs_remove_process_at_cursor(list)) < DLT_RETURN_OK) + if((tmp_ret = dlt_kpi_remove_process_at_cursor(list)) < DLT_RETURN_OK) return tmp_ret; } else if(current_dir_pid == list->cursor->pid) // Staying process { /* update data */ - if((tmp_ret = dlt_procfs_update_process(list->cursor, time_dif_ms)) < DLT_RETURN_OK) + if((tmp_ret = dlt_kpi_update_process(list->cursor, time_dif_ms)) < DLT_RETURN_OK) return tmp_ret; if(list->cursor->cpu_time > 0) // only log active processes - if((tmp_ret = dlt_procfs_add_process_after_cursor(update_process_list, dlt_procfs_clone_process(list->cursor))) < DLT_RETURN_OK) + if((tmp_ret = dlt_kpi_add_process_after_cursor(update_process_list, dlt_kpi_clone_process(list->cursor))) < DLT_RETURN_OK) { - fprintf(stderr, "dlt_procfs_update_process_list: Can't add process to list updateProcessList\n"); + fprintf(stderr, "dlt_kpi_update_process_list: Can't add process to list updateProcessList\n"); return tmp_ret; } - if((tmp_ret = dlt_procfs_increment_cursor(list)) < DLT_RETURN_OK) // next process in list + if((tmp_ret = dlt_kpi_increment_cursor(list)) < DLT_RETURN_OK) // next process in list return tmp_ret; current_dir = readdir(proc_dir); // next process in proc-fs @@ -396,15 +403,15 @@ DltReturnValue dlt_procfs_update_process_list(DltProcfsProcessList *list, unsign } /* Log new processes */ - if((tmp_ret = dlt_procfs_log_list(new_process_list, &dlt_procfs_get_msg_process_new, "NEW", 1)) < DLT_RETURN_OK) + if((tmp_ret = dlt_kpi_log_list(new_process_list, &dlt_kpi_get_msg_process_new, "NEW", 1)) < DLT_RETURN_OK) return tmp_ret; /* Log stopped processes */ - if((tmp_ret = dlt_procfs_log_list(stopped_process_list, &dlt_procfs_get_msg_process_stop, "STP", 1)) < DLT_RETURN_OK) + if((tmp_ret = dlt_kpi_log_list(stopped_process_list, &dlt_kpi_get_msg_process_stop, "STP", 1)) < DLT_RETURN_OK) return tmp_ret; /* Log active processes */ - if((tmp_ret = dlt_procfs_log_list(update_process_list, &dlt_procfs_get_msg_process_update, "ACT", 1)) < DLT_RETURN_OK) + if((tmp_ret = dlt_kpi_log_list(update_process_list, &dlt_kpi_get_msg_process_update, "ACT", 1)) < DLT_RETURN_OK) return tmp_ret; if(closedir(proc_dir) < 0) @@ -413,15 +420,15 @@ DltReturnValue dlt_procfs_update_process_list(DltProcfsProcessList *list, unsign return DLT_RETURN_OK; } -void *dlt_procfs_start_irq_thread() +void *dlt_kpi_start_irq_thread() { - if(dlt_procfs_irq_loop() < DLT_RETURN_OK) - dlt_procfs_stop_loops(-1); + if(dlt_kpi_irq_loop() < DLT_RETURN_OK) + dlt_kpi_stop_loops(-1); return NULL; } -DltReturnValue dlt_procfs_irq_loop() +DltReturnValue dlt_kpi_irq_loop() { static unsigned long int old_millis, sleep_millis, dif_millis; @@ -429,7 +436,7 @@ DltReturnValue dlt_procfs_irq_loop() while(!stop_loop) { - /*DltReturnValue ret = */ dlt_procfs_log_interrupts(&procfs_ctx, config.log_level); + /*DltReturnValue ret = */ dlt_kpi_log_interrupts(&kpi_ctx, config.log_level); //if(ret < DLT_RETURN_OK) // return ret; @@ -448,15 +455,15 @@ DltReturnValue dlt_procfs_irq_loop() return DLT_RETURN_OK; } -void *dlt_procfs_start_check_thread() +void *dlt_kpi_start_check_thread() { - if(dlt_procfs_check_loop() < DLT_RETURN_OK) - dlt_procfs_stop_loops(-1); + if(dlt_kpi_check_loop() < DLT_RETURN_OK) + dlt_kpi_stop_loops(-1); return NULL; } -DltReturnValue dlt_procfs_check_loop() +DltReturnValue dlt_kpi_check_loop() { static unsigned long int old_millis, sleep_millis, dif_millis; @@ -464,7 +471,7 @@ DltReturnValue dlt_procfs_check_loop() while(!stop_loop) { - /*DltReturnValue ret = */ dlt_procfs_log_check_commandlines(); + /*DltReturnValue ret = */ dlt_kpi_log_check_commandlines(); //if(ret < DLT_RETURN_OK) // return ret; @@ -483,7 +490,7 @@ DltReturnValue dlt_procfs_check_loop() return DLT_RETURN_OK; } -DltReturnValue dlt_procfs_log_check_commandlines() +DltReturnValue dlt_kpi_log_check_commandlines() { if(pthread_mutex_lock(&process_list_mutex) < 0) { @@ -491,7 +498,7 @@ DltReturnValue dlt_procfs_log_check_commandlines() return DLT_RETURN_ERROR; } - DltReturnValue ret = dlt_procfs_log_list(list, dlt_procfs_get_msg_process_commandline, "CHK", 0); + DltReturnValue ret = dlt_kpi_log_list(list, dlt_kpi_get_msg_process_commandline, "CHK", 0); if(pthread_mutex_unlock(&process_list_mutex) < 0) { diff --git a/src/procfs/dlt-procfs.conf b/src/kpi/dlt-kpi.conf index 5abd2a7..bb93d47 100644 --- a/src/procfs/dlt-procfs.conf +++ b/src/kpi/dlt-kpi.conf @@ -1,4 +1,4 @@ -# Configuration file for DLT /proc/-filesystem logger +# Configuration file for DLT KPI logger # ######################################################################## diff --git a/src/procfs/dlt-procfs.h b/src/kpi/dlt-kpi.h index 637aecb..bb5b48c 100644 --- a/src/procfs/dlt-procfs.h +++ b/src/kpi/dlt-kpi.h @@ -21,21 +21,22 @@ * \copyright Copyright © 2011-2015 BMW AG. \n * License MPL-2.0: Mozilla Public License version 2.0 http://mozilla.org/MPL/2.0/. * - * \file dlt-procfs.h + * \file dlt-kpi.h */ -#ifndef SRC_PROCFS_DLT_PROCFS_H_ -#define SRC_PROCFS_DLT_PROCFS_H_ +#ifndef SRC_KPI_DLT_KPI_H_ +#define SRC_KPI_DLT_KPI_H_ #include "dlt.h" -#include "dlt-procfs-common.h" -#include "dlt-procfs-process.h" -#include "dlt-procfs-process-list.h" -#include "dlt-procfs-interrupt.h" #include <syslog.h> +#include "dlt-kpi-common.h" +#include "dlt-kpi-interrupt.h" +#include "dlt-kpi-process.h" +#include "dlt-kpi-process-list.h" + // CONSTANT DEFINITIONS -#define DEFAULT_CONF_FILE ( CONFIGURATION_FILES_DIR "/dlt-procfs.conf") +#define DEFAULT_CONF_FILE ( CONFIGURATION_FILES_DIR "/dlt-kpi.conf") #define COMMAND_LINE_SIZE 1024 @@ -44,18 +45,18 @@ typedef struct { char *configurationFileName; int customConfigFile; -} DltProcfsOptions; +} DltKpiOptions; typedef struct { int process_log_interval, irq_log_interval, check_log_interval; DltLogLevelType log_level; -} DltProcfsConfig; +} DltKpiConfig; // FUNCTION DECLARATIONS: -DltReturnValue dlt_procfs_read_command_line(DltProcfsOptions *options, int argc, char **argv); -DltReturnValue dlt_procfs_read_configuration_file(DltProcfsConfig *config, char *file_name); -void dlt_procfs_free_cli_options(DltProcfsOptions *options); -DltReturnValue dlt_procfs_init(int argc, char **argv, DltProcfsConfig *config); +DltReturnValue dlt_kpi_read_command_line(DltKpiOptions *options, int argc, char **argv); +DltReturnValue dlt_kpi_read_configuration_file(DltKpiConfig *config, char *file_name); +void dlt_kpi_free_cli_options(DltKpiOptions *options); +DltReturnValue dlt_kpi_init(int argc, char **argv, DltKpiConfig *config); -#endif /* SRC_PROCFS_DLT_PROCFS_H_ */ +#endif /* SRC_KPI_DLT_KPI_H_ */ diff --git a/src/procfs/dlt-procfs-process-list.h b/src/procfs/dlt-procfs-process-list.h deleted file mode 100644 index 1545ab3..0000000 --- a/src/procfs/dlt-procfs-process-list.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * @licence app begin@ - * SPDX license identifier: MPL-2.0 - * - * Copyright (C) 2011-2015, BMW AG - * - * This file is part of GENIVI Project DLT - Diagnostic Log and Trace. - * - * This Source Code Form is subject to the terms of the - * Mozilla Public License (MPL), 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/. - * - * For further information see http://www.genivi.org/. - * @licence end@ - */ - -/*! - * \author Sven Hassler <sven_hassler@mentor.com> - * - * \copyright Copyright © 2011-2015 BMW AG. \n - * License MPL-2.0: Mozilla Public License version 2.0 http://mozilla.org/MPL/2.0/. - * - * \file dlt-procfs-process-list.h - */ - -#ifndef SRC_PROCFS_DLT_PROCFS_PROCESS_LIST_H_ -#define SRC_PROCFS_DLT_PROCFS_PROCESS_LIST_H_ - -#include "dlt-procfs-common.h" -#include "dlt-procfs-process.h" - -typedef struct -{ - struct DltProcfsProcess *start, *cursor; -} DltProcfsProcessList; - -DltProcfsProcessList *dlt_procfs_create_process_list(); -DltReturnValue dlt_procfs_free_process_list_soft(DltProcfsProcessList *list); -DltReturnValue dlt_procfs_free_process_list(DltProcfsProcessList *list); -DltProcfsProcess *dlt_procfs_get_process_at_cursor(DltProcfsProcessList *list); -DltReturnValue dlt_procfs_increment_cursor(DltProcfsProcessList *list); -DltReturnValue dlt_procfs_decrement_cursor(DltProcfsProcessList *list); -DltReturnValue dlt_procfs_reset_cursor(DltProcfsProcessList *list); -DltReturnValue dlt_procfs_add_process_at_start(DltProcfsProcessList *list, DltProcfsProcess *process); -DltReturnValue dlt_procfs_add_process_before_cursor(DltProcfsProcessList *list, DltProcfsProcess *process); -DltReturnValue dlt_procfs_add_process_after_cursor(DltProcfsProcessList *list, DltProcfsProcess *process); -DltReturnValue dlt_procfs_remove_process_at_cursor_soft(DltProcfsProcessList *list); -DltReturnValue dlt_procfs_remove_process_at_cursor(DltProcfsProcessList *list); - -// DltReturnValue dlt_procfs_remove_process_after_cursor(DltProcfsProcessList *list); -// DltReturnValue dlt_procfs_remove_first_process(DltProcfsProcessList *list); - -#endif /* SRC_PROCFS_DLT_PROCFS_PROCESS_LIST_H_ */ diff --git a/src/procfs/dlt-procfs-process.h b/src/procfs/dlt-procfs-process.h deleted file mode 100644 index 92c32db..0000000 --- a/src/procfs/dlt-procfs-process.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * @licence app begin@ - * SPDX license identifier: MPL-2.0 - * - * Copyright (C) 2011-2015, BMW AG - * - * This file is part of GENIVI Project DLT - Diagnostic Log and Trace. - * - * This Source Code Form is subject to the terms of the - * Mozilla Public License (MPL), 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/. - * - * For further information see http://www.genivi.org/. - * @licence end@ - */ - -/*! - * \author Sven Hassler <sven_hassler@mentor.com> - * - * \copyright Copyright © 2011-2015 BMW AG. \n - * License MPL-2.0: Mozilla Public License version 2.0 http://mozilla.org/MPL/2.0/. - * - * \file dlt-procfs-process.h - */ - -#ifndef SRC_PROCFS_DLT_PROCFS_PROCESS_H_ -#define SRC_PROCFS_DLT_PROCFS_PROCESS_H_ - -#include "dlt.h" -#include "dlt-procfs-common.h" -#include <stdlib.h> - -typedef struct DltProcfsEventWatch DltProcfsEventWatch; // forward declaration - -typedef struct DltProcfsProcess -{ - pid_t pid, ppid; - char *command_line; - unsigned long int cpu_time, last_cpu_time, io_wait, last_io_wait, io_bytes; - long int rss, ctx_switches; - - struct DltProcfsProcess *next, *prev; -} DltProcfsProcess; - -DltProcfsProcess *dlt_procfs_create_process(); -DltProcfsProcess *dlt_procfs_clone_process(DltProcfsProcess *original); -DltReturnValue dlt_procfs_free_process(DltProcfsProcess *process); -DltReturnValue dlt_procfs_print_process(DltProcfsProcess *process); -DltReturnValue dlt_procfs_update_process(DltProcfsProcess *process, unsigned long int time_dif_ms); -DltReturnValue dlt_procfs_get_msg_process_new(DltProcfsProcess *process, char *buffer, int maxlen); -DltReturnValue dlt_procfs_get_msg_process_stop(DltProcfsProcess *process, char *buffer, int maxlen); -DltReturnValue dlt_procfs_get_msg_process_update(DltProcfsProcess *process, char *buffer, int maxlen); -DltReturnValue dlt_procfs_get_msg_process_commandline(DltProcfsProcess *process, char *buffer, int maxlen); - -#endif /* SRC_PROCFS_DLT_PROCFS_PROCESS_H_ */ |