Skip to content

Instantly share code, notes, and snippets.

Last active February 4, 2018 06:57
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save avivl/4a67cf3db820eda5b76981874df50a22 to your computer and use it in GitHub Desktop.
def calc_slope(self, minuets):
Calculate the slope of available memory change.
:param: minuets how long to go back in time
met = metrics.Metrics(self.cluster_name)
series = met.read_timeseries('YARNMemoryAvailablePercentage', minuets)
retlist = []
x = []
y = []
i = len(retlist)
for rl in retlist:
x.insert(0, rl['value']['doubleValue'])
y.insert(0, i)
i = i - 1
slope, intercept = np.polyfit(x, y, 1)
logging.debug('Slope is %s', slope)
except np.RankWarning:
# not enough data so add remove by 2
if self.scaling_direction == 'up':
slope = 1
slope = -1
logging.debug('No Data slope is %s', slope)
return slope
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment