• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python test_psutil.sh函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中test_psutil.sh函数的典型用法代码示例。如果您正苦于以下问题:Python sh函数的具体用法?Python sh怎么用?Python sh使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了sh函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_vmem_used

 def test_vmem_used(self):
     lines = sh('free').split('\n')[1:]
     total = int(lines[0].split()[1])
     free = int(lines[0].split()[3])
     used = (total - free) * 1024
     self.assertAlmostEqual(used, psutil.virtual_memory().used,
                            delta=MEMORY_TOLERANCE)
开发者ID:dpavlenkov,项目名称:psutil,代码行数:7,代码来源:_linux.py


示例2: test_swap_memory

 def test_swap_memory(self):
     out = sh("pstat -s")
     _, total, used, free, _, _ = out.split('\n')[1].split()
     smem = psutil.swap_memory()
     self.assertEqual(smem.total, int(total) * 512)
     self.assertEqual(smem.used, int(used) * 512)
     self.assertEqual(smem.free, int(free) * 512)
开发者ID:sethp-jive,项目名称:psutil,代码行数:7,代码来源:_openbsd.py


示例3: test_swapmem_total

 def test_swapmem_total(self):
     out = sh('sysctl vm.swapusage')
     out = out.replace('vm.swapusage: ', '')
     total, used, free = re.findall('\d+.\d+\w', out)
     psutil_smem = psutil.swap_memory()
     self.assertEqual(psutil_smem.total, human2bytes(total))
     self.assertEqual(psutil_smem.used, human2bytes(used))
     self.assertEqual(psutil_smem.free, human2bytes(free))
开发者ID:rdaunce,项目名称:psutil,代码行数:8,代码来源:_osx.py


示例4: test_users

 def test_users(self):
     out = sh("who")
     lines = out.split('\n')
     users = [x.split()[0] for x in lines]
     self.assertEqual(len(users), len(psutil.users()))
     terminals = [x.split()[1] for x in lines]
     for u in psutil.users():
         self.assertTrue(u.name in users, u.name)
         self.assertTrue(u.terminal in terminals, u.terminal)
开发者ID:2089764,项目名称:psutil,代码行数:9,代码来源:_posix.py


示例5: muse

def muse(field):
    """Thin wrapper around 'muse' cmdline utility."""
    out = sh('muse', stderr=DEVNULL)
    for line in out.split('\n'):
        if line.startswith(field):
            break
    else:
        raise ValueError("line not found")
    return int(line.split()[1])
开发者ID:CaiZhongda,项目名称:psutil,代码行数:9,代码来源:_bsd.py


示例6: vm_stat

def vm_stat(field):
    """Wrapper around 'vm_stat' cmdline utility."""
    out = sh('vm_stat')
    for line in out.split('\n'):
        if field in line:
            break
    else:
        raise ValueError("line not found")
    return int(re.search('\d+', line).group(0)) * PAGESIZE
开发者ID:hybridlogic,项目名称:psutil,代码行数:9,代码来源:_osx.py


示例7: sysctl

def sysctl(cmdline):
    """Expects a sysctl command with an argument and parse the result
    returning only the value of interest.
    """
    result = sh("sysctl " + cmdline)
    result = result[result.find(": ") + 2:]
    try:
        return int(result)
    except ValueError:
        return result
开发者ID:CaiZhongda,项目名称:psutil,代码行数:10,代码来源:_bsd.py


示例8: df

 def df(path):
     out = sh('df -P -B 1 "%s"' % path).strip()
     lines = out.split("\n")
     lines.pop(0)
     line = lines.pop(0)
     dev, total, used, free = line.split()[:4]
     if dev == "none":
         dev = ""
     total, used, free = int(total), int(used), int(free)
     return dev, total, used, free
开发者ID:blackbone23,项目名称:HDD-Monitoring,代码行数:10,代码来源:_linux.py


示例9: test_net_if_names

 def test_net_if_names(self):
     out = sh("ip addr").strip()
     nics = psutil.net_if_addrs()
     found = 0
     for line in out.split('\n'):
         line = line.strip()
         if re.search("^\d+:", line):
             found += 1
             name = line.split(':')[1].strip()
             self.assertIn(name, nics.keys())
     self.assertEqual(len(nics), found, msg="%s\n---\n%s" % (
         pprint.pformat(nics), out))
开发者ID:AvishaySebban,项目名称:NTM-Monitoring,代码行数:12,代码来源:_linux.py


示例10: test_uids_gids

 def test_uids_gids(self):
     out = sh('procstat -s %s' % self.pid)
     euid, ruid, suid, egid, rgid, sgid = out.split('\n')[1].split()[2:8]
     p = psutil.Process(self.pid)
     uids = p.uids()
     gids = p.gids()
     self.assertEqual(uids.real, int(ruid))
     self.assertEqual(uids.effective, int(euid))
     self.assertEqual(uids.saved, int(suid))
     self.assertEqual(gids.real, int(rgid))
     self.assertEqual(gids.effective, int(egid))
     self.assertEqual(gids.saved, int(sgid))
开发者ID:ryoon,项目名称:psutil,代码行数:12,代码来源:_freebsd.py


示例11: df

 def df(path):
     out = sh('df -k "%s"' % path).strip()
     lines = out.split('\n')
     lines.pop(0)
     line = lines.pop(0)
     dev, total, used, free = line.split()[:4]
     if dev == 'none':
         dev = ''
     total = int(total) * 1024
     used = int(used) * 1024
     free = int(free) * 1024
     return dev, total, used, free
