def get_group_history(self, groupID): db = Database(self.filePath) history = db.get_data("select SUM(clients), timestamp from wlc_ap_clients where ap_key in (select ap_key from wlc_ap_group_binding where group_id=?) group by timestamp order by timestamp asc",(groupID,)) data = [] for x in xrange(0,len(history)): node = {} node['val'] = history[x][0] time_struct = time.gmtime(history[x][1]) node['timestamp'] = time.strftime('%Y-%m-%d %H:%M:%S', time_struct) data.append(node) return data
def get_ap_history(self, apID): db = Database(self.filePath) history = db.get_data("select clients, timestamp from wlc_ap_clients where ap_key=? order by timestamp asc",(apID,)) data = [] for x in xrange(0,len(history)): node = {} node['val'] = history[x][0] time_struct = time.gmtime(history[x][1]) node['timestamp'] = time.strftime('%Y-%m-%d %H:%M:%S', time_struct) data.append(node) return data
def get_ap_history_span(self, apID, start, stop): db = Database(self.filePath) start = calendar.timegm(time.strptime(start,"%Y-%m-%d %H:%M:%S")) stop = calendar.timegm(time.strptime(stop,"%Y-%m-%d %H:%M:%S")) history = db.get_data("select clients, timestamp from wlc_ap_clients where ap_key =? AND (timestamp >= ? AND timestamp <= ?) order by timestamp asc",(apID,start,stop,)) data = [] for x in xrange(0,len(history)): node = {} node['val'] = history[x][0] time_struct = time.gmtime(history[x][1]) node['timestamp'] = time.strftime('%Y-%m-%d %H:%M:%S', time_struct) data.append(node) return data
def get_groups(self): db = Database(self.filePath) data = [] groups = db.get_data_raw("SELECT * FROM wlc_ap_groups") for group in groups: node = {} node['id'] = group[0] node['name'] = group[1] node['lat'] = group[2] node['lng'] = group[3] node['aps'] = [] node['cnt'] = 0 bindings = db.get_data("SELECT * FROM wlc_ap_group_binding WHERE group_id=?",(node['id'],)) for binding in bindings: apNode = {} apNode['key'] = binding[2] adDetails = db.get_data("SELECT * FROM wlc_aps WHERE ap_key=?",(apNode['key'],)) apNode["name"] = adDetails[0][1] node['aps'].append(apNode) node['cnt'] += int(db.get_data_single("SELECT clients from wlc_ap_clients WHERE ap_key=? ORDER BY timestamp DESC",(str(apNode['key']),))) data.append(node) data = sorted(data, key=lambda k: k['cnt'], reverse = True) return data
def get_group_details(self, groupID): db = Database(self.filePath) data = db.get_data("SELECT * FROM wlc_ap_groups WHERE id=?",(groupID,)) return data
def get_ap_details(self, apID): db = Database(self.filePath) data = db.get_data("SELECT * FROM wlc_aps WHERE ap_key=?",(apID,)) return data