2- Open the Zip file in Windows explorer and copy the QlikAlert folder directly in your C:\ root. Resulting path should be C:\QlikAlert\ with 2 files in it.
3- Open the sendemail.ps1 file using a text editor or PowerShell editor. (right click -> Edit should open in PowerShell Editor)
4- Modify the file with the email server & user name & recipient information based on the server that you would like to use. And SAVE the file.
If you are planning to use GMAIL to send emails, make sure to turn ON "Access for less secure apps" option on your account to enable SMTP access. This is described in the INFO section at the bottom of this page.
At a minimum, you have to modify items 1,2,6 & 7 if you are using GMAIL for sending emails.(for GMAIL, user name is your gmail address)
If you are not using GMAIL, items 3,4 & 5 should also be modified to match your email server settings.
5- Start windows Task Scheduler from Control Panel --> Administrative Tools section or Just search for "Scheduler" in the programs menu.
6- Right Click on Task Scheduler Library, choose Import Task and pick the QlikSense Services Stopped.xml file located in C:\QlikAlert\ folder.
7- Click OK and enter an admin user name and password to accept the changes.
8- You are done! To test it:
Testing service shutdown alert: Just go in to services and shut down any of the QlikSense services. You should receive an email in less than a minute!
Testing service failure alert: Open windows task manager and END one of the qliksense executables such as Engine.exe.
How does it work?
Idea is very simple. Every time an application fails such as any of the QlikSense services, it is logged in to windows event logs with a new entry. Windows also has a automated task processing system called Windows Task Scheduler which can be setup to execute commands based on a time schedule or based on specific event(s) that happen on the computer. Luckly new Operating systems also have PowerShell which you can program many tasks much like a batch command file on steroids.
If we tie all these three standard windows features together, we can have an active email alert system that can alert us when one of the QlikSense Services fail for any reason. So if we purposely fail a qliksense service such as Engine Service by stopping the Engine.exe from task manager, windows will automatically log that in to window event logs under Windows Logs\System\ area as an Error and will assign a EventID 7031. Now all we have to do is to use this event which detects a failure error for sense service to trigger a windows scheduler task that executes a PowerShell Script that is designed to send an email.
If you look at the properties of the "QlikSense Services Stopped" task that was created via importing the xml file:
You will see two triggers setup in the triggers tab which are designed to fire up the script that sends the emails. One trigger is for detecting crashes & errors for services and another for detecting normal shutdown events.
**Update: Added a new 3rd trigger for detecting services not starting due to user credentials such as expired/changed passwords.
And in the Actions tab, there is a single action configured which is starting the PowerShell.exe with the parameters to execute the sendemail.ps1 script file.
This setup will automatically send the exact same email whenever it detects a failure or shutdown on any of the services. If you would like to receive separate email messages for failures vs. normal shutdowns, you can duplicate sendemail.ps1 file in the same directory and edit each ps1 file to have specific subject & body lines. (one for failures and another for normal shutdowns). Once done create two task events by importing the xml file twice and changing their names appropriately. Then edit each task by modifying the triggers tab to disable/remove the unwanted trigger and actions tabs to point to the matching .ps1 file with correct subject and body lines.
**** CHANGING GMAIL SECURITY SETTINGS TO ALLOW SMTP ****
If you are planning to use Gmail SMTP server to send emails then you need to follow these instructions to allow 3rd party apps to use your gmail account.