Skip to content

Commit 99328cd

Browse files
committed
Add VM efficiency
1 parent ad02414 commit 99328cd

1 file changed

Lines changed: 28 additions & 0 deletions

File tree

system/vm_stats/python_modules/vm_stats.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,27 @@ def get_delta(name):
8989
return delta
9090

9191

92+
# Calculate VM efficiency
93+
# Works similar like sar -B 1
94+
# Calculated as pgsteal / pgscan, this is a metric of the efficiency of page reclaim. If it is near 100% then
95+
# almost every page coming off the tail of the inactive list is being reaped. If it gets too low (e.g. less than 30%)
96+
# then the virtual memory is having some difficulty. This field is displayed as zero if no pages have been
97+
# scanned during the interval of time
98+
def get_vmeff(name):
99+
# get metrics
100+
[curr_metrics, last_metrics] = get_metrics()
101+
try:
102+
delta = 100 * (float(curr_metrics['data']['pgsteal_normal']) - float(last_metrics['data']['pgsteal_normal'])) /(float(curr_metrics['data']['pgscan_kswapd_normal']) - float(last_metrics['data']['pgscan_kswapd_normal']))
103+
if delta < 0:
104+
print name + " is less 0"
105+
delta = 0
106+
except KeyError:
107+
delta = 0.0
108+
109+
return delta
110+
111+
112+
92113
def create_desc(skel, prop):
93114
d = skel.copy()
94115
for k,v in prop.iteritems():
@@ -670,6 +691,13 @@ def metric_init(params):
670691
"description": "compact_success",
671692
}))
672693

694+
descriptors.append(create_desc(Desc_Skel, {
695+
"name" : NAME_PREFIX + "vmeff",
696+
"description": "VM efficiency",
697+
'call_back' : get_vmeff,
698+
'units' : 'pct',
699+
}))
700+
673701
return descriptors
674702

675703
def metric_cleanup():

0 commit comments

Comments
 (0)