Active IQ Unified Manager Discussions

Unified Manager 9.4 and json file creation

Pat_Parent

Hi folks,

 

I need to send a json file when an alert occur. Is there a way of doing the json file automatically ?

if i need to do it with a script, is there a way to send it with a utility....

 

Thank you

 

2 REPLIES 2

Re: Unified Manager 9.4 and json file creation

GidonMarcus

Hi

 

Assuming your OCUM is Windows based. you can use the PS i published in the following link to consume the parameters:

 

 

 

#create hashtable, Get rid of chars that break the script, append any word that start with " -" to a hashtable index with the input following it until the next " -" as a value.
$parms=@{};" "+($args -replace "\]|\[|@"," " -join " ") -split " -"|?{$_}|%{$t=$_ -split " ",2;$parms.($t[0])=$t[1]}

#run on $parms.eventArgs and append the first word before a "=" as a eventArgs_* index, and as the value any words after it  - until the next word that come before "=".
($parms.eventArgs -split " "|%{if($_ -match "="){".cut."}$_}) -join " " -split ".cut. "|?{$_}|%{$t=$_ -split "=";$parms.("eventArgs_"+$t[0])=$t[1]}  

and use the following command to save it to a json:

 

 

$parms | ConvertTo-Json | Out-File "C:\temp\$($parms.EventID).json"

 

Gidi

 

Gidi Marcus (Linkedin) - Storage and Microsoft technologies consultant - Hydro IT LTD - UK

Re: Unified Manager 9.4 and json file creation

Pat_Parent

Nope, the appliance so in perl....  

 

#!/usr/bin/perl
#Pour initialiser les variables et assurer un standard
use warnings;
use strict;
use POSIX;
use JSON.pm;

my $Notification = "Yes";
my $Ticket = "Yes";
my $Status = $ARGV[13];
my $Category = $ARGV[5];
my $Time = localtime(time);
my $Timezone = strftime("%Z", localtime());
my $AlertName = $ARGV[3];
my $AlertDesc = $ARGV[15];
my $SysOrigin = $ARGV[9];

my %file_json = ('Need_Notification' => $Notification, 'Need_Ticket'=> $Ticket, 'Status' => $Status, 'Alert_Category' => $Category, 'AlertTime' => $Time, 'AlertTime_TimeZone' => $Timezone, 'Alert_Name' => $AlertName, 'Alert_Description' => $AlertDesc, 'System_Origin' => $SysOrigin);

my $json = encode_json \%file_json;

print $json;

Earn Rewards for Your Review!
GPI Review Banner
All Community Forums
Public