mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-07-02 12:02:09 +08:00
loggerd: log all disk space usage in initData (#25455)
* bootlog: log all disk space usage * not just agnos * move to initData * cleanup old-commit-hash: aa32ea0f64e4035ac929e09ee85d268c3185221c
This commit is contained in:
+1
-1
Submodule cereal updated: 5ab1970017...2d648b0dc4
@@ -7,12 +7,6 @@
|
||||
|
||||
|
||||
static kj::Array<capnp::word> build_boot_log() {
|
||||
std::vector<std::string> bootlog_commands;
|
||||
if (Hardware::AGNOS()) {
|
||||
bootlog_commands.push_back("journalctl");
|
||||
bootlog_commands.push_back("sudo nvme smart-log --output-format=json /dev/nvme0");
|
||||
}
|
||||
|
||||
MessageBuilder msg;
|
||||
auto boot = msg.initEvent().initBoot();
|
||||
|
||||
@@ -31,17 +25,19 @@ static kj::Array<capnp::word> build_boot_log() {
|
||||
}
|
||||
|
||||
// Gather output of commands
|
||||
i = 0;
|
||||
std::vector<std::string> bootlog_commands = {
|
||||
"[ -e /dev/nvme0 ] && sudo nvme smart-log --output-format=json /dev/nvme0",
|
||||
"[ -x \"$(command -v journalctl)\" ] && journalctl",
|
||||
};
|
||||
|
||||
auto commands = boot.initCommands().initEntries(bootlog_commands.size());
|
||||
for (auto &command : bootlog_commands) {
|
||||
auto lentry = commands[i];
|
||||
for (int j = 0; j < bootlog_commands.size(); j++) {
|
||||
auto lentry = commands[j];
|
||||
|
||||
lentry.setKey(command);
|
||||
lentry.setKey(bootlog_commands[j]);
|
||||
|
||||
const std::string result = util::check_output(command);
|
||||
const std::string result = util::check_output(bootlog_commands[j]);
|
||||
lentry.setValue(capnp::Data::Reader((const kj::byte*)result.data(), result.size()));
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
boot.setLaunchLog(util::read_file("/tmp/launch_log"));
|
||||
|
||||
@@ -24,9 +24,11 @@ kj::Array<capnp::word> logger_build_init_data() {
|
||||
MessageBuilder msg;
|
||||
auto init = msg.initEvent().initInitData();
|
||||
|
||||
init.setDeviceType(Hardware::get_device_type());
|
||||
init.setVersion(COMMA_VERSION);
|
||||
init.setDirty(!getenv("CLEAN"));
|
||||
init.setDeviceType(Hardware::get_device_type());
|
||||
|
||||
// log kernel args
|
||||
std::ifstream cmdline_stream("/proc/cmdline");
|
||||
std::vector<std::string> kernel_args;
|
||||
std::string buf;
|
||||
@@ -42,8 +44,6 @@ kj::Array<capnp::word> logger_build_init_data() {
|
||||
init.setKernelVersion(util::read_file("/proc/version"));
|
||||
init.setOsVersion(util::read_file("/VERSION"));
|
||||
|
||||
init.setDirty(!getenv("CLEAN"));
|
||||
|
||||
// log params
|
||||
auto params = Params();
|
||||
std::map<std::string, std::string> params_map = params.readAll();
|
||||
@@ -55,16 +55,31 @@ kj::Array<capnp::word> logger_build_init_data() {
|
||||
init.setDongleId(params_map["DongleId"]);
|
||||
|
||||
auto lparams = init.initParams().initEntries(params_map.size());
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
for (auto& [key, value] : params_map) {
|
||||
auto lentry = lparams[i];
|
||||
auto lentry = lparams[j];
|
||||
lentry.setKey(key);
|
||||
if ( !(params.getKeyType(key) & DONT_LOG) ) {
|
||||
lentry.setValue(capnp::Data::Reader((const kj::byte*)value.data(), value.size()));
|
||||
}
|
||||
i++;
|
||||
|
||||
j++;
|
||||
}
|
||||
|
||||
// log commands
|
||||
std::vector<std::string> log_commands = {
|
||||
"df -h", // usage for all filesystems
|
||||
};
|
||||
|
||||
auto commands = init.initCommands().initEntries(log_commands.size());
|
||||
for (int i = 0; i < log_commands.size(); i++) {
|
||||
auto lentry = commands[i];
|
||||
|
||||
lentry.setKey(log_commands[i]);
|
||||
|
||||
const std::string result = util::check_output(log_commands[i]);
|
||||
lentry.setValue(capnp::Data::Reader((const kj::byte*)result.data(), result.size()));
|
||||
}
|
||||
|
||||
return capnp::messageToFlatArray(msg);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user