Exemplo n.º 1
0
def Main():
    cgiEnv = lib_common.ScriptEnvironment()
    try:
        the_pid = int(cgiEnv.GetId())
    except Exception:
        lib_common.ErrorMessageHtml("Must provide a pid")

    grph = cgiEnv.GetGraph()

    node_process = lib_uris.gUriGen.PidUri(the_pid)
    CIM_Process.AddInfo(grph, node_process, [str(the_pid)])

    fil_cgroups = "/proc/%d/cgroup" % the_pid

    for lin_cg in open(fil_cgroups):
        split_cg = lin_cg.split(':')
        hierarchy = split_cg[0]
        subsys_name_list = split_cg[1]
        mount_path = split_cg[2]
        mount_path = mount_path[:-1]  # Strip trailing backslash-N
        mount_path_node = lib_uris.gUriGen.DirectoryUri(mount_path)

        for subsys_name in subsys_name_list.split(","):
            if subsys_name:
                cgrp_node = survol_cgroup.MakeUri(subsys_name)
                grph.add(
                    (node_process, lib_common.MakeProp("CGroup"), cgrp_node))
                grph.add((cgrp_node, lib_common.MakeProp("Hierarchy"),
                          lib_util.NodeLiteral(hierarchy)))
                grph.add((cgrp_node, lib_common.MakeProp("Control group path"),
                          mount_path_node))

    cgiEnv.OutCgiRdf()
Exemplo n.º 2
0
def Main():
    cgiEnv = lib_common.CgiEnv()

    grph = cgiEnv.GetGraph()

    for lin_cg in open("/proc/cgroups"):
        # Just in case there would be a comment.
        lin_cg = lin_cg.strip()
        if lin_cg.startswith("#"):
            continue
        split_cg = lin_cg.split('\t')
        subsys_name = split_cg[0]
        hierarchy = split_cg[1]
        num_cgroups = split_cg[2]
        enabled = split_cg[3]

        cgrpNode = survol_cgroup.MakeUri(subsys_name)
        grph.add((cgrpNode, lib_common.MakeProp("Hierarchy"),
                  lib_common.NodeLiteral(hierarchy)))
        grph.add((cgrpNode, lib_common.MakeProp("Num CGroups"),
                  lib_common.NodeLiteral(num_cgroups)))
        grph.add((cgrpNode, lib_common.MakeProp("Enabled"),
                  lib_common.NodeLiteral(enabled)))

    cgiEnv.OutCgiRdf()
Exemplo n.º 3
0
def Main():
    cgiEnv = lib_common.CgiEnv()
    try:
        thePid = int(cgiEnv.GetId())
    except Exception:
        lib_common.ErrorMessageHtml("Must provide a pid")

    grph = cgiEnv.GetGraph()

    proc_obj = CIM_Process.PsutilGetProcObj(thePid)

    node_process = lib_common.gUriGen.PidUri(thePid)
    CIM_Process.AddInfo(grph, node_process, [str(thePid)])

    filCGroups = "/proc/%d/cgroup" % thePid

    for lin_cg in open(filCGroups):
        split_cg = lin_cg.split(':')
        hierarchy = split_cg[0]
        subsys_name_list = split_cg[1]
        mount_path = split_cg[2]
        mount_path_node = lib_common.gUriGen.DirectoryUri(mount_path)

        for subsys_name in subsys_name_list.split(","):
            cgrpNode = survol_cgroup.MakeUri(subsys_name)
            grph.add((node_process, lib_common.MakeProp("CGroup"), cgrpNode))
            grph.add((cgrpNode, lib_common.MakeProp("Hierarchy"),
                      lib_common.NodeLiteral(hierarchy)))
            grph.add((cgrpNode, lib_common.MakeProp("Control group path"),
                      mount_path_node))

    cgiEnv.OutCgiRdf()
Exemplo n.º 4
0
def Main():
	cgiEnv = lib_common.ScriptEnvironment()

	grph = cgiEnv.GetGraph()

	cgroupName = cgiEnv.GetId()
	cgroupNode = survol_cgroup.MakeUri(cgroupName)

	propCGroup = lib_common.MakeProp("cgroup")

	# This file contains all processes belonging to this cgroup.
	# Example "/sys/fs/cgroup/cpuset/cgroup.procs"
	# Read access might be forbidden.
	filNamCGroup = "/sys/fs/cgroup/%s/cgroup.procs" % cgroupName

	try:
		for lin_cg in open(filNamCGroup):
			procId = int(lin_cg)
			procNode = lib_uris.gUriGen.PidUri(procId)

			grph.add( ( cgroupNode, propCGroup, procNode ) )
	except:
		logging.error("Invalid cgroup:%s",cgroupName)
		lib_common.ErrorMessageHtml("Invalid cgroup:%s"%cgroupName)

	# This lists processes in a table instead of scattered nodes.
	# This is because there might be a lot of processes.
	cgiEnv.OutCgiRdf("LAYOUT_RECT", [propCGroup] )
Exemplo n.º 5
0
def Main():
    cgiEnv = lib_common.CgiEnv()
    grph = cgiEnv.GetGraph()

    filCG = open("/proc/cgroups")
    propCGroup = lib_common.MakeProp("cgroup")

    linHeader = filCG.readline()
    for linCG in filCG.readlines():
        splitCG = linCG.split("\t")
        cgroupName = splitCG[0]
        cgroupNode = survol_cgroup.MakeUri(cgroupName)
        grph.add( ( cgroupNode, lib_common.MakeProp("Hierarchy"), lib_common.NodeLiteral(splitCG[1] ) ) )
        grph.add( ( cgroupNode, lib_common.MakeProp("Num cgroups"), lib_common.NodeLiteral(splitCG[2] ) ) )
        grph.add( ( cgroupNode, lib_common.MakeProp("Enabled"), lib_common.NodeLiteral(splitCG[3] ) ) )

        grph.add( ( lib_common.nodeMachine, propCGroup, cgroupNode ) )

        
    cgiEnv.OutCgiRdf("LAYOUT_RECT", [propCGroup] )
Exemplo n.º 6
0
def Main():
    cgiEnv = lib_common.ScriptEnvironment()
    grph = cgiEnv.GetGraph()

    fil_cg = open("/proc/cgroups")
    prop_cgroup = lib_common.MakeProp("cgroup")

    linHeader = fil_cg.readline()
    for lin_cg in fil_cg.readlines():
        split_cg = lin_cg.split("\t")
        cgroup_name = split_cg[0]
        cgroup_node = survol_cgroup.MakeUri(cgroup_name)
        grph.add((cgroup_node, lib_common.MakeProp("Hierarchy"),
                  lib_util.NodeLiteral(split_cg[1])))
        grph.add((cgroup_node, lib_common.MakeProp("Num cgroups"),
                  lib_util.NodeLiteral(split_cg[2])))
        grph.add((cgroup_node, lib_common.MakeProp("Enabled"),
                  lib_util.NodeLiteral(split_cg[3])))

        grph.add((lib_common.nodeMachine, prop_cgroup, cgroup_node))

    cgiEnv.OutCgiRdf("LAYOUT_RECT", [prop_cgroup])