Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get mma linux more generic #1284

Merged
merged 21 commits into from
Dec 22, 2023
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions contrib/mma/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,13 @@ The MachineMonitoringAgent application on Windows needs the performance counters

## Linux

Before running the Machine Monitoring Application on Linux make sure the following packages are installed:
- systat : sudo apt install sysstat
- ifstat : sudo apt install ifstat
The Machine Monitoring Application on Linux collects information via:
- /proc virtual file system
- command df
- file /etc/os-release

These should be available on all standard Linux distributions
and even on embedded Linux distributions.

### Installation

Expand Down
51 changes: 42 additions & 9 deletions contrib/mma/include/linux/mma_linux.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,20 +44,53 @@ class MMALinux : public MMAImpl
~MMALinux();

std::mutex mutex;
bool is_vrm;
std::string os_name;
int nr_of_cpu_cores;
const std::string root = "/";
const std::string home = "/home";
const std::string media = "/media";
const std::string boot = "/boot";

std::string cpu_pipe_result_;
std::string network_pipe_result_;
std::string disk_pipe_result_;
std::string process_pipe_result_;



unsigned int cpu_pipe_count_ = 0;
unsigned int network_pipe_count_ = 0;
unsigned int disk_pipe_count_ = 0;
unsigned int process_pipe_count_ = 0;

unsigned int cpu_prev_count_;
unsigned int net_prev_count_;
unsigned int disk_prev_count_;
unsigned int proc_prev_count_;
double cpu_prev_idle_time_;

struct t_netIo
{
unsigned long rec;
unsigned long snd;
};
std::unordered_map<std::string, t_netIo> net_prev_map;

struct t_procItem
jheeks marked this conversation as resolved.
Show resolved Hide resolved
{
unsigned long utime{};
unsigned int count{};
ResourceLinux::Process process_stats;
};
std::map<uint32_t, t_procItem> proc_prev_map;

struct t_diskIo
{
unsigned long read;
unsigned long write;
};
std::unordered_map<std::string, t_diskIo> disk_prev_map;

std::map<uid_t, std::string> uname_map;
std::string root_dev;
std::string arm_vcgencmd;
long page_size;
long ticks_per_second;

/**
* @brief Get machine statistics: CPU, Memory, Disk, Network
*
Expand Down Expand Up @@ -114,7 +147,7 @@ class MMALinux : public MMAImpl
void SetResourceData(eCAL::pb::mma::State& state);
int GetCpuCores(void);

bool CheckIfIsALinuxVRM();
std::string GetOsName();
ResourceLinux::ProcessStatsList GetProcesses();


Expand All @@ -128,7 +161,7 @@ class MMALinux : public MMAImpl
std::list<std::string> TokenizeIntoLines(const std::string& str);
bool SetDiskInformation(ResourceLinux::DiskStatsList& disks);
bool SetDiskIOInformation(ResourceLinux::DiskStatsList& disk_stats_info);
bool MergeBootWithRootARM(ResourceLinux::DiskStatsList& disk_stats_info);
std::string GetArmvcgencmd();

std::unique_ptr<PipeRefresher> cpu_pipe_;
std::unique_ptr<PipeRefresher> network_pipe_;
Expand Down
Loading
Loading