Great community. Great ideas.

Welcome to ASP/Free, a community dedicated to helping beginners and professionals alike in improving their knowledge of Microsoft's development and administration technologies. Sign up today to gain access to the combined insight of tens of thousands of members.

Thread: ASP : Find disk space and CPU Utilization

Results 1 to 2 of 2
Share This Thread →
  1. #1
    AnithaRexy is offline Registered User
    Join Date
    Jun 2011
    Rep Power

    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
    Join Date
    Aug 2008
    Rep Power
    here you can fine disk space utilization 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
    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)
    	SET objTextFile = nothing
    end sub
    refer this article on how to get CPU utilization.
    if you found this post is useful click Give Rep button (bottom side on this reply ) and agree

    Andriod KitKat
    Jquery Shake Effect ,

    Thank You,

Share This Thread →

Become Part of This Conversation

Join NowFor Free!

ASP Free Advertisers and Affiliates