fix save hard status bugs

This commit is contained in:
zhangsheng 2026-01-16 18:16:52 +08:00
parent 6a0fcb53e9
commit 7ba1399289
3 changed files with 15 additions and 6 deletions

View File

@ -1466,15 +1466,24 @@ int SqliteDB::SaveSystemHardStatus(){
Json::Value jsData; Json::Value jsData;
std::string sysStatus = GetSysStatus(jsData); std::string sysStatus = GetSysStatus(jsData);
char insertSql[1024] = {0}; char insertSql[1024] = {0};
int mem_use = jsData["memoryUse"].asInt(); float cpu_use = jsData["cpuUserUse"].asDouble();
float mem_use_rate = jsData["memoryUse"].asDouble();
int mem_free = jsData["memoryFree"].asInt(); int mem_free = jsData["memoryFree"].asInt();
int mem_total = jsData["memoryTotal"].asInt(); int mem_total = jsData["memoryTotal"].asInt();
float mem_rate = float(mem_use / mem_total); int mem_use = mem_total - mem_free;
float disk_free = jsData["hardDiskFree"].asDouble(); float disk_free = jsData["hardDiskFree"].asDouble();
float disk_total = jsData["hardDiskTotal"].asDouble(); float disk_total = jsData["hardDiskTotal"].asDouble();
float disk_use = jsData["hardDiskUse"].asDouble(); float disk_use_rate = jsData["hardDiskUse"].asDouble();
sprintf(insertSql, " '%s','%d','%d','%d','%f','%f','%f','%f','%s'", int temp = jsData["temperature"].asDouble();
jsData["cpuUserUse"].asString(),mem_use,mem_free,mem_rate,disk_use,disk_free,disk_use/disk_total,jsData["temperature"].asDouble(),jsData["updateTime"].asString()); zlog_info(zct,"cpu_use = %f,mem_use = %d,mem_free = %d,mem_rate = %f,total = %f,free = %f,rate = %f",cpu_use,mem_use,mem_free,mem_use_rate,disk_total,disk_free,disk_use_rate);
std::string updateTime = jsData["updateTime"].asString();
sprintf(insertSql, " '%f','%d','%d','%f','%f','%f','%f','%d','%s' ",
cpu_use,
mem_use,mem_free,mem_use_rate,
disk_total-disk_free,disk_free,disk_use_rate,
temp,
updateTime.c_str());
sqlite_db_ctrl::instance().InsertData("t_system_info", insertSql); sqlite_db_ctrl::instance().InsertData("t_system_info", insertSql);
} }
int SqliteDB::TransBegin() { return sqlite3_exec(mDBAcess, "begin;", 0, 0, 0); } int SqliteDB::TransBegin() { return sqlite3_exec(mDBAcess, "begin;", 0, 0, 0); }

View File

@ -149,7 +149,6 @@ int main(int argc, char *argv[]) {
zlog_error(zbt, "internal error - lzo_init() failed !!!"); zlog_error(zbt, "internal error - lzo_init() failed !!!");
zlog_error(zbt, "(this usually indicates a compiler bug - try recompiling\nwithout optimizations, and enable '-DLZO_DEBUG' for diagnostics)"); zlog_error(zbt, "(this usually indicates a compiler bug - try recompiling\nwithout optimizations, and enable '-DLZO_DEBUG' for diagnostics)");
} }
int fd = OpenWatchDog(); int fd = OpenWatchDog();
int count = 0; int count = 0;
while (GlobalConfig::QuitFlag_G) { while (GlobalConfig::QuitFlag_G) {

View File

@ -189,6 +189,7 @@ void CheckThread() {
long lTime = atol(nowTimetamp.c_str()) - atol(strTime.c_str()); long lTime = atol(nowTimetamp.c_str()) - atol(strTime.c_str());
zlog_info(zct, "online check = %ld", lTime); zlog_info(zct, "online check = %ld", lTime);
} }
} }
if (7200 == Battery) { if (7200 == Battery) {
Battery = 0; Battery = 0;