Calling all Dev's and Dot Net Heads amongst us - writing a wmi poller
#1
Scooby Regular
Thread Starter
Join Date: May 2005
Location: AKA *Smiles* Laindon, Essex. MY04 Psuedo-STI Wagon http://swrt.verio.co.uk www.remanissradio.net
Posts: 716
Likes: 0
Received 0 Likes
on
0 Posts
Calling all Dev's and Dot Net Heads amongst us - writing a wmi poller
Help !!!!!!!!!
having trouble plumbing some stuff together with my wmi scripts amy wmi gurus in here or people that spend way more time than is healthy in MSDN
Scenario is... I have my wmi scripts that I put together for our Sys admins that collect various bits of sys info using wmi classes (objOperatingSystem.Version; objOperatingSystem.ServicePackMinorVersion; objProcess.ProcessID; objProcess.Nameetc etc)
then collated all these into a basic hta.
The next stage that has me is getting the WITHIN Clause to work for WMI polling onder2:
i.e requests that WMI check every 10 seconds for changes that occur to instances of the Win32_LogicalDisk or Win32_Process classes . If an instance of the class is modified within the specified polling interval, a notification event is sent for each modification.
So here is extract from my code:
==========================
Sub GetProcesses
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colProcesses = objWMIService.ExecQuery("Select * from Win32_Process")
strHTML = "<table border='1' style='border-collapse: collapse' " & _
"bordercolor='#111111' width='100%' id='Table1' >"
For Each objProcess in colProcesses
strHTML = strHTML & "<tr>"
strHTML = strHTML & "<td width='50%'>" & objProcess.Name & "</td>"
strHTML = strHTML & "<td width='50%'>" & objProcess.ProcessID & _
=========================================
So the 64 milliion dollar question is where do I plumb the WITHIN Clause into this.
My guess was directly after Win32_Process in the below line:
Set colProcesses = objWMIService.ExecQuery("Select * from Win32_Process")
But guess I'm missing some more plumbing somewhere as it aint working.
Or even better still am I heading the wrong way up a one way strasse and there is a better way of WMI poling.
Ohhh.. one more thing ... may as well get my moneys worth out of this post
Any ideas how to turn my hta into a web service, now thats the funky stuff i want to get onto
Cheeers all
having trouble plumbing some stuff together with my wmi scripts amy wmi gurus in here or people that spend way more time than is healthy in MSDN
Scenario is... I have my wmi scripts that I put together for our Sys admins that collect various bits of sys info using wmi classes (objOperatingSystem.Version; objOperatingSystem.ServicePackMinorVersion; objProcess.ProcessID; objProcess.Nameetc etc)
then collated all these into a basic hta.
The next stage that has me is getting the WITHIN Clause to work for WMI polling onder2:
i.e requests that WMI check every 10 seconds for changes that occur to instances of the Win32_LogicalDisk or Win32_Process classes . If an instance of the class is modified within the specified polling interval, a notification event is sent for each modification.
So here is extract from my code:
==========================
Sub GetProcesses
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colProcesses = objWMIService.ExecQuery("Select * from Win32_Process")
strHTML = "<table border='1' style='border-collapse: collapse' " & _
"bordercolor='#111111' width='100%' id='Table1' >"
For Each objProcess in colProcesses
strHTML = strHTML & "<tr>"
strHTML = strHTML & "<td width='50%'>" & objProcess.Name & "</td>"
strHTML = strHTML & "<td width='50%'>" & objProcess.ProcessID & _
=========================================
So the 64 milliion dollar question is where do I plumb the WITHIN Clause into this.
My guess was directly after Win32_Process in the below line:
Set colProcesses = objWMIService.ExecQuery("Select * from Win32_Process")
But guess I'm missing some more plumbing somewhere as it aint working.
Or even better still am I heading the wrong way up a one way strasse and there is a better way of WMI poling.
Ohhh.. one more thing ... may as well get my moneys worth out of this post
Any ideas how to turn my hta into a web service, now thats the funky stuff i want to get onto
Cheeers all
#2
Scooby Regular
Join Date: Nov 2001
Location: Leeds - It was 562.4bhp@28psi on Optimax, How much closer to 600 with race fuel and a bigger turbo?
Posts: 15,239
Likes: 0
Received 1 Like
on
1 Post
Hmm... pass.. do a search for WQL... however isnt it easier (messier!) to do something like..
But I found this example at http://msdn.microsoft.com/library/de...g_with_wql.asp
See http://msdn.microsoft.com/library/de...hin_clause.asp
David
Code:
strComputer = "." Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2") Set colProcesses = objWMIService.ExecQuery("Select * from Win32_Process") For Each objProcess in colProcesses wscript.echo objProcess.Name wscript.echo objProcess.ProcessID Next Set objprocess=Nothing Set ColProcesses=Nothing Set OSInfo = objWMIService.ExecQuery(Select * from Win32_Computer") Blah Blah..
But I found this example at http://msdn.microsoft.com/library/de...g_with_wql.asp
Code:
strComputer = "." Set objWMIService = GetObject("winmgmts:\\" _ & strComputer & "\root\CIMV2") Set objEvents = objWMIService.ExecNotificationQuery _ ("SELECT * FROM __InstanceModificationEvent WITHIN 10 WHERE " & _ "TargetInstance ISA 'Win32_Service'" & _ " AND TargetInstance._Class = 'win32_TerminalService'") i = TRUE Do While i = TRUE Set strReceivedEvent = objEvents.NextEvent 'report an event Wscript.Echo "An event has occurred." Loop
David
#3
Scooby Regular
Thread Starter
Join Date: May 2005
Location: AKA *Smiles* Laindon, Essex. MY04 Psuedo-STI Wagon http://swrt.verio.co.uk www.remanissradio.net
Posts: 716
Likes: 0
Received 0 Likes
on
0 Posts
Originally Posted by David_Wallis
But I found this example at http://msdn.microsoft.com/library/d...ng_with_wql.asp
Originally Posted by David_Wallis
Hmm pass... do a search for WQL... however isnt it easier (messier!) to do something like..
Thats one of the reasons why I have moved most of the admin scripts into one hta and then output it to the DataArea table etc instead of the wscript.echo method and format it into tables and stuff.
Horses for courses I guess what you need your scripts to do for the task you need .
When I get past this boring/ tedious bit I can get onto the fun stuff of the web service ... I need to see if I can get an XML-RPC web service [ failing that SOAP ] not explored this bit yet.
Any good links again for this or sample snippets appreciated
let us Know if I can give anything back.. dont want to be all take, take, take
Cheers
Steve
#4
Scooby Regular
Join Date: Nov 2001
Location: Leeds - It was 562.4bhp@28psi on Optimax, How much closer to 600 with race fuel and a bigger turbo?
Posts: 15,239
Likes: 0
Received 1 Like
on
1 Post
Steve,
if you save that as test.vbs, and type cscript test.vbs in a cmd prompt then it will output to the command prompt window so its ok for echoing /testing
David
if you save that as test.vbs, and type cscript test.vbs in a cmd prompt then it will output to the command prompt window so its ok for echoing /testing
David
#5
Scooby Regular
Thread Starter
Join Date: May 2005
Location: AKA *Smiles* Laindon, Essex. MY04 Psuedo-STI Wagon http://swrt.verio.co.uk www.remanissradio.net
Posts: 716
Likes: 0
Received 0 Likes
on
0 Posts
Originally Posted by Mutts Nutts
...I mainly use cscript as my default WSH engine....
I do this vice versa... sometimes its a pain that the default script host is set to wscript thats why always set my default script host to CScript, so not needing to type cscript in front of stuff.
All different ways to skin a cat i guess .
Going to trawl google for inspiration and plagerism for writing this WMI poller and a web service
#7
Scooby Regular
Thread Starter
Join Date: May 2005
Location: AKA *Smiles* Laindon, Essex. MY04 Psuedo-STI Wagon http://swrt.verio.co.uk www.remanissradio.net
Posts: 716
Likes: 0
Received 0 Likes
on
0 Posts
Ohh if only the end user requests were that simple
Originally Posted by David_Wallis
you could just do it as an ASP page if you dont want to do it in a complicated way
Trending Topics
Thread
Thread Starter
Forum
Replies
Last Post
Mattybr5@MB Developments
Full Cars Breaking For Spares
20
22 October 2015 06:12 AM
Danny0608
Subaru
6
27 September 2015 02:16 PM
IanG1983
Wheels, Tyres & Brakes
1
22 September 2015 09:47 PM
Danny0608
Subaru Parts
0
12 September 2015 02:59 PM