Commit d30f8220 by leiguo1029

\

parent 54f9f189
......@@ -430,32 +430,33 @@ void collect_mem_info(JNIEnv *env, cJSON *json) {
//get ram
struct sysinfo si;
if(WDSYSCALL(SYS_sysinfo, &si) == 0) {
double ram_total = ((double)(si.totalram * si.mem_unit)) / 1024 / 1024 / 1024;
double ram_free = ((double)(si.freeram * si.mem_unit)) / 1024 / 1024 / 1024;
u_long ram_total = si.totalram * si.mem_unit;
u_long ram_free = si.freeram * si.mem_unit;
char ram_buf[32] = {0};
snprintf(ram_buf, 31, "%.3lf, %.3lf", ram_total, ram_free);
snprintf(ram_buf, 31, "lu, %lu", ram_total, ram_free);
cJSON_AddStringToObject(item, "ram", ram_buf);
}
//get rom
struct statfs sf;
if(WDSYSCALL(SYS_statfs, "/data", &sf) == 0) {
double rom_total = ((double)(sf.f_blocks * sf.f_bsize)) / 1024 / 1024 / 1024;
double rom_free = ((double)(sf.f_bfree * sf.f_bsize)) / 1024 / 1024 / 1024;
char rom_buf[32] = {0};
snprintf(rom_buf, 31, "%.3lf, %.3lf", rom_total, rom_free);
cJSON_AddStringToObject(item, "rom", rom_buf);
u_long data_total = sf.f_blocks * sf.f_bsize;
u_long data_free = sf.f_bfree * sf.f_bsize;
char sdcard_buf[32] = {0};
snprintf(sdcard_buf, 31, "%lu, %lu", data_total, data_free);
cJSON_AddStringToObject(item, "rom", sdcard_buf);
}
//get sdcard
/*
struct statfs sf2;
if(WDSYSCALL(SYS_statfs, "/sdcard", &sf2) == 0) {
double sdcard_total = ((double)(sf2.f_blocks * sf2.f_bsize)) / 1024 / 1024 / 1024;
double sdcard_free = ((double)(sf2.f_bfree * sf2.f_bsize)) / 1024 / 1024 / 1024;
u_long sdcard_total = sf2.f_blocks * sf2.f_bsize;
u_long sdcard_free = sf2.f_bfree * sf2.f_bsize;
char sdcard_buf[32] = {0};
snprintf(sdcard_buf, 31, "%.3lf, %.3lf", sdcard_total, sdcard_free);
snprintf(sdcard_buf, 31, "%lu, %lu", sdcard_total, sdcard_free);
cJSON_AddStringToObject(item, "sdcard", sdcard_buf);
}
}*/
cJSON_AddItemToObject(json, "mem", item);
logd(WD_COLLECT, "%s", "collect mem_info finished...");
......@@ -635,12 +636,14 @@ void collect_system_id(JNIEnv *env, cJSON *json) {
void collect_time_info(JNIEnv *env, cJSON *json) {
// current_time
struct timespec ts = {0};
time_t cur;
if(WDSYSCALL(SYS_clock_gettime, CLOCK_REALTIME, &ts) == 0) {
cJSON_AddNumberToObject(json, "cur_time", ts.tv_sec);
cur = ts.tv_sec;
cJSON_AddNumberToObject(json, "cur_time", cur);
}
if(WDSYSCALL(SYS_clock_gettime, CLOCK_BOOTTIME, &ts) == 0) {
cJSON_AddNumberToObject(json, "start_boot_time", ts.tv_sec);
cJSON_AddNumberToObject(json, "boot_time", ts.tv_sec - cur);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment