Check all HD volumes for free space (variable threshold)

If you have information, script, utility, or idea that can be useful for HostMonitor community, you welcome to share information in this forum.
Paul_NHS
Posts: 59
Joined: Wed Feb 25, 2009 6:17 am

Post by Paul_NHS »

Yes, it would be good if it was a core disk test - it's one of the first tests I added.

I really like the ability to add additional tests and get a bit of user driven development. I also like the way the KS boys take notice and fix things.

cheers, Paul
davephan
Posts: 14
Joined: Fri Oct 19, 2007 1:53 pm

Post by davephan »

Paul_NHS wrote:GreyHat64, I liked your script so much I thought we should have a more flexible version.
I have added the ability to supply drive specific sizes on the command line.

Usage: CSCRIPT HDFree.VBS {computer_name} {[drive:]threshold [[drive:]threshold] [.....]}

e.g. CSCRIPT HDFree.VBS Mycomp C:2 D:20%% 10%%
The final free space parameter sets the default for unspecified drives.

p.s. It is worth mentioning the mechanism for running this script.
  1. Select the "Shell Script" test method.
  2. Click on the "Script Manager" icon.
  3. Select "New" for a new script.
  4. Name the script appropriately.
  5. Check the "Start Command" is set to: cmd /c cscript /B /E:VBScript %Script% %Params%
  6. Copy and paste the VBS file into the script box.
  7. Add a hint, e.g. {computer_name} {[drive:]threshold [[drive:]threshold] [.....]}
Now you can select the script from the HostMonitor dropdown and specify the parameters.
Note: You also don't require 2 percent signs in the parameters, one works nicely. e.g. Mycomp C:5% D:10% 20%

If you use this "Shell Script" method and you run a lot of these tests, check the potential problem discussed in the post where the code is shown below.

cheers, Paul

Code: Select all

Please see lower down on this page for the latest code.
I don't follow how to implement the test on the last step. Could you tell me more specifically how I would implement the free diskspace percentage? I would like to setup a 10% threshold for the C, D, E, R, and S drives.

Dave
KS-Soft
Posts: 12869
Joined: Wed Apr 03, 2002 6:00 pm
Location: USA
Contact:

Post by KS-Soft »

As I understand you should specify the following parameters
computername C:.1 D:.1 E:.1 R:.1 S:.1

Regards
Alex
Paul_NHS
Posts: 59
Joined: Wed Feb 25, 2009 6:17 am

Post by Paul_NHS »

It depends on what drives you have and which ones you want to check.
If you only have drives C, D, E, R, and S, then you only need to specify the threshold once.
computername 10%
if you have other drives that you don't want to check you can just specify individual drives as Alex has mentioned.
If you have other drives and want to set a different threshold for only C: & D: you can specify those drives and then a global threshold.
computername C:10% D:15% 20%

Note: you can either specify a number which tests for a specific size in GB, or a % of disk space. There is no requirement to use double % signs.

cheers, Paul
Paul_NHS
Posts: 59
Joined: Wed Feb 25, 2009 6:17 am

Post by Paul_NHS »

Latest version, hot off the presses.

We have a new Exchange box and it uses Mount Points for the database disks. This requires the use of Win32_Volume, but this is not supported in XP. The test for compatability (line 183) is ugly so all suggestions welcome on a nice way to do this.

Unfortunately I have not added the ability to specify a specific threshold for mount points, or a test for specific MPs, but you can probably work around that by specifying a threshold for the real disks and use a default for the MPs.

Return values for MPs include colons and trailing slashes so I've replaced ":\" with "-" and added a trailing colon to satisfy HostMonitor.

cheers, Paul
chhm
Posts: 7
Joined: Tue Jun 05, 2012 8:47 am

Post by chhm »

jivetolkein wrote: Anyway, my main point of posting is - who thinks this should now move to a feature request? Move Paul/greyhats work into an official HM test? I like scripts, but I think this is core requirement for most Windows shops, that perhaps people are missing if they don't follow the forums, and maybe discounting the product without investigating thoroughly enough.
I would LOVE this to be added to host monitor. We are starting to use mount points and need to monitor the volume name a certain servers. Hope I can figure out how to do this until then :)
chhm
Posts: 7
Joined: Tue Jun 05, 2012 8:47 am

Error: Script Returns no Results

Post by chhm »

Hi -

I set up this scrtip in HM using Shell Script. If I plug in the Params under the "Lets try" tab it runs and returns a Status and Reply (e.g - Status: Ok
- Reply: C:46%(7.79) ) Though when the Params are set in "Test properties" and test is ran I receive the following:

Status: Unknown
Reply: Error: Script Returns no Results

Thoughts?

Thanks!
KS-Soft
Posts: 12869
Joined: Wed Apr 03, 2002 6:00 pm
Location: USA
Contact:

Post by KS-Soft »

Windows version?
Service Pack?
HostMonitor version?
What exactly command line do you use to start the script?

Regards
Alex
chhm
Posts: 7
Joined: Tue Jun 05, 2012 8:47 am

Post by chhm »

KS-Soft wrote:Windows version?
Service Pack?
HostMonitor version?
What exactly command line do you use to start the script?
Windows Server 2003
SP 2
HM v 9.18
cmd /c cscript /B /E:VBScript %Script% %Params%
KS-Soft
Posts: 12869
Joined: Wed Apr 03, 2002 6:00 pm
Location: USA
Contact:

Post by KS-Soft »

We can start it just fine on Windows 2003 SP2.
Try to save script into .VBS file and start it without /B switch, cscript will display error message...

Note: start script on HostMonitor system
(in case you are managing HostMonitor remotely using RCC)

Regards
Alex
chhm
Posts: 7
Joined: Tue Jun 05, 2012 8:47 am

Post by chhm »

KS-Soft wrote:We can start it just fine on Windows 2003 SP2.
Try to save script into .VBS file and start it without /B switch, cscript will display error message...

Note: start script on HostMonitor system
(in case you are managing HostMonitor remotely using RCC)

Regards
Alex
I'm not sure I understand what you mean "cscript will display error message... ". Should I be using Shell script for a test method? Excuse my ignorance, I'm not much of a scripting person.
KS-Soft
Posts: 12869
Joined: Wed Apr 03, 2002 6:00 pm
Location: USA
Contact:

Post by KS-Soft »

Yes, you should use Shell Script test for the test.
But you said it does not work on your system. And you do not know the reason why it does not work. This means you should debug the problem, e.g. you may start script using command line without /B switch

Regards
Alex
chhm
Posts: 7
Joined: Tue Jun 05, 2012 8:47 am

Post by chhm »

Looks like line 101 character 1 is the issue:

WScript.StdOut.Write HDFreeTest(sCompStatus, aThreshold)
KS-Soft Europe
Posts: 2832
Joined: Tue May 16, 2006 4:41 am
Contact:

Post by KS-Soft Europe »

What command line did you use to start script from cmd shell ?
What exactly error message did you get ?
chhm
Posts: 7
Joined: Tue Jun 05, 2012 8:47 am

Post by chhm »

I'm giving up on this method and am working on using WMI. Thanks for the help.
Post Reply