Login with Facebook

Wednesday, January 19, 2011

Get Network Utilization Using VBs script

Last week I have faced challenge in responding to HP support (ITRC) thread regarding collecting Network utilization for Operation Manger to evaluate it against threshold.

Infrastructure SPI contain some policies for Monitoring network utilization but it is quite complicated (but efficient) as it has various  mathematical calculations.

Any way the script I have provided was just for calculating the utilization based on two factors total bytes transferred per second and the bandwidth.

We can get this data using WMI through "Win32_PerfFormattedData_TCPIP_NetworkInterface" class located on namespace "root\CIMV2"
We can use the attributes below to match factors stated above:

BytesTotalPersec
CurrentBandwidth

Network utilization calculation:
BytesTotalPerSec / CurrentBandwidth * 100


strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\Root\CIMV2")
Set colItems = objWMIService.ExecQuery _
("select * from Win32_PerfFormattedData_TCPIP_NetworkInterface ")
For Each objItem in colItems
bytesTotal = objitem.BytesTotalPersec * 8
bandwidth = objItem.CurrentBandwidth
result = FormatNumber(( bytesTotal / bandwidth) * 100)
output = objitem.Name & " Network Bandwidth: " & result & " % Utilized"
WScript.Echo output
Next


Screenshot of the output.



networkutilization



source: http://forums11.itrc.hp.com/service/forums/questionanswer.do?threadId=1464068

3 comments:

Anonymous said...

I get a null value, it states starting on the line for the FOR Loop

Babeman said...

Awesome thanks!!

DedicatedHosting4u said...

This is precisely what I need to familiarize myself with this area. Looking forward to many interesting and useful articles from you. the article is very interesting and effective.

Dedicatedhosting4u.com

Post a Comment