rmcmon change to work with the new monitoring infrastructure

git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@1988 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
linggao 2008-08-06 18:14:52 +00:00
parent d836988691
commit 32ff984b67
4 changed files with 689 additions and 377 deletions

File diff suppressed because it is too large Load Diff

View File

@ -7,7 +7,7 @@
# usage:
# To add node to the cluster:
# NODE=nodename NODEID=fbb5ec1f64dd299c \
# MONSERVER=msname_or_ip MS_NODEID=fbb5ec1f64dd299c \
# MONMASTER=msname_or_ip MS_NODEID=fbb5ec1f64dd299c \
# configrmcnode 1
# To remove node to the cluster
# NODE=nodename configrmcnode -1
@ -18,46 +18,82 @@ else
ADD=1
fi
logger xCAT "configrmcnode: ADD=$ADD, NODE=$NODE, NODEID=$NODEID MONSERVER=$MONSERVER,MS_NODEID=$MS_NODEID"
logger xCAT "configrmcnode: ADD=$ADD, NODE=$NODE, NODEID=$NODEID MONMASTER=$MONMASTER,MS_NODEID=$MS_NODEID"
#check if rsct is installed and running
if [ ! -e /usr/bin/lsrsrc ]; then
echo "RMC setup on node $NODE: RSCT is not is not installed."
logger xCAT "RMC setup on node $NODE: RSCT is not is not installed."
exit 1;
fi
#check if the resource is defined
result=`/usr/bin/lsrsrc-api -s IBM.MCP::"NodeID=0x$MS_NODEID"::MNName 2>&1`
if [ $? -gt 0 ]; then
# echo $result
p="2612-023" #resource not found
result1=`awk -v a="$result" -v b="$p" 'BEGIN{print index(a,b)}'`
if [ $result1 -gt 0 ]; then
if [ $ADD -eq -1 ]; then
exit 0; #resource already removed, do nothing
fi
else
echo "$result"
logger xCAT "$result"
exit 1
fi
else
if [ $ADD -eq 1 ]; then
exit 0; #resource already defined, do nothing
fi
fi
#ask RMC take the new nodeid
if [[ $NODEID != "" ]]; then
#stop all rmc daemons
/usr/sbin/rsct/bin/rmcctrl -z
#get new nodeid into id files
if [ -e /var/ct/cfg/ct_node_id ]; then
sed s/^[^\#].*$/$NODEID/ /var/ct/cfg/ct_node_id > /tmp/id.tmp
else
if [ -e /etc/ct_node_id ]; then
sed s/^[^\#].*$/$NODEID/ /etc/ct_node_id > /tmp/id.tmp
oldid=`/usr/sbin/rsct/bin/lsnodeid`
oldidU=`echo "$oldid" | awk '{ print toupper($1) }'`
newidU=`echo "$NODEID" | awk '{ print toupper($1) }'`
if [ $oldidU != $newidU ]; then
if [ -e /usr/sbin/rsct/install/bin/recfgctnid ]; then
result=`/usr/sbin/rsct/install/bin/recfgctnid $NODEID 2>&1`
if [ $? -ne 0 ]; then
echo "Reset nodeid: $result"
logger xCAT "Reset nodeid: $result"
fi
else
echo $NODEID > /tmp/id.tmp
#stop all rmc daemons
/usr/sbin/rsct/bin/rmcctrl -z
#get new nodeid into id files
if [ -e /var/ct/cfg/ct_node_id ]; then
sed s/^[^\#].*$/$NODEID/ /var/ct/cfg/ct_node_id > /tmp/id.tmp
else
if [ -e /etc/ct_node_id ]; then
sed s/^[^\#].*$/$NODEID/ /etc/ct_node_id > /tmp/id.tmp
else
echo $NODEID > /tmp/id.tmp
fi
fi
cp /tmp/id.tmp /var/ct/cfg/ct_node_id
cp /tmp/id.tmp /etc/ct_node_id
rm /tmp/id.tmp
#reconfig RMC
result=`/usr/sbin/rsct/install/bin/recfgct -s 2>&1`
if [ $? -ne 0 ]; then
echo "RMC setup on node $NODE: Cannot reconfig RSCT with new node id"
logger xCAT "RMC setup on node $NODE: Cannot reconfig RSCT with new node id"
fi
fi
fi
cp /tmp/id.tmp /var/ct/cfg/ct_node_id
cp /tmp/id.tmp /etc/ct_node_id
rm /tmp/id.tmp
#reconfig RMC
result=`/usr/sbin/rsct/install/bin/recfgct -s 2>&1`
if [ $? -ne 0 ]; then
logger xCAT "RMC setup on node $NODE: Cannot reconfig RSCT with new node id"
fi
fi
PID=`/bin/ps -ef | /bin/grep rmcd | /bin/grep -v grep | /bin/awk '{print $2}'`
if [ !$PID ]; then
#restart rmc daemon
result=`startsrc -s ctrmc 2>&1`;
if [ $? -gt 0 ]; then
echo "RMC deamon cannot be started on node $NODE:$result"
logger xCAT "RMC deamon cannot be started on node $NODE:$result"
exit 1;
fi
@ -69,8 +105,8 @@ if [ $ADD -eq 1 ]; then
/usr/bin/rmcctrl -p; /usr/bin/refrsrc IBM.MCP
#get IP address of MS
ms_ip=$MONSERVER
result=`ping -c1 $MONSERVER 2>&1`
ms_ip=$MONMASTER
result=`ping -c1 $MONMASTER 2>&1`
if [ $? -eq 0 ]; then
index1=`expr index "$result" "\("`
index2=`expr index "$result" "\)"`
@ -80,12 +116,14 @@ if [ $ADD -eq 1 ]; then
length=`expr $length - 1`
ms_ip=`expr substr "$result" $pos $length`
else
echo "RMC setup on node $NODE:$result"
logger xCAT "RMC setup on node $NODE:$result"
fi
#define resource in IBM.MCP class on node
result1=`/usr/bin/mkrsrc-api IBM.MCP::MNName::"$NODE"::KeyToken::"$MONSERVER"::IPAddresses::"{\"$ms_ip\"}"::NodeID::0x$MS_NODEID 2>&1`
result1=`/usr/bin/mkrsrc-api IBM.MCP::MNName::"$NODE"::KeyToken::"$MONMASTER"::IPAddresses::"{\"$ms_ip\"}"::NodeID::0x$MS_NODEID 2>&1`
if [ $? -gt 0 ]; then
echo "Define resource in IBM.MCP class on node $NODE. result=$result1"
logger xCAT "Define resource in IBM.MCP class on node $NODE. result=$result1"
exit 1
fi
@ -93,8 +131,9 @@ if [ $ADD -eq 1 ]; then
#TODO: create predefined sensors
else
#remove resource in IBM.MCP class on the node
result2= `/usr/bin/rmrsrc-api -s IBM.MCP::"MNName=\\\"\"$NODE\\\"\"" 2>&1`
result2=`/usr/bin/rmrsrc-api -s IBM.MCP::"NodeID=0x$MS_NODEID" 2>&1`
if [ $? -gt 0 ]; then
echo "Remove resource in IBM.MCP class on noderesult=$result2"
logger xCAT "Remove resource in IBM.MCP class on noderesult=$result2"
exit 1
fi

View File

@ -164,7 +164,6 @@ sub stop {
=cut
#-------------------------------------------------------------------------------
sub handleMonSignal {
print "handleMonSignal: go there\n";
refreshProductList();
#setup the signal again
@ -973,7 +972,7 @@ sub getMonServerWithInfo {
for a node, "servicenode" is used. If none is defined, use the local host as the
the monitoring server.
Arguments:
nodes: An array ref of nodes.
nodes: An array ref of nodes. an empty array means all.
Returns:
A hash reference keyed by the monitoring server nodes and each value is a ref to
an array of [nodes, nodetype, status] arrays monitored by the server. So the format is:
@ -990,20 +989,19 @@ sub getMonServer {
$p_input=shift;
}
my @in_nodes=@$p_input;
my @allnodes=@$p_input;
my $pPairHash=getNodeMonServerPair(\@allnodes, 0);
if (@allnodes==0) {
@allnodes= keys(%$pPairHash);
}
my $ret={};
#get all from nodelist table and noderes table
my @allnodes=();
foreach (@in_nodes) {
push(@allnodes, $_->[0]);
}
my $table=xCAT::Table->new("nodelist", -create =>0);
my $tabdata=$table->getNodesAttribs(\@allnodes,['node', 'status']);
my $table3=xCAT::Table->new("nodetype", -create =>0);
my $tabdata3=$table3->getNodesAttribs(\@allnodes,['nodetype']);
my $pPairHash=getNodeMonServerPair(\@allnodes, 0);
foreach my $node (@allnodes) {
my $tmp1=$tabdata->{$node}->[0];

View File

@ -221,7 +221,7 @@ sub stopNodeStatusMon {
#--------------------------------------------------------------------------------
=head3 config
This function configures the cluster for the given nodes.
This function is called when monconfig command is issued or when xcatd starts
This function is called when moncfg command is issued or when xcatd starts
on the service node. It will configure the cluster to include the given nodes within
the monitoring doamin.
Arguments:
@ -290,8 +290,8 @@ sub config {
#--------------------------------------------------------------------------------
=head3 deconfig
This function de-configures the cluster for the given nodes.
This function is called by the monitorctrl module when nodes are removed
from the xCAT cluster. It should remove the nodes from the product for monitoring.
This function is called when mondecfg command is issued by the user.
It should remove the given nodes from the product for monitoring.
Arguments:
p_nodes -- a pointer to an arrays of nodes to be removed for monitoring. none means all.
scope -- the action scope, it indicates the node type the action will take place.
@ -412,7 +412,6 @@ sub configBMC {
print "XCATBYPASS=Y rspconfig $noderange alert=dis\n";
my $result = `XCATBYPASS=Y rspconfig $noderange alert=dis 2>&1`;
if ($?) {
$ret_val=1;
xCAT::MsgUtils->message('S', "[mon]: Changeing SNMP PEF policy for IPMI nodes $noderange:\n $result\n");
$ret_text .= "Changeing SNMP PEF policy for IPMI nodes $noderange:\n $result\n";
}
@ -420,7 +419,6 @@ sub configBMC {
print "XCATBYPASS=Y rspconfig $noderange alert=en\n";
my $result = `XCATBYPASS=Y rspconfig $noderange alert=en 2>&1`;
if ($?) {
$ret_val=1;
xCAT::MsgUtils->message('S', "[mon]: Changeing SNMP PEF policy for IPMI nodes $noderange:\n $result\n");
$ret_text .= "Changeing SNMP PEF policy for IPMI nodes $noderange:\n $result\n";
}
@ -440,7 +438,6 @@ sub configBMC {
print "XCATBYPASS=Y rspconfig $nr2 snmpdest=$ptmp->[1]\n";
my $result2 = `XCATBYPASS=Y rspconfig $nr2 snmpdest=$ptmp->[1] 2>&1`;
if ($?) {
$ret_val=1;
xCAT::MsgUtils->message('S', "[mon]: Changing SNMP destination for IPMI nodes $nr2:\n $result2\n");
$ret_text .= "Changing SNMP destination for IPMI nodes $nr2:\n $result2\n";
}
@ -546,7 +543,6 @@ sub configMPA {
print "XCATBYPASS=Y rspconfig $noderange alert=dis\n";
my $result = `XCATBYPASS=Y rspconfig $noderange alert=dis 2>&1`;
if ($?) {
$ret_val=1;
xCAT::MsgUtils->message('S', "[mon]: Changeing SNMP remote alert profile for Blade Center MM $noderange:\n $result\n");
$ret_text .= "Changeing SNMP remote alert profile for Blade Center MM $noderange:\n $result\n";
}
@ -554,7 +550,6 @@ sub configMPA {
print "XCATBYPASS=Y rspconfig $noderange alert=en\n";
my $result = `XCATBYPASS=Y rspconfig $noderange alert=en 2>&1`;
if ($?) {
$ret_val=1;
xCAT::MsgUtils->message('S', "[mon]: Changeing SNMP remote alert profile for Blade Center MM $noderange:\n $result\n");
$ret_text .= "Changeing SNMP remote alert profile for Blade Center MM $noderange:\n $result\n";
}
@ -574,7 +569,6 @@ sub configMPA {
print "XCATBYPASS=Y rspconfig $nr2 snmpdest=$ptmp->[1]\n";
my $result2 = `XCATBYPASS=Y rspconfig $nr2 snmpdest=$ptmp->[1] 2>&1`;
if ($?) {
$ret_val=1;
xCAT::MsgUtils->message('S', "[mon]: Changing SNMP destination for Blade Center MM $nr2:\n $result2\n");
$ret_text .= "Changing SNMP destination for Blade Center MM $nr2:\n $result2\n";
}