Esempio n. 1
0
File: statfs.py Progetto: svinota/cx
 def __init__(self):
     self.s = genl_socket()
     self.prid = self.s.get_protocol_id("TASKSTATS")
Esempio n. 2
0
from cxnet.netlink.core import nlattr, NLMSG_ALIGN
from cxnet.netlink.generic import genl_socket
from cxnet.netlink.taskstats import (
    TASKSTATS_CMD_GET, TASKSTATS_CMD_ATTR_PID,
    TASKSTATS_CMD_ATTR_REGISTER_CPUMASK,
    TASKSTATS_TYPE_PID, TASKSTATS_TYPE_AGGR_PID,

    taskstatsmsg
)
from cxnet.utils import hprint


if __name__ == "__main__":
    # 1. get TASKSTATS protocol id
    s = genl_socket()
    prid = s.get_protocol_id("TASKSTATS")

    # 2. get TASKSTATS structure for a pid or for own process
    pid, mask = None, None

    if len(sys.argv) > 1:
        try:
            pid = int(sys.argv[1])
        except ValueError:
            mask = sys.argv[1][1:]
    else:
        import os
        pid = os.getpid()

    if pid:
Esempio n. 3
0
 def __init__(self):
     self.s = genl_socket()
     self.prid = self.s.get_protocol_id("TASKSTATS")