cup.res package

Submodules

cup.res.linux module

author:Giampaolo Rodola of psutil
descrition:The class [Process] is back ported from python open-source project [psutil]. Guannan finished porting in early 2014. Here is the original license applied.
copyright:Psutil. Copyright (c) 2009, Giampaolo Rodola’. All rights reserved. Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
class cup.res.linux.CPUInfo[source]

Bases: cup.res.linux.CPUInfo

CPUInfo是在调用get_cpu_usage返回的python namedtuple. 返回值中的如下属性可以直接访问: usr, nice, system, idle, iowait, irq, softirq, steal, guest

I.g.

import cup
# 计算60内cpu的使用情况。
cpuinfo = cup.res.linux.get_cpu_usage(intvl_in_sec=60)
print cpuinfo.usr
class cup.res.linux.MemInfo[source]

Bases: cup.res.linux.vmem

get_meminfo函数取得系统Mem信息的回返信息。 是个namedtuple
total, available, percent, used, free, active, inactive, buffers, cached是她的属性

E.g.:

import cup
meminfo = cup.res.linux.get_meminfo()
print meminfo.total
print meminfo.available
class cup.res.linux.Process(pid)[source]

Bases: object

Linux中进程的抽象类, 可以进行进程的信息获取。

get_connections(*args, **kwargs)[source]

internal wrapper for wrap_exceptions

get_cpu_times(*args, **kwargs)[source]

internal wrapper for wrap_exceptions

get_ext_memory_info(*args, **kwargs)[source]

internal wrapper for wrap_exceptions

get_memory_info(*args, **kwargs)[source]

internal wrapper for wrap_exceptions

get_memory_maps()[source]

获取memory map的信息。 取自proc目录的smaps

get_num_ctx_switches(*args, **kwargs)[source]

internal wrapper for wrap_exceptions

get_num_fds(*args, **kwargs)[source]

internal wrapper for wrap_exceptions

get_open_files(*args, **kwargs)[source]

internal wrapper for wrap_exceptions

get_process_cmdline(*args, **kwargs)[source]

internal wrapper for wrap_exceptions

get_process_create_time(*args, **kwargs)[source]

internal wrapper for wrap_exceptions

get_process_cwd(*args, **kwargs)[source]

internal wrapper for wrap_exceptions

get_process_exe()[source]

获得进程的Exe信息。 如果这个进程是个daemon,请使用get_process_name

get_process_gids(*args, **kwargs)[source]

internal wrapper for wrap_exceptions

get_process_io_counters(*args, **kwargs)[source]

internal wrapper for wrap_exceptions

get_process_name(*args, **kwargs)[source]

internal wrapper for wrap_exceptions

get_process_nice(*args, **kwargs)[source]

internal wrapper for wrap_exceptions

get_process_num_threads(*args, **kwargs)[source]

internal wrapper for wrap_exceptions

get_process_ppid(*args, **kwargs)[source]

internal wrapper for wrap_exceptions

get_process_status(*args, **kwargs)[source]

internal wrapper for wrap_exceptions

get_process_threads(*args, **kwargs)[source]

internal wrapper for wrap_exceptions

get_process_uids(*args, **kwargs)[source]

internal wrapper for wrap_exceptions

nt_mmap_ext

alias of mmap

nt_mmap_grouped

alias of mmap

class cup.res.linux.SWAPINFO[source]

Bases: cup.res.linux.SwapInfo

get_swapinfo函数回返的数据结构信息。 total,free,used,sin,sout是她的属性

cup.res.linux.get_boottime_since_epoch()[source]
Returns:回返自从epoch以来的时间。 以秒记.
cup.res.linux.get_cpu_nums()[source]

回返机器的CPU个数信息

cup.res.linux.get_cpu_usage(intvl_in_sec=1)[source]

取得下个intvl_in_sec时间内的CPU使用率信息 回返CPUInfo

cup.res.linux.get_kernel_version()[source]

拿到Linux系统的kernel信息, 回返是一个三元组 e.g.(‘2’, ‘6’, ‘32’):

cup.res.linux.get_meminfo()[source]

获得当前系统的内存信息, 回返MemInfo数据结构。

cup.res.linux.get_net_recv_speed(str_interface, intvl_in_sec)[source]

获得某个网卡在intvl_in_sec时间内的收包速度

cup.res.linux.get_net_through(str_interface)[source]

获取网卡的收发包的统计信息。 回返结果为(rx_bytes, tx_bytes)

cup.res.linux.get_net_transmit_speed(str_interface, intvl_in_sec=1)[source]

获得网卡在intvl_in_sec时间内的网络发包速度

E.g.

import cup
print cup.res.linux.get_net_transmit_speed('eth1', 5)
cup.res.linux.get_swapinfo()[source]

获得当前系统的swap信息

cup.res.linux.net_io_counters()[source]

回返系统中每一个(包括回环lo)网络使用统计信息。 其中每个网卡list的信息包含 (bytes_sent, bytes_recv, packets_sent, packets_recv,

errin, errout, dropin, dropout)

回返信息示例

{
    'lo':
     (
         235805206817, 235805206817, 315060887, 315060887, 0, 0, 0, 0
     ),
     'eth1':
     (
         18508976300272, 8079464483699, 32776530804,
         32719666038, 0, 0, 708015, 0
     ),
     'eth0':
     (
         0, 0, 0, 0, 0, 0, 0, 0
     )
 }
cup.res.linux.wrap_exceptions(fun)[source]

内部使用函数, 普通使用者可忽略 Decorator which translates bare OSError and IOError exceptions into cup.err.NoSuchProcess and cup.err.AccessDenied.

Module contents

author:Guannan Ma
create_date:2014
last_date:2014
descrition:resource related module

Table Of Contents

Previous topic

cup.net.async package

Next topic

cup.services package

This Page