Re: [python-win32] Win32pdhutil - GetFormattedCounterValue while
running python thu IIS
by Thomas HERVE other posts by this author
Mar 29 2004 9:48AM messages near this date
[python-win32] Detach a process from IIS
|
Re: [python-win32] Win32pdhutil - GetFormattedCounterValue while
running python thu IIS
> sebastien Pastor <spastor@[...].com>
>
> Thanx Thomas,
You're welcome.
> Thanx for the link, it does help already !
> Here is the code i have been using
>
> "import win32pdhutil
> nbConnections=win32pdhutil.GetPerformanceAttributes("Web Service",
> "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")
> print res
> print query.collectdata()
Well, my way to do this.
<code>
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,
commbytes))
base = win32pdh.OpenQuery()
count_comm = win32pdh.AddCounter(self.base, self.path_comm)
# We query a first time to initialise counter
win32pdh.CollectQueryData(self.base)
# 100 Ms of sleep to be sure getLoad won't be called too fast
time.sleep(0.1)
# Second query to fetch results
win32pdh.CollectQueryData(base)
# Get results
count_format = win32pdh.PDH_FMT_LONG
m_comm = win32pdh.GetFormattedCounterValue(count_comm, count_format)[1]
</code>
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
> created ?
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
> improvement
Well obviously it's an IIS problem. Are you sure you can access this with
cgi ?
What are your windows and IIS version ?
Sorry but I can't help you anymore on this...
> Seb
--
Thomas
_______________________________________________
Python-win32 mailing list
Python-win32@[...].org
http://mail.python.org/mailman/listinfo/python-win32
Thread:
Thomas HERVE
sebastien Pastor
|