Page 1 of 1 1
Topic Options
#84819 - 2002-01-08 05:26 PM Perfmon Counters
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
Shawn/Radimus,

As requested of Shawn, I have moved this over here.

Continuing on undaunted.

Conversation starts here.

To do:

  • Get SQL Statement working.
  • Convert Uint32, Uint64, etc. as needed.

I am getting the following error though -

code:
 BREAK ON 
CLS
; -- Ref - WMIQuery structure: http://kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=12&t=000082
; -- Ref - Perfmon counters: http://www.scriptinternals.de/content/ref/wmi/nam espaces/root_cimv2/CIM_StatisticalInformation/CIM_StatisticalInformation.htm
; -- Ref - Remote execution: http://cwashington.netreach.net/depo/view.asp?Index=314&ScriptType=vbscript
; -- Ref - Pull Perfmon Counters: http://cwashington.netreach.net/depo/view.asp?Index=345&ScriptType=vbscript
$myarray = Split("SERVER1~~SERVER2", "~~")
FOR EACH $element IN $myarray

FOR EACH $disk IN Split(WMIQuery("FreeMegabytes","Win32_PerfFormattedData_PerfDisk_LogicalDisk",$element),"|")
? "Free Space is = "val($disk) / 1048576 " MB"
NEXT
FOR EACH $disk IN Split(WMIQuery("AvgDiskQueueLength","Win32_PerfFormattedData_PerfDisk_LogicalDisk",$element),"|")
? "Average Diskqueue Length = "$disk
NEXT
? "Percent Processor Time = "WMIQuery("PercentProcessorTime","Win32_PerfRawData_PerfProc_Thread",$element)
? "SQL Server Buffer Hit Cache Ratio = "WMIQuery("Buffercachehitratio","Win32_PerfRawData_MSSQLSERVER_SQLServerBuffer",$myarray)
NEXT


;$wmi = GetObject("winmgmts:root/CIMV2")
;$strQuery = "select * from CIM_StatisticalInformation"
;$result = $wmi.ExecQuery($strQuery)

FUNCTION WMIQuery($what,$where,$element)
DIM $strquery, $objenumerator, $value, $element
$strquery = "Select $what From $where"
?$strquery
$systemset = GetObject("winmgmts:{impersonationLevel=impersonate}!//"+$element+"\root\default")
;$SystemSet = GetObject("winmgmts:{impersonationLevel=impersonate}!//$Element")
$objenumerator = $systemset.execquery($strquery)
FOR EACH $objinstance IN $objenumerator
IF @error = 0 AND $objinstance <> ""
$=execute("$$value = $$objInstance.$what")
$wmiquery="$value"+"|"+"$WMIQuery"
ENDIF
NEXT
$wmiquery=left($wmiquery,len($wmiquery)-1)
EXIT @error
ENDFUNCTION


Cheers!

- Kent

[ 08 January 2002: Message edited by: kdyer ]

_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
#84820 - 2002-01-08 06:27 PM Re: Perfmon Counters
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Kent,

Have you been able to get this far yet ?

Script Code:



break on


$wmi = getobject("winmgmts:root/CIMV2")


$wql = "select * from CIM_StatisticalInformation"


$result = $wmi.execquery($wql)


for each $instance in $result


?"instance=" $instance.getobjecttext_


next


exit 1


-Shawn

Top
#84821 - 2002-01-08 06:47 PM Re: Perfmon Counters
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
Shawn,

Works great!

- Kent

_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
#84822 - 2002-01-08 06:58 PM Re: Perfmon Counters
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Kent,

Is that a good thing Are you further ahead ?

Is this where you are heading with this ? A WmiSelect type UDF ?


break on


$hostlist = "shawn","shawn"


for each $hostname in $hostlist


$response = WmiSelect($hostname,"select * from CIM_StatisticalInformation")


for each $instance in $response
?"instance=" $instance.getobjecttext_
next


next


exit


function WmiSelect($hostname,$query)


dim $wmi


$wmi = getobject("winmgmts:{impersonationlevel=impersonate}!//"+$hostname+"\root\cimv2")


$wmiselect = $wmi.execquery($query)


endfunction

-Shawn

Top
#84823 - 2002-01-08 07:14 PM Re: Perfmon Counters
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
Shawn,

CIM_StatisticalInformation is cool..
But, I want to query a sub-set of it like Win32_PerfFormattedData_PerfDisk_LogicalDisk..

Thanks!

- Kent

_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
#84824 - 2002-01-08 07:56 PM Re: Perfmon Counters
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
Shawn,

Did some playing around with your script and have the following result:
[quote]
Script error : unknown command !
$wmiselect = $wmi.execquery($$query)
[quote]

Here is code as it stands now:

