From 011568c4fdf57ca7331334ed2151b0d62ed72b91 Mon Sep 17 00:00:00 2001 From: linggao Date: Wed, 10 Nov 2010 19:55:16 +0000 Subject: [PATCH] more work for different conditons and reponses git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@8123 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-rmc/plugin/rmcmon.pm | 2 +- .../IBM.Condition/AllServiceableEvents_HB.pm | 12 ++ ...ability_Batch.pm => NodeReachability_B.pm} | 6 +- ...rchicalEvents.pm => EmailRootAnyTime_H.pm} | 4 +- ...atchEvents_H.pm => EmailRootAnyTime_HB.pm} | 4 +- .../LogEventToTealEvenetLog_B.pm} | 4 +- ...e_Batch.pm => LogEventToxCATDatabase_B.pm} | 4 +- .../mn/IBM.EventResponse/LogEvents_H.pm | 8 + .../mn/IBM.EventResponse/LogEvents_HB.pm | 8 + ...lEvents.pm => MsgEventsToRootAnyTime_H.pm} | 4 +- ...ents_H.pm => MsgEventsToRootAnyTime_HB.pm} | 4 +- ...tus_Batch.pm => UpdatexCATNodeStatus_B.pm} | 4 +- .../IBM.Condition/AllServiceableEvents_HB.pm | 12 ++ ...ability_Batch.pm => NodeReachability_B.pm} | 6 +- .../LogEventToTealEvenetLog_B.pm} | 4 +- ...e_Batch.pm => LogEventToxCATDatabase_B.pm} | 4 +- ...tus_Batch.pm => UpdatexCATNodeStatus_B.pm} | 4 +- xCAT-rmc/scripts/log-hierarchical-batch-event | 161 ++++++++++++++++++ xCAT-rmc/scripts/log-hierarchical-event | 112 ++++++++++++ 19 files changed, 340 insertions(+), 27 deletions(-) create mode 100644 xCAT-rmc/resources/mn/IBM.Condition/AllServiceableEvents_HB.pm rename xCAT-rmc/resources/mn/IBM.Condition/{NodeReachability_Batch.pm => NodeReachability_B.pm} (83%) rename xCAT-rmc/resources/mn/IBM.EventResponse/{EmailRootHierarchicalEvents.pm => EmailRootAnyTime_H.pm} (61%) rename xCAT-rmc/resources/mn/IBM.EventResponse/{EmailRootBatchEvents_H.pm => EmailRootAnyTime_HB.pm} (65%) rename xCAT-rmc/resources/{sn/IBM.EventResponse/LogEventToTealEvenetLog_Batch.pm => mn/IBM.EventResponse/LogEventToTealEvenetLog_B.pm} (81%) rename xCAT-rmc/resources/mn/IBM.EventResponse/{LogEventToxCATDatabase_Batch.pm => LogEventToxCATDatabase_B.pm} (81%) create mode 100644 xCAT-rmc/resources/mn/IBM.EventResponse/LogEvents_H.pm create mode 100644 xCAT-rmc/resources/mn/IBM.EventResponse/LogEvents_HB.pm rename xCAT-rmc/resources/mn/IBM.EventResponse/{MsgRootHierarchicalEvents.pm => MsgEventsToRootAnyTime_H.pm} (61%) rename xCAT-rmc/resources/mn/IBM.EventResponse/{MsgRootBatchEvents_H.pm => MsgEventsToRootAnyTime_HB.pm} (63%) rename xCAT-rmc/resources/mn/IBM.EventResponse/{UpdatexCATNodeStatus_Batch.pm => UpdatexCATNodeStatus_B.pm} (82%) create mode 100644 xCAT-rmc/resources/sn/IBM.Condition/AllServiceableEvents_HB.pm rename xCAT-rmc/resources/sn/IBM.Condition/{NodeReachability_Batch.pm => NodeReachability_B.pm} (83%) rename xCAT-rmc/resources/{mn/IBM.EventResponse/LogEventToTealEvenetLog_Batch.pm => sn/IBM.EventResponse/LogEventToTealEvenetLog_B.pm} (81%) rename xCAT-rmc/resources/sn/IBM.EventResponse/{LogEventToxCATDatabase_Batch.pm => LogEventToxCATDatabase_B.pm} (81%) rename xCAT-rmc/resources/sn/IBM.EventResponse/{UpdatexCATNodeStatus_Batch.pm => UpdatexCATNodeStatus_B.pm} (82%) create mode 100755 xCAT-rmc/scripts/log-hierarchical-batch-event create mode 100755 xCAT-rmc/scripts/log-hierarchical-event diff --git a/xCAT-rmc/plugin/rmcmon.pm b/xCAT-rmc/plugin/rmcmon.pm index 3a06dbeaf..9d1b0f753 100644 --- a/xCAT-rmc/plugin/rmcmon.pm +++ b/xCAT-rmc/plugin/rmcmon.pm @@ -685,7 +685,7 @@ sub startNodeStatusMon { } if ($batch) { - my $result=`startcondresp NodeReachability_Batch UpdatexCATNodeStatus_Batch 2>&1`; + my $result=`startcondresp NodeReachability_B UpdatexCATNodeStatus_B 2>&1`; if (($?) && ($result !~ /2618-244|2618-008/)) { #started $retcode=$?; $retmsg="Error start node status monitoring: $result"; diff --git a/xCAT-rmc/resources/mn/IBM.Condition/AllServiceableEvents_HB.pm b/xCAT-rmc/resources/mn/IBM.Condition/AllServiceableEvents_HB.pm new file mode 100644 index 000000000..079a32f46 --- /dev/null +++ b/xCAT-rmc/resources/mn/IBM.Condition/AllServiceableEvents_HB.pm @@ -0,0 +1,12 @@ +#!/usr/bin/perl + +$RES::Condition{'AllServiceableEvents_HB'} = { + Name => q(AllServiceableEvents_HB), + ResourceClass => q(IBM.Condition), + EventExpression => q(LastBatchedEventFile.Saved != 0), + EventDescription => q(An event will be generated when a serviceable event occurs on a HMC. The serviceable events are monitored by a batch condition called AllServiceableEvents_B on the HMC. This condition monitors the batch condition. This way, if the mn is down, the conditions events will still be saved on the batch files on the HMC. ), + SelectionString => q(Name="AllServiceableEvents_B"), + ManagementScope => q(4), + Severity => q(0), +}; +1; diff --git a/xCAT-rmc/resources/mn/IBM.Condition/NodeReachability_Batch.pm b/xCAT-rmc/resources/mn/IBM.Condition/NodeReachability_B.pm similarity index 83% rename from xCAT-rmc/resources/mn/IBM.Condition/NodeReachability_Batch.pm rename to xCAT-rmc/resources/mn/IBM.Condition/NodeReachability_B.pm index ea1b00268..76c6bf37d 100644 --- a/xCAT-rmc/resources/mn/IBM.Condition/NodeReachability_Batch.pm +++ b/xCAT-rmc/resources/mn/IBM.Condition/NodeReachability_B.pm @@ -14,11 +14,11 @@ if (exists($ENV{RSCT_VER})) { } } -$RES::Condition{'NodeReachability_Batch'} = { - Name => q(NodeReachability_Batch), +$RES::Condition{'NodeReachability_B'} = { + Name => q(NodeReachability_B), ResourceClass => q(IBM.MngNode), EventExpression => q(Status!=Status@P), - EventDescription => q(An event will be generated when a status changes), + EventDescription => q(An event will be generated when a status changes. This is a batch condition.), ManagementScope => q(1), EventBatchingInterval => q(60), EventBatchingMaxEvents => q(200), diff --git a/xCAT-rmc/resources/mn/IBM.EventResponse/EmailRootHierarchicalEvents.pm b/xCAT-rmc/resources/mn/IBM.EventResponse/EmailRootAnyTime_H.pm similarity index 61% rename from xCAT-rmc/resources/mn/IBM.EventResponse/EmailRootHierarchicalEvents.pm rename to xCAT-rmc/resources/mn/IBM.EventResponse/EmailRootAnyTime_H.pm index e1c810aac..6f20be8df 100644 --- a/xCAT-rmc/resources/mn/IBM.EventResponse/EmailRootHierarchicalEvents.pm +++ b/xCAT-rmc/resources/mn/IBM.EventResponse/EmailRootAnyTime_H.pm @@ -1,7 +1,7 @@ #!/usr/bin/perl -$RES::EventResponse{'EmailRootHierarchicalEvents'} = { - Name => q(EmailRootHierarchicalEvents), +$RES::EventResponse{'EmailRootAnyTime_H'} = { + Name => q(EmailRootAnyTime_H), Locked => q(0), Actions => q({[emailEvent,{127},{0},{86400},/opt/xcat/sbin/rmcmon/email-hierarchical-event root,3,0,0,0,{},0]}), }; diff --git a/xCAT-rmc/resources/mn/IBM.EventResponse/EmailRootBatchEvents_H.pm b/xCAT-rmc/resources/mn/IBM.EventResponse/EmailRootAnyTime_HB.pm similarity index 65% rename from xCAT-rmc/resources/mn/IBM.EventResponse/EmailRootBatchEvents_H.pm rename to xCAT-rmc/resources/mn/IBM.EventResponse/EmailRootAnyTime_HB.pm index db3a87e9a..a377d83c3 100644 --- a/xCAT-rmc/resources/mn/IBM.EventResponse/EmailRootBatchEvents_H.pm +++ b/xCAT-rmc/resources/mn/IBM.EventResponse/EmailRootAnyTime_HB.pm @@ -1,7 +1,7 @@ #!/usr/bin/perl -$RES::EventResponse{'EmailRootBatchEvents_H'} = { - Name => q(EmailRootBatchEvents_H), +$RES::EventResponse{'EmailRootAnyTime_HB'} = { + Name => q(EmailRootAnyTime_HB), Locked => q(0), Actions => q({[emailEvent,{127},{0},{86400},/opt/xcat/sbin/rmcmon/email-hierarchical-batch-event root -d,3,0,0,0,{},0]}), }; diff --git a/xCAT-rmc/resources/sn/IBM.EventResponse/LogEventToTealEvenetLog_Batch.pm b/xCAT-rmc/resources/mn/IBM.EventResponse/LogEventToTealEvenetLog_B.pm similarity index 81% rename from xCAT-rmc/resources/sn/IBM.EventResponse/LogEventToTealEvenetLog_Batch.pm rename to xCAT-rmc/resources/mn/IBM.EventResponse/LogEventToTealEvenetLog_B.pm index 509f6c77b..b268bb108 100644 --- a/xCAT-rmc/resources/sn/IBM.EventResponse/LogEventToTealEvenetLog_Batch.pm +++ b/xCAT-rmc/resources/mn/IBM.EventResponse/LogEventToTealEvenetLog_B.pm @@ -11,8 +11,8 @@ if (exists($ENV{RSCT_VER})) { if (xCAT::Utils->CheckVersion($rsct_ver, "2.3.5.0") < 0) { exit 0;} } -$RES::EventResponse{'LogEventToTealEvenetLog_Batch'} = { - Name => q(LogEventToTealEvenetLog_Batch), +$RES::EventResponse{'LogEventToTealEvenetLog_B'} = { + Name => q(LogEventToTealEvenetLog_B), Locked => q(0), EventBatching => q(1), Actions => q({[logToTeal,{127},{0},{86400},/opt/xcat/sbin/rmcmon/logeventtoteal,3,0,0,0,{},0]}), diff --git a/xCAT-rmc/resources/mn/IBM.EventResponse/LogEventToxCATDatabase_Batch.pm b/xCAT-rmc/resources/mn/IBM.EventResponse/LogEventToxCATDatabase_B.pm similarity index 81% rename from xCAT-rmc/resources/mn/IBM.EventResponse/LogEventToxCATDatabase_Batch.pm rename to xCAT-rmc/resources/mn/IBM.EventResponse/LogEventToxCATDatabase_B.pm index b9d769e41..87834c079 100644 --- a/xCAT-rmc/resources/mn/IBM.EventResponse/LogEventToxCATDatabase_Batch.pm +++ b/xCAT-rmc/resources/mn/IBM.EventResponse/LogEventToxCATDatabase_B.pm @@ -11,8 +11,8 @@ if (exists($ENV{RSCT_VER})) { if (xCAT::Utils->CheckVersion($rsct_ver, "2.3.5.0") < 0) { exit 0;} } -$RES::EventResponse{'LogEventToxCATDatabase_Batch'} = { - Name => q(LogEventToxCATDatabase_Batch), +$RES::EventResponse{'LogEventToxCATDatabase_B'} = { + Name => q(LogEventToxCATDatabase_B), Locked => q(0), EventBatching => q(1), Actions => q({[updatexCAT,{127},{0},{86400},/opt/xcat/sbin/rmcmon/logeventtoxcat,3,0,0,0,{},0]}), diff --git a/xCAT-rmc/resources/mn/IBM.EventResponse/LogEvents_H.pm b/xCAT-rmc/resources/mn/IBM.EventResponse/LogEvents_H.pm new file mode 100644 index 000000000..a55a94dfe --- /dev/null +++ b/xCAT-rmc/resources/mn/IBM.EventResponse/LogEvents_H.pm @@ -0,0 +1,8 @@ +#!/usr/bin/perl + +$RES::EventResponse{'LogEvents_H'} = { + Name => q(LogEvents_H), + Locked => q(0), + Actions => q({[logEvent,{127},{0},{86400},/opt/xcat/sbin/rmcmon/log-hierarchical-event /tmp/eventlog,3,0,0,0,{},0]}), +}; +1; diff --git a/xCAT-rmc/resources/mn/IBM.EventResponse/LogEvents_HB.pm b/xCAT-rmc/resources/mn/IBM.EventResponse/LogEvents_HB.pm new file mode 100644 index 000000000..dca88d287 --- /dev/null +++ b/xCAT-rmc/resources/mn/IBM.EventResponse/LogEvents_HB.pm @@ -0,0 +1,8 @@ +#!/usr/bin/perl + +$RES::EventResponse{'LogEvents_HB'} = { + Name => q(LogEvents_HB), + Locked => q(0), + Actions => q({[logEvent,{127},{0},{86400},/opt/xcat/sbin/rmcmon/log-hierarchical-batch-event /tmp/eventlog -d,3,0,0,0,{},0]}), +}; +1; diff --git a/xCAT-rmc/resources/mn/IBM.EventResponse/MsgRootHierarchicalEvents.pm b/xCAT-rmc/resources/mn/IBM.EventResponse/MsgEventsToRootAnyTime_H.pm similarity index 61% rename from xCAT-rmc/resources/mn/IBM.EventResponse/MsgRootHierarchicalEvents.pm rename to xCAT-rmc/resources/mn/IBM.EventResponse/MsgEventsToRootAnyTime_H.pm index 5cfdeffd4..88c77b37a 100644 --- a/xCAT-rmc/resources/mn/IBM.EventResponse/MsgRootHierarchicalEvents.pm +++ b/xCAT-rmc/resources/mn/IBM.EventResponse/MsgEventsToRootAnyTime_H.pm @@ -1,7 +1,7 @@ #!/usr/bin/perl -$RES::EventResponse{'MsgRootHierarchicalEvents'} = { - Name => q(MsgRootHierarchicalEvents), +$RES::EventResponse{'MsgEventsToRootAnyTime_H'} = { + Name => q(MsgEventsToRootAnyTime_H), Locked => q(0), Actions => q({[msgEvent,{127},{0},{86400},/opt/xcat/sbin/rmcmon/msg-hierarchical-event root,3,0,0,0,{},0]}), }; diff --git a/xCAT-rmc/resources/mn/IBM.EventResponse/MsgRootBatchEvents_H.pm b/xCAT-rmc/resources/mn/IBM.EventResponse/MsgEventsToRootAnyTime_HB.pm similarity index 63% rename from xCAT-rmc/resources/mn/IBM.EventResponse/MsgRootBatchEvents_H.pm rename to xCAT-rmc/resources/mn/IBM.EventResponse/MsgEventsToRootAnyTime_HB.pm index 4e58e7273..767c29a01 100644 --- a/xCAT-rmc/resources/mn/IBM.EventResponse/MsgRootBatchEvents_H.pm +++ b/xCAT-rmc/resources/mn/IBM.EventResponse/MsgEventsToRootAnyTime_HB.pm @@ -1,7 +1,7 @@ #!/usr/bin/perl -$RES::EventResponse{'MsgRootBatchEvents_H'} = { - Name => q(MsgRootBatchEvents_H), +$RES::EventResponse{'MsgEventsToRootAnyTime_HB'} = { + Name => q(MsgEventsToRootAnyTime_HB), Locked => q(0), Actions => q({[msgEvent,{127},{0},{86400},/opt/xcat/sbin/rmcmon/msg-hierarchical-batch-event root -d,3,0,0,0,{},0]}), }; diff --git a/xCAT-rmc/resources/mn/IBM.EventResponse/UpdatexCATNodeStatus_Batch.pm b/xCAT-rmc/resources/mn/IBM.EventResponse/UpdatexCATNodeStatus_B.pm similarity index 82% rename from xCAT-rmc/resources/mn/IBM.EventResponse/UpdatexCATNodeStatus_Batch.pm rename to xCAT-rmc/resources/mn/IBM.EventResponse/UpdatexCATNodeStatus_B.pm index 819c52b50..11248f509 100644 --- a/xCAT-rmc/resources/mn/IBM.EventResponse/UpdatexCATNodeStatus_Batch.pm +++ b/xCAT-rmc/resources/mn/IBM.EventResponse/UpdatexCATNodeStatus_B.pm @@ -11,8 +11,8 @@ if (exists($ENV{RSCT_VER})) { if (xCAT::Utils->CheckVersion($rsct_ver, "2.3.5.0") < 0) { exit 0;} } -$RES::EventResponse{'UpdatexCATNodeStatus_Batch'} = { - Name => q(UpdatexCATNodeStatus_Batch), +$RES::EventResponse{'UpdatexCATNodeStatus_B'} = { + Name => q(UpdatexCATNodeStatus_B), Locked => q(0), EventBatching => q(1), Actions => q({[updatexCAT,{127},{0},{86400},/opt/xcat/sbin/rmcmon/updatexcatnodestatus,3,0,0,0,{},0]}), diff --git a/xCAT-rmc/resources/sn/IBM.Condition/AllServiceableEvents_HB.pm b/xCAT-rmc/resources/sn/IBM.Condition/AllServiceableEvents_HB.pm new file mode 100644 index 000000000..079a32f46 --- /dev/null +++ b/xCAT-rmc/resources/sn/IBM.Condition/AllServiceableEvents_HB.pm @@ -0,0 +1,12 @@ +#!/usr/bin/perl + +$RES::Condition{'AllServiceableEvents_HB'} = { + Name => q(AllServiceableEvents_HB), + ResourceClass => q(IBM.Condition), + EventExpression => q(LastBatchedEventFile.Saved != 0), + EventDescription => q(An event will be generated when a serviceable event occurs on a HMC. The serviceable events are monitored by a batch condition called AllServiceableEvents_B on the HMC. This condition monitors the batch condition. This way, if the mn is down, the conditions events will still be saved on the batch files on the HMC. ), + SelectionString => q(Name="AllServiceableEvents_B"), + ManagementScope => q(4), + Severity => q(0), +}; +1; diff --git a/xCAT-rmc/resources/sn/IBM.Condition/NodeReachability_Batch.pm b/xCAT-rmc/resources/sn/IBM.Condition/NodeReachability_B.pm similarity index 83% rename from xCAT-rmc/resources/sn/IBM.Condition/NodeReachability_Batch.pm rename to xCAT-rmc/resources/sn/IBM.Condition/NodeReachability_B.pm index ea1b00268..76c6bf37d 100644 --- a/xCAT-rmc/resources/sn/IBM.Condition/NodeReachability_Batch.pm +++ b/xCAT-rmc/resources/sn/IBM.Condition/NodeReachability_B.pm @@ -14,11 +14,11 @@ if (exists($ENV{RSCT_VER})) { } } -$RES::Condition{'NodeReachability_Batch'} = { - Name => q(NodeReachability_Batch), +$RES::Condition{'NodeReachability_B'} = { + Name => q(NodeReachability_B), ResourceClass => q(IBM.MngNode), EventExpression => q(Status!=Status@P), - EventDescription => q(An event will be generated when a status changes), + EventDescription => q(An event will be generated when a status changes. This is a batch condition.), ManagementScope => q(1), EventBatchingInterval => q(60), EventBatchingMaxEvents => q(200), diff --git a/xCAT-rmc/resources/mn/IBM.EventResponse/LogEventToTealEvenetLog_Batch.pm b/xCAT-rmc/resources/sn/IBM.EventResponse/LogEventToTealEvenetLog_B.pm similarity index 81% rename from xCAT-rmc/resources/mn/IBM.EventResponse/LogEventToTealEvenetLog_Batch.pm rename to xCAT-rmc/resources/sn/IBM.EventResponse/LogEventToTealEvenetLog_B.pm index 509f6c77b..b268bb108 100644 --- a/xCAT-rmc/resources/mn/IBM.EventResponse/LogEventToTealEvenetLog_Batch.pm +++ b/xCAT-rmc/resources/sn/IBM.EventResponse/LogEventToTealEvenetLog_B.pm @@ -11,8 +11,8 @@ if (exists($ENV{RSCT_VER})) { if (xCAT::Utils->CheckVersion($rsct_ver, "2.3.5.0") < 0) { exit 0;} } -$RES::EventResponse{'LogEventToTealEvenetLog_Batch'} = { - Name => q(LogEventToTealEvenetLog_Batch), +$RES::EventResponse{'LogEventToTealEvenetLog_B'} = { + Name => q(LogEventToTealEvenetLog_B), Locked => q(0), EventBatching => q(1), Actions => q({[logToTeal,{127},{0},{86400},/opt/xcat/sbin/rmcmon/logeventtoteal,3,0,0,0,{},0]}), diff --git a/xCAT-rmc/resources/sn/IBM.EventResponse/LogEventToxCATDatabase_Batch.pm b/xCAT-rmc/resources/sn/IBM.EventResponse/LogEventToxCATDatabase_B.pm similarity index 81% rename from xCAT-rmc/resources/sn/IBM.EventResponse/LogEventToxCATDatabase_Batch.pm rename to xCAT-rmc/resources/sn/IBM.EventResponse/LogEventToxCATDatabase_B.pm index b9d769e41..87834c079 100644 --- a/xCAT-rmc/resources/sn/IBM.EventResponse/LogEventToxCATDatabase_Batch.pm +++ b/xCAT-rmc/resources/sn/IBM.EventResponse/LogEventToxCATDatabase_B.pm @@ -11,8 +11,8 @@ if (exists($ENV{RSCT_VER})) { if (xCAT::Utils->CheckVersion($rsct_ver, "2.3.5.0") < 0) { exit 0;} } -$RES::EventResponse{'LogEventToxCATDatabase_Batch'} = { - Name => q(LogEventToxCATDatabase_Batch), +$RES::EventResponse{'LogEventToxCATDatabase_B'} = { + Name => q(LogEventToxCATDatabase_B), Locked => q(0), EventBatching => q(1), Actions => q({[updatexCAT,{127},{0},{86400},/opt/xcat/sbin/rmcmon/logeventtoxcat,3,0,0,0,{},0]}), diff --git a/xCAT-rmc/resources/sn/IBM.EventResponse/UpdatexCATNodeStatus_Batch.pm b/xCAT-rmc/resources/sn/IBM.EventResponse/UpdatexCATNodeStatus_B.pm similarity index 82% rename from xCAT-rmc/resources/sn/IBM.EventResponse/UpdatexCATNodeStatus_Batch.pm rename to xCAT-rmc/resources/sn/IBM.EventResponse/UpdatexCATNodeStatus_B.pm index 819c52b50..11248f509 100644 --- a/xCAT-rmc/resources/sn/IBM.EventResponse/UpdatexCATNodeStatus_Batch.pm +++ b/xCAT-rmc/resources/sn/IBM.EventResponse/UpdatexCATNodeStatus_B.pm @@ -11,8 +11,8 @@ if (exists($ENV{RSCT_VER})) { if (xCAT::Utils->CheckVersion($rsct_ver, "2.3.5.0") < 0) { exit 0;} } -$RES::EventResponse{'UpdatexCATNodeStatus_Batch'} = { - Name => q(UpdatexCATNodeStatus_Batch), +$RES::EventResponse{'UpdatexCATNodeStatus_B'} = { + Name => q(UpdatexCATNodeStatus_B), Locked => q(0), EventBatching => q(1), Actions => q({[updatexCAT,{127},{0},{86400},/opt/xcat/sbin/rmcmon/updatexcatnodestatus,3,0,0,0,{},0]}), diff --git a/xCAT-rmc/scripts/log-hierarchical-batch-event b/xCAT-rmc/scripts/log-hierarchical-batch-event new file mode 100755 index 000000000..f4ed01a5b --- /dev/null +++ b/xCAT-rmc/scripts/log-hierarchical-batch-event @@ -0,0 +1,161 @@ +#!/usr/bin/env perl +# IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html + +# Script to demonstrate how to parse out the event info that comes from a +# Condition that is watching another Condition in a hierarchical cluster environment. +# The condition that is being watched is a batch event. This script will go th the +# node that has the watched condition, get the event batch file. And parse the file +# and then send email to a user with the detailed info of the events in the batch file. +# The batch file will be then deleted if -d flag is set. + +# To use this script, create a Response that invokes this script with user id as the input. +# Then associate the Response with a Condition that is watching Conditions on other +# nodes. When the Conditions occur, this script will wall the relevant event information. + +# This info that is passed into this sample is structured as follows: +# EMS Condition/Event: +# $ENV{ERRM_COND_NAME} +# $ENV{ERRM_TYPEID} +# ... +# $ENV{ERRM_NODE_NAME} --> SN +# $ENV{ERRM_RSRC_NAME} --> SN Condition +# $ENV{ERRM_VALUE} --> SN Event: LastBatchedEventFile +# $Saved +# $FileName +# $Size + +use strict; +use Getopt::Std; +use POSIX qw(strftime); +use File::Basename; +use File::Path; + +my $logfn = join(' ', @ARGV); +my $delete=0; +if ($logfn =~ /-d/) { + $delete=1; +} + +$logfn =~ s/-d//; #remove -d + +# Convert Severity and Type environment variables from integers to strings +my @COND_SEVERITY = qw(Informational Warning Critical); +my @TYPE = ('event', 'rearm event'); +my $severity=$COND_SEVERITY[$ENV{ERRM_COND_SEVERITYID}]; +my $type=$TYPE[$ENV{ERRM_TYPEID }]; + + +# Parse the ERRM_VALUE attribute, which will contain the EventOccurred structured data variable from the Condition class +# The fields in this structured data variable are documented below where we parse them out. +my $event = $ENV{ERRM_VALUE}; +$event =~ s/^\[(.*)\]$/$1/; # SD variables have square brackets around them + +# This parse the LastEvent +my ( # split the SD into the following fields: + $Saved, # batch file has been saved + $filename, # location of the batch file + $Size, # The size of the batch file + ) = split(/,/, $event); + +my $sn_condname=$ENV{ERRM_RSRC_NAME}; +my $sn_name=$ENV{ERRM_NODE_NAME}; + +my ( + $EventTime, # Time of event expressed in seconds since 1/1/1970 + $EventTimeMicros, # Number of microseconds past EventTime + ) = split(/,/, $ENV{ERRM_TIME}); + +my $msg="===================================================================\n";; +$msg .= " Event Time: " . convertTime($EventTime) . "\n"; +$msg .= " Condition name: $ENV{ERRM_COND_NAME}\n"; +$msg .= " Event Type: $type\n"; +$msg .= " Severiry: $severity\n"; +$msg .= " Condition being monitored: $sn_condname\n"; +$msg .= " Node where the condition was monitored: $sn_name\n"; # do we have to use $ERRM_NODE_NAMELIST here? +$msg .= " SN batch files name: $filename\n"; + +#copy the batch file from sn to mn +$filename =~ s/"//g; +my $bn=basename($filename); + +#printf stderr "ful path :$filename\n"; +#printf stderr "base name:$bn\n"; + +my $dirname="/tmp/batch_process/"; +if (! -d $dirname) { + mkdir($dirname); +} + +my $cmd; +my $isHMC=0; +if ($filename =~ /\/home\/hscroot\/tmp/) { + $isHMC=1; + $cmd="scp hscroot\@$sn_name:$filename $dirname/$bn"; +} +else { + $cmd="scp $sn_name:$filename $dirname/$bn"; +} +my $rc=`$cmd 2>&1`; +if ($? != 0) { + $msg .= "$rc\n"; +} + +#now process the batch file +open(FILE1, "<$dirname/$bn"); +readline(FILE1);#skip first 2 lines +readline(FILE1); +my $line1=readline(FILE1); +my @aTemp=split(/=/, $line1); +my $num_events=$aTemp[1]; +close(FILE1); + +my $count; +for ($count = 1; $count <= $num_events; $count++) { + my $content=`sed -n "/Event $count:/,/ERRM_COND_BATCH/ p" $dirname/$bn`; + + my @content_array=split(/\n/, $content); + pop(@content_array); #get rid of last line + shift(@content_array); #get rid of firt line + + my %content_hash=(); + foreach(@content_array) { + /([^\=]+)\=(.*)/; + $content_hash{$1}=$2; + } + + my $event = "Event count: $count\n"; + #$event .= " Event time: " . $content_hash{ERRM_TIME} . "\n"; + $event .= " Node where the event occurred: " . $content_hash{ERRM_NODE_NAMELIST} . "\n"; + $event .= " Resource class: " . $content_hash{ERRM_RSRC_CLASS_PNAME} . "\n"; + $event .= " Resource name: " . $content_hash{ERRM_RSRC_NAME} . "\n"; + $event .= " Attribute name: " . $content_hash{ERRM_ATTR_PNAME} . "\n"; + $event .= " Attribute value: " . $content_hash{ERRM_VALUE} . "\n\n"; + + $msg .= $event; +} + +#log the events +if (open (FILE, ">>$logfn")) { + print FILE "$msg\n"; + close (FILE); +} +#delete the batch file on the mn +`rm $dirname/$bn`; + +#remove the batch file on the sn if needed +if ($delete) { + if ($isHMC) { + `ssh -l hscroot $sn_name "rm $filename"`; + } else { + `ssh -l root $sn_name "rm $filename"`; + } +} + +exit; + + +# convert time string +sub convertTime { + my ($seconds, $micro) = split(/\./, $_[0]); + return strftime("%A %D %T", localtime($seconds)); +} diff --git a/xCAT-rmc/scripts/log-hierarchical-event b/xCAT-rmc/scripts/log-hierarchical-event new file mode 100755 index 000000000..d7183fdcb --- /dev/null +++ b/xCAT-rmc/scripts/log-hierarchical-event @@ -0,0 +1,112 @@ +#!/usr/bin/env perl +# IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html + +# Script to demonstrate how to parse out the event info that comes from a +# Condition that is watching another Condition in a hierarchical cluster environment. + +# To use this script, create a Response that invokes this script with a log file name as the input. +# Then associate the Response with a Condition that is watching Conditions on other +# nodes. When the Conditions occur, this script will wall the relevant event information. + +# This info that is passed into this sample is structured as follows: +# EMS Condition/Event: +# $ENV{ERRM_COND_NAME} +# $ENV{ERRM_TYPEID} +# ... +# $ENV{ERRM_NODE_NAME} --> SN +# $ENV{ERRM_RSRC_NAME} --> SN Condition +# $ENV{ERRM_VALUE} --> SN Event: +# $Occurred +# $ErrNum +# ... +# $NodeName --> Leaf Node: +# $ResourceName --> Resource +# $Attribute 1 --> Attr 1 +# $Attribute 2 --> Attr 2 + +use strict; +use Getopt::Std; +use POSIX qw(strftime); +use File::Path; + + +# Convert Severity and Type environment variables from integers to strings +my @COND_SEVERITY = qw(Informational Warning Critical); +my @TYPE = ('Event', 'Rearm event'); +my $severity=$COND_SEVERITY[$ENV{ERRM_COND_SEVERITYID}]; +my $type=$TYPE[$ENV{ERRM_TYPEID }]; + +my $filename = shift; + +# Parse the ERRM_VALUE attribute, which will contain the EventOccurred structured data variable from the Condition class +# The fields in this structured data variable are documented below where we parse them out. +my $event = $ENV{ERRM_VALUE}; +$event =~ s/^\[(.*)\]$/$1/; # SD variables have square brackets around them + +# This parse the LastEvent +my ( # split the SD into the following fields: + $Occurred, # One if the condition has been triggered + $ErrNum, # Non-zero if there was in error in the event registration + $ErrMsg, # The string msg related to ErrNum + $EventFlags, # Bit mask giving some additional info about the event + $EventTime, # Time of event expressed in seconds since 1/1/1970 + $EventTimeMicros, # Number of microseconds past EventTime + $ResourceHandle, # Binary address of the RMC resource that caused the condition to be triggered + $NodeName, # The node on which the event occurred. For conditions that use the management domain scope (4), + # this will be the leaf node. For conditions that use the local scope (e.g. NodeReachability), + # this will be the FMS. + $NumAttrs, # Number of attr values from the resource returned in this event + $NumAttrsInExpr, # How many of the above were attributes in the event expression + $IndexForAttrs, # The starting index of the array of values. Until new fixed fields are added + # to LastEvent, this will be the element right after this one. + $AttrArray # This list of attribute names, types, and values + ) = split(/,/, $event, 12); + +my @attrArray = split(/,/, $AttrArray); # Note: parsing this way does not support SDs or SD Arrays that may be in this list + +my ($ResourceName, $valuesMsg); +my $j = 0; # index into attrArray +for (my $i=0; $i<$NumAttrs; $i++) { + my $attrName = $attrArray[$j++]; + my $attrType = $attrArray[$j++]; # Types <= 8 are "simple" types. Types > 8 are SDs and arrays. + my $attrValue = $attrArray[$j++]; + if ($attrName eq '"Name"') { $ResourceName = $attrValue; } + $valuesMsg .= " Attribute Value $i: $attrName = $attrValue\n"; +} +if (!length($ResourceName)) { $ResourceName = '(unknown)'; } + +my $msg="=============================================================================\n"; +$msg .= " Time: " . convertTime($EventTime) . " \n"; +$msg .= " MN Condition: $ENV{ERRM_COND_NAME}\n"; +$msg .= " Severity: $severity\n"; +$msg .= " Event Type: $type\n"; +$msg .= " SN Condition: $ENV{ERRM_RSRC_NAME}\n"; +$msg .= " SN: $ENV{ERRM_NODE_NAME}\n"; # do we have to use $ERRM_NODE_NAMELIST here? +$msg .= " Node: $NodeName\n"; +$msg .= " Resource Name: $ResourceName\n"; +if (length($valuesMsg)) { + $msg .= " Attributes:\n"; + $msg .= $valuesMsg; +} + +# Skipped the following: $ERRM_EXPR $ERRM_RSRC_CLASS_PNAME $ERRM_DATA_TYPE $ERRM_NODE_NAMELIST $ERRM_RSRC_TYPE +#$str = escape_chars($str); +if (open (FILE, ">>$filename")) { + print FILE "$msg\n"; + close (FILE); +} + +exit; + + +# convert time string +sub convertTime { + my ($seconds, $micro) = split(/\./, $_[0]); + return strftime("%A %D %T", localtime($seconds)); +} + + + + + +