Some customers have asked to be alerted when certain criteria are met in the Argos database. This article shows how to utilize SQL Database Mail to create alert scripts for the following scenarios:
- Users have pending activity records for more than four days
- Activity has not been recorded for a device for more than four days
Additional alert scripts can be provided as a professional service through Sepialine Support. Contact us for more details.
This article assumes basic familiarity with SQL Management Studio and your email server. If you are unfamiliar with Database Mail, consult Microsoft's SQL Server Books Online for more information. |
Set up Database Mail
Argos alerts are generated through SQL Server's Database Mail component. Database Mail is not enabled in SQL Express, so you must be using the full version of SQL 2012 or 2014.
You will need to create a Database Mail profile if one does not already exist.
- Open SQL Management Studio, connect to your SQL instance and browse to Management>Database Mail.
- Right-click and choose "Configure Database Mail"
- Click "Next"
- Choose "Set up Database Mail by performing the following tasks" and click "Next"
- Create a profile with the name "ArgosAlerts"
- Click "Add" under "SMTP Accounts"
- Click "New Account"
- Enter "ArgosAlerts" as the Account Name
- Use a valid email address to send accounts (we recommend creating "ArgosAlerts@yourcompany.com"
- Set Display name as "Argos Alerts"
- Enter mail server name in "Server name" field
- Set SMTP Authetntication settings as required by your mail server
- Click "OK"
- Click "Next"
- Select your Profile Name from the Public Profiles list and click "Next"
- Review the System Parameters and change as desired (we recommend changing Account Retry Attempts from 1 to 2)
- Click "Next"
- Click "Finish"
- Click "Close"
- Send a test email to verify that the system is functioning. Right-click Management>Database mail and choose "Send Test Email"
- Verify that you receive the test email
Set Argos Administrator email address
the Alert scripts send an email to the Argos administrator as defined in the Argos Manager. If this should be sent to multiple users, we recommend creating an email distribution address in your mail server and adding the desired recipients in there.
- Click Settings>General
- Enter email address in Administrator email field
- Click "OK"
Download Alert Scripts
Alerts are stored in a separate database. Use the following scripts to create the database and generate the alert emails. Save these files to C:\Argos7Installers\Alerts.
Create Argos7Alerts Database
- Open SQL Management Studio and connect to the server/instance that contains your Argos database
- Log in using an account that has rights to create databases
- Open CreateAlertDatabase.sql
- Click "Execute". This will create a new database within your SQL Server instance called "Argos7Alerts", and generate two tables within that database - "UnbilledJobs" and "IdleDevices"
Create Unbilled Users script
The Unbilled Users script will send an email alert when any user has pending activity that has not been billed for more than four days.
- Open SQL Management Studio and connect to the server/instance that contains your Argos database
- Open UnbilledUsers.sql
- Click "Execute"
Create Idle Devices script
The Idle Devices script will send an email alert when any device has not had activity for more than four days.
- Open SQL Management Studio and connect to the server/instance that contains your Argos database
- Open IdleDevices.sql
- Click "Execute"
To change the number of days in either script, look for set @WAITDAYS = 4; in the script and change accordingly. |
Create a SQL Agent task to automate the alert generation
The final step is to create tasks that will generate the email alerts on a schedule.
Enable SQL Server Agent
The SQL Server Agent is not started by default. You must enable it to run scheduled tasks.
- Click Start>Run and type Services.msc
- Locate the SQL Server Agent service for your SQL instance
- Double-click and change the Startup Type to "Automatic"
- Change the Service status to "Started"
- Click OK and close Services
Create a SQL Agent job
- Open SQL Management Studio and right-click on SQL Server Agent>Jobs
- Choose "New Job..."
- Name the job "Idle Devices"
- Click "Steps" from the left hand menu
- Click "New"
- Name the step "Run Script"
- Set Type to "Transact-SQL script (T-SQL)
- Set Database to Argos7Alerts
- Click "Open..." and locate IdleDevices.sql. This will populate the command screen with the SQL script
- Click OK
- Click Schedules
- Click New
- Enter a name, such as "Daily"
- Change "Frequency" to "Daily"
- Choose a time that does not interfere with mail server maintenance and SQL backup schedules
- Click OK
- Note that the Daily schedule is selected. Multiple schedules can be defined if desired
- Click OK and to exit the SQL job settings
Repeat the above steps to create the Unbilled Users job, using UnbilledUsers.sql. |
0 Comments