code:

BREAK ON
CLS
$myarray = Split("SERVER1~~SERVER2", "~~")
FOR EACH $element IN $myarray

FOR EACH $disk IN Split(WmiSelect("FreeMegabytes","Win32_PerfFormattedData_PerfDisk_LogicalDisk",$element),"|")
? "Free Space is = "val($disk) / 1048576 " MB"
NEXT
FOR EACH $disk IN Split(WmiSelect("AvgDiskQueueLength","Win32_PerfFormattedData_PerfDisk_LogicalDisk",$element),"|")
? "Average Diskqueue Length = "$disk
NEXT
? "Percent Processor Time = "WmiSelect("PercentProcessorTime","Win32_PerfRawData_PerfProc_Thread",$element)
? "SQL Server Buffer Hit Cache Ratio = "WmiSelect("Buffercachehitratio","Win32_PerfRawData_MSSQLSERVER_SQLServerBuffer",$element)
NEXT


;$wmi = GetObject("winmgmts:root/CIMV2")
;$strQuery = "select * from CIM_StatisticalInformation"
;$result = $wmi.ExecQuery($strQuery)

function WmiSelect($what,$where,$element)

dim $wmi
$query = "Select $what From $where"
$wmi = getobject("winmgmts:{impersonationlevel=impersonate}!//"+$element+"\root\cimv2")

$wmiselect = $wmi.execquery($$query)

endfunction


Thanks!

- Kent

_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
#84825 - 2002-01-08 08:08 PM Re: Perfmon Counters
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Kent,

I can get the non-cooked (raw) data ok ... plus, based on the numbers im getting here, it looks as if the suspision that kixtart deals-out large negative numbers (remember?) is true:


break on


$hostname = "shawn"


$WMI = GetObject("winmgmts:{impersonationlevel=impersonate}!//$hostname\root\cimv2")


$WSL = "select * From Win32_PerfRawData_PerfDisk_LogicalDisk"


$Collection = $WMI.ExecQuery($WSL)


For Each $LogicalDisk in $Collection


?
?"LogicalDisk : " $LogicalDisk.Name
?"AvgDiskSecPerRead : " $LogicalDisk.AvgDiskSecPerRead
?"AvgDiskSecPerTransfer : " $LogicalDisk.AvgDiskSecPerTransfer
?"AvgDiskSecPerWrite : " $LogicalDisk.AvgDiskSecPerWrite


Next


exit 1

-Shawn

[ 08 January 2002: Message edited by: Shawn ]

Top
#84826 - 2002-01-09 05:15 PM Re: Perfmon Counters
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
Well...

Here is the code at this point.. There still appears to be conversion issues with this as this is RAW Data. Maybe "decompile" Perfmon to see what the conversions are for UINT32, and UINT64, for example?

code:

break on

$hostname = "Servername"

$WMI = GetObject("winmgmts:{impersonationlevel=impersonate}!//$hostname\root\cimv2")

$WSL = "select * From Win32_PerfRawData_PerfDisk_LogicalDisk"

$Collection = $WMI.ExecQuery($WSL)

; -- Disk Stats

For Each $LogicalDisk in $Collection

?
?"LogicalDisk : " $LogicalDisk.Name
?"AvgDiskQueueLength : " $LogicalDisk.AvgDiskQueueLength
?"AvgDiskSecPerRead : " $LogicalDisk.AvgDiskSecPerRead
?"AvgDiskSecPerTransfer : " $LogicalDisk.AvgDiskSecPerTransfer
?"AvgDiskSecPerWrite : " $LogicalDisk.AvgDiskSecPerWrite
?"FreeMegabytes : " $LogicalDisk.FreeMegabytes

Next

; -- Procesor

$WSL = "select * From Win32_PerfRawData_PerfOS_Processor"

$Collection = $WMI.ExecQuery($WSL)

For Each $Processor in $Collection
?
?"PercentProcessorTime : " $Processor.PercentProcessorTime
Next

; -- SQL Server
$WSL = "select * From Win32_PerfRawData_MSSQLSERVER_SQLServerBufferManager"

$Collection = $WMI.ExecQuery($WSL)

For Each $SQLStat in $Collection
?"Buffercachehitratio : " $SQLStat.Buffercachehitratio
Next

exit 1


L8r!

- Kent

[ 09 January 2002: Message edited by: kdyer ]

_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
Page 1 of 1 1


Moderator:  Shawn, ShaneEP, Ruud van Velsen, Arend_, Jochen, Radimus, Glenn Barnas, Allen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 2312 anonymous users online.
Newest Members
fgarcia, Viginette, ManuvdWielNL, Sir_Barrington, batdk82
17889 Registered Users

Generated in 0.058 seconds in which 0.025 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org