query.py
def query_last_mean(self, indicator, host, timeframe='10m', filters=None):
        """Get the last mean value of the indicator"""
        if filters is not None:
            filters_str = ' AND '
            for k, v in filters.items():
                filters_str += "%s = '%s'" % (k, v)
            filters_str += ' '
        else:
            filters_str = ''

        query = "select mean(value) from %s where host = '%s' %s \
            and time > now() - %s  group by time(%s) order by time desc limit 1;" % (
                indicator, host, filters_str, timeframe, timeframe
            )
        result = self.client.query(query)

        try:
            return next(result[indicator])['mean']
        except StopIteration:
            click.secho('No value found for indicator %s at host %s' % (indicator, host), fg='red')
Get the last mean value of the indicator
Get the last mean value of the indicator
Get the last mean value of the indicator
def query_last_mean(self, indicator, host, timeframe='10m', filters=None):
        if filters is not None:
            filters_str = ' AND '
            for k, v in filters.items():
                filters_str += "%s = '%s'" % (k, v)
            filters_str += ' '
        else:
            filters_str = ''
        query = "select mean(value) from %s where host = '%s' %s \
            and time > now() - %s  group by time(%s) order by time desc limit 1;" % (
                indicator, host, filters_str, timeframe, timeframe
            )
        result = self.client.query(query)
        try:
            return next(result[indicator])['mean']
        except StopIteration:
            click.secho('No value found for indicator %s at host %s' % (indicator, host), fg='red')
def query_last_mean ( self , indicator , host , timeframe = '10m' , filters = None ) : if filters is not None : filters_str = ' AND ' for k , v in filters . items ( ) : filters_str += "%s = '%s'" % ( k , v ) filters_str += ' ' else : filters_str = '' query = "select mean(value) from %s where host = '%s' %s \
            and time > now() - %s  group by time(%s) order by time desc limit 1;" % ( indicator , host , filters_str , timeframe , timeframe ) result = self . client . query ( query ) try : return next ( result [ indicator ] ) [ 'mean' ] except StopIteration : click . secho ( 'No value found for indicator %s at host %s' % ( indicator , host ) , fg = 'red' )
Get the last mean value of the indicator
Get the last mean value of the indicator
"""Get the last mean value of the indicator"""
self
indicator
host
timeframe
filters