 |
VB How-To Ask your "How do I do this with VB?" questions in this forum. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the VB How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|

January 4th, 2007, 08:11 PM
|
Registered User
|
|
Join Date: Jan 2007
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Heap Monitor
Hi,
I am trying to retrieve the Heap data from the dheapmon.exe. The exe return the below mentioned in the command prompt.
Desktop Heap Information Monitor Tool (Version 7.0.2727.0)
Copyright (c) 2003-2004 Microsoft Corp.
-------------------------------------------------------------
Session ID: 0 Total Desktop: ( 5824 KB - 8 desktops)
WinStation\Desktop Heap Size(KB) Used Rate(%)
-------------------------------------------------------------
WinSta0\Default 3072 5.7
WinSta0\Disconnect 64 4.0
WinSta0\Winlogon 128 8.7
Service-0x0-3e7$\Default 512 15.1
Service-0x0-3e4$\Default 512 5.1
Service-0x0-3e5$\Default 512 1.1
SAWinSta\SADesktop 512 0.4
__X78B95_89_IW\__A8D9S1_42_ID 512 0.4
-------------------------------------------------------------
I am interested in retrieving the value returned for WinSta0\Default Heap Size and the Used Rate(%). I am trying to achieve it using the below method but seem to know how to proceed.
Set oShell = CreateObject("WScript.Shell")
Set fso = CreateObject("Scripting.FileSystemObject")
oshell.Run """C:\ntutils\kktools\dheapmon8.1\x86\dheapmon.exe "" file.doc"
|

January 5th, 2007, 12:16 AM
|
Friend of Wrox
|
|
Join Date: Dec 2004
Posts: 221
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hello
If you want to write the output of that .exe file to a text file then
change to this
Set oShell = CreateObject("WScript.Shell")
Rem Set fso = CreateObject("Scripting.FileSystemObject") [Not needed]
oshell.Run "D:\Raghavendra_MS\RandD\dir.bat" (call batch file here)
And in that .bat file, write...
ipconfig/all > file.txt
or in your case
C:\ntutils\kktools\dheapmon8.1\x86\dheapmon.exe > file.txt
Now when you call this batch file you will see the output saved in the above mentioned file. And you can open that text file and read the
5th line...
"WinSta0\Default 3072 5.7"
and split it on the "tab" delimiter
arr(0) = "WinSta0\Default "
arr(1) = "3072 "
arr(2) = "5.7"
So now you have the trim(arr(2)) = 3072
as the value of the default heap size
I guess i understood your problem, if not please explain it still clearly, will try to fix your problem.
Hope this helps.
With Regards,
Raghavendra Mudugal
|

January 8th, 2007, 02:10 PM
|
Registered User
|
|
Join Date: Jan 2007
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hi Raghavendra,
Your solution works fine for me. Thanks for your help.
Regards,
Pallavi
|

January 10th, 2007, 04:29 PM
|
Registered User
|
|
Join Date: Jan 2007
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hi,
I am trying to achieve this with the following code where I am not creating file.txt
' Run the heapMon command
Set WSHShell = CreateObject("WScript.Shell")
Set objHeapMonExec = WSHShell.Exec("C:\ntutils\kktools\dheapmon8.1\x86\ dheapmon.exe")
Do Until objHeapMonExec.StdOut.AtEndOfStream
strText = objHeapMonExec.StdOut.ReadLine
If InStr(strText,"WinSta0\Default") Then
arr=Split(strText)
For i=0 To UBound(arr)
If arr(i) <> "" Then
strHeap=strHeap & arr(i) & "," End if
Next
arrHeap=Split(strHeap,",")
If arrHeap(2) > val(intCritical) Then
gstrOutput= "Critical. Heap Percentage exceeding 95%"
CheckHeap= gCRITICAL
ElseIf arrHeap(2) > val(intWarning) Then
gstrOutput= "Warning. Heap Percentage exceeding 90%"
CheckHeap= gWARNING
Else
CheckHeap = gOK
End If
End If
Loop
but the above code doesnt seem to work
|

January 11th, 2007, 01:21 AM
|
Friend of Wrox
|
|
Join Date: Dec 2004
Posts: 221
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hello
Copy the content between the lines and open a notepad paste it and
save the file as <any_name>.vbs and double click the file, it works.
There was a sight changes in the code. Check it out by comparing to your
written code.
Please let me know, if any.
Hope this helps.
================================================== =====================
Set WSHShell = CreateObject("WScript.Shell")
Set objHeapMonExec = WSHShell.Exec("C:\WINNT\system32\ipconfig.exe")
intCritical = 6
intWarning = 5.5
s = "Desktop Heap Information Monitor Tool (Version 7.0.2727.0)"
s = s & "Copyright (c) 2003-2004 Microsoft Corp."
s = s & "-------------------------------------------------------------"
s = s & " Session ID: 0 Total Desktop: ( 5824 KB - 8 desktops)"
s = s & " WinStation\Desktop Heap Size(KB) Used Rate(%)"
s = s & "-------------------------------------------------------------"
s = s & " WinSta0\Default 3072 5.7"
s = s & " WinSta0\Disconnect 64 4.0"
s = s & " WinSta0\Winlogon 128 8.7"
s = s & " Service-0x0-3e7$\Default 512 15.1"
s = s & " Service-0x0-3e4$\Default 512 5.1"
s = s & " Service-0x0-3e5$\Default 512 1.1"
s = s & " SAWinSta\SADesktop 512 0.4"
s = s & " __X78B95_89_IW\__A8D9S1_42_ID 512 0.4"
s = s & "-------------------------------------------------------------"
s1 = " WinSta0\Default 3072 5.7"
Do Until objHeapMonExec.StdOut.AtEndOfStream
strText = objHeapMonExec.StdOut.ReadLine
Rem msgbox strText
strText = s1
If InStr(strText,"WinSta0\Default") Then
arr=Split(strText)
For i=0 To UBound(arr)
If arr(i) <> "" Then
strHeap=strHeap & arr(i) & ","
End if
Next
Rem msgbox strHeap
arrHeap=Split(strHeap,",")
Rem msgbox arrHeap(2)
Rem msgbox intCritical
If cdbl(arrHeap(2)) > cdbl(intCritical) Then
gstrOutput= "Critical. Heap Percentage exceeding 95%"
CheckHeap= gCRITICAL
ElseIf cdbl(arrHeap(2)) > cdbl(intWarning) Then
gstrOutput= "Warning. Heap Percentage exceeding 90%"
CheckHeap= gWARNING
Else
CheckHeap = gOK
End If
End If
Loop
msgbox gstrOutput
================================================== =====================
With Regards,
Raghavendra Mudugal
|

January 11th, 2007, 08:37 PM
|
Registered User
|
|
Join Date: Jan 2007
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
hi,
Thanks a lot. it worked for me
Regards,
Pallavi
|
|
 |