Skip to content

Commit

Permalink
MMA: General improvements and corrections of the Linux part (#1284)
Browse files Browse the repository at this point in the history
  • Loading branch information
jheeks authored Dec 22, 2023
1 parent 41bd969 commit cd67b47
Show file tree
Hide file tree
Showing 3 changed files with 337 additions and 174 deletions.
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
55 changes: 44 additions & 11 deletions contrib/mma/include/linux/mma_linux.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,21 +43,54 @@ class MMALinux : public MMAImpl
**/
~MMALinux();

std::mutex mutex;
bool is_vrm;
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::mutex mutex_;
std::string os_name_;
int nr_of_cpu_cores_;

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
{
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

0 comments on commit cd67b47

Please sign in to comment.