Windows Scripting
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsSystem AdministrationWindows Scripting

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old June 22nd, 2007, 10:22 AM
vishal saini vishal saini is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jun 2007
Posts: 2 vishal saini User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 m 43 sec
Reputation Power: 0
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

Reply With Quote
  #2  
Old June 22nd, 2007, 05:06 PM
mehere's Avatar
mehere mehere is offline
Senior Sarcasm Wizardess
Click here for more information.
 
Join Date: Feb 2005
Location: Dreamland
Posts: 12,867 mehere User rank is General 12nd Grade (Above 100000 Reputation Level)mehere User rank is General 12nd Grade (Above 100000 Reputation Level)mehere User rank is General 12nd Grade (Above 100000 Reputation Level)mehere User rank is General 12nd Grade (Above 100000 Reputation Level)mehere User rank is General 12nd Grade (Above 100000 Reputation Level)mehere User rank is General 12nd Grade (Above 100000 Reputation Level)mehere User rank is General 12nd Grade (Above 100000 Reputation Level)mehere User rank is General 12nd Grade (Above 100000 Reputation Level)mehere User rank is General 12nd Grade (Above 100000 Reputation Level)mehere User rank is General 12nd Grade (Above 100000 Reputation Level)mehere User rank is General 12nd Grade (Above 100000 Reputation Level)mehere User rank is General 12nd Grade (Above 100000 Reputation Level)mehere User rank is General 12nd Grade (Above 100000 Reputation Level)mehere User rank is General 12nd Grade (Above 100000 Reputation Level)mehere User rank is General 12nd Grade (Above 100000 Reputation Level)mehere User rank is General 12nd Grade (Above 100000 Reputation Level)  Folding Points: 10976 Folding Title: Novice Folder
Time spent in forums: 4 Months 4 Weeks 15 h 20 m 54 sec
Reputation Power: 1762
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

Reply With Quote
  #3  
Old June 23rd, 2007, 11:55 PM
Nilpo's Avatar
Nilpo Nilpo is offline
ASP Free Beginner (1000 - 1499 posts)
 
Join Date: Jun 2006
Location: Salem, OH
Posts: 1,048 Nilpo User rank is Colonel (50000 - 60000 Reputation Level)Nilpo User rank is Colonel (50000 - 60000 Reputation Level)Nilpo User rank is Colonel (50000 - 60000 Reputation Level)Nilpo User rank is Colonel (50000 - 60000 Reputation Level)Nilpo User rank is Colonel (50000 - 60000 Reputation Level)Nilpo User rank is Colonel (50000 - 60000 Reputation Level)Nilpo User rank is Colonel (50000 - 60000 Reputation Level)Nilpo User rank is Colonel (50000 - 60000 Reputation Level)Nilpo User rank is Colonel (50000 - 60000 Reputation Level)Nilpo User rank is Colonel (50000 - 60000 Reputation Level)Nilpo User rank is Colonel (50000 - 60000 Reputation Level)Nilpo User rank is Colonel (50000 - 60000 Reputation Level)  Folding Points: 206875 Folding Title: Super Ultimate Folder - Level 1Folding Points: 206875 Folding Title: Super Ultimate Folder - Level 1Folding Points: 206875 Folding Title: Super Ultimate Folder - Level 1Folding Points: 206875 Folding Title: Super Ultimate Folder - Level 1Folding Points: 206875 Folding Title: Super Ultimate Folder - Level 1Folding Points: 206875 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 5 Days 12 h 32 m 33 sec
Reputation Power: 555
Send a message via ICQ to Nilpo Send a message via AIM to Nilpo Send a message via MSN to Nilpo Send a message via Yahoo to Nilpo Send a message via Google Talk to Nilpo Send a message via Skype to Nilpo
MySpace
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!


Reply With Quote
  #4  
Old June 24th, 2007, 04:03 AM
Nilpo's Avatar
Nilpo Nilpo is offline
ASP Free Beginner (1000 - 1499 posts)
 
