Submit a ticketCall us

Looking to compare latest NPM features with previous versions of NPM?
The NPM new feature summary offers a comparison of new features and improvements offered with this release.

 

Home > Success Center > Virtualization Manager (VMAN) > VMAN 7.1 Administrator Guide > References > External alert notification action reference

External alert notification action reference

Created by Caroline Juszczak, last modified by MindTouch on Jun 23, 2016

Views: 139 Votes: 0 Revisions: 3

This sample manifest file provides an example of an external action that you can automatically run when an alert is triggered.

For information about using alert notification actions, see Configure alert notifications.

Prerequisites

This script uses the Perl Client (Hyper9::Client) module. Download this module from the SolarWinds Customer Portal, and install it in your Perl path. For more information, see Use Perl SDK scripts.

Consult the Web Services Description Language (WSDL) of your system (http://your-server:8983/swvm/ws/hyper9.wsdl) for information about all you can do through the SOAP web services.

Configure an external alert notification action

  1. Save the manifest file to the data/content/externalActions folder of your server.
  2. Name it logAlert.manifest.
  3. When the file is saved, click Reload on the Select an External Action window.
  4. Select the action from the list.

    <?xml version="1.0" encoding="UTF-8"?>
    <manifest xmlns="http://www.hyper9.com/ws"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <enabled>true</enabled>
    <type>ALERT</type>
    <uniqueId>alert-test</uniqueId>
    <name>Log Alert Summary</name>
    <description>Logs a summary of this alert's firing details to a file</description>

    <command>perl</command>
    <command>$MANIFEST_HOME/logAlert.pl</command>
    <argumentPrefix>-</argumentPrefix>
    <successCode>0</successCode>
    <!--Optionally specify the directory to start from -->
    <!--<workingDirectory></workingDirectory>-->
    </manifest>

For this example, a script was customized to run as the command, called logAlert.pl. There are two command elements. Use a new element for every time you have whitespace in your arguments.

Save the following code in the same data/content/externalActions folder as logAlert.pl. Because it is saved in the same folder as the manifest, the $MANIFEST_HOME variable from the previous manifest is used to describe its path.

#!/usr/bin/perl
# Author: Ryan Kruse
#
# Description: Designed to be called through the Hyper9 external actions framework,
# this script simply uses the SOAP API to retrieve an Alert and log its values to a file
#
use strict;
use Hyper9::Client;
use Getopt::Long;

my $timestamp;
my $alertId;
my $loginToken;

get_args();

my $client = Hyper9::Client->new( host => 'localhost:8983', );
#$client->{services_path} = '/single-vm';
$client->loginWithToken( username => 'admin', token => $loginToken, ) || die "Login failed\n\n";
my $alert = $client->getWorkspaceAsset(assetId=>$alertId);
$client->logout();

my $status = ($alert->{raised} eq 'true') ? "RAISED" : "LOWERED";
open( LOG, ">>logAlert.log" );
print LOG $timestamp."\t".$alert->{name}."\t$status\t".$alert->{value}."\n";
close(LOG);

sub get_args
{
my $help;
GetOptions(
"timestamp:i" => \$timestamp,
"alertId:s" => \$alertId,
"loginToken:s" => \$loginToken,
"help" => \$help,
"h" => \$help,
);
usage() if ( $help || !($alertId) );
}

sub usage
{
print STDERR << "EOF";

usage: $0 -timestamp=1271186678 -alertId=404cb4f0-4732-11df-9879-0800200c9a66
-loginToken=62b796e0-4732-11df-9879-0800200c9a66

-timestamp : seconds since epoch
-alertId : hyper9 ID of the alert
-loginToken : a token that can be used to login to the hyper9 web service

EOF
exit;
}

These arguments are passed to all commands:

  • timestamp
    The time stamp of the alert firing instance. This can be used to retrieve more details of this alert.
  • alertId
    The ID of the alert. This can be used to retrieve more details of the alert.
  • loginToken
    A short-lived one-time use token that can be used to log in to the Hyper9 web service.
 
Last modified
04:20, 23 Jun 2016

Tags

Classifications

Public