Skip to content
Snippets Groups Projects
Commit a02007a6 authored by Dmitry Pyzyrkov's avatar Dmitry Pyzyrkov
Browse files

[+] partial macos build

parent 0dd7cf98
No related branches found
No related tags found
No related merge requests found
cmake_minimum_required(VERSION 3.10) cmake_minimum_required(VERSION 3.10)
project(cellframe-diagtool) project(cellframe-diagtool)
set(CMAKE_CXX_STANDARD 17)
if(DEFINED ENV{OSXCROSS_HOST}) if(DEFINED ENV{OSXCROSS_HOST})
message(STATUS "[*] Using OSXCROSS for build (OSXCROSS_HOST is set)") message(STATUS "[*] Using OSXCROSS for build (OSXCROSS_HOST is set)")
......
#include "MacDiagnostic.h" #include "MacDiagnostic.h"
#include <sys/stat.h>
#include <filesystem>
#include <unistd.h>
static unsigned long long _previousTotalTicks = 0; static unsigned long long _previousTotalTicks = 0;
static unsigned long long _previousIdleTicks = 0; static unsigned long long _previousIdleTicks = 0;
...@@ -11,6 +13,37 @@ MacDiagnostic::MacDiagnostic(AbstractDiagnostic *parent) ...@@ -11,6 +13,37 @@ MacDiagnostic::MacDiagnostic(AbstractDiagnostic *parent)
Qt::QueuedConnection); Qt::QueuedConnection);
} }
#include <filesystem>
long MacDiagnostic::get_pid()
{
return getpid();
}
QJsonObject MacDiagnostic::get_disk_info()
{
QString path = "/opt/cellframe-node";
QString apath = QDir(path).absolutePath();
std::error_code ec;
const std::filesystem::space_info si = std::filesystem::space(apath.toStdString(), ec);
quint64 total = si.capacity;
quint64 free = si.free;
quint64 available = si.available;
quint64 used = si.free - si.available;
QJsonObject diskObj;
diskObj.insert("total", QString::number(total));
diskObj.insert("free", QString::number(free));
diskObj.insert("available", QString::number(available));
diskObj.insert("used", QString::number(used));
return diskObj;
}
QJsonObject MacDiagnostic::get_sys_info() QJsonObject MacDiagnostic::get_sys_info()
{ {
// qInfo()<<"MacDiagnostic::get_sys_info "; // qInfo()<<"MacDiagnostic::get_sys_info ";
...@@ -115,7 +148,8 @@ float MacDiagnostic::calculate_cpu_load(unsigned long long idleTicks, unsigned l ...@@ -115,7 +148,8 @@ float MacDiagnostic::calculate_cpu_load(unsigned long long idleTicks, unsigned l
/// --------------------------------------------------------------- /// ---------------------------------------------------------------
/// Process info /// Process info
/// --------------------------------------------------------------- /// ---------------------------------------------------------------
QJsonObject MacDiagnostic::get_process_info(int totalRam) QJsonObject MacDiagnostic::get_process_info( long proc_id,
int totalRam)
{ {
// qInfo()<<"MacDiagnostic::get_process_info "; // qInfo()<<"MacDiagnostic::get_process_info ";
QJsonObject process_info; QJsonObject process_info;
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include <time.h> #include <time.h>
#include <mach/mach_time.h> #include <mach/mach_time.h>
using namespace std; using namespace std;
...@@ -23,7 +24,9 @@ public: ...@@ -23,7 +24,9 @@ public:
private: private:
QJsonObject get_sys_info(); QJsonObject get_sys_info();
QJsonObject get_process_info(int totalRam); QJsonObject get_process_info(long proc_id = 0, int totalRam = 0);
QJsonObject get_disk_info();
long get_pid();
//cpu //cpu
float calculate_cpu_load(unsigned long long idleTick, unsigned long long totakTicks ); float calculate_cpu_load(unsigned long long idleTick, unsigned long long totakTicks );
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment