Thread: ASP : Find disk space and CPU Utilization

Results 1 to 2 of 2
Share This Thread →
  1. #1
    AnithaRexy is offline Registered User ASP Free Newbie (0 - 499 posts)
    Join Date
    Jun 2011
    Posts
    1
    Rep Power
    0

    ASP : Find disk space and CPU Utilization

    Hi ,

    Please let me know In ASP, how to find the disk space in a server and the CPU utilizatcion . Please let me know the code in ASP to implement the same

  2. #2
    markWilson's Avatar
    markWilson is offline Contributing User ASP Free Beginner (1000 - 1499 posts)
    Join Date
    Aug 2008
    Posts
    1,453
    Rep Power
    341
    here you can fine disk space utilization code.

    Code:
    Option Explicit
    
    const strComputer = "."
    const strReport = "c:\diskspace.txt"
    
    
    Dim objWMIService, objItem, colItems
    Dim strDriveType, strDiskSize, txt
    
    Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
    Set colItems = objWMIService.ExecQuery("Select * from Win32_LogicalDisk WHERE DriveType=3")
    txt = "Drive" & vbtab & "Size" & vbtab & "Used" & vbtab & "Free" & vbtab & "Free(%)" & vbcrlf
    For Each objItem in colItems
    	
    	DIM pctFreeSpace,strFreeSpace,strusedSpace
    	
    	pctFreeSpace = INT((objItem.FreeSpace / objItem.Size) * 1000)/10
    	strDiskSize = Int(objItem.Size /1073741824) & "Gb"
    	strFreeSpace = Int(objItem.FreeSpace /1073741824) & "Gb"
    	strUsedSpace = Int((objItem.Size-objItem.FreeSpace)/1073741824) & "Gb"
    	txt = txt & objItem.Name & vbtab & strDiskSize & vbtab & strUsedSpace & vbTab & strFreeSpace & vbtab & pctFreeSpace & vbcrlf
    
    Next
    
    writeTextFile txt, strReport
    wscript.echo "Report written to " & strReport & vbcrlf & vbcrlf & txt
    
    ' Procedure to write output to a text file
    private sub writeTextFile(byval txt,byval strTextFilePath)
    	Dim objFSO,objTextFile
    	
    	set objFSO = createobject("Scripting.FileSystemObject")
    
    	set objTextFile = objFSO.CreateTextFile(strTextFilePath)
    
    	objTextFile.Write(txt)
    
    	objTextFile.Close
    	SET objTextFile = nothing
    end sub
    refer this article on how to get CPU utilization.
    if you found this post is useful click * button (bottom side on this reply ) and agree

    Jquery Shake Effect ,
    JQUERY on Blogger

    Thank You,
    KiranK

Share This Thread →

Become Part of This Conversation

Join NowFor Free!

ASP Free Advertisers and Affiliates