Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > VB How-To
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old January 4th, 2007, 08:11 PM
Registered User
 
Join Date: Jan 2007
Location: , , .
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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"



Reply With Quote
  #2 (permalink)  
Old January 5th, 2007, 12:16 AM
Friend of Wrox
Points: 687, Level: 9
Points: 687, Level: 9 Points: 687, Level: 9 Points: 687, Level: 9
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Dec 2004
Location: Chennai, Tamilnadu, India.
Posts: 221
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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
Reply With Quote
  #3 (permalink)  
Old January 8th, 2007, 02:10 PM
Registered User
 
Join Date: Jan 2007
Location: , , .
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Raghavendra,

Your solution works fine for me. Thanks for your help.

Regards,
Pallavi

Reply With Quote
  #4 (permalink)  
Old January 10th, 2007, 04:29 PM
Registered User
 
Join Date: Jan 2007
Location: , , .
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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

Reply With Quote
  #5 (permalink)  
Old January 11th, 2007, 01:21 AM
Friend of Wrox
Points: 687, Level: 9
Points: 687, Level: 9 Points: 687, Level: 9 Points: 687, Level: 9
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Dec 2004
Location: Chennai, Tamilnadu, India.
Posts: 221
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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
Reply With Quote
  #6 (permalink)  
Old January 11th, 2007, 08:37 PM
Registered User
 
Join Date: Jan 2007
Location: , , .
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

hi,

Thanks a lot. it worked for me

Regards,
Pallavi

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
java.lang.OutOfMemoryError: Java heap space meetkotresh J2EE 1 February 2nd, 2008 01:52 AM
Heap of typing errors HELP!!! ours All Other Wrox Books 11 December 24th, 2007 11:23 AM
Replication Monitor AristotleYu SQL Server 2005 1 October 17th, 2006 09:49 PM
Could not reserve enough space for object Heap overcit Apache Tomcat 0 February 23rd, 2006 12:11 PM
How to monitor printing chinedu Classic ASP Professional 0 November 15th, 2004 07:46 AM



All times are GMT -4. The time now is 06:02 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.