def post_processing(self, axol_task_value): clusters = {'api': [], 'web': []} clusters = CommonMath.derive_clusters(clusters=clusters, map_value='current_usage', axol_task_value=axol_task_value) for cluster in clusters: clusters[cluster] = CommonMath.map_deviation( integer_list=clusters[cluster]) clusters[cluster]['source'] = self.source clusters[cluster]['name'] = cluster self.query([ insert(data_object=clusters, table_space='axol_metrics.clusters') ]) return axol_task_value
def calculate_new_fields(self, response_object): def calculate_current_usage(response_object): disk_list = [] for attr in response_object.__dict__: if re.search(r'disk.*', attr): usage = getattr(response_object, attr) disk_list.append(int(usage['percent_used'])) response_object.current_usage = float(max(disk_list)) return response_object def calculate_usage_for_health(response_object): response_object.normalized_indicator = response_object.current_usage / 100 response_object.multiplier = 1 response_object.threshold_red = 80 response_object.scale = 50 return response_object if response_object.error == None: response_object = calculate_current_usage( response_object=response_object ) response_object = calculate_usage_for_health( response_object=response_object ) response_object.health_indicator = CommonMath.adaptive_filtration( normalized_indicator=response_object.normalized_indicator, multiplier=response_object.multiplier, threshold_red=response_object.threshold_red, scale=response_object.scale ) self.threshold_validation(response_object) return response_object
def calculate_new_fields(self, response_object): def calculate_current_usage(response_object): n = float(response_object.one_minute) * 100 n = float(n) / float(response_object.number_of_processing_units) if n == 0: n = 1 response_object.current_usage = n return response_object def calculate_usage_for_health(response_object): x = (2 * float(response_object.one_minute) + 3 * float(response_object.five_minute)) / 5 response_object.normalized_indicator = x response_object.multiplier = response_object.number_of_processing_units response_object.threshold_red = 100 response_object.scale = 0 return response_object if response_object.error == None: response_object = calculate_usage_for_health( response_object=response_object) response_object = calculate_current_usage( response_object=response_object) response_object.health_indicator = CommonMath.adaptive_filtration( normalized_indicator=response_object.normalized_indicator, multiplier=response_object.multiplier, threshold_red=response_object.threshold_red, scale=response_object.scale) response_object = self.threshold_validation(response_object) return response_object
def run_task(self, task): print 'RUN TASK 1 ##############' print task for server in task.value: for _type in self.sources: key = '%s_%s' % (_type, str(server)) try: cache_data = DW.cache_key_get(key) if type(eval(str(cache_data))) is dict: try: task.value[server][_type] = GenericDataObject(eval(str(cache_data))) if task.value[server][_type].warnings[server] != None: print 'RED FLAG: %s %s' % (server, _type) print task.value[server][_type].warnings else: task.value[server][_type].health_indicator = CommonMath.adaptive_filtration( task.value[server][_type].normalized_indicator, task.value[server][_type].multiplier, task.value[server][_type].threshold_red, task.value[server][_type].scale ) except Exception, e: print 'ERROR 1: %s' % e except Exception, e: CommonLogger.log(e, 'create_health_metrics', 'run_task-<%s-%s>' % (server, _type)) print 'ERROR 2: %s' % e return jsonify({'response': {'error': str(e)}})
def run_task(self, task): print 'RUN TASK 1 ##############' print task for server in task.value: for _type in self.sources: key = '%s_%s' % (_type, str(server)) try: cache_data = DW.cache_key_get(key) if type(eval(str(cache_data))) is dict: try: task.value[server][_type] = GenericDataObject( eval(str(cache_data))) if task.value[server][_type].warnings[ server] != None: print 'RED FLAG: %s %s' % (server, _type) print task.value[server][_type].warnings else: task.value[server][ _type].health_indicator = CommonMath.adaptive_filtration( task.value[server] [_type].normalized_indicator, task.value[server][_type].multiplier, task.value[server] [_type].threshold_red, task.value[server][_type].scale) except Exception, e: print 'ERROR 1: %s' % e except Exception, e: CommonLogger.log(e, 'create_health_metrics', 'run_task-<%s-%s>' % (server, _type)) print 'ERROR 2: %s' % e return jsonify({'response': {'error': str(e)}})
def calculate_new_fields(self, response_object): def calculate_current_usage(response_object): disk_list = [] for attr in response_object.__dict__: if re.search(r'disk.*', attr): usage = getattr(response_object, attr) disk_list.append(int(usage['percent_used'])) response_object.current_usage = float(max(disk_list)) return response_object def calculate_usage_for_health(response_object): response_object.normalized_indicator = response_object.current_usage / 100 response_object.multiplier = 1 response_object.threshold_red = 80 response_object.scale = 50 return response_object if response_object.error == None: response_object = calculate_current_usage( response_object=response_object) response_object = calculate_usage_for_health( response_object=response_object) response_object.health_indicator = CommonMath.adaptive_filtration( normalized_indicator=response_object.normalized_indicator, multiplier=response_object.multiplier, threshold_red=response_object.threshold_red, scale=response_object.scale) self.threshold_validation(response_object) return response_object
def calculate_new_fields(self, response_object): def calculate_current_usage(response_object): n = float(response_object.memused) / 1000 n = int(n) + 0 response_object.current_usage = n return response_object def calculate_usage_for_health(response_object): response_object.normalized_indicator = ( float(response_object.memused) / float(response_object.memtotal) ) / 1 + 0 response_object.multiplier = 1 response_object.threshold_red = 90 response_object.scale = response_object.memtotal / 200000 return response_object if response_object.error == None: response_object = calculate_usage_for_health( response_object=response_object ) response_object = calculate_current_usage( response_object=response_object ) response_object.health_indicator = CommonMath.adaptive_filtration( normalized_indicator=response_object.normalized_indicator, multiplier=response_object.multiplier, threshold_red=response_object.threshold_red, scale=response_object.scale ) self.threshold_validation(response_object) return response_object
def fudge_data(time_list_2): deviation_pos_list = [] deviation_neg_list = [] variance_list = [] mean_list = [] time_list = [] int_list = [] deviation_amount = [] n = 0 init_data_list = [ 1675, 3223, 2017, 1501, 2067, 2500, 1000, 2972, 1975, 2104, 2100, 2973, 1980 ] deviation = CommonMath.map_deviation(init_data_list) deviation_amount = [0 for i in range(len(init_data_list))] mean_list = init_data_list int_list = range(len(init_data_list)) time_list = time_list_2[:len(init_data_list)] time_list_2 = time_list_2[:len(init_data_list)] variance_list = [0 for i in range(len(init_data_list))] deviation_neg_list = [0 for i in range(len(init_data_list))] deviation_pos_list = [0 for i in range(len(init_data_list))] return deviation_amount, mean_list, int_list, time_list, time_list_2, variance_list, deviation_neg_list, deviation_pos_list
def post_processing(self, axol_task_value): clusters = {'api': [], 'web': []} try: clusters = CommonMath.derive_clusters( clusters=clusters, map_value='current_usage', axol_task_value=axol_task_value ) except Exception, e: print 'ERROR POST-PROC: %s' % e
def post_processing(self, axol_task_value): clusters = {'api': [], 'web': []} clusters = CommonMath.derive_clusters( clusters=clusters, map_value='current_usage', axol_task_value=axol_task_value ) for cluster in clusters: clusters[cluster] = CommonMath.map_deviation( integer_list=clusters[cluster] ) clusters[cluster]['source'] = self.source clusters[cluster]['name'] = cluster self.query([ insert( data_object=clusters, table_space='axol_metrics.clusters' )] ) return axol_task_value
return response_object def post_processing(self, axol_task_value): clusters = {'api': [], 'web': []} try: clusters = CommonMath.derive_clusters( clusters=clusters, map_value='current_usage', axol_task_value=axol_task_value ) except Exception, e: print 'ERROR POST-PROC: %s' % e try: for cluster in clusters: clusters[cluster] = CommonMath.map_deviation( integer_list=clusters[cluster] ) clusters[cluster]['source'] = self.source clusters[cluster]['name'] = cluster except Exception, e: print 'ERROR POST-PROC 2: %s' % e try: self.query([ insert( data_object=clusters, table_space='axol_metrics.clusters' )] ) except Exception, e: print 'ERROR POST-PROC 3: %s' % e return axol_task_value