diff --git a/xCAT-rmc/resources/mn/IBM.EventResponse/LogEventToxCATDatabase.pm b/xCAT-rmc/resources/mn/IBM.EventResponse/LogEventToxCATDatabase.pm new file mode 100644 index 000000000..60994f12b --- /dev/null +++ b/xCAT-rmc/resources/mn/IBM.EventResponse/LogEventToxCATDatabase.pm @@ -0,0 +1,8 @@ +#!/usr/bin/perl + +$RES::EventResponse{'LogEventToxCATDatabase'} = { + Name => q(LogEventToxCATDatabase), + Locked => q(0), + Actions => q({[updatexCAT,{127},{0},{86400},/opt/xcat/sbin/rmcmon/logeventtoxcat,3,0,0,0,{},0]}), +}; +1; diff --git a/xCAT-rmc/scripts/logeventtoxcat b/xCAT-rmc/scripts/logeventtoxcat new file mode 100755 index 000000000..1435332a8 --- /dev/null +++ b/xCAT-rmc/scripts/logeventtoxcat @@ -0,0 +1,58 @@ +#!/usr/bin/env perl +# IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html + +# This script is used by LogEventToxCATDatabase event response to put RMC events into +# the xCAT evnetlog table. It handles both batch and non-batching events. + +BEGIN +{ + $::XCATROOT = $ENV{'XCATROOT'} ? $ENV{'XCATROOT'} : '/opt/xcat'; +} +use lib "$::XCATROOT/lib/perl"; +use strict; +use Getopt::Std; +use POSIX qw(strftime); +use xCAT::Utils; +use xCAT::MsgUtils; + +#`echo "---------------" >> /tmp/ling.log`; +#foreach(keys %ENV) { +# my $s="$_=" . $ENV{$_}; +# `echo $s >> /tmp/ling.log`; +#} + +my $batch=$ENV{ERRM_COND_BATCH}; +my @a=(); + +if (!$batch) { + my $time=$ENV{ERRM_TIME}; + my $nodenamelist=$ENV{ERRM_NODE_NAMELIST}; + $nodenamelist =~ s/\{(.*)\}/$1/; + + my $event={ + eventtype => $ENV{ERRM_TYPE}, + monitor => $ENV{ERRM_COND_NAME}, + monnode => $ENV{ERRM_NODE_NAME}, + node => $nodenamelist, + application => 'RMC', + component => $ENV{ERRM_RSRC_CLASS_PNAME}, + id => $ENV{ERRM_RSRC_NAME} . "," . $ENV{ERRM_ATTR_PNAME}, + severity => $ENV{ERRM_COND_SEVERITY}, + message => '', + rawdata => $ENV{ERRM_ATTR_PNAME} . "=" . $ENV{ERRM_VALUE}, + }; + + push(@a, $event); +} else { + xCAT::MsgUtils->message('S', "logeventtoxcat:batching is not supported by this script yet.\n"); + exit 0; +} + +my ($rc, $msg)=xCAT::Utils->logEventsToDatabase(\@a); +if ($rc) { + xCAT::MsgUtils->message('S', "logeventtoxcat:$msg\n"); +} + +exit $rc; + +