Server Management (Insight Manager 7)
1833784 Members
1994 Online
110063 Solutions
New Discussion

Re: hpasm and trapemail directive

 
Ronnie_16
Occasional Advisor

hpasm and trapemail directive

I have hpasm-7.3.0-58 and snmpd installed and running on a 380 G3. I get output from hpasmd in /var/log/messages if I for example pull out a power chord, but I don't get an email (as i would like to).

In /opt/compaq/cma.conf there are these lines describing trapemail:

########################################################################
# trapemail is used for configuring email command(s) which will be
# executed whenever a SNMP trap is generated.
# Multiple trapemail lines are allowed.
# Note: any command that reads standard input can be used. For example:
# trapemail /usr/bin/logger
# will log trap messages into system log (/var/log/messages).
########################################################################

I have tried different trapemail commands, including the normal logger, but none of them are executed.

Anyone got "trapemail" working, i.e. piping messages to custom programs? This seems like a nice solution if it works, instead of watching logs...
5 REPLIES 5
David Claypool
Honored Contributor

Re: hpasm and trapemail directive

http://www.hp.com/go/proliantlinux --> "Managing ProLiant Servers with Linux" page 24.
Ronnie_16
Occasional Advisor

Re: hpasm and trapemail directive

Thanks for replying. I have already read that and tried various trapemail commands. The problem is that the commands never get executed.
What should trigger the trapemail command? Are there any configurable thresholds?
Ronnie_16
Occasional Advisor

Re: hpasm and trapemail directive

It's working now (uncommented/edited cmaXSocketBase in /opt/compaq/cma.conf)
Michael Sutton
Occasional Advisor

Re: hpasm and trapemail directive

I've been looking everywhere for exactly what commands to use in this config file to send the email alerts. Page 24 of the guide only gives general overview. Can you please post an example config? Thanks.
Ronnie_16
Occasional Advisor

Re: hpasm and trapemail directive

The messages get piped to whatever command that follows "trapemail". Basically you can write your own script that reads STDIN and does something with it.
In my cma.conf I have two "trapemail" commands:

trapemail /usr/bin/logger -t TRAPEMAIL
trapemail /usr/bin/hptrapmail

The first line sends the message to the logger. The second line sends the message to my own script (hptrapmail) which is as follows:

#!/usr/bin/perl
#
# Script which sends mail from HP Insight Manager snmp agents.

# list recipients here
@recipients = ("recipient1\@somehost.com",
"recipient2\@otherhost.com");

# sysadmin email (used in from and reply-to email headers)
$sysadmin = "sysadmin\@somehost.com";

# variables
$sendmail = "/usr/sbin/sendmail -t -oi"; # mail program
$server = `hostname`; # this computer name
$dt = `date`; # current date and time
chomp ($dt); # remove newline

open(MAIL, "|$sendmail") || die("Could not open pipe to sendmail: $!");
foreach $recipient (@recipients) {
print MAIL "To: " . $recipient . "\n";
}
print MAIL <From: HP Insight Management Agent <$sysadmin>
Reply-To: Sysadmin <$sysadmin>
Subject: Agent Trap Alarm on $server ($dt)
EOF

while (<>) {
print MAIL $_;
}

close MAIL || die("Could not close pipe to sendmail: $!");



/usr/sbin/sendmail in this case is not sendmail but a symlink to a wrapper(ssmtp):
lrwxrwxrwx 1 root root 15 Dec 6 2004 /usr/sbin/sendmail -> /usr/sbin/ssmtp

Good luck!