article Creating Custom Alert Scripts in up.time Alert Profiles

Related Documentation Version of up.time affected Affected Platforms
All All

Article Contents


Overview

When a service outage occurs, up.time can generate an alert in a number of ways including sending an email, opening a Windows pop-up or initiating a pager message. You can also define your own Script Alert that will be executed on the monitoring station when an outage occurs. You can use the Script Alert option to create custom alerting methods that fit your exact needs. Some examples of custom alerting implementations include:

  • SMS modem-based alerting
  • TAPI modem alerting
  • Internal Problem Ticket creation system alerts
  • On call team rotation
  • Customized alert email body formatting


How custom alert scripts work

Custom alert scripts are defined with the Script Alert option on the Alert Profile page. The script is a path to a script or executable on the monitoring station system that up.time will run when a service outage occurs. You control the actions that the script or executable takes, which provides full control over how up.time sends out alert notifications during a service outage.

Note: For Windows alert scripts, the path used must use UNIX-style / instead of \ and must be quoted if your path contains spaces. For example:
"C:/Program Files/uptime software/uptime/scripts/my_custom_alerter.bat"


When up.time runs the script or executable, it passes on information about the specific service outage that triggered the alert. This information is passed using the system environment variables that are local to each execution of the recovery script. The script or executable is run once for each up.time user that will be notified using this alert.

The environment variables passed to the alert script and their meanings are included below:

Variable Description Example Contents
Service Message Fields - These will remain constant for each execution of your script associated with a single service outage.
UPTIME_ALERTTYPE This is the type of alert message One of: Problem, Recovery
UPTIME_HOSTNAME The name of the host that the service outage is associated with. oracle_server
UPTIME_HOSTSTATUS The status of the host that the service outage is associated with. One of: OK, WARN, CRIT, MAINT, UNKNOWN
UPTIME_MESSAGE The output section of the alert. Type: Problem
Service: db_status (CRIT/threshold error)
Host: oracle_db (OK)
UPTIME_SUBJECT The subject line that would normally appear in an emailed alert for this alert. Uptime Alert - UPTIME-oracle_server -> CRIT
UPTIME_SVCNAME The name of the service monitor generating this alert. UPTIME-oracle_server
UPTIME_SVCOUTPUT The output of the service monitor generating this alert. processoccurrences: 0 is less than 1
UPTIME_SVCSTATUS The current status of the service monitor generating this alert. One of: OK, WARN, CRIT, MAINT, UNKNOWN.
UPTIME_DATETIME The date and time of the alert. Mon May 15 11:12:22 EDT 2006
User related fields - these will change for each user that is passed to your script, the script will be executed once for each user that should be notified.
UPTIME_CONTACTLOGINNAME The login name of the user who is being notified. testuser
UPTIME_DESKTOPHOST The windows desktop hostname setting for the user being notified. testuser-pc
UPTIME_DESKTOPWORKGROUP The windows workgroup for the desktop host specified above. WORKGROUP
UPTIME_EMAIL The email address associated with the user who is being notified. [email protected]
UPTIME_MOBILE The pager number associated with the user being notified. [email protected]
General fields
UPTIME_SCRIPT The name of the current script being executed. C:/Program Files/uptime software/uptime4/scripts/my_custom_alerter.bat
UPTIME_SMTPHELOSTRING The HELO string used in your SMTP server configuration.
UPTIME_SMTPPASSWORD The password used from authentication in your SMTP server configuration.
UPTIME_SMTPPORT The server port used in your SMTP server configuration.
UPTIME_SMTPSENDER The sender address string used in your SMTP server configuration.
UPTIME_SMTPSERVER The server hostname used in your SMTP server configuration.
UPTIME_SMTPUSER The user name used for authentication in your SMTP server configuration.


Environment Variable Examples

How the script or executable uses environment variables will vary depending on the language you have used to write your script or executable. The following examples illustrate how environment variables are accessed in several common languages:

Language Common methods of accessing environment variables.
Perl

Use of the ENV array to access environment variables with Perl. For example:

#!/usr/bin/perl
my $user_email = $ENV{UPTIME_EMAIL};
my $user_mobile = $ENV{UPTIME_MOBILE};

PHP When run from the command line, use the getenv() function to access environment variables within PHP. For example:

«?php
$user_email = getenv('UPTIME_EMAIL');
$user_mobile = getenv('UPTIME_MOBILE');

Bash and Ksh Bash and Ksh enable you to access local environment variables just like any other local variable. For example:

#!/bin/bash
EMAIL=$UPTIME_EMAIL
MOBILE=$UPTIME_MOBILE

Batch File Add the % symbol around the names of environment variables in Windows batch files. For example:

echo %UPTIME_EMAIL%
echo %UPTIME_MOBILE%

VB Script Use the the oShell.Environment lookup function to access environment variables with VB Script. For example:

Dim email, mobile
Dim WshShell, objEnv

Set WshShell = CreateObject("WScript.Shell")

Set objEnv = WshShell.Environment("Process")

email = objEnv("UPTIME_EMAIL")
mobile = objEnv("UPTIME_MOBILE")

Related Articles


Playing a custom sound during an alert

RatingViews
article

up.time is not able to natively play a sound on the monitoring station or a target PC to indicate a service outage. Through a combination of custom scripts and the Script Alert option in an alert...

By: uptime Support | Date Created: 12-31-1969 | Last Modified: 8-10-2011 | Index: 303

  2888

How many characters are supported in a custom alert?

RatingViews
article

Both the subject and body are capped at 255 characters.

By: uptime Support | Date Created: 6-11-2010 | Last Modified: 12-3-2011 | Index: 448

  1979

Working with Custom Alert Formats

RatingViews
article

This article explains how to build custom alert formats within the up.time Web interface.

By: uptime Support | Date Created: 2-6-2007 | Last Modified: 6-30-2011 | Index: 139

  4678

Custom Alert Format Variables

RatingViews
article

This article explains the variables that you can use to create a custom alert format.

By: uptime Support | Date Created: 2-6-2007 | Last Modified: 6-30-2011 | Index: 138

  4888

Test Service Instance doesn't trigger action or alert profile

RatingViews
article

The Test Service Instance feature does not trigger action and alert profiles associated with the monitor by design.

By: uptime Support | Date Created: 12-31-1969 | Last Modified: 8-10-2011 | Index: 297

  2508

User Comments



No comments have been posted.

Copyright © 2021 IDERA, Inc.   Legal   Privacy Statement