Join Date: Jun 2006
Location: Salem, OH
Posts: 1,048 Nilpo User rank is Colonel (50000 - 60000 Reputation Level)Nilpo User rank is Colonel (50000 - 60000 Reputation Level)Nilpo User rank is Colonel (50000 - 60000 Reputation Level)Nilpo User rank is Colonel (50000 - 60000 Reputation Level)Nilpo User rank is Colonel (50000 - 60000 Reputation Level)Nilpo User rank is Colonel (50000 - 60000 Reputation Level)Nilpo User rank is Colonel (50000 - 60000 Reputation Level)Nilpo User rank is Colonel (50000 - 60000 Reputation Level)Nilpo User rank is Colonel (50000 - 60000 Reputation Level)Nilpo User rank is Colonel (50000 - 60000 Reputation Level)Nilpo User rank is Colonel (50000 - 60000 Reputation Level)Nilpo User rank is Colonel (50000 - 60000 Reputation Level)  Folding Points: 206875 Folding Title: Super Ultimate Folder - Level 1Folding Points: 206875 Folding Title: Super Ultimate Folder - Level 1Folding Points: 206875 Folding Title: Super Ultimate Folder - Level 1Folding Points: 206875 Folding Title: Super Ultimate Folder - Level 1Folding Points: 206875 Folding Title: Super Ultimate Folder - Level 1Folding Points: 206875 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 5 Days 12 h 32 m 33 sec
Reputation Power: 555
Send a message via ICQ to Nilpo Send a message via AIM to Nilpo Send a message via MSN to Nilpo Send a message via Yahoo to Nilpo Send a message via Google Talk to Nilpo Send a message via Skype to Nilpo
MySpace
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.

Reply With Quote
  #5  
Old June 25th, 2007, 09:06 AM
vishal saini vishal saini is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jun 2007
Posts: 2 vishal saini User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 m 43 sec
Reputation Power: 0
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

Reply With Quote
  #6  
Old June 25th, 2007, 09:32 AM
Nilpo's Avatar
Nilpo Nilpo is offline
ASP Free Beginner (1000 - 1499 posts)
 
Join Date: Jun 2006
Location: Salem, OH
Posts: 1,048 Nilpo User rank is Colonel (50000 - 60000 Reputation Level)Nilpo User rank is Colonel (50000 - 60000 Reputation Level)Nilpo User rank is Colonel (50000 - 60000 Reputation Level)Nilpo User rank is Colonel (50000 - 60000 Reputation Level)Nilpo User rank is Colonel (50000 - 60000 Reputation Level)Nilpo User rank is Colonel (50000 - 60000 Reputation Level)Nilpo User rank is Colonel (50000 - 60000 Reputation Level)Nilpo User rank is Colonel (50000 - 60000 Reputation Level)Nilpo User rank is Colonel (50000 - 60000 Reputation Level)Nilpo User rank is Colonel (50000 - 60000 Reputation Level)Nilpo User rank is Colonel (50000 - 60000 Reputation Level)Nilpo User rank is Colonel (50000 - 60000 Reputation Level)  Folding Points: 206875 Folding Title: Super Ultimate Folder - Level 1Folding Points: 206875 Folding Title: Super Ultimate Folder - Level 1Folding Points: 206875 Folding Title: Super Ultimate Folder - Level 1Folding Points: 206875 Folding Title: Super Ultimate Folder - Level 1Folding Points: 206875 Folding Title: Super Ultimate Folder - Level 1Folding Points: 206875 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 5 Days 12 h 32 m 33 sec
Reputation Power: 555
Send a message via ICQ to Nilpo Send a message via AIM to Nilpo Send a message via MSN to Nilpo Send a message via Yahoo to Nilpo Send a message via Google Talk to Nilpo Send a message via Skype to Nilpo
MySpace
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

Reply With Quote
Reply

Viewing: ASP Free ForumsSystem AdministrationWindows Scripting > WMI - Need a script to monitor servers disk free space remotely


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
Stay green...Green IT