-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsys_info_parser.h
More file actions
48 lines (36 loc) · 893 Bytes
/
Copy pathsys_info_parser.h
File metadata and controls
48 lines (36 loc) · 893 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#ifndef __CPU_INFO_PARSER_H__
#define __CPU_INFO_PARSER_H__
#include <sys/statfs.h>
#include "sys_info_struct.h"
#include "config.h"
#include <list>
class sys_info_parser
{
typedef std::list<std::string>::const_iterator const_file_sys_list_it;
public:
void init();
void get_sys_info();
_nic_stat_sys* get_sys_state() {return &stat_sys;}
private:
void calc_cpu_occupy();
uint64_t get_cpu_sum(_cpu_occupy_info &info)
{
return info.cpu_user + info.cpu_nice + info.cpu_sys + info.cpu_idle + info.cpu_iowait
+ info.cpu_irq + info.cpu_softirq;
}
void calc_memory_occupy();
void calc_disk_occupy();
private:
Config_parser config_;
private:
//计算结果集
_nic_stat_sys stat_sys;
private:
//读取2次cpu信息做差值计算
_cpu_occupy_info cpu_info[2];
//统计磁盘信息
struct statfs disk_info;
private:
std::list<std::string> list_file_sys_point;
};
#endif