NetXMS Support Forum

English Support => General Support => Topic started by: DanG on December 29, 2011, 04:53:11 PM

Title: Schedule starting at a specific date/time
Post by: DanG on December 29, 2011, 04:53:11 PM
Hi,

I'm trying to set a website monitoring where the content changes at a specific date/time.
Otherwise said, I need to stop monitoring the current content at some moment and the start monitoring other content from that moment forwards.

What would be the most efficient way to achieve this?

I was thinking of creating two DCI's and set them when they should start/stop monitoring, can the cron syntax of the custom Schedule property of a DCI handle this?
Otherwise scripting will surly get things done, but is it really needed?

Regards,

Dan
Title: Re: Schedule starting at a specific date/time
Post by: Victor Kirhenshtein on December 30, 2011, 12:38:25 PM
Hi!

What is exact purpose of monitoring this web site? If you need to detect content changes on any time except allowed, you can just use "diff" threshold, and in event processing policy skip event generated by threshold if it occurs within valid content change time interval.

Best regards,
Victor
Title: Re: Schedule starting at a specific date/time
Post by: DanG on December 30, 2011, 02:27:01 PM
Hi Victor,

The content of this website changes at a specific date, I want the monitoring system to verify that the new content shows at that time.
If the test runs before the due date it will fail, so I need a way to start monitoring at a specific date/time.

Regards,

Dan
Title: Re: Schedule starting at a specific date/time
Post by: Victor Kirhenshtein on January 02, 2012, 12:21:35 PM
Hi!

If you are not interested in checking that new content matches some exact text, but just to check for fact of change, then my proposed solution with diff thresholds will work. However, if you have to check that new content is available and matching some specific text/regexp, you have to create new DCI for each upcoming content change, and use advanced scheduling to execute it at specific time. With advanced scheduling, you will be able to execute the check at exact time or in given short interval. You can also use Java or C API to automate DCI creation if you have some external application which knows what the content will be.

Best regards,
Victor
Title: Re: Schedule starting at a specific date/time
Post by: DanG on January 03, 2012, 11:21:29 AM
Hi Victor,
I'm afraid it doesn't solve my problem. Having a one shot to test the website is not good enough, I need to test that page every minute starting on a specific date. To my best knowledge cron does not offer this functionality.

I ended up adding a DCI Transformation Script to filter the event for a given date range:

sub main()
{
if(
        localtime(time())->year == 2012
       
     && localtime(time())->mon >= 0
     && localtime(time())->mday >= 1
     
     && localtime(time())->mon <= 0
     && localtime(time())->mday =< 15
  )
  {
   return $1;
  }

  return 0;
}

In this example for all tests within 1st and 15th of January 2012 the real result is returned ($1).
For anything outside that period, success (=0) is always returned disregarding the actual result.
Alternatively I could have added something similar to the Filtering Script of the Event Processing Policy, however that would require me to create a new Event and Processing Policy for each date rage I want to test on. Using the Transformation Script  for Filtering may be misusing it, but it does the job. I guess that adding a Filtering Script feature before the Transformation Script is an overkill.

Regards,

Dan
Title: Re: Schedule starting at a specific date/time
Post by: Victor Kirhenshtein on January 03, 2012, 02:43:16 PM
Hi!

Yes, the main problem with advanced schedule is that you cannot specify year in schedule. Otherwise within a year you can create very flexible schedules - don't forget that you can specify more than one schedule for DCI. For example, monitoring from 15.01 9:00 till 10.03 14:59 can be defined as follows:

* 9-23 15 1 *
* * 16-31 1 *
* * * 2 *
* * 1-9 3 *
* 0-14 10 3 *

1 - covers period 15.01 9:00 - 23:59
2 - covers period 16.01 00:00 - 31.01 23:59
3 - covers entire February
4 - covers period 01.03 00:00 - 09.03 23:59
5 - covers period 10.03 00:00 - 10.03 14:59

And I don't think that using transformation script here is a misuse - it is what they was intended for.

Best regards,
Victor
Title: Re: Schedule starting at a specific date/time
Post by: DanG on January 03, 2012, 03:43:35 PM
Hi Victor,

Thanks for the example. Although it surly works I find it to be too error-prone, at least for me it is :-)
I'm glad I'm not misusing anything, so I'll stick to my script ;-)

Regards,

Dan