mirror of
https://github.com/sunnypilot/sunnypilot.git
synced 2026-02-20 17:13:53 +08:00
* cp msg to remove the space * no orphans * cleanup * parse using istringstream * add test * split files * cleanup * add parser.cc to files_common * add test for build message * use > 0 * cleanup * test proc/self/stat * more test * dd * fix bug * update test * refactor pidStat * cleanup * test exe * check procs size in message * rename pidStat->ProcStat * don't use util::format_string * robust pids() * catch conversion exception * fix softirq * udpate test * use istringstream * use REQUIRE_THAT&cleanup * reserve vector of procStats * use istream to parse cmdline * cleanup
41 lines
966 B
C++
41 lines
966 B
C++
#include <optional>
|
|
#include <string>
|
|
#include <unordered_map>
|
|
#include <vector>
|
|
|
|
#include "cereal/messaging/messaging.h"
|
|
|
|
struct CPUTime {
|
|
int id;
|
|
unsigned long utime, ntime, stime, itime;
|
|
unsigned long iowtime, irqtime, sirqtime;
|
|
};
|
|
|
|
struct ProcCache {
|
|
int pid;
|
|
std::string name, exe;
|
|
std::vector<std::string> cmdline;
|
|
};
|
|
|
|
struct ProcStat {
|
|
int pid, ppid, processor;
|
|
char state;
|
|
long cutime, cstime, priority, nice, num_threads;
|
|
unsigned long utime, stime, vms, rss;
|
|
unsigned long long starttime;
|
|
std::string name;
|
|
};
|
|
|
|
namespace Parser {
|
|
|
|
std::vector<int> pids();
|
|
std::optional<ProcStat> procStat(std::string stat);
|
|
std::vector<std::string> cmdline(std::istream &stream);
|
|
std::vector<CPUTime> cpuTimes(std::istream &stream);
|
|
std::unordered_map<std::string, uint64_t> memInfo(std::istream &stream);
|
|
const ProcCache &getProcExtraInfo(int pid, const std::string &name);
|
|
|
|
}; // namespace Parser
|
|
|
|
void buildProcLogMessage(MessageBuilder &msg);
|