load_mon: get mem_usage by reading /proc/meminfo on Linux

This commit is contained in:
SalimTerryLi
2020-10-27 18:49:25 -04:00
committed by GitHub
parent 91da194bd7
commit 05f1efd1a4
7 changed files with 84 additions and 10 deletions
+3 -1
View File
@@ -33,7 +33,9 @@
#pragma once
#if defined(__PX4_NUTTX)
#include <malloc.h>
#endif
#include <drivers/drv_hrt.h>
#include <lib/perf/perf_counter.h>
#include <px4_platform_common/px4_config.h>
@@ -48,7 +50,6 @@
#if defined(__PX4_LINUX)
#include <sys/times.h>
#include <malloc.h>
#endif
namespace load_mon
@@ -92,6 +93,7 @@ private:
uORB::Publication<cpuload_s> _cpuload_pub {ORB_ID(cpuload)};
#if defined(__PX4_LINUX)
FILE *_proc_fd = nullptr;
/* calculate usage directly from clock ticks on Linux */
clock_t _last_total_time_stamp{};
clock_t _last_spent_time_stamp{};