Specifications
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;
}
The following arguments are passed to all commands:
175
Example Action