提交 e55b5339 authored 作者: blu's avatar blu

feature: clean disk if it's full

上级 0a343654
......@@ -1095,6 +1095,12 @@ public:
// TODO: move to failed folder
string dirDest = "/var/data/evsuits/failed_events/";
system((string("mkdir -p ") + dirDest).c_str());
auto bfPer = sysutils::getDiskAvailPercent(dirDest);
if(bfPer >= 0.1) {
}else{
system((string("rm -fr ") + dirDest).c_str());
}
json postArgs;
postArgs["params"] = params;
postArgs["fileNames"] = fileNames;
......
......@@ -700,3 +700,16 @@ json getModulesOperFromConfDiff(json& oldConfig, json &newConfig, json &diff, st
return ret;
}
} // cfgutils
namespace sysutils {
double getDiskAvailPercent(string path) {
struct statvfs fiData;
if((statvfs(path.c_str(),&fiData)) < 0 ) {
} else {
double fper = fiData.f_bavail/double(fiData.f_blocks);
return fper;
}
return -1;
}
}
......@@ -16,6 +16,7 @@
#include <string>
#include <fstream>
#include <fmt/format.h>
#include <sys/statvfs.h>
#define EVCLOUD_REQ_E_CONN -2
#define EVCLOUD_REQ_E_DATA -3
......@@ -50,6 +51,10 @@ namespace cfgutils {
json getModuleGidsFromCfg(string sn, json &data, string caller = "", int ipcIdx = -1);
}
namespace sysutils{
double getDiskAvailPercent(string path);
}
struct StrException : public std::exception
{
std::string s;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论