def mem_used():
    counter = r'\Memory\Committed Bytes'
    machine, object, instance, parentInstance, index, counter = win32pdh.ParseCounterPath(
        counter)

    instance = None
    inum = -1
    format = win32pdh.PDH_FMT_DOUBLE
    machine = None

    path = win32pdh.MakeCounterPath(
        (machine, object, instance, None, inum, counter))
    hq = win32pdh.OpenQuery()
    try:
        hc = win32pdh.AddCounter(hq, path)
        try:
            win32pdh.CollectQueryData(hq)
            type, val = win32pdh.GetFormattedCounterValue(hc, format)
            return int(val / 1024)
        except pywintypes.error:
            return 0
        finally:
            win32pdh.RemoveCounter(hc)
    finally:
        win32pdh.CloseQuery(hq)
예제 #2
0
def BrowseCallBackDemo(counter):
    machine, object, instance, parentInstance, index, counterName = \
            win32pdh.ParseCounterPath(counter)

    result = GetPerformanceAttributes(object, counterName, instance, index,
                                      win32pdh.PDH_FMT_DOUBLE, machine)
    print "Value of '%s' is" % counter, result
    print "Added '%s' on object '%s' (machine %s), instance %s(%d)-parent of %s" \
          % (counterName, object, machine, instance, index, parentInstance)
예제 #3
0
def BrowseCallBackDemo(counters):
    ## BrowseCounters can now return multiple counter paths
    for counter in counters:
        machine, object, instance, parentInstance, index, counterName = \
            win32pdh.ParseCounterPath(counter)

        result = GetPerformanceAttributes(object, counterName, instance, index,
                                          win32pdh.PDH_FMT_DOUBLE, machine)
        print("Value of '%s' is" % counter, result)
        print("Added '%s' on object '%s' (machine %s), instance %s(%d)-parent of %s" \
              % (counterName, object, machine, instance, index, parentInstance))
    return 0