Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


help on script

 
Logged in as: Guest
arrSession:exec spGetSession 2,13,63668
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Welcome] >> Test Posting Messages >> help on script
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 help on script - 8/20/2008 12:07:26 PM   
  jeffablang

 

Posts: 16
Score: 0
Joined: 6/5/2008
Status: offline
Hi I am using this monitoring script and I found out that the output for the processor is increasing, its not getting the true value can anyone help me regarding this script?... thank you!


' ========================================================
' Script Information
'
' Created for:         
' Title:                             Hard Disk Space , CPU and Memory Usage Script 
' Author:                         Jeffrey G. Ablang
' Originally created:          6/19/2008 - 10:58:36
' Original path:                PCEWKDB24CF1S D:\share\Coding Project\hdd_cpu_ram_MONv1.csv
' Description:                  Script to monitor my computers hard disk space, my cpu usage in (%) and memory RAM usage in (%)

' ========================================================
Option Explicit

Dim oWsh, oWshSysEnv, objFSO, objWMIService
Dim oDrives, oDrive, objOutFile, colItems, objItem
Dim strLineDate, strLineTime, strLineProcessorTime, strLineDriveSpace, strLinePercentCommittedBytesInUse

Set oWsh = WScript.CreateObject("WScript.Shell")
Set oWshSysEnv = oWsh.Environment("PROCESS")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objWMIService = GetObject("winmgmts:\\.\root\CIMV2")

strLineDate = Date()
strLineTime = Time()

'Gets PROCESSOR Usage
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_PerfFormattedData_PerfOS_Processor WHERE Name = '_Total'")
For Each objItem In colItems   
strLineProcessorTime = strLineProcessorTime & " " & objItem.PercentProcessorTime
Next


'Gets MEMORY Usage
Set colItems = GetObject("WinMgmts:root/cimv2").ExecQuery("Select * FROM Win32_PerfFormattedData_PerfOS_Memory ")
For Each objItem In colItems   
strLinePercentCommittedBytesInUse = strLinePercentCommittedBytesInUse & " " & objItem.PercentCommittedBytesInUse
Next
'Gets FREE SPACE Report
Set oDrives = objFSO.Drives
For Each oDrive In oDrives
Select Case oDrive.DriveType
 Case 2 'Fixed Drives    
  strLineDriveSpace = strLineDriveSpace & " " & oDrive.DriveLetter & "\: " & Round(oDrive.FreeSpace / (1024 * 1024)) & "MB free (" & Round(100 * (oDrive.FreeSpace / oDrive.TotalSize), 2) & " %) "
End Select
Next

'Output to text
Set objOutFile = objFSO.OpenTextFile("C:\hdd_cpu_ram_MONv1.csv", 8, True)
objOutFile.WriteLine "Date,Time,Computer Name,Processor Usage (%),Memory Usage (%),Drive Free Space"
objOutFile.WriteLine strLineDate & "," & strLineTime & "," & oWshSysEnv("COMPUTERNAME") & "," & strLineProcessorTime & "," & strLinePercentCommittedBytesInUse & "," & strLineDriveSpace

'WScript.Echo "DONE"
WScript.Quit
 
 
Post #: 1
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Welcome] >> Test Posting Messages >> help on script Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts