Purpose
The following activity captures empirical data on DHCP service performance. This data, which is collected daily (or multiple times a day) will be reviewed weekly. It will also be used to create monthly reports that are reviewed quarterly for service level agreement (SLA) compliance. Service performance statistics are different from system performance in that they measure the characteristics of the DHCP service, not the underlying infrastructure, such as disk, memory, or processor.
Script Listing:
rem – DHCP Service Performance Basic Collector ---------------------
On Error Resume Next
rem ---------------------------------------------------------------------------------
rem -- List all DHCP Servers in the strDHCPServer array in quotes
rem -- and separated by commas. use "." for localsystem.
rem --
rem -- Example:
rem -- strDHCPServer=array("dhcpsvr01","dchpsvr02","192.168.23.21")
rem --
arrDHCPSvr = array( ".","dhcpsvr01")
rem ---------------------------------------------------------------------------------
For Each strComputer in arrDHCPsvr
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_PerfRawData_DHCPServer_DHCPServer",,48)
For Each objItem in colItems
rem -- Timing Objects---------------------------------------------
Wscript.Echo "Name: " & objItem.Name
Wscript.Echo "Timestamp_Object: " & objItem.Timestamp_Object
Wscript.Echo "Timestamp_PerfTime: " & objItem.Timestamp_PerfTime
Wscript.Echo "Timestamp_Sys100NS: " & objItem.Timestamp_Sys100NS
rem --Log Events Similar to What is Captured in Performance Logs and Alerts Console -------
Wscript.Echo "AcksPersec: " & objItem.AcksPersec
Wscript.Echo "ActiveQueueLength: " & objItem.ActiveQueueLength
Wscript.Echo "ConflictCheckQueueLength: " & objItem.ConflictCheckQueueLength
Wscript.Echo "DeclinesPersec: " & objItem.DeclinesPersec
Wscript.Echo "DiscoversPersec: " & objItem.DiscoversPersec
Wscript.Echo "DuplicatesDroppedPersec: " & objItem.DuplicatesDroppedPersec
Wscript.Echo "InformsPersec: " & objItem.InformsPersec
Wscript.Echo "MillisecondsperpacketAvg: " & objItem.MillisecondsperpacketAvg
Wscript.Echo "NacksPersec: " & objItem.NacksPersec
Wscript.Echo "OffersPersec: " & objItem.OffersPersec
Wscript.Echo "RequestsPersec: " & objItem.RequestsPersec
rem --Additional Events -------
Wscript.Echo "Frequency_Object: " & objItem.Frequency_Object
Wscript.Echo "Frequency_PerfTime: " & objItem.Frequency_PerfTime
Wscript.Echo "Frequency_Sys100NS: " & objItem.Frequency_Sys100NS
Wscript.Echo "PacketsExpiredPersec: " & objItem.PacketsExpiredPersec
Wscript.Echo "PacketsReceivedPersec: " & objItem.PacketsReceivedPersec
Wscript.Echo "ReleasesPersec: " & objItem.ReleasesPersec
Next
Next
rem – END OF SCRIPT --
a. At the top of the script add the following lines:
m=Month(Now)
d=Day(Now)
s=Second(Now)
If (m<10) Then
m="0" & m
End If
If (d<10) Then
d="0" & d
End If
If (s<10) Then
s="0" & s
End If
strFormattedDate = chr(34) & m & "/" & d & "/" & Year(Now) & " " & Hour(Now) & ":" & Minute(Now) & ":" & s & ".000" & chr(34)b. After the line “For Each objItem in colItems” all the way to “Next” are the output commands to echo the results to screen. Select the objects you would like to log and replace the “Wscript.Echo …” lines with one concatenated and formatted output including formatting such as “ (quotes) represented by chr(34) and , (commas).
For example, to create a PerfMon-style output for DHCP Nacks/sec, Offers/sec, and Requests/sec, the result would be:
…
For Each objItem in colItems
Wscript.Echo strFormattedDate & “,” & chr(34) & objItem.NacksPersec & chr(34) &“,” & chr(34) & objItem.OffersPersec & chr(34) & “,” & chr(34) &objItem.RequestsPersec & chr(34)
Next
…
Dependencies
None
Technology Required