Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Luke is correct. In order to get the localized version of Processor(_Total)\% Processor Time, we have to get the localized names of each of the components of the path "Processor" and "%Processor Time" with the '(_Total)' being constant. The indexes can vary across OS versions, so you have to discover them on each run. The <strong>win32pyutil</strong> module contains methods that will load the english-to-index map but retains it, and since it's not small if you only need it once then that can be a memory waster. We use the following:</p> <pre><code>def _find_pdh_counter_localized_name(eng_names,machine_name=None): ''' Create a map of english names to indexes. We then lookup the english name in the map to get the localized name. Shamefully lifted from win32pdhutil, only this one uses a transient map instead of a persistent one. Will throw KeyError if a name is asked for that is not in the list. ''' import win32api, win32con counter_reg_value = win32api.RegQueryValueEx( win32con.HKEY_PERFORMANCE_DATA, "Counter 009" ) counter_list = counter_reg_value[0] eng_map={} for i in range(0, len(counter_list) - 1, 2): try: counter_id = int(counter_list[i]) except ValueError: continue eng_map[counter_list[i+1].lower()] = counter_id ret = [] for name in eng_names: ret.append(win32pdh.LookupPerfNameByIndex( machine_name, eng_map[name.lower()]) ) del eng_map return tuple(ret) </code></pre> <p>To construct the counter name:</p> <pre><code> names = _find_pdh_counter_localized_name(['processor','% processor time']) counter_name = r'\%s(_Total)\%s' % names </code></pre> <p>which yields the desired value. e.g., "\Processore(_Total)\% Tempo Processore" in Italian.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload