Webmaster Forum

Go Back   Webmaster Forum > Scripting/Programming & Debugging > ASP & VBScript Forum
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

ASP & VBScript Forum Need help from a webmaster with ASP or VBScript, you may ask in this forum?

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 06-13-2008, 06:14 AM
jeffablang jeffablang is offline
Junior Member
 
Join Date: Jun 2008
Posts: 1
jeffablang is an unknown quantity at this point
Submit to Clesto Submit to Digg Submit to Reddit Submit to Furl Submit to Del.icio.us Submit to Jeqq Submit to Spurl
Default Help! Help me to automate my task on my VB Script

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!
Reply With Quote

This ad is part of our Revenue Sharing program
Reply


Thread Tools
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

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



All times are GMT. The time now is 05:22 AM.


Creative Commons License
Powered by vBulletin Version 3.6.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.0.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30