Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

NNM 7.5, Automatic Action: Email on Windows 2003 server

Status
Not open for further replies.

Koing

Technical User
Jun 1, 2006
5
0
0
GB
Hi guys,

I'm a complete beginner with HPOV NNM and Perl. Please bear with me if you can.

I have read a lot of the threads in regards to email alerts and automatic actions on here and other forums. I have used the infamous perl email alert script (Nigel's and the other guy that took out the time stamp). It will be posted in the next reply.

In the Automatic Action text area I have

perl C:\\Perl\\bin\\email_alert.pl $2 "Vault Door Open Test Koing" $1


I'm not sure if this is the correct command.

In this directory:
C:\Program Files\HP OpenView\NNM\conf\trustedCmds.conf


I have 2 files:
ALLOW_ALL
NNM

In NNM I have the commands:

snmpnotify=$OV_BIN/snmpnotify
ovIfIndexRemap.ovpl=$OV_BIN/ovIfIndexRemap.ovpl

email_alert.pl=C:/Perl/bin/email_alert.pl


The email_alert.pl does reside in this directory also:
C:/Perl/bin/email_alert.pl

I have tested it works from the commandline and I get an email:
c:\perl\bin\perl.exe C:/Perl/bin/email_alert.pl Test_Node "Test Message" "1028713184" me@my_company.com

When I look in ovactiond.log I get this:
Thu Jun 08 14:13:30 Command "perl C:\Perl\bin\email_alert.pl 1.3.6.1.4.1.13669.1.4.1.5.521 "Vault Door Open Test Koing" Coin Vault Door Open" exited with value 1.

It exits out with value 1. I read something about this but I can't remember, but remembering it being not good.

Thanks guys and ESPECIALLY Nigel for doing the script and the other guys involved with the perl script. Much appreciated.

Koing
 
# Perl script to send email alerts from HP OV events
#
# The event must pass the following parameters :
#
# 1. The node name/ip address (mandatory)
# 2. The alert message (e.g. node down) (mandatory)
#
# These fields may optionally be followed by any number of email addresses alert to be sent to.
#
# To generate documentation for this script, use the command :
#
# pod2html --infile=email_alert.pl --outfile=email_alert.html
#
use Net::SMTP;
use strict;

my $DISABLE = '0'; # set this to 1 to disable this script (for maintenance) and 0 to enable.

exit if ($DISABLE);

# Configure the mail server IP/name here
my $MAILHOST = '10.10.10.10';

# Configure the email address of the receivers here.
# format for multiple entries : my @EMAIL_TO = ( 'what.ever@anydomain.com', 'das.fsfswf@sdfsdfs.com', 'nnm@nocview.sgfsf.com');
my @EMAIL_TO = ( 'emailTO@company.com');

# Configure a name to appear in the 'From' field of the email msg here
my $FROM = 'nnm_admin@company.com';

###################################################
# Don't change anything below here !!!
###################################################

my ($node, $alert, @email_addresses) = @ARGV;

# check that we have the miminum fields which we require
if (! ($node && $alert) ) {
die "You must supply a value for the node, alert message !\nNode = $node\nMessage = $alert\n\n";
}


my $msg = ("$node : $alert\n");

# connect to the smtp server
my $smtp = Net::SMTP->new($MAILHOST, Timeout => 10) or die "Unable to connect to mail host :

$MAILHOST - $!\n";

# add email addresses configured in @EMAIL_TO to any email addresses
# passed in args from command line
@email_addresses = (@email_addresses, @EMAIL_TO);

foreach my $address (@email_addresses) {

$smtp->mail($address);
$smtp->to($address);
$smtp->data();
$smtp->datasend("From: $FROM\n");
$smtp->datasend("To: $address\n");
$smtp->datasend("Subject: $alert : $node\n");
$smtp->datasend("\n$msg \n\n");
$smtp->datasend;
$smtp->dataend();
}
$smtp->quit;

####################################################################
# End of script, beginning of documentation
####################################################################
 
Hi,

I think that you have an issue with the entry in your NNM file.

You need to add :

perl=c:/perl/bin/perl.exe

You need to remove : email_alert.pl=C:/Perl/bin/email_alert.pl

Hope this does the trick..!





Nigel Bowden
 
Thanks for your input. I'll try it out as soon as the machine sending the traps are sending it. Or that NNM is receiving them. I got a new software build on the sending machine and no traps are being sent for some reason.

Friday night I was getting an email automatically generated with what I originally had. I think I needed to restart ovactiond and with the restart of the server it worked afterwards.

Again thanks for doing the original script and all your help. Really appreciate it.

Koing
 
hey,

i've tried to do the same thing as you koing, geting my nnm 7.5 to send me an automated email when something happens for example OV_Node_Down, and i copied the whole thing that you wrote, including the script and all.

but when i tried to run the perl script in the command prompt it gave me a message that there was a syntax error in line 7 which in my case was on this line :
my @EMAIL_TO = ( 'emailTO@company.com');

i have zero knowledge in perl, thats why i have no idea where is the problem in that line...

any help would be much appriciated !!!
 
Wow thanks a lot Nigel. I appreciate the effort and work you put in. Thanks a lot.

I know this is cheeky but I'll ask anyway :p

How would I go about setting the alerts to send via SMS (text messages) to a mobile phone also? I have done some research before and they had some software that I could use but that wasn't free. Anything like your script but to send to a SMS to a mobile phone?

Regards,
Koing
 
I'm afraid I haven't come across any SMS-type scripts.

The only way that I am aware of doing this, besides a commercial package that dials up an SMS service, is to use an SMS email/gateway that converts emails to SMS.

I've never looked in to this, so I can't give any specific recommendations I'm afraid.



Nigel Bowden
 
I see.

Can exchange be used as an sms email/ gateway that converts emails to SMS? I'll check with the IT guys.

Thanks for the info.

Koing
 
Hi,
I'm back in this wonderful site after almost 3 years...!

Nigel Bowden,
I'm so happy to see you around!

Koing,
Just saw your question Koing, any mail relay server will do, you just need to use the phone# then the domain for that number and it will reach the desired cell phone.

Most of SMS services are made of the following combination:
i.e. 123456786263@mymobilecompany.com

Just as any regular text mail, send it to the "account/cell phone" you are plannning to reach and it will get router through the relay server to the SMS gateway you need for finally delivery.

Hopefully I was able to explain myself, please let me know.
Hope this helps,
Vlan52

vlan52
The end of wisdom is freedom. The end of culture is perfection. The end of
education is character. The end of knowledge is love.
 
Hi,
I found this thread to be extremely helpful and have this script running on my NNM server.
There are a few extra things I'd like to do with the email notifications:

* subject order (to allow better sorting) set as follows: devicename: device port: status (link up/down)

* include in the body of the email notification, the snmp entry for device location and description of the port.

Lil' help, please? :-D

Any info will be greatly appreciated. Thanks!
 
Hi,

The subject order issue should be quite easy to fix.

If you open the file email_alert.pl with Notepad, you will find the line :
Code:
 my $subject = "$alert : $node";
If you change this to :
Code:
 my $subject = "$node : $alert";
The issue regarding the device location and the description of the port is quite a tough one. You can really only use data that is supplied in the event variables. If you wanted to pull out info such as location fields from the device object, the script would have to query the OV database which would make it very cumbersome and slow. It is possible, but not easy. I'll give it some thought, but don't hold your breath as it won't be any time soon I'm afraid.

When I get some time, I've been thinking of adding various improvements, but it will be some time in the future when I get a little spare time.

Hope this has helped you a little, even though I haven't managed to come up with the goods on all of your queries.

All the best.



Nigel Bowden
 
Hi,

I am not at all familiar with perl and i am trying what Nigel has for download from his site. I have NNM 7.51 evaluation version running on Windows. The perl script works from the command line without giving the output for the variables ie $1, $2, is this normal ?

But when I try the same from the the NNM Command for Automatic action line the email alert does not work. I have configured a concurent popup message box and it works. I created a bat file with the command line recommended , it works but variables are not captured. I checked the ovactiond logfile and it gives the following error.
Fri Feb 16 17:37:28 ShellExecute(e:\opt\email_alert\bin\perl e:\opt\email_alert\email_alert.pl) failed. Returned 2

Nigel any clues on what could be the issue ?
 
Hi,

Sorry to hear you are having an issue with this....

Have you configured perl to run in NNM (i.e. added it to the trusted commands file ? - e:/opt/email_alert/doc/email_alert.html#%24OV_CONF%2ftrustedCmds.conf%2fNNM).

If you have added it as recommended in the doc, then your command line in the NNM event should be something like :

perl e:\opt\email_alert\email_alert.pl $2 "Node Down"

If it runs Ok from the command line, there can't be too much of an issue with the way that it has been installed and your smtp server config must be OK....

Can you post the exact line that you are putting in to your NNM event ?


Nigel Bowden
 
Hi

Does this Perl script work on Unix (Solaris) Openview v7.50 ?

Thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top