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

Thursday, December 30, 2010

Copy Files using VBS

 

-----copyfiles.vbs----

Dim nodeName
Dim argsObj
Set argsObj=WScript.Arguments
If argsObj.Count=1 Then
    nodeName = argsObj(0)
Else
    WScript.echo "usage: cscript.exe copyfiles.vbs <nodeName>"
    WScript.Quit (1)
End If
Set objWMIService = GetObject _
    ("winmgmts:\\" & nodeName & "\root\cimv2:Win32_Process")
errReturn = objWMIService.Create _
    ("cmd.exe /c md c:\Temp", Null, Null, intProcessID)
Wscript.Echo errReturns
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & nodeName & "\root\cimv2")
Set colFiles = _
    objWMIService.ExecQuery("Select * From CIM_DataFile Where Drive = 'C:' and Path = '\\Scripts\\' and FileName Like 'coda%'") 
	'Wscript.Echo colFiles.Count echo number of files
For Each objFile in colFiles
    strNewFile = "C:\Temp\" & objFile.FileName & "." & objFile.Extension 
   	errResults = objFile.Copy(strNewFile)
	Wscript.Echo errResults 'displaying error code
Next
------ 

This script allow copy selected files on a remote machine

usage : cscript copyfiles.vbs computername

Notes:

The script is doing the following:



  1. Create Folder Named C:\temp this done by this statement " ("cmd.exe /c md c:\Temp", Null, Null, intProcessID)

  2. Select files located on drive C: on folder named \scripts\ and all files starts with coda this is done by " objWMIService.ExecQuery("Select * From CIM_DataFile Where Drive = 'C:' and Path = '\\Scripts\\' and FileName Like 'coda%'") "

  3. Writes those files into folder c:\temp “strNewFile = "C:\Temp\" & objFile.FileName & "." & objFile.Extension “

Tuesday, September 28, 2010

How to use WBEMTEST to get WMI data level 2

I got anonymous reader comment on continuing the series for how to use WBEMTEST to get WMI data

In this article I will add two points to cover in this fabulous tool

1- Connect to remote node

2- Run WQL queries.

 

Connect to remote node

usually we use wbemtest locally to access local classes, but WMI support access to remote computers naturally and for applications like PowerShell version 1 which support local scripting, it uses WMI to expand its functionality and to allow PowerShell access to remote computers.

Anyhow, we can use WBEMTEST utility to achieve this by using the connect button located on the main screen, we usually use root\ to locate our local classes like ROOT\MicrosoftIISv2 to get the status for website hosted on IIS server

but if the IIS is not hosted on my local machine I can query this server by adding \\servername\ROOT\MicrosoftIISv2 so it will look like “unified naming convention” UNC same like the one used for Windows file sharing, also you can use Credentials section to access the remote system with different account.

image

 

Run WQL query to retrieve data from WMI classes.

WMI supports a subset of Structured Query Language that support WMI event and WMI-Specific features which we can use to filter the content of the data (instances) within a class like select certain attributes or limit the number of instance.

My 1st encounter  to WQL was in Windows Server 2003 group policy where you can filter the group policy application to only certain set of computers based on certain attributes like OS version and Service Pack or disk free space.

In our tool we can use Query button to write our query

image

Press Apply to get the result

image

You can try to use

Select * from Win32_LogicalDisk where FreeSpace > 104857600

To list only drives where is have diskspace more than 100 MB

for more statements check http://technet.microsoft.com/en-us/library/cc779036(WS.10).aspx

Thursday, September 23, 2010

Launch Network Overview Map

In NNMi you may need only to launch a single MAP in your browser without having the full console view.

This is achievable by launch command available with NNMi.

http://NNMiServerName:PortNumber/nnm/launch?cmd=showNetworkOverview

for launch your node group map use the below

http://NNMiServerName:PortNumber/nnm/launch?cmd=showView&objtype=Node&nodegroup=<NodeGroup>

Example:

To launch "Routers" map:

http://NNMiServerName:PortNumber/nnm/launch?cmd=showView&objtype=Node&nodegroup=Routers

To launch the Networking Infrastructure Devices node group map you can use the command below.

Replace space with + plus sign in group name “Networking Infrastructure Devices”.

http://NNMiServerName:PortNumber/nnm/launch?cmd=showView&objtype=Node&nodegroup=Networking+Infrastructure+Devices

Friday, August 6, 2010

Tips: Enable NNMi integration with OMW

Draft Article

I found very strange trick where sometimes the integration is not working ang keep giving you error access your OMW server.

The trick is to either:

  • Add the OMW server in the trusted zone in the internet explorer settings. 

OR

  • Disable Internet Explorer Security Configuration. Tested 16th August 2010

By the way: I do not know what is the relation between the integration script and internet explorer settings, but I have done this step on different systems and it works.

image

 

image

Monday, August 2, 2010

Had a meeting.

image

US government approves Jailbreak for Iphone, today Jailbreak for iOS 4.0 and 4.0.1 is release

http://www.washingtonpost.com/wp-dyn/content/article/2010/07/26/AR2010072602813.html

 

Comex (the creator of Spirit ) has released browser based jailbreak for iOS 4.0 and iOS 4.0.1

this time is the easiest it is done from the iPhone itself

Open Safari,

open www.jailbreakme.com

then slide the the button to jailbreak

image

That’s it.

If you have issue in installing it like you stuck with the purple screen please use the below steps.

Step 1: Navigate to Settings –> Safari and then clear out History, Cookies and Cache.

Step 2: Reboot your iOS device by turning it off, and then back on.

Step 3: Now try http://jailbreakme.com or http://jailbreakme.modmyi.com again.