refactor: merged system cpu and mem reports into one struct 46/184246/2
authorMichal Kolodziejski <m.kolodziejs@samsung.com>
Mon, 16 Jul 2018 14:41:23 +0000 (16:41 +0200)
committerMichal Kolodziejski <m.kolodziejs@samsung.com>
Mon, 16 Jul 2018 15:27:12 +0000 (17:27 +0200)
Change-Id: I2c5e8ae3d8ea520c4ed86233ccde5f6309c81c11
Signed-off-by: Michal Kolodziejski <m.kolodziejs@samsung.com>
src/report-generator.c
src/report-generator.h
src/report-json-serializer.c
src/report-json-serializer.h
src/report.h
src/task-factory.c

index 71b3798..e442523 100644 (file)
@@ -142,7 +142,7 @@ void report_generator_free_app_generator(report_generator_app_t *generator)
 int report_generator_generate_system_cpu_usage_report(
                report_generator_system_t *generator,
                int interval,
-               struct system_cpu_usage_report *report)
+               struct system_usage_report *report)
 {
        ON_NULL_RETURN_VAL(generator, -1);
        ON_TRUE_RETURN_VAL(interval < 0, -1);
@@ -181,7 +181,7 @@ int report_generator_generate_system_cpu_usage_report(
 
 int report_generator_generate_system_memory_usage_report(
                report_generator_system_t *generator,
-               struct system_memory_usage_report *report) {
+               struct system_usage_report *report) {
        ON_NULL_RETURN_VAL(generator, -1);
        ON_NULL_RETURN_VAL(report, -1);
 
index 2aa05bd..d50dc2d 100644 (file)
@@ -107,7 +107,7 @@ report_generator_top_t *report_generator_new_top_report_generator(report_generat
 void report_generator_free_top_generator(report_generator_top_t *generator);
 
 /**
- * @brief Fills system_cpu_usage_report.
+ * @brief Fills system_usage_report.
  *
  * When interval > 0 the function will block for interval seconds and return report with
  * system cpu usage calculated as average during interval period.
@@ -123,10 +123,10 @@ void report_generator_free_top_generator(report_generator_top_t *generator);
 int report_generator_generate_system_cpu_usage_report(
                report_generator_system_t *generator,
                int interval,
-               struct system_cpu_usage_report *report);
+               struct system_usage_report *report);
 
 /**
- * @brief Fills system_memory_usage_report.
+ * @brief Fills system_usage_report.
  *
  * @param[in] generator system generator
  * @param[out] report
@@ -134,7 +134,7 @@ int report_generator_generate_system_cpu_usage_report(
  */
 int report_generator_generate_system_memory_usage_report(
                report_generator_system_t *generator,
-               struct system_memory_usage_report *report);
+               struct system_usage_report *report);
 
 /**
  * @brief Fills process_cpu_usage_report.
index a835e06..3a02755 100644 (file)
@@ -82,7 +82,7 @@ static void system_load_average_report_to_json_object(JsonBuilder *builder, stru
        json_builder_end_object(builder);
 }
 
-static void system_memory_usage_report_to_json_object(JsonBuilder *builder, struct system_memory_usage_report *report)
+static void system_memory_usage_report_to_json_object(JsonBuilder *builder, struct system_usage_report *report)
 {
        json_builder_begin_object(builder);
 
@@ -105,7 +105,7 @@ static void system_memory_usage_report_to_json_object(JsonBuilder *builder, stru
        json_builder_end_object(builder);
 }
 
-static void system_cpu_usage_report_to_json_object(JsonBuilder *builder, struct system_cpu_usage_report *report)
+static void system_cpu_usage_report_to_json_object(JsonBuilder *builder, struct system_usage_report *report)
 {
        json_builder_begin_object(builder);
 
@@ -274,12 +274,12 @@ IMPLEMENT_SERIALIZER_FUNC(
 
 IMPLEMENT_SERIALIZER_FUNC(
                report_json_serializer_serialize_system_memory_usage_report,
-               struct system_memory_usage_report,
+               struct system_usage_report,
                system_memory_usage_report_to_json_object)
 
 IMPLEMENT_SERIALIZER_FUNC(
                report_json_serializer_serialize_system_cpu_usage_report,
-               struct system_cpu_usage_report,
+               struct system_usage_report,
                system_cpu_usage_report_to_json_object)
 
 IMPLEMENT_SERIALIZER_FUNC(
index 43c62a9..73a236c 100644 (file)
 char *report_json_serializer_serialize_system_load_average_report(struct system_load_average_report *report);
 
 /**
- * @brief Serializes system_memory_usage_report to json string
+ * @brief Serializes system_usage_report to json string
  *
  * @param[in] report Report structure with usage data.
  *
  * @return dynamically allocated string on NULL on error.
  * @remark returned value should be released with @free
  */
-char *report_json_serializer_serialize_system_memory_usage_report(struct system_memory_usage_report *report);
+char *report_json_serializer_serialize_system_memory_usage_report(struct system_usage_report *report);
 
 /**
- * @brief Serializes system_cpus_usage_report to json string
+ * @brief Serializes system_usage_report to json string
  *
  * @param[in] report Report structure with usage data.
  *
  * @return dynamically allocated string on NULL on error.
  * @remark returned value should be released with @free
  */
-char *report_json_serializer_serialize_system_cpu_usage_report(struct system_cpu_usage_report *report);
+char *report_json_serializer_serialize_system_cpu_usage_report(struct system_usage_report *report);
 
 /**
  * @brief Serializes process_memory_usage_report to json string
index 811a532..2f59c1b 100644 (file)
@@ -32,22 +32,14 @@ struct system_load_average_report {
 };
 
 /**
- * @brief System Memory usage report
+ * @brief System usage report
  */
-struct system_memory_usage_report {
+struct system_usage_report {
        time_t time; /** Number of seconds after the Epoch */
        float usage; /** Memory utilization (Percent) */
 };
 
 /**
- * @brief System CPU usage report
- */
-struct system_cpu_usage_report {
-       time_t time; /** Number of seconds after the Epoch */
-       float usage; /** Cpu utilization (Percent) */
-};
-
-/**
  * @brief Process CPU usage report.
  */
 struct process_cpu_usage_report {
index c4ea70d..fb11077 100644 (file)
@@ -123,7 +123,7 @@ static void execute_scan_system_memory(task_t *task)
 
     system_task_t *_system_task = container_of(task, system_task_t, task);
 
-    struct system_memory_usage_report report;
+    struct system_usage_report report;
 
     int ret = report_generator_generate_system_memory_usage_report(_system_task->report_generator, &report);
     ON_TRUE_RETURN(ret != 0);
@@ -139,7 +139,7 @@ static void execute_scan_system_cpu(task_t *task)
 
     system_task_t *_system_task = container_of(task, system_task_t, task);
 
-    struct system_cpu_usage_report report;
+    struct system_usage_report report;
 
     int ret = report_generator_generate_system_cpu_usage_report(_system_task->report_generator, 0, &report);
     ON_TRUE_RETURN(ret != 0);