def __init__(self, sensor_ip=G.SENSOR_MEMORY.DEFAULT_IP, sensor_port=G.SENSOR_MEMORY.DEFAULT_PORT, cache_timeout=0, name=None, use_threading=False, timeout=1, retries=5): """ Initialize our memory sensor. Just saving values at this point. @param cache_timeout: How long to keep data in the cache (seconds) @param name: Human name of the sensor @param use_threading: This will spawn a new process to read replys from the sensor. Enables much faster reads, but will eventually blow the UDP stack in the FPGA. """ # Sensor info self.sensor_ip = sensor_ip self.sensor_port = sensor_port # Socket variables self._sock = None self.TIMEOUT = timeout self.RETRIES = retries self.TIMED_OUT = False self.connect_count = 0 # Are we reading a separate process? self.use_threading = use_threading self.read_queue = None self.packet_reader = None # Cache self.cache = {} self.cache_timeouts = {} self.CACHE_TIMEOUT = cache_timeout # seconds # Keep track of our transaction self.transaction_no = 1 if name is not None: self.name = name # Bad read regions (On XPSP3x86) # Ref: http://wiki.osdev.org/Memory_Map_%28x86%29 self.BAD_MEM_REGIONS = [ (0xA0000, 0x100000), # VGA and PCI (0x7fe00000, 0x80000000), # No Clue (0xdbf00000, 0x100000000), # High Mem PCI devices (0x3ff00000, 0x40000000) # No clue (End of memory? ] # Initialize our superclass as well MemorySensor.__init__(self)
def __init__(self, sensor_ip=G.SENSOR_MEMORY.DEFAULT_IP, sensor_port=G.SENSOR_MEMORY.DEFAULT_PORT, cache_timeout=0, name=None, use_threading=False, timeout=1, retries=5): """ Initialize our memory sensor. Just saving values at this point. @param cache_timeout: How long to keep data in the cache (seconds) @param name: Human name of the sensor @param use_threading: This will spawn a new process to read replys from the sensor. Enables much faster reads, but will eventually blow the UDP stack in the FPGA. """ # Sensor info self.sensor_ip = sensor_ip self.sensor_port = sensor_port # Socket variables self._sock = None self.TIMEOUT = timeout self.RETRIES = retries self.TIMED_OUT = False self.connect_count = 0 # Are we reading a separate process? self.use_threading = use_threading self.read_queue = None self.packet_reader = None # Cache self.cache = {} self.cache_timeouts = {} self.CACHE_TIMEOUT = cache_timeout # seconds # Keep track of our transaction self.transaction_no = 1 if name is not None: self.name = name # Bad read regions (On XPSP3x86) # Ref: http://wiki.osdev.org/Memory_Map_%28x86%29 self.BAD_MEM_REGIONS = [(0xA0000, 0x100000), # VGA and PCI (0x7fe00000,0x80000000), # No Clue (0xdbf00000,0x100000000), # High Mem PCI devices (0x3ff00000,0x40000000) # No clue (End of memory? ] # Initialize our superclass as well MemorySensor.__init__(self)
def __init__(self, vm_name, cache_timeout=0): """ Initialize our class """ self.vmi = None # Ensure that we are root if not os.geteuid() == 0: logger.error("WARNING: Memory sensor should be run as root!") # Initialize our sensor self.vm_name = vm_name self.name = vm_name + "-MemorySensor" # Caching self.cache = {} self.cache_timeouts = {} self.CACHE_TIMEOUT = cache_timeout # seconds # Bad Memory regions self.BAD_MEM_REGIONS = [(0x0, 4096)] self.SOCK = None self.RETRIES = 3 MemorySensor.__init__(self)