cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Alert script - run script .bat when an alert is raised

emanuele_longo
Participant

Hello,


I need to run a script when an alert is raised.

Below my steps:

- created script .bat (insert in CAS folder);

- add my script on "Recipients" (tab "script") on Alert management;

- add script on a specific alert (in alert management....type "Real User Performance (probe)");

- enabled notification on script in alert configured;

Unfortunately the script do not run.

Why?

How can I troubleshooting?

Have anyone any suggestion?

Regards

6 REPLIES 6

luke_boyling
Dynatrace Pro
Dynatrace Pro

Here are few starting points to go about troubleshooting alerts:

* In the CAS logs folder, the server.log files contain entries for each time when the CAS evaluates an alert rule - search for "detection finished for METRIC_ALM_1####", to confirm that your alert rule is being evaluated to begin with

* Next, you should look in the Alerts explorer to check whether there
have been any alert events generated as a result of the alert conditions being met - you can filter by alert type
and recipient to see if there are alerts and whether the script should
have been called.

* If this is all good, the CAS should write information to the scriptExecution.log whenever it attempts to run a script. It should include what the command line parameters are, and what the result of the script is. You may be able to see if there's a problem with your command line or the .bat file itself.

Hopefully, this can help you narrow down where the problem might be.

emanuele_longo
Participant

Hello Luke.

Thanks for your suggestions.

So I cannot find the scriptExecution.log in CAS.

Where I find it?

Regards

All the CAS logs are stored in the log folder inside the main CAS folder (by default, C:\Program Files\Dynatrace\CAS\log\). The scriptExecution.log is only created if required, so if it's not present in the logs folder, then it indicates that there's possibly a problem with triggering the alert to begin with (it never gets to the point of running the script).

If you're just testing things out at this stage, you may want to configure a new alert that will always trigger on every interval (a condition of Total bytes > 0 should always be met :)). Then you could set yourself up as an email recipient in addition to adding the script recipient. That way, if you *do* get an email but the script doesn't run, then the problem is likely in how you configured the script recipient in the RUM Console.

If you still get stuck, then you should probably raise a ticket with Dynatrace Support, who can assist further.

dariusz_kalita
Dynatrace Helper
Dynatrace Helper

Hello Ema,

In my opinion if there's nothing obvious that is written into a log file - we'll need a support ticket to troubleshoot it.

Kind regards,

Darek

emanuele_longo
Participant

Hello guys,

Now I have the error "Timeout" in scriptExecution.log when script start.

Why?

If I run manually my script, the execution during 1s.

Any suggestions?

Regards

See comments with crucial info on how to call (powershell) script with parameters, here:

https://answers.dynatrace.com/questions/191051/scr...