Beispiel #1
0
 def test_top(self):
     linux_info = linux.LinuxInfo()
     summary, ps_info = linux_info.top()
     self.assertTrue(summary.has_key('uptime'))
     self.assertTrue(summary.has_key('cpu-usage'))
     self.assertGreaterEqual(len(ps_info), 1)
     self.assertEquals(len(ps_info[0]), 12)
Beispiel #2
0
 def execute(self):
     linux_info = linux.LinuxInfo()
     ns_info = linux_info.netstat(False)
     if ns_info is not None:
         for ns_item in ns_info:
             protocol = ns_item.get('protocol')
             local = ns_item.get('local')
             state = ns_item.get('state')
             
             if protocol == self.protocol and self.port in local and state == 'LISTENING':
                 return
     
     execute.run(self.action)   
             
     
     
Beispiel #3
0
 def execute(self):
     linux_info = linux.LinuxInfo()
     ps_info = linux_info.ps(False)
     if ps_info is not None:
         for ps_item in ps_info:
             p_id = ps_item.get('pid')
             p_cmd = ps_item.get('cmd')
             
             if string_utils.is_numeric(self.pid):
                 if str(self.pid) == p_id:
                     return
             else:
                 if str(self.pid) == p_cmd:
                     return 
     
     execute.run(self.action)
Beispiel #4
0
 def test_cpu(self):
     linux_info = linux.LinuxInfo()
     cpu_info = linux_info.cpu()
     self.assertGreaterEqual(len(cpu_info), 1)
     self.assertTrue(cpu_info[0].has_key('processor'))
     self.assertTrue(cpu_info[0].has_key('model name'))
Beispiel #5
0
 def test_iostat(self):
     linux_info = linux.LinuxInfo()
     iostat_info = linux_info.iostat()
     
Beispiel #6
0
 def test_netstat(self):
     linux_info = linux.LinuxInfo()
     netstat_info = linux_info.netstat('tcp')
     self.assertGreaterEqual(len(netstat_info), 1)
     self.assertEquals(len(netstat_info[0]), 7)
Beispiel #7
0
 def test_net_if(self):
     linux_info = linux.LinuxInfo()
     iface_info = linux_info.net_if()
     self.assertGreaterEqual(len(iface_info), 1)
     self.assertEquals(len(iface_info[0]), 17)
Beispiel #8
0
 def test_filesystem(self):
     linux_info = linux.LinuxInfo()
     df_info = linux_info.filesystem()
     self.assertGreaterEqual(len(df_info), 1)
     self.assertEquals(len(df_info[0]), 7)
Beispiel #9
0
 def test_ps(self): 
     linux_info = linux.LinuxInfo()
     ps_info = linux_info.ps(False)
     self.assertGreaterEqual(len(ps_info), 1)
     self.assertEquals(len(ps_info[0]), 8)
Beispiel #10
0
 def test_memory(self):
     linux_info = linux.LinuxInfo()
     mem_info = linux_info.memory()
     self.assertTrue(mem_info.has_key('MemTotal'))
     self.assertTrue(mem_info.has_key('MemFree'))
Beispiel #11
0
 def __init__(self):
     self.linux_info = linux.LinuxInfo()