objects.logic.process.extXportTableDict.extXportTableDict.extXportTableDict.__xportImpl Class Reference

Actual implementation class for extXportTableDict. More...

List of all members.

Public Member Functions

def __init__
def getXportTableInfo
 Returns the process Dictionary associated with the supplied source port.
def updateAllDicts
 Takes a snapshot of the current TCP table, and updates all internal dictionaries.
def getEnrichedProcessDict
 Returns a dictionary containing all distinct process names (lower case) and whether they are currently running or not.

Public Attributes

 lck
 activeTCPDict
 globalTCPDict
 procNameDict


Detailed Description

Actual implementation class for extXportTableDict.

This needs to be alive for the duration of the application for a number of reasons. For starters this class (or its single instance) will keep running Dictionaries of all processes (past or present) on the system, as well as information pertaining to them. For additonal information, see the included extendedTCPTableLib C/SWIG wrapper module

Definition at line 58 of file extXportTableDict.py.


Member Function Documentation

def objects.logic.process.extXportTableDict.extXportTableDict.extXportTableDict.__xportImpl.__init__ (   self  ) 

Definition at line 60 of file extXportTableDict.py.

00060                           :
00061             self.lck = RLock()
00062             
00063             # dictionary of all active connections 
00064             # (i.e. anything contained in the current TCP Table) 
00065             #
00066             # {SourcePort: {processDict}}
00067             self.activeTCPDict = dict()
00068             
00069             # dictionary of all connections, active or inactive.
00070             # this dictionary will continually grow during the 
00071             # application lifetime
00072             #
00073             # {SourcePort: {processDict}}
00074             self.globalTCPDict = dict()
00075             
00076             # simple dictionary of all distinct process names
00077             # {procName: 1}
00078             self.procNameDict  = dict()
00079             
00080         
00081         
        ## Returns the process Dictionary associated with the supplied source port

def objects.logic.process.extXportTableDict.extXportTableDict.extXportTableDict.__xportImpl.getEnrichedProcessDict (   self  ) 

Returns a dictionary containing all distinct process names (lower case) and whether they are currently running or not.

Definition at line 177 of file extXportTableDict.py.

00177                                         :
00178             
00179             self.lck.acquire(1)
00180             
00181             try:                
00182                 # this dictionary is only used to avoid duplicates
00183                 procDict = dict()
00184                 
00185                 #get latest extended TCP table.
00186                 ExtendedXportTable.updateV4Tables()
00187                 tableSize = ExtendedXportTable.getV4TableSize()
00188                 
00189                 # get a snapshot of current processes.
00190                 for i in range(0, tableSize):
00191                     procName = ExtendedXportTable.getV4ProcessName(i)
00192                     if procName != "UNKNOWN" and procName != "unknown":
00193                         procDict[procName.lower()] = "Yes"
00194                         
00195                 # now add all processes which were currently accrued
00196                 for key, val in self.procNameDict.iteritems():
00197                     if not procDict.has_key(key.lower()):
00198                         if key != "UNKNOWN" and key != "unknown":
00199                             procDict[key.lower()] = "No"
00200                 
00201                 return procDict
00202                 
00203                         
00204                 
00205             except Exception, err:
00206                 
00207                 logger.log(__name__ + "There was error populating TCP Table Dictionaries")
00208                 logger.log(__name__ + str(err))
00209                 
00210                 raise Exception, err
00211                 
00212             finally:
00213                 self.lck.release()
00214                 
00215         """
            Various helped Functions

def objects.logic.process.extXportTableDict.extXportTableDict.extXportTableDict.__xportImpl.getXportTableInfo (   self,
  srcPort 
)

Returns the process Dictionary associated with the supplied source port.

Parameters:
srcPort Integer
Returns:
Dictionary

Definition at line 85 of file extXportTableDict.py.

00085                                             :
00086     
00087             nodeInfo, processState = self.__findInCache(srcPort)
00088             
00089             # look in cache first
00090             if (nodeInfo == None):            
00091                 self.updateAllDicts();
00092             else:
00093                 # if not found, load TCP and UPD table again
00094                 return nodeInfo, processState
00095             
00096             # return anything found
00097             return self.__findInCache(srcPort)
00098                 
00099             
00100         
        ## Checks the "active process dictionary" (as in latest TCP table dump) and the "global process dictionary"

def objects.logic.process.extXportTableDict.extXportTableDict.extXportTableDict.__xportImpl.updateAllDicts (   self  ) 

Takes a snapshot of the current TCP table, and updates all internal dictionaries.

Definition at line 132 of file extXportTableDict.py.

00132                                 :        
00133             # now update the various dictionaries
00134             self.lck.acquire(1)
00135             
00136             try:
00137                 #get latest extended TCP table.
00138                 ExtendedXportTable.updateV4Tables()
00139                 tableSize = ExtendedXportTable.getV4TableSize()
00140             
00141                 #clear the active TCP dictionary
00142                 self.activeTCPDict.clear()
00143                 for i in range(0, tableSize):
00144                     # get the dictionary key
00145                     srcPort = ExtendedXportTable.getV4SrcPort(i)
00146                     
00147                     key = srcPort
00148                     
00149                     # now generated its value
00150                     nodeInfo = dict()
00151                     nodeInfo["Pid"]             =  ExtendedXportTable.getV4Pid(i)
00152                     nodeInfo["ProcessName"]     =  ExtendedXportTable.getV4ProcessName(i)                
00153                     nodeInfo["SourcePort"]      =  ExtendedXportTable.getV4SrcPort(i)
00154                     nodeInfo["Transport"]       =  ExtendedXportTable.getV4Transport(i)
00155                     
00156                     self.activeTCPDict[key] = nodeInfo
00157                     self.globalTCPDict[key] = nodeInfo
00158                     
00159                     self.procNameDict[nodeInfo["ProcessName"].lower()] = 1
00160                     
00161             except Exception, err:
00162                 
00163                 logger.log(__name__ + "There was error populating TCP Table Dictionaries")
00164                 logger.log(__name__ + str(err))
00165                 
00166                 # do something here
00167             finally:
00168                 self.lck.release()
00169                 
00170         """


Member Data Documentation

objects.logic.process.extXportTableDict.extXportTableDict.extXportTableDict.__xportImpl.activeTCPDict

Definition at line 67 of file extXportTableDict.py.

objects.logic.process.extXportTableDict.extXportTableDict.extXportTableDict.__xportImpl.globalTCPDict

Definition at line 74 of file extXportTableDict.py.

objects.logic.process.extXportTableDict.extXportTableDict.extXportTableDict.__xportImpl.lck

Definition at line 61 of file extXportTableDict.py.

objects.logic.process.extXportTableDict.extXportTableDict.extXportTableDict.__xportImpl.procNameDict

Definition at line 78 of file extXportTableDict.py.


The documentation for this class was generated from the following file:

Generated on Mon Mar 30 00:26:45 2009 for EyeSpy by  doxygen 1.5.8