Test Registry-Key with WMI-Test

All questions related to installations, configurations and maintenance of Advanced Host Monitor (including additional tools such as RMA for Windows, RMA Manager, Web Servie, RCC).
Post Reply
Seitter
Posts: 27
Joined: Wed Jan 08, 2003 6:00 pm

Test Registry-Key with WMI-Test

Post by Seitter »

I want to test the content of a registry-key,
the key is: HKEY_LOCAL_MACHINE\SOFTWARE\Network Associates\ePolicy Orchestrator\Application Plugins\VIRUSCAN8600
the name is datdate
the content is a date value like 08/10/2007
the typ is : REG_SZ

The Test is bad when the value is older then 4 days

Is there a way to do this with Hostmonitor

Regards
Wolfgang
KS-Soft Europe
Posts: 2832
Joined: Tue May 16, 2006 4:41 am
Contact:

Post by KS-Soft Europe »

You may copy the following script into into some file with .js extension (e.g. read_reg_data.js) and use it with "Active Script" test method:

Code: Select all

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

AlertThreshold = 4;
Datekey = "HKLM\\Software\\Network Associates\\ePolicy Orchestrator\\Application Plugins\\VIRUSCAN8600\\datdate"

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

function performtest()
{
  var WshShell, KeyStr;
  var CurrDate = new Date();

 
  WshShell = new ActiveXObject ("WScript.Shell");
  KeyStr = WshShell.RegRead(Datekey);
  
  var Month = KeyStr.substr(0,2);
  var Day = KeyStr.substr(3,2);
  var Year = KeyStr.substr(6,4);
  var CheckDate = new Date(Year,--Month,Day);

  if (compareDate(CurrDate,CheckDate) > AlertThreshold) return (statusBad+KeyStr); else return (statusOk+KeyStr);
}

function compareDate(d1,d2) {
 return (d1-d2)/86400000;
}
Note 1: Script is designed for "Active Script" test method: http://www.ks-soft.net/hostmon.eng/mfra ... htm#script
Note 2: Expected date format is mm/dd/yyyy (i.e. 08/10/2007)
Note 3: You have to select "JScript" from "Language" input box in "Test Properties" window of "Active script" test to make it work.

Regards,
Max
Post Reply