<s> import stats_buffer <EOL> import util_cli as util <EOL> class AvgDiskQueue : <EOL> def run ( self , accessor ) : <EOL> result = { } <EOL> for bucket , stats_info in stats_buffer . buckets . iteritems ( ) : <EOL> disk_queue_avg_error = [ ] <EOL> disk_queue_avg_warn = [ ] <EOL> values = stats_info [ accessor [ "<STR_LIT>" ] ] [ accessor [ "<STR_LIT>" ] ] <EOL> nodeStats = values [ "<STR_LIT>" ] <EOL> samplesCount = values [ "<STR_LIT>" ] <EOL> for node , vals in nodeStats . iteritems ( ) : <EOL> avg = sum ( vals ) / samplesCount <EOL> if avg > accessor [ "<STR_LIT>" ] [ "<STR_LIT>" ] : <EOL> disk_queue_avg_error . append ( { "<STR_LIT>" : node , "<STR_LIT>" : "<STR_LIT>" , "<STR_LIT:value>" : avg } ) <EOL> elif avg > accessor [ "<STR_LIT>" ] [ "<STR_LIT>" ] : <EOL> disk_queue_avg_warn . append ( { "<STR_LIT>" : node , "<STR_LIT>" : "<STR_LIT>" , "<STR_LIT:value>" : avg } ) <EOL> if len ( disk_queue_avg_error ) > <NUM_LIT:0> : <EOL> result [ bucket ] = { "<STR_LIT:error>" : disk_queue_avg_error } <EOL> if len ( disk_queue_avg_warn ) > <NUM_LIT:0> : <EOL> result [ bucket ] = { "<STR_LIT>" : disk_queue_avg_warn } <EOL> return result <EOL> class DiskQueueTrend : <EOL> def run ( self , accessor ) : <EOL> result = { } <EOL> for bucket , stats_info in stats_buffer . buckets . iteritems ( ) : <EOL> trend_error = [ ] <EOL> trend_warn = [ ] <EOL> values = stats_info [ accessor [ "<STR_LIT>" ] ] [ accessor [ "<STR_LIT>" ] ] <EOL> timestamps = values [ "<STR_LIT>" ] <EOL> timestamps = [ x - timestamps [ <NUM_LIT:0> ] for x in timestamps ] <EOL> nodeStats = values [ "<STR_LIT>" ] <EOL> samplesCount = values [ "<STR_LIT>" ] <EOL> for node , vals in nodeStats . iteritems ( ) : <EOL> a , b = util . linreg ( timestamps , vals ) <EOL> if a > accessor [ "<STR_LIT>" ] [ "<STR_LIT>" ] : <EOL> trend_error . append ( { "<STR_LIT>" : node , "<STR_LIT>" : "<STR_LIT>" , "<STR_LIT:value>" : a } ) <EOL> elif a > accessor [ "<STR_LIT>" ] [ "<STR_LIT>" ] : <EOL> trend_warn . append ( { "<STR_LIT>" : node , "<STR_LIT>" : "<STR_LIT>" , "<STR_LIT:value>" : a } ) <EOL> if len ( trend_error ) > <NUM_LIT:0> : <EOL> result [ bucket ] = { "<STR_LIT:error>" : trend_error } <EOL> if len ( trend_warn ) > <NUM_LIT:0> : <EOL> result [ bucket ] = { "<STR_LIT>" : trend_warn } <EOL> return result <EOL> class TapQueueTrend : <EOL> def run ( self , accessor ) : <EOL> result = { } <EOL> for bucket , stats_info in stats_buffer . buckets . iteritems ( ) : <EOL> trend_error = [ ] <EOL> trend_warn = [ ] <EOL> values = stats_info [ accessor [ "<STR_LIT>" ] ] [ accessor [ "<STR_LIT>" ] ] <EOL> timestamps = values [ "<STR_LIT>" ] <EOL> timestamps = [ x - timestamps [ <NUM_LIT:0> ] for x in timestamps ] <EOL> nodeStats = values [ "<STR_LIT>" ] <EOL> samplesCount = values [ "<STR_LIT>" ] <EOL> for node , vals in nodeStats . iteritems ( ) : <EOL> a , b = util . linreg ( timestamps , vals ) <EOL> if a > accessor [ "<STR_LIT>" ] [ "<STR_LIT>" ] : <EOL> trend_error . append ( { "<STR_LIT>" : node , "<STR_LIT>" : "<STR_LIT>" , "<STR_LIT:value>" : a } ) <EOL> elif a > accessor [ "<STR_LIT>" ] [ "<STR_LIT>" ] : <EOL> trend_warn . append ( { "<STR_LIT>" : node , "<STR_LIT>" : "<STR_LIT>" , "<STR_LIT:value>" : a } ) <EOL> if len ( trend_error ) > <NUM_LIT:0> : <EOL> result [ bucket ] = { "<STR_LIT:error>" : trend_error } <EOL> if len ( trend_warn ) > <NUM_LIT:0> : <EOL> result [ bucket ] = { "<STR_LIT>" : trend_warn } <EOL> return result <EOL> class DiskQueueDrainingRate : <EOL> def run ( self , accessor ) : <EOL> result = { } <EOL> for bucket , stats_info in stats_buffer . buckets . iteritems ( ) : <EOL> disk_queue_avg_error = [ ] <EOL> disk_queue_avg_warn = [ ] <EOL> drain_values = stats_info [ accessor [ "<STR_LIT>" ] ] [ accessor [ "<STR_LIT>" ] [ <NUM_LIT:0> ] ] <EOL> len_values = stats_info [ accessor [ "<STR_LIT>" ] ] [ accessor [ "<STR_LIT>" ] [ <NUM_LIT:1> ] ] <EOL> nodeStats = drain_values [ "<STR_LIT>" ] <EOL> samplesCount = drain_values [ "<STR_LIT>" ] <EOL> for node , vals in nodeStats . iteritems ( ) : <EOL> avg = sum ( vals ) / samplesCount <EOL> disk_len_vals = len_values [ "<STR_LIT>" ] [ node ] <EOL> len_avg = sum ( disk_len_vals ) / samplesCount <EOL> if avg < accessor [ "<STR_LIT>" ] [ "<STR_LIT>" ] and len_avg > accessor [ "<STR_LIT>" ] [ "<STR_LIT>" ] : <EOL> disk_queue_avg_error . append ( { "<STR_LIT>" : node , "<STR_LIT>" : "<STR_LIT>" , "<STR_LIT:value>" : avg } ) <EOL> if len ( disk_queue_avg_error ) > <NUM_LIT:0> : <EOL> result [ bucket ] = { "<STR_LIT:error>" : disk_queue_avg_error } <EOL> return result <EOL> DiskQueueCapsule = [ <EOL> { "<STR_LIT:name>" : "<STR_LIT>" , <EOL> "<STR_LIT:description>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : [ <EOL> { <EOL> "<STR_LIT:name>" : "<STR_LIT>" , <EOL> "<STR_LIT:description>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : True , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT:code>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : { <EOL> "<STR_LIT>" : <NUM_LIT> , <EOL> "<STR_LIT>" : <NUM_LIT> <EOL> } , <EOL> } , <EOL> { <EOL> "<STR_LIT:name>" : "<STR_LIT>" , <EOL> "<STR_LIT:description>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : True , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT:code>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : { <EOL> "<STR_LIT>" : <NUM_LIT:0> , <EOL> "<STR_LIT>" : <NUM_LIT> <EOL> } , <EOL> } , <EOL> ] , <EOL> "<STR_LIT>" : True , <EOL> } , <EOL> { "<STR_LIT:name>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : [ <EOL> { <EOL> "<STR_LIT:name>" : "<STR_LIT>" , <EOL> "<STR_LIT:description>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : True , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT:code>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : { <EOL> "<STR_LIT>" : <NUM_LIT:0> , <EOL> "<STR_LIT>" : <NUM_LIT> <EOL> } , <EOL> } <EOL> ] , <EOL> "<STR_LIT>" : True , <EOL> } , <EOL> { "<STR_LIT:name>" : "<STR_LIT>" , <EOL> "<STR_LIT:description>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : [ <EOL> { <EOL> "<STR_LIT:name>" : "<STR_LIT>" , <EOL> "<STR_LIT:description>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : [ "<STR_LIT>" , "<STR_LIT>" ] , <EOL> "<STR_LIT>" : True , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT:code>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : { <EOL> "<STR_LIT>" : <NUM_LIT:0> , <EOL> "<STR_LIT>" : <NUM_LIT> , <EOL> } , <EOL> } , <EOL> { <EOL> "<STR_LIT:name>" : "<STR_LIT>" , <EOL> "<STR_LIT:description>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : [ "<STR_LIT>" , "<STR_LIT>" ] , <EOL> "<STR_LIT>" : True , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT:code>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : { <EOL> "<STR_LIT>" : <NUM_LIT:0> , <EOL> "<STR_LIT>" : <NUM_LIT> , <EOL> } , <EOL> } , <EOL> ] , <EOL> "<STR_LIT>" : True , <EOL> } , <EOL> ] </s>
