|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
WMI - Need a script to monitor servers disk free space remotely
Hello
I need a script or utility (free) to monitor the disk space into my network. Can you please provide me a script which can fulfill my requirements: I want to run this script remotely from one server to monitor the disk space on all other servers into the network. I'll put this into Schedule task and i want to get output into the text file (just total space on server disks and available free space, if possible then show in percentage also) Please provide me a script which pick the name of the server one by one from a text file then store the information of all the servers into the another text file. Please let me know your concerns. Thanks in advance Waiting for positive reply soon |
|
#2
|
||||
|
||||
|
if you're looking for someone to write the script for you, you should post in the Programmers for Hire forum otherwise you will be hardpressed to get someone to write it for you.
if you want to have a go at an already build script that you would need to change to suit your needs ... have a look here
__________________
Come JOIN the party!!! Quote of the Month: Retirement: Because you've given so much of yourself to the company that you don't have anything left we can use. Questions to Ponder: What do you do when you see an endangered animal eating an endangered plant? iif([sarcasm]=true,iif([you have to ask]=true,"didn't work","ha ha ha"),"not sarcasm") copyright© 2008 sbenj69 |
|
#3
|
||||
|
||||
|
I'd be willing to write the script for you. But I need to know a little bit about your network structure. Are you accessing these servers over an intranet or the internet? Do you have admin priveleges on these machines? And what OS's are they running?
If you can provide this info I can put a script together to do the job.
__________________
Click the image if at any point you don't like my decision.Scripting problems? Windows questions? Ask the Windows Guru! |
|
#4
|
||||
|
||||
|
Without seeing exactly what you need, here's a basic example that will probably work for you. This script only runs on Windows XP and newer.
Diskspace.vbs Code:
' These should be valid hostnames or IP addresses
arrServers = Array("Server1", "Server2", "Server3")
For Each strComputer In arrServers
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colDiskDrives = objWMIService.ExecQuery _
("Select * from Win32_PerfFormattedData_PerfDisk_LogicalDisk Where " _
& "Name <> '_Total'")
For Each objDiskDrive In colDiskDrives
WScript.Echo "Drive", objDiskDrive.Name, "has", objDiskDrive.FreeMegabytes & "MB (" & objDiskDrive.PercentFreeSpace & "%) Free"
Next
Next
Last edited by Nilpo : June 24th, 2007 at 04:07 AM. |
|
#5
|
|||
|
|||
|
thanks !@!
In our network all servers are on Intranet, yes i have right on all the servers, all servers are running OS as win server 2000 and win servr 2003. Can you please modify your script little bit so that it send the name of the all the servers and corresponding output of free disk space of all the servers into a common text file rather than on the console, so that we can keep the records about the disk space and can take necessary step for the required server. I tried to run your script into my test environment. ' These should be valid hostnames or IP addresses arrServers = Array("172.21.110.122", "172.21.110.61", "172.21.110.94") For Each strComputer In arrServers Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2") Set colDiskDrives = objWMIService.ExecQuery _ ("Select * from Win32_PerfFormattedData_PerfDisk_LogicalDisk Where " _ & "Name <> '_Total'") For Each objDiskDrive In colDiskDrives WScript.Echo "Drive", objDiskDrive.Name, "has", objDiskDrive.FreeMegabytes & "MB (" & objDiskDrive.PercentFreeSpace & "%) Free" Next Next But it is giving the free space for my local machine (where i am running the script) after then it is throwing the error message Line: 5 Char: 2 Error: The remote server machine does not exist on is unavailable: 'GetObject' Code: 800A01CE Source: Microsoft VBScript runtime error But i have admin right on all the system. Please suggest me the same |
|
#6
|
||||
|
||||
|
This script may not like the servers that are running Win 2K.
If it's stopping with that error (on that line), it means that it was unable to connect to a certain hostname. I'll modify the script to add some error handling for you. I'm also adding the local text dump. I'm just creating a file in the same location as the script. This can be modified as necessary by changing the path. Code:
' These should be valid hostnames or IP addresses
arrServers = Array("Server1", "Server2", "Server3")
' Path to text file. May be absolute or relative to the script.
strFilePath = "freespace.txt"
On Error Resume Next
Set objFso = CreateObject("Scripting.FileSystemObject")
Set oFile = objFso.OpenTextFile(strFilePath, 2, vbTrue)
If Not IsNothing(oFile) Then
For Each strComputer In arrServers
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
If objWMIService Then
Set colDiskDrives = objWMIService.ExecQuery _
("Select * from Win32_PerfFormattedData_PerfDisk_LogicalDisk Where " _
& "Name <> '_Total'")
For Each objDiskDrive In colDiskDrives
oFile.WriteLine "Drive", objDiskDrive.Name, "on", strComputer, "has", _
objDiskDrive.FreeMegabytes & "MB (" & objDiskDrive.PercentFreeSpace & "%) Free"
Next
Else
oFile.WriteLine "Could not connect to " & strComputer
End If
Next
Else
WScript.Echo "Could not open text file."
End If
|
![]() |
| Viewing: ASP Free Forums > System Administration > Windows Scripting > WMI - Need a script to monitor servers disk free space remotely |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|