Put journal and nvme stats in bootlog (#22849)

* Run commands and put output in bootlog

* log nvme

* fix indent

* cereal without event

* use regular array
This commit is contained in:
Willem Melching
2021-11-10 16:07:22 +01:00
committed by GitHub
parent 6ace88a0f1
commit fa0cbe5d40
4 changed files with 40 additions and 1 deletions
+16
View File
@@ -209,6 +209,22 @@ std::string dir_name(std::string const &path) {
return path.substr(0, pos);
}
std::string check_output(const std::string& command) {
char buffer[128];
std::string result;
std::unique_ptr<FILE, decltype(&pclose)> pipe(popen(command.c_str(), "r"), pclose);
if (!pipe) {
return "";
}
while (fgets(buffer, std::size(buffer), pipe.get()) != nullptr) {
result += std::string(buffer);
}
return result;
}
struct tm get_time() {
time_t rawtime;
time(&rawtime);
+2
View File
@@ -89,6 +89,8 @@ std::string readlink(const std::string& path);
bool file_exists(const std::string& fn);
bool create_directories(const std::string &dir, mode_t mode);
std::string check_output(const std::string& command);
inline void sleep_for(const int milliseconds) {
std::this_thread::sleep_for(std::chrono::milliseconds(milliseconds));
}