incorporated XCATCFG and hierachy in xcatmon.pm to support node liveness status monitoring
git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@785 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
parent
50a4e0a813
commit
41e5425d8c
@ -899,7 +899,8 @@ sub getPluginSettings {
|
||||
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:
|
||||
{monserver1=>[['node1', 'osi', 'active'], ['node2', 'switch', 'booting']...], ...}
|
||||
{monserver1=>[['node1', 'osi', 'active'], ['node2', 'switch', 'booting']...], ...}
|
||||
If there is no service node for a node, the key will be "noservicenode".
|
||||
=cut
|
||||
#--------------------------------------------------------------------------------
|
||||
sub getMonHierarchy {
|
||||
@ -913,20 +914,19 @@ sub getMonHierarchy {
|
||||
|
||||
#get monserver for each node. use "monserver" attribute from noderes table, if not
|
||||
#defined, use "servicenode". otherwise, use loca lhost.
|
||||
my @hostinfo=xCAT::Utils->determinehostname();
|
||||
my $host=pop(@hostinfo);
|
||||
if (defined(@tmp1) && (@tmp1 > 0)) {
|
||||
foreach(@tmp1) {
|
||||
my $node=$_->{node};
|
||||
my $status=$_->{status};
|
||||
my $nodetype=$_->{nodetype};
|
||||
my $monserver=$host;
|
||||
my $monserver;
|
||||
my $tmp2=$table2->getNodeAttribs($node, ['monserver', 'servicenode']);
|
||||
if (defined($tmp2) && ($tmp2)) {
|
||||
if ($tmp2->{monserver}) { $monserver=$tmp2->{monserver}; }
|
||||
elsif ($tmp2->{servicenode}) { $monserver=$tmp2->{servicenode}; }
|
||||
}
|
||||
|
||||
#print "node=$node, monserver=$monserver\n";
|
||||
if (!$monserver) { $monserver="noservicenode"; }
|
||||
if (exists($ret->{$monserver})) {
|
||||
my $pa=$ret->{$monserver};
|
||||
push(@$pa, [$node, $nodetype, $status]);
|
||||
|
@ -9,7 +9,7 @@ use lib "$::XCATROOT/lib/perl";
|
||||
use xCAT::Utils;
|
||||
use xCAT::GlobalDef;
|
||||
use xCAT_monitoring::monitorctrl;
|
||||
use Sys::Hostname;
|
||||
|
||||
|
||||
|
||||
1;
|
||||
@ -115,7 +115,7 @@ sub startNodeStatusMon {
|
||||
if ($reading>0) { $value=$reading;}
|
||||
|
||||
#create the cron job, it will run the command every 3 minutes.
|
||||
my $newentry="*/$value * * * * XCATROOT=$::XCATROOT $cmd";
|
||||
my $newentry="*/$value * * * * XCATROOT=$::XCATROOT PATH=$ENV{'PATH'} XCATCFG='$ENV{'XCATCFG'}' $cmd";
|
||||
my ($code, $msg)=xCAT::Utils::add_cron_job($newentry);
|
||||
if ($code==0) { return (0, "started"); }
|
||||
else { return ($code, $msg); }
|
||||
@ -203,11 +203,29 @@ sub getMonNodesStatus {
|
||||
my @unknown_nodes=();
|
||||
|
||||
my $monservers=xCAT_monitoring::monitorctrl->getMonHierarchy();
|
||||
|
||||
my $host=hostname();
|
||||
my $monnodes=$monservers->{$host};
|
||||
if (($monnodes) && (@$monnodes >0)) {
|
||||
foreach(@$monnodes) {
|
||||
my $isSV=xCAT::Utils->isServiceNode();
|
||||
|
||||
#on a service node or on ms, get the nodes that has local host as the server node
|
||||
my $monnodes;
|
||||
my @hostinfo=xCAT::Utils->determinehostname();
|
||||
my %iphash=();
|
||||
foreach(@hostinfo) {$iphash{$_}=1;}
|
||||
foreach my $host (@hostinfo) {
|
||||
$monnodes=$monservers->{$host};
|
||||
if (($monnodes) && (@$monnodes >0)) { last;}
|
||||
}
|
||||
foreach(@$monnodes) {
|
||||
my $node=$_->[0];
|
||||
my $status=$_->[2];
|
||||
if ($status eq $::STATUS_ACTIVE) { push(@active_nodes, $node);}
|
||||
elsif ($status eq $::STATUS_INACTIVE) { push(@inactive_nodes, $node);}
|
||||
else { push(@unknown_nodes, $node);}
|
||||
}
|
||||
|
||||
#on ms, add the ones that has no service nodes
|
||||
if (!$isSV) {
|
||||
my $monnodes_ms=$monservers->{'noservicenode'};
|
||||
foreach(@$monnodes_ms) {
|
||||
my $node=$_->[0];
|
||||
my $status=$_->[2];
|
||||
if ($status eq $::STATUS_ACTIVE) { push(@active_nodes, $node);}
|
||||
|
@ -246,11 +246,11 @@ sub startmon {
|
||||
}
|
||||
else {
|
||||
#update the monsetting table
|
||||
if ($settings) {
|
||||
if ($settings) {
|
||||
my $table1=xCAT::Table->new("monsetting", -create => 1,-autocommit => 1);
|
||||
my %key_col1 = (name=>$pname);
|
||||
#parse the settings. Setting format: key="value",key="value"....
|
||||
while ($settings =~ s/^\[([^\[\]\=]*)=([^\[\]]*)\](,)*//) {
|
||||
while ($settings =~ s/^\[([^\[\]\=]*)=([^\[\]]*)\](,)*//) {
|
||||
$key_col1{key}=$1;
|
||||
$setting_hash{value}=$2;
|
||||
$table1->setAttribs(\%key_col1, \%setting_hash);
|
||||
@ -278,7 +278,7 @@ sub startmon {
|
||||
%iphash=();
|
||||
foreach(@hostinfo) {$iphash{$_}=1;}
|
||||
foreach (@mon_servers) {
|
||||
if (! $iphash{$_}) { #if it is not this node, meaning it is ms
|
||||
if (! $iphash{$_} && ($_ ne "noservicenode")) { #if it is not this node, meaning it is ms
|
||||
my %rsp2;
|
||||
$rsp2->{data}->[0]="sending request to $_...";
|
||||
$callback->($rsp2);
|
||||
@ -419,7 +419,7 @@ sub stopmon {
|
||||
%iphash=();
|
||||
foreach(@hostinfo) {$iphash{$_}=1;}
|
||||
foreach (@mon_servers) {
|
||||
if (! $iphash{$_}) { #if it is not this node, meaning it is ms
|
||||
if (! $iphash{$_} && ($_ ne "noservicenode")) { #if it is not this node, meaning it is ms
|
||||
my %rsp2;
|
||||
$rsp2->{data}->[0]="sending request to $_...";
|
||||
$callback->($rsp2);
|
||||
|
Loading…
x
Reference in New Issue
Block a user