acl/app/master_dispatch/server/sysload.cpp
2015-02-04 06:26:20 -08:00

19 lines
391 B
C++

#include "stdafx.h"
#include "sysload.h"
double sysload::get_load(acl::string* out)
{
acl::string buf;
if (acl::ifstream::load("/proc/loadavg", &buf) == false)
{
logger_error("can't system load: %s", acl::last_serror());
return -1;
}
std::vector<acl::string>& tokens = buf.split2(" \t");
if (out)
*out = tokens[0].c_str();
return atof(tokens[0].c_str());
}