Check performance เครื่อง server โดยที่ไม่ต้องจดแต่ละเครื่อง
ตัวอย่าง file เป็น .vbs ใช้ร่วมกับ schedule task
Dim objWMIService, objItem, colItems ,objNetwork
Dim strDriveType, strDiskSize, txt
set objNetwork = createobject("wscript.network")
'wscript.echo objNetwork.Username
'Display Computer Name
strUser=objNetwork.Username
'strComputer=objNetwork.ComputerName
strServers="Server1,server2,server3"
txtdate=year(now()) & month(now()) & day(now())
strReport = "\\logper\Serverlog"
strReport=strReport & txtdate & ".txt"
'Create newtextfile and close
set objFSO = createobject("Scripting.FileSystemObject")
set objTextFile = objFSO.CreateTextFile(strReport)
objTextFile.close
'array server
For each strServer in SPLIT(strServers,",")
Dim objFSO,objTextFile
Set objWMIService = GetObject("winmgmts:\\" &strServer & "\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
'create textfile for append
set objFSO = createobject("Scripting.FileSystemObject")
set objTextFile = objFSO.OpenTextFile(strReport,8)
'set objTextFile = objFSO.CreateTextFile(strReport)
objTextFile.Writeline "#####################" & vbtab & strServer & vbtab & "#####################"
objTextFile.Writeline now
'objTextFile.Writeline strServer
objTextFile.Writeline strUser
objTextFile.Writeline txt
objTextFile.Writeline
objTextFile.Close
SET objTextFile = nothing
Next
ผลลัพธ์
##################### Server #####################
4/28/2009 7:08:07 AM
username log on *******
Drive Size Used Free Free(%)
C: 29Gb 6Gb 23Gb 79.5
D: 243Gb 171Gb 71Gb 29.5
Tuesday, April 28, 2009
Saturday, April 04, 2009
VBScript Functions
อ้างอิง http://www.w3schools.com/VBscript/vbscript_ref_functions.asp
Set objFso = CreateObject("Scripting.FileSystemObject")
Set objFile = objFso.GetFile("C:\pathtofile")
objFile.DateCreated
objFile.DateLastAccessed
objFile.DateLastModified
Subscribe to:
Posts (Atom)