File tree Expand file tree Collapse file tree
system/vm_stats/python_modules Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -98,8 +98,14 @@ def get_delta(name):
9898def get_vmeff (name ):
9999 # get metrics
100100 [curr_metrics , last_metrics ] = get_metrics ()
101+
101102 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+ pgscan_diff = float (curr_metrics ['data' ]['pgscan_kswapd_normal' ]) - float (last_metrics ['data' ]['pgscan_kswapd_normal' ])
104+ # To avoid division by 0 errors check whether pgscan is 0
105+ if pgscan_diff == 0 :
106+ return 0.0
107+
108+ delta = 100 * (float (curr_metrics ['data' ]['pgsteal_normal' ]) - float (last_metrics ['data' ]['pgsteal_normal' ])) / pgscan_diff
103109 if delta < 0 :
104110 print name + " is less 0"
105111 delta = 0
@@ -108,7 +114,6 @@ def get_vmeff(name):
108114
109115 return delta
110116
111-
112117
113118def create_desc (skel , prop ):
114119 d = skel .copy ()
You can’t perform that action at this time.
0 commit comments