-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathProcVmstat.rb
More file actions
39 lines (32 loc) · 729 Bytes
/
ProcVmstat.rb
File metadata and controls
39 lines (32 loc) · 729 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
#
# SPDX-License-Identifier: GPL-2.0
#
# Copyright (c) 2018 Intel Corporation
#
# Authors: Fengguang Wu <fengguang.wu@intel.com>
#
class ProcVmstat
PAGE_SIZE = `getconf PAGESIZE`.to_i rescue 4096
def load_hash(file)
hash = Hash.new
File.open(file).each_line do |line|
key, val = line.split
hash["#{key}"] = val.to_i if val != nil
end
hash
end
def vmstat
@vmstat ||= load_hash("/proc/vmstat")
end
def numa_vmstat
@numa_vmstat || load_numa_vmstat
end
def load_numa_vmstat
@numa_vmstat = Array.new
Dir.glob("/sys/devices/system/node/node*/vmstat") do |file|
nid = file[29..-1].to_i
@numa_vmstat[nid] = load_hash(file)
end
@numa_vmstat
end
end