//-----------------------------------------------------------------------------
// File    : DiskSpaces.JS
// Purpose : Sample script test for Advanced Host Monitor
// Comment : Checks difference between free disk space on drive C: and drive D: 
//           Sets status to "Bad" when drive C: has less amount of free space 
//           than drive D:
// Language: JScript
// Version : 1.0
// Author  : KS-Soft (www.ks-soft.net)
//-----------------------------------------------------------------------------

statusAlive       = "Host is alive:"
statusDead        = "No answer:"
statusUnknown     = "Unknown:"
statusNotResolved = "Unknown host:"
statusOk          = "Ok:"
statusBad         = "Bad:"
statusBadContents = "Bad contents:"

//---- entry point ----

function performtest()
{
  var deltaspace;
  deltaspace = availablespace("C:\\") - availablespace("D:\\");
  if (deltaspace >= 0)
     return(statusOk + deltaspace/1024 + " K");
  else
     return(statusBad + deltaspace/1024 + " K");
}

//----- functions -----

function availablespace(drvPath)
{
  var fso, d;
  fso = new ActiveXObject("Scripting.FileSystemObject");
  d = fso.GetDrive(fso.GetDriveName(drvPath));
  return(d.AvailableSpace);
}
