def GetSessionCount(self): """ get number of client sessions """ allsc = base.GetSessions() sc = len(filter(lambda x: x.userid is not None and hasattr(x, 'clientID'), allsc)) return sc
def OnObjectPublicAttributesUpdated(self, uuid, pa, args, keywords): for sess in base.GetSessions(): try: if sess.machoObjectConnectionsByObjectID.get(uuid, 0): for conn in sess.machoObjectConnectionsByObjectID[uuid][1].itervalues(): k = keywords.get('partial', []) if k: old = {} for each in k: old[each] = conn.__publicattributes__[each] conn.__publicattributes__[each] = pa[each] else: old = conn.__publicattributes__ conn.__publicattributes__ = pa for each in conn.objectChangeHandlers.iterkeys(): try: func = getattr(each, 'OnObjectChanged') except StandardError: log.LogException() sys.exc_clear() continue theArgs = [conn, old, conn.__publicattributes__] + list(args) uthread.worker('machoNet::OnObjectChanged', func, *theArgs, **keywords) except Exception: log.LogException('Exception during OnObjectPublicAttributesUpdated') sys.exc_clear()
def GetOptions(self): """ This fucntion will return the options for the console web page. This produces a list of all the Solnodes, proxys, and conected sessions. """ ret = OrderedDict() if boot.role == 'server': ret.update({ 'all': 'All Proxy and Sol Servers', 'remote': 'Any Proxy', 'local': 'Locally', 'proxies': 'All Proxies', 'servers': 'All Sol Servers' }) for nodeID in sm.services['machoNet'].GetConnectedProxyNodes(): transport = sm.services['machoNet'].GetTransportOfNode(nodeID) ret[nodeID] = 'Proxy %d (%s)' % (nodeID, transport.transport.address) for nodeID in sm.services['machoNet'].GetConnectedSolNodes(): transport = sm.services['machoNet'].GetTransportOfNode(nodeID) ret[nodeID] = 'Sol %d (%s)' % (nodeID, transport.transport.address) else: ret.update({ 'all': 'All Proxy and Sol Servers', 'remote': 'Any Proxy', 'local': 'Locally', 'proxies': 'All Proxies', 'servers': 'All Sol Servers' }) for nodeID in sm.services['machoNet'].GetConnectedProxyNodes(): transport = sm.services['machoNet'].GetTransportOfNode(nodeID) ret[nodeID] = 'Proxy %d (%s)' % (nodeID, transport.transport.address) for nodeID in sm.services['machoNet'].GetConnectedSolNodes(): transport = sm.services['machoNet'].GetTransportOfNode(nodeID) ret[nodeID] = 'Sol %d (%s)' % (nodeID, transport.transport.address) for s in base.GetSessions(): clientID = getattr(s, 'clientID', None) if clientID and clientID / 10000000000L: charID = getattr(s, 'charid', None) userID = getattr(s, 'userid', None) if charID: ret[-clientID] = self.GetClientDisplayString( clientID, charID) elif userID: ret[-clientID] = 'Client #%d (user #%d)' % (clientID, userID) else: ret[-clientID] = 'Client #%d' % clientID return ret
def evePostStacktraceCallback(out): """ At the end of a StackTraceAll we will dump out the sessions""" try: import log import base from service import ROLE_SERVICE import util sessions = [] for sess in base.GetSessions(): if getattr(sess, 'userid') and not sess.role & ROLE_SERVICE: sessions.append(sess) if sessions: out.write('\nActive client sessions:\n\n') out.write( '------------------------------------------------------------------------------------------------------\n' ) out.write( '| userid | role | charid | shipid | locationid | last remote call | address |\n' ) out.write( '------------------------------------------------------------------------------------------------------\n' ) for sess in sessions: fmt = '| %6s | %10s | %10s | %10s | %10s | %19s | %15s |\n' try: out.write( fmt % (sess.userid, sess.role, sess.charid, sess.shipid, sess.locationid, util.FmtDate(sess.lastRemoteCall, 'll') if sess.lastRemoteCall is not None else 'No info on last call', sess.address.split(':')[0] if sess.address is not None else 'No address')) except: out.write('!error writing out session %s\n' % str(sess)) log.LogException() out.write( '------------------------------------------------------------------------------------------------------\n' ) out.write('%s sessions total.\n' % len(sessions)) else: out.write('There were no active client sessions.\n') except: log.LogException()