Remote uptime with win32pdh

Jamie jamie.ivanov at gmail.com
Tue Sep 29 14:19:10 EDT 2009


On Sep 29, 1:08 pm, Jamie <jamie.iva... at gmail.com> wrote:
> I'm new to python and I'm trying to write a script which takes the
> computer name from the variable 'name' and gets the uptime.
>
> What I have so far:
>     query = win32pdh.OpenQuery()
>     counter = win32pdh.AddCounter(query, r'\System\System Up Time')
>     win32pdh.CollectQueryData(query)
>     var1, val = win32pdh.GetFormattedCounterValue(counter,
> win32pdh.PDH_FMT_LONG)
>     uptime = val / 3600
>
>     print "--> Uptime: %s hours" % uptime
>
> That works just fine for the local system, but I'm at a loss figuring
> out how to make it gater that data from a remote system. Any help
> would be much appreciated!

Oh, and I can't use WMI because WMI doesn't seem to work in Portable
Python (long story)



More information about the Python-list mailing list