Exemple #1
0
    def sample(processDetail):
        """
        Return a single float representing percentage usage of the main
        memory by the process.

        """
        return ProcessMemoryPoller.sample(processDetail)
Exemple #2
0
    def sample(processDetail):
        """
        Return a single float representing percentage usage of the main
        memory by the process.

        """
        return ProcessMemoryPoller.sample(processDetail)
Exemple #3
0
 def testProcessMemoryPollerBasic(self):
     pid = os.getpid()
     name = "mytestprocess"
     pd = ProcessDetail(pid, name)
     poller = ProcessMemoryPoller()
     v = poller.sample(pd)
     self.assertTrue(isinstance(v, types.FloatType))
Exemple #4
0
 def testProcessMemoryPollerBasic(self):
     pid = os.getpid()
     name = "mytestprocess"
     pd = ProcessDetail(pid, name)
     poller = ProcessMemoryPoller()
     v = poller.sample(pd)
     self.assertTrue(isinstance(v, float))
Exemple #5
0
 def testProcessMemoryPollerBasic(self):
     p = utils.getProcess()
     self.testProcesses.append(p)
     name = "mytestprocess"
     pd = ProcessDetail(p.pid, name)        
     poller = ProcessMemoryPoller()
     v = poller.sample(pd)
     self.assertTrue(isinstance(v, types.FloatType))
     # psutil.error.AccessDenied will result into -1 returned
     self.assertTrue(v > 0)
Exemple #6
0
 def testProcessMemoryPollerNoSuchProcess(self):
     """
     Poller should handle if the watched processed crashed or was
     terminated, so polling on NoSuchProcess.
     
     """
     pd = self._getKilledProcessDetail()        
     poller = ProcessMemoryPoller()
     self.assertFalse(pd.proc.is_running())
     v = poller.sample(pd)
     self.assertTrue(isinstance(v, types.FloatType))
     # above situation shall result into handled psutil.error.NoSuchProcess
     self.assertEquals(v, -1)