![]() |
|
|||||||
| ASP & VBScript Forum Need help from a webmaster with ASP or VBScript, you may ask in this forum? |
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
Hi, I am just a newbie in scripting and I'm having a hard time on this thing that i'm doing. I just want some help from you guys which i know are expert in this. I just want to ask if anyone of you can help me with the script i need to monitor my computers hard disk space, my cpu usage in (%) and memory RAM usage in (%). I will surely appreciate if you can help me with this one. My OS is windows XP and windows 2000
I made a script but when I run it has an error can someone help me with my problem. All i want is to get the Hard Disk Space, Memory Usage and CPU Usage. the output could be a log file *.txt format of in microsoft excel *.xls file. VBScript Code: strComputerName = GetCurrentComputerName ' get name only once for performance reasons subject = "Drive Space Report " & strComputerName str = str & Date() & Space(2) & Time() & vbcrlf & vbcrlf str = str & strComputerName & vbcrlf str = str & GetFreeSpaceReport strComputer = "." ' Constants for drive types Const Unknown = 0 Const Removable = 1 Const Fixed = 2 Const Remote = 3 Const CDROM = 4 Const RAMDisk = 5 ' get current computer name (from system environment variables) Function GetCurrentComputerName Set oWsh = WScript.CreateObject("WScript.Shell") Set oWshSysEnv = oWsh.Environment("PROCESS") GetCurrentComputerName = oWshSysEnv("COMPUTERNAME") End Function 'Get free space report Function GetFreeSpaceReport Set oFs = WScript.CreateObject("Scripting.FileSystemObject") Set oDrives = oFs.Drives For Each oDrive In oDrives Select Case oDrive.DriveType Case Fixed GetFreeSpaceReport = GetFreeSpaceReport & oDrive.DriveLetter & ": " & Round(oDrive.FreeSpace/(1024*1024)) & "MB free (" & Round(100 * (oDrive.FreeSpace/oDrive.TotalSize),2) & "%)" & vbcrlf End Select Next End Function 'Gets CPU Processor Speed strComputer = "." Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2") Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_PerfFormattedData_PerfOS_Processor WHERE Name = '_Total'") For Each objItem In colItems WScript.Echo objItem.PercentProcessorTime Next 'Get CPU Memory Usage Status" Sub TestMemoryStatus Dim Mem Set Mem = Win32API.TMemoryStatus Mem.dwLength = 32 Win32API.GlobalMemoryStatus Mem Log.Message "MEMORYSTATUS test", _ "Percent of memory in use - " + _ CStr(Mem.dwMemoryLoad) End Sub 'Output to text Set objFSO = CreateObject("Scripting.FileSystemObject" & "%") Set objOutFile = objFSO.OpenTextFile("D:\Server_hdd_cpu_mem.txt", 8, True) strLine = str objOutFile.WriteLine strLine Output To screen - useful For debugging MsgBox "Hard Disk Space, Memory and CPU UsageChecking DONE" THANK YOU! |
|
This ad is part of our Revenue Sharing program |