Simple reminder 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
User avatar
Bobzbobz
Posts: 30
Joined: Tue Nov 30, 2010 4:01 am
Location: Denmark

Simple reminder test

Post by Bobzbobz »

Hello

Is it possible to create a simple "reminder test" based on a specific date, which then alerts when X days until a date is reached.

I am using a license server to apply educational licenses to our Autodesk-products. These licenses only last 1 year and then need renewal. The licenses are specified in a .txt-file.

I would like to create a test where I can specify the renewal-date and then have it come out with "bad status" when there are 30 days left.
KS-Soft
Posts: 13012
Joined: Wed Apr 03, 2002 6:00 pm
Location: USA
Contact:

Post by KS-Soft »

I see several options

1) If your system date format looks like YYYY-MM-DD, you may set any test with static good result (e.g. Ping localhost) with the following option
- Use Warning status if "%Date%">"2021-05-01"

2) You may use Schell Script test method and create simple script that will check system date (e.g. VBScript, JavaScript or PowerShell)

3) Create any file, set modification timestamp to May 02, 2021, set File/Folder Availablity test using the following option
- Alert when file does not exist or older then 1 min

Option #2 is the most reliable, it will work if system date format changes, it will not fail if someone opens file in text editor and clicks File->Save

Regards
Alex
User avatar
Bobzbobz
Posts: 30
Joined: Tue Nov 30, 2010 4:01 am
Location: Denmark

Post by Bobzbobz »

Thank you for the quick reply :)

Should this work?
I get "Error: Invalid Result"

Code: Select all

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

$CurDate = Get-Date -Format "dd-MM-yyyy"

if ($args[0]>$CurDate) 
{
  echo  $statusBad"$CurDate" 
  exit
}
else
{
  echo  $statusOk
  exit
}
KS-Soft
Posts: 13012
Joined: Wed Apr 03, 2002 6:00 pm
Location: USA
Contact:

Post by KS-Soft »

Get-Date -Format "dd-MM-yyyy" returns a string, not a date.
(Get-Date returns date)
So if you want to compare strings then use different format
Get-Date -Format "yyyy-MM-dd"

Also, check list of comparison operators
https://docs.microsoft.com/en-us/powers ... wershell-7

Code: Select all

$statusUnknown     = "ScriptRes:Unknown:"
$statusOk          = "ScriptRes:Ok:"
$statusBad         = "ScriptRes:Bad:"

if (!$args[0]) {
  echo  $statusUnknown"Date (YYYY-MM-DD) parameter is not specified"
  exit
}

$CurDate = Get-Date -Format "yyyy-MM-dd"
if ($args[0] -gt $CurDate)
{
  echo  $statusBad"$CurDate"
}
else
{
  echo  $statusOk
}
Regards
Alex
User avatar
Bobzbobz
Posts: 30
Joined: Tue Nov 30, 2010 4:01 am
Location: Denmark

Post by Bobzbobz »

Thank you.
Post Reply