mirror of
https://gitee.com/acl-dev/acl.git
synced 2024-12-16 01:40:52 +08:00
19 lines
391 B
C++
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());
|
|
}
|