This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 = [] | |
retlist.extend(series[0]['points']) | |
i = len(retlist) | |
for rl in retlist: | |
x.insert(0, rl['value']['doubleValue']) | |
y.insert(0, i) | |
i = i - 1 | |
try: | |
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 | |
else: | |
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