src/unifi_api/api.py
def _gateway_stats(self, gran, def_range, attrs=['mem', 'cpu', 'loadavg_5'], start=None, end=None, site='default'):
        '''
            Get gateway stats
            -------------------------
            returns an array of stats for the given ap or for all aps on a given site
            params:
                Name        | required  | description
                -----------------------------------------
                gran        |   True    | granularity of the stats, only permitted: 5minutes, hourly, daily
                def_range   |   True    | default range for the stats, only used if start wasn't given
                attrs       |   False   | list of attributes to be returned, defalts to [mem, cpu, loadavg_5]
                start       |   False   | Unix timestamp in seconds or datetime, defaults to end - 12h
                end         |   False   | Unix timestamp in seconds or datetime, defaults to now
                site        |   False   | site where the USG is located

            # support and restrictions apply from 'gateway_stat_*' functions
        '''
        end = end*1000 if isinstance(end, int) else int(datetime.now().timestamp()*1000) if end is None else int(end.timestamp()*1000)
        start = start*1000 if isinstance(start, int) else end - def_range if start is None else int(start.timestamp()*1000)
        assert 0 < start < end, 'start must be before end (and both positive)'

        data = {
            'attrs': attrs if 'time' in attrs else attrs.append('time'),
            'start': start,
            'end': end,
        }

        r = self.get(self.endpoint('/api/s/%s/stat/report/%s.gw' % (site, gran)), json=data)
        return self.process_response(r)

            Get gateway stats
            -------------------------
            returns an array of stats for the given ap or for all aps on a given site
            params:
                Name        | required  | description
                -----------------------------------------
                gran        |   True    | granularity of the stats, only permitted: 5minutes, hourly, daily
                def_range   |   True    | default range for the stats, only used if start wasn't given
                attrs       |   False   | list of attributes to be returned, defalts to [mem, cpu, loadavg_5]
                start       |   False   | Unix timestamp in seconds or datetime, defaults to end - 12h
                end         |   False   | Unix timestamp in seconds or datetime, defaults to now
                site        |   False   | site where the USG is located

            # support and restrictions apply from 'gateway_stat_*' functions
        
Get gateway stats
returns an array of stats for the given ap or for all aps on a given site
params:
Name        | required  | description



support and restrictions apply from 'gateway_stat_*' functions
Get gateway stats returns an array of stats for the given ap or for all aps on a given site params : Name | required | description support and restrictions apply from ' gateway_stat_ * ' functions
def _gateway_stats(self, gran, def_range, attrs=['mem', 'cpu', 'loadavg_5'], start=None, end=None, site='default'):
        end = end*1000 if isinstance(end, int) else int(datetime.now().timestamp()*1000) if end is None else int(end.timestamp()*1000)
        start = start*1000 if isinstance(start, int) else end - def_range if start is None else int(start.timestamp()*1000)
        assert 0 < start < end, 'start must be before end (and both positive)'
        data = {
            'attrs': attrs if 'time' in attrs else attrs.append('time'),
            'start': start,
            'end': end,
        }
        r = self.get(self.endpoint('/api/s/%s/stat/report/%s.gw' % (site, gran)), json=data)
        return self.process_response(r)
def _gateway_stats ( self , gran , def_range , attrs = [ 'mem' , 'cpu' , 'loadavg_5' ] , start = None , end = None , site = 'default' ) : end = end * 1000 if isinstance ( end , int ) else int ( datetime . now ( ) . timestamp ( ) * 1000 ) if end is None else int ( end . timestamp ( ) * 1000 ) start = start * 1000 if isinstance ( start , int ) else end - def_range if start is None else int ( start . timestamp ( ) * 1000 ) assert 0 < start < end , 'start must be before end (and both positive)' data = { 'attrs' : attrs if 'time' in attrs else attrs . append ( 'time' ) , 'start' : start , 'end' : end , } r = self . get ( self . endpoint ( '/api/s/%s/stat/report/%s.gw' % ( site , gran ) ) , json = data ) return self . process_response ( r )
Get gateway stats
returns an array of stats for the given ap or for all aps on a given site
params:
Name        | required  | description
Get gateway stats returns an array of stats for the given ap or for all aps on a given site params : Name | required | description
'''
            Get gateway stats
            -------------------------
            returns an array of stats for the given ap or for all aps on a given site
            params:
                Name        | required  | description
                -----------------------------------------
                gran        |   True    | granularity of the stats, only permitted: 5minutes, hourly, daily
                def_range   |   True    | default range for the stats, only used if start wasn't given
                attrs       |   False   | list of attributes to be returned, defalts to [mem, cpu, loadavg_5]
                start       |   False   | Unix timestamp in seconds or datetime, defaults to end - 12h
                end         |   False   | Unix timestamp in seconds or datetime, defaults to now
                site        |   False   | site where the USG is located

            # support and restrictions apply from 'gateway_stat_*' functions
        '''
self
gran
def_range
attrs
start
end
site