[python-win32] Win32pdhutil - GetFormattedCounterValue while
running python thu IIS
therve at neocles.com
Mon Mar 29 04:48:19 EST 2004
>sebastien Pastor <spastor at center.com>
>Thanx for the link, it does help already !
>Here is the code i have been using
>"Current Connections", instance="_Total")
>quite straightforward really...
Yes, not much to say about that.
>Since then i have been doing this as a test :
>query = win32pdhquery.Query(["\\Memory\\Available Bytes"])
>print "here is the query Object " + str(query)
>res=query.rawaddcounter("Memory", "Available Bytes",machine="127.0.0.1")
Well, my way to do this.
MEMORY = "Memory"
COMMBYTES = "Committed Bytes"
memory = win32pdhutil.find_pdh_counter_localized_name(MEMORY)
commbytes = win32pdhutil.find_pdh_counter_localized_name(COMMBYTES)
path_comm = win32pdh.MakeCounterPath((None, memory, None, None, -1,
base = win32pdh.OpenQuery()
count_comm = win32pdh.AddCounter(self.base, self.path_comm)
# We query a first time to initialise counter
# 100 Ms of sleep to be sure getLoad won't be called too fast
# Second query to fetch results
# Get results
count_format = win32pdh.PDH_FMT_LONG
m_comm = win32pdh.GetFormattedCounterValue(count_comm, count_format)
If you have an error you can see where it is more clearly.
>In order to try to understand where i am failing ... but so far no much
>of success . For instance when i run locally those lines i can see "Here
>is the query Object <win32pdhquery.Query instance at 0x00811480> but
>when i call the script from my web browser i have "Here is the query
>Object " then nothing afterwards ... does it mean my object is not
Probably. You may have the error in IIS logs.
> How can i access the object status and eventually the reason
>of creation failure ? Moreover, i have added the machine parameter just
>in case the code would get confused when ran from IIS .. but no
Well obviously it's an IIS problem. Are you sure you can access this with
What are your windows and IIS version ?
Sorry but I can't help you anymore on this...
More information about the Python-win32