Server Management - Systems Insight Manager
1832910 Members
2806 Online
110048 Solutions
New Discussion

Script attached: Parsing $NOTICEPLAINTEXT and emailing it

 
Shane Shelton
New Member

Script attached: Parsing $NOTICEPLAINTEXT and emailing it

How to Parse the $NOTICEPLAINTEXT variable from HP SIM and email it

I struggled with this forever and finally broke down and wrote the perl script that does this. Basically just create a new custom tool that calls: C:\Perl\bin\perl.exe C:\hp\sim_alerts\parse.pl

Then set up your notifications to call the custom tool you just created. Next was the hard part, parse.pl. This file takes the $NOTICEPLAINTEXT env. variable from SIM Alerts and parses by pipe delimitation and put it in a friend format. The email portion of this is done with a free email program call blat (Thanks Ron Buxton) that is super easy to set on your SIM server and has no security risk.

Parse.pl
-------------------
#So you can use Environment variables
use Env;

#assigns NOTICEPLAINTEXT to info
$info = $NOTICEPLAINTEXT;

#Splits the NOTICEPLAINTEXT variable up by pipe delimitation and stores it in an array
@array = split('\|', $info);

#opens the email body up
open MAILDIST, '<>open MAILTMP, '> mailmajor.tmp';

#Prints the SIM event array in the message body (I've seen up to 15, so that's why I print 15 times)
print MAILTMP @array[0];
print MAILTMP "\n";
print MAILTMP @array[1];
print MAILTMP "\n";
print MAILTMP @array[2];
print MAILTMP "\n";
print MAILTMP @array[3];
print MAILTMP "\n";
print MAILTMP @array[4];
print MAILTMP "\n";
print MAILTMP @array[5];
print MAILTMP "\n";
print MAILTMP @array[6];
print MAILTMP "\n";
print MAILTMP @array[7];
print MAILTMP "\n";
print MAILTMP @array[8];
print MAILTMP "\n";
print MAILTMP @array[9];
print MAILTMP "\n";
print MAILTMP @array[10];
print MAILTMP "\n";
print MAILTMP @array[11];
print MAILTMP "\n";
print MAILTMP @array[12];
print MAILTMP "\n";
print MAILTMP @array[13];
print MAILTMP "\n";
print MAILTMP @array[14];
print MAILTMP "\n";
print MAILTMP @array[15];
print MAILTMP "\n";


#Sets the email Subject to the Event Name: passed by $NOTICEPLAINTEXT
$Subject=@array[0];

#closes the body of the email
close MAILTMP;

#set who you are sending to
$MailUser='someone@someone.com';

#sends the email
system "blat.exe mailmajor.tmp -to \"$MailUser\" -subject \"$Subject \" \n";

#email cleanup
unlink 'mailmajor.tmp';
close MAILDIST;
--------------------------------------------------------

Please reply to this post if you have any issues.
This script has been attached to this post.