git-svn-id: svn://db.shs.com.ru/pip@728 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5
This commit is contained in:
@@ -20,7 +20,6 @@
|
||||
#include "piincludes_p.h"
|
||||
|
||||
#ifdef ESP_PLATFORM
|
||||
# include "esp_heap_caps.h"
|
||||
# include "esp_system.h"
|
||||
# include "esp_spi_flash.h"
|
||||
#endif
|
||||
@@ -37,35 +36,6 @@ PISystemInfo * PISystemInfo::instance() {
|
||||
}
|
||||
|
||||
|
||||
ullong PISystemInfo::totalRAM() {
|
||||
#ifdef ESP_PLATFORM
|
||||
multi_heap_info_t heap_info;
|
||||
memset(&heap_info, 0, sizeof(multi_heap_info_t));
|
||||
heap_caps_get_info(&heap_info, MALLOC_CAP_8BIT);
|
||||
return heap_info.total_allocated_bytes + heap_info.total_free_bytes;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
ullong PISystemInfo::freeRAM() {
|
||||
#ifdef ESP_PLATFORM
|
||||
multi_heap_info_t heap_info;
|
||||
memset(&heap_info, 0, sizeof(multi_heap_info_t));
|
||||
heap_caps_get_info(&heap_info, MALLOC_CAP_8BIT);
|
||||
return heap_info.total_free_bytes;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
ullong PISystemInfo::usedRAM() {
|
||||
#ifdef ESP_PLATFORM
|
||||
multi_heap_info_t heap_info;
|
||||
memset(&heap_info, 0, sizeof(multi_heap_info_t));
|
||||
heap_caps_get_info(&heap_info, MALLOC_CAP_8BIT);
|
||||
return heap_info.total_allocated_bytes;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
PIStringList PISystemInfo::mountRoots() {
|
||||
PIStringList ret;
|
||||
|
||||
@@ -38,7 +38,6 @@ public:
|
||||
};
|
||||
|
||||
PIString ifconfigPath, execCommand, hostname, user, OS_name, OS_version, architecture;
|
||||
ullong RAM_total, RAM_free;
|
||||
PIDateTime execDateTime;
|
||||
int processorsCount;
|
||||
|
||||
@@ -46,9 +45,6 @@ public:
|
||||
static PIVector<MountInfo> mountInfo();
|
||||
|
||||
static PISystemInfo * instance();
|
||||
static ullong totalRAM();
|
||||
static ullong freeRAM();
|
||||
static ullong usedRAM();
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -32,6 +32,9 @@
|
||||
# include <libproc.h>
|
||||
# include <sys/proc_info.h>
|
||||
#endif
|
||||
#ifdef ESP_PLATFORM
|
||||
# include "esp_heap_caps.h"
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef FREERTOS
|
||||
@@ -320,7 +323,9 @@ void PISystemMonitor::run() {
|
||||
lock();
|
||||
cur_ts = cur_tm.values();
|
||||
unlock();
|
||||
|
||||
stat.ram_total = totalRAM();
|
||||
stat.ram_used = usedRAM();
|
||||
stat.ram_free = freeRAM();
|
||||
makeStrings();
|
||||
}
|
||||
|
||||
@@ -390,3 +395,36 @@ float PISystemMonitor::calcThreadUsage(PISystemTime & t_new, PISystemTime & t_ol
|
||||
if (delay_ <= 0) return -1.;
|
||||
return piClampf(100. * ((t_new - t_old).toMilliseconds() / delay_), 0.f, 100.f);
|
||||
}
|
||||
|
||||
|
||||
ullong PISystemMonitor::totalRAM() {
|
||||
#ifdef ESP_PLATFORM
|
||||
multi_heap_info_t heap_info;
|
||||
memset(&heap_info, 0, sizeof(multi_heap_info_t));
|
||||
heap_caps_get_info(&heap_info, MALLOC_CAP_8BIT);
|
||||
return heap_info.total_allocated_bytes + heap_info.total_free_bytes;
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
ullong PISystemMonitor::freeRAM() {
|
||||
#ifdef ESP_PLATFORM
|
||||
multi_heap_info_t heap_info;
|
||||
memset(&heap_info, 0, sizeof(multi_heap_info_t));
|
||||
heap_caps_get_info(&heap_info, MALLOC_CAP_8BIT);
|
||||
return heap_info.total_free_bytes;
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
ullong PISystemMonitor::usedRAM() {
|
||||
#ifdef ESP_PLATFORM
|
||||
multi_heap_info_t heap_info;
|
||||
memset(&heap_info, 0, sizeof(multi_heap_info_t));
|
||||
heap_caps_get_info(&heap_info, MALLOC_CAP_8BIT);
|
||||
return heap_info.total_allocated_bytes;
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -40,11 +40,14 @@ public:
|
||||
int session_ID;
|
||||
int priority;
|
||||
int threads;
|
||||
ulong physical_memsize;
|
||||
ulong resident_memsize;
|
||||
ulong share_memsize;
|
||||
ulong virtual_memsize;
|
||||
ulong data_memsize;
|
||||
ullong physical_memsize;
|
||||
ullong resident_memsize;
|
||||
ullong share_memsize;
|
||||
ullong virtual_memsize;
|
||||
ullong data_memsize;
|
||||
ullong ram_total;
|
||||
ullong ram_free;
|
||||
ullong ram_used;
|
||||
PIString physical_memsize_readable;
|
||||
PIString resident_memsize_readable;
|
||||
PIString share_memsize_readable;
|
||||
@@ -80,12 +83,18 @@ public:
|
||||
PIVector<ThreadStats> threadsStatistic() const;
|
||||
void setStatistic(const ProcessStats & s) {stat = s; makeStrings();}
|
||||
|
||||
static ullong totalRAM();
|
||||
static ullong freeRAM();
|
||||
static ullong usedRAM();
|
||||
|
||||
|
||||
private:
|
||||
void run();
|
||||
void makeStrings();
|
||||
void gatherThread(llong id);
|
||||
float calcThreadUsage(PISystemTime & t_new, PISystemTime & t_old);
|
||||
|
||||
|
||||
ProcessStats stat;
|
||||
PIVector<ThreadStats> cur_ts;
|
||||
PIMap<llong, ThreadStats> last_tm, cur_tm;
|
||||
|
||||
Reference in New Issue
Block a user