#include "systemstatehelper.h"

#include <iostream>
#include <fstream>
#include <sstream>
#include <string>

int system_state_helper::getLoadAvg() {
    std::ifstream file("/proc/loadavg");
    if (!file.is_open()) {
        return -1;
    }

    std::string line;
    if (std::getline(file, line)) {
        std::istringstream iss(line);
        std::string firstValue;
        iss >> firstValue; 

        file.close();
        return (int)std::stod(firstValue); 
    }

    file.close();
    return -1;
}
