16#include <sys/sysinfo.h>
17#include <sys/socket.h>
19#include <netinet/in.h>
30 struct sysinfo memInfo;
43 size_t totalPhysMemRAM = memInfo.totalram;
45 totalPhysMemRAM *= memInfo.mem_unit;
48 size_t physMemUsed = memInfo.totalram - memInfo.freeram;
50 physMemUsed *= memInfo.mem_unit;
52 return (
float)(((double)physMemUsed)/((double)totalPhysMemRAM));
59 struct sysinfo memInfo;
62 size_t totalPhysMemRAM = memInfo.totalram;
64 totalPhysMemRAM *= memInfo.mem_unit;
65 float totalRamGB(totalPhysMemRAM/1e9);
77 struct hostent *host_entry;
81 hostNameId = gethostname(hostbuffer,
sizeof(hostbuffer));
82 if(hostNameId == -1){
return;}
85 host_entry = gethostbyname(hostbuffer);
86 if(host_entry == NULL){
return;}
88 hostName = hostbuffer;
90 ipAddress = inet_ntoa(*((
struct in_addr*) host_entry->h_addr_list[0]));
98 unsigned int processor_count = std::thread::hardware_concurrency();
99 if(processor_count == 0u){
101 int numCPU = sysconf(_SC_NPROCESSORS_ONLN);
102 if(numCPU == -1){
return 0lu;}
105 return processor_count;
void phoenix_hardware_hostNameIp(std::string &hostName, std::string &ipAddress)
Get the host name and the IP address and the current host.
float phoenix_hardware_usedRAM()
Get the ratio of RAM used when this function is called.
size_t phoenix_hardware_nbCore()
Get the number of cores on the current host.
float phoenix_hardware_totalRAM()
Get the total amount of RAM (in GB) of the current host.