#1
  1. No Profile Picture
    Registered User
    ASP Explorer (0 - 99 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
  3. Contributing User
    ASP Skiller (1500 - 1999 posts)

    Join Date
    Aug 2008
    Location
    USA
    Posts
    1,597
    Rep Power
    343
    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 Give Rep button (bottom side on this reply ) and agree

    Jquery Shake Effect ,
    Andriod KitKat


    Thank You,
    KiranK

IMN logo majestic logo threadwatch logo seochat tools logo