开发者ID:hybridlogic,项目名称:psutil,代码行数:12,代码来源:_osx.py


示例12: test_memory_maps

 def test_memory_maps(self):
     out = sh('procstat -v %s' % self.pid)
     maps = psutil.Process(self.pid).get_memory_maps(grouped=False)
     lines = out.split('\n')[1:]
     while lines:
         line = lines.pop()
         fields = line.split()
         _, start, stop, perms, res = fields[:5]
         map = maps.pop()
         self.assertEqual("%s-%s" % (start, stop), map.addr)
         self.assertEqual(int(res), map.rss)
         if not map.path.startswith('['):
             self.assertEqual(fields[10], map.path)
开发者ID:CaiZhongda,项目名称:psutil,代码行数:13,代码来源:_bsd.py


示例13: test_memory_maps

 def test_memory_maps(self):
     sproc = get_test_subprocess()
     time.sleep(1)
     p = psutil.Process(sproc.pid)
     maps = p.get_memory_maps(grouped=False)
     pmap = sh('pmap -x %s' % p.pid).split('\n')
     del pmap[0]; del pmap[0]  # get rid of header
     while maps and pmap:
         this = maps.pop(0)
         other = pmap.pop(0)
         addr, _, rss, dirty, mode, path = other.split(None, 5)
         if not path.startswith('[') and not path.endswith(']'):
             self.assertEqual(path, os.path.basename(this.path))
         self.assertEqual(int(rss) * 1024, this.rss)
         # test only rwx chars, ignore 's' and 'p'
         self.assertEqual(mode[:3], this.perms[:3])
开发者ID:hybridlogic,项目名称:psutil,代码行数:16,代码来源:_linux.py


示例14: test_swap_memory

    def test_swap_memory(self):
        out = sh('env PATH=/usr/sbin:/sbin:%s swap -l' % os.environ['PATH'])
        lines = out.strip().split('\n')[1:]
        if not lines:
            raise ValueError('no swap device(s) configured')
        total = free = 0
        for line in lines:
            line = line.split()
            t, f = line[-2:]
            total += int(int(t) * 512)
            free += int(int(f) * 512)
        used = total - free

        psutil_swap = psutil.swap_memory()
        self.assertEqual(psutil_swap.total, total)
        self.assertEqual(psutil_swap.used, used)
        self.assertEqual(psutil_swap.free, free)
开发者ID:goodtiding5,项目名称:psutil,代码行数:17,代码来源:_sunos.py


示例15: test_swap_memory

    def test_swap_memory(self):
        out = sh('swap -l -k')
        lines = out.strip().split('\n')[1:]
        if not lines:
            raise ValueError('no swap device(s) configured')
        total = free = 0
        for line in lines:
            line = line.split()
            t, f = line[-2:]
            t = t.replace('K', '')
            f = f.replace('K', '')
            total += int(int(t) * 1024)
            free += int(int(f) * 1024)
        used = total - free

        psutil_swap = psutil.swap_memory()
        self.assertEqual(psutil_swap.total, total)
        self.assertEqual(psutil_swap.used, used)
        self.assertEqual(psutil_swap.free, free)
开发者ID:2089764,项目名称:psutil,代码行数:19,代码来源:_sunos.py


示例16: test_vmem_free

 def test_vmem_free(self):
     lines = sh('free').split('\n')[1:]
     free = int(lines[0].split()[3]) * 1024
     self.assertAlmostEqual(free, psutil.virtual_memory().free,
                            delta=MEMORY_TOLERANCE)
开发者ID:dpavlenkov,项目名称:psutil,代码行数:5,代码来源:_linux.py


示例17: test_cpu_count_logical_w_lscpu

 def test_cpu_count_logical_w_lscpu(self):
     out = sh("lscpu -p")
     num = len([x for x in out.split('\n') if not x.startswith('#')])
     self.assertEqual(psutil.cpu_count(logical=True), num)
开发者ID:AvishaySebban,项目名称:NTM-Monitoring,代码行数:4,代码来源:_linux.py


示例18: test_vmem_cached

 def test_vmem_cached(self):
     cached = int(sh('vmstat').split('\n')[2].split()[5]) * 1024
     self.assertAlmostEqual(cached, psutil.virtual_memory().cached,
                            delta=MEMORY_TOLERANCE)
开发者ID:dpavlenkov,项目名称:psutil,代码行数:4,代码来源:_linux.py


示例19: test_vmem_buffers

 def test_vmem_buffers(self):
     buffers = int(sh('vmstat').split('\n')[2].split()[4]) * 1024
     self.assertAlmostEqual(buffers, psutil.virtual_memory().buffers,
                            delta=MEMORY_TOLERANCE)
开发者ID:dpavlenkov,项目名称:psutil,代码行数:4,代码来源:_linux.py


示例20: test_swapmem_free

 def test_swapmem_free(self):
     lines = sh('free').split('\n')[1:]
     free = int(lines[2 if OLD_PROCPS_NG_VERSION else 1].split()[1]) * 1024
     self.assertAlmostEqual(free, psutil.swap_memory().free,
                            delta=MEMORY_TOLERANCE)
开发者ID:dpavlenkov,项目名称:psutil,代码行数:5,代码来源:_linux.py



注:本文中的test_psutil.sh函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python test_py_scripts.get_py_script函数代码示例发布时间:2022-05-27
下一篇:
Python test_psutil.reap_children函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap