for item: clean up Utils.pm, the code in xCAT-server/lib/xcat/monitoring

git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@13466 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
zhaoertao 2012-08-09 04:05:37 +00:00
parent b9811ba810
commit 3a4f26c3cc
7 changed files with 34 additions and 30 deletions

View File

@ -13,6 +13,7 @@ use xCAT::Utils;
use xCAT::GlobalDef;
use xCAT_monitoring::monitorctrl;
use xCAT::MsgUtils;
use xCAT::TableUtils;
use strict;
use warnings;
1;
@ -125,7 +126,7 @@ sub start {
}
# Identification of this node
my @hostinfo = xCAT::Utils->determinehostname();
my @hostinfo = xCAT::NetworkUtils->determinehostname();
my $isSV = xCAT::Utils->isServiceNode();
my %iphash = ();
foreach (@hostinfo) {
@ -290,7 +291,7 @@ sub confGmond {
}
# Identification of this node
my @hostinfo = xCAT::Utils->determinehostname();
my @hostinfo = xCAT::NetworkUtils->determinehostname();
my $isSV = xCAT::Utils->isServiceNode();
my %iphash = ();
foreach (@hostinfo) {
@ -348,7 +349,7 @@ sub confGmond {
if ($scope) {
my @children;
my $install_root = xCAT::Utils->getInstallDir();
my $install_root = xCAT::TableUtils->getInstallDir();
foreach my $key ( keys(%$pPairHash) ) {
my @key_a = split( ':', $key );
if ( !$iphash{ $key_a[0] } ) {
@ -473,7 +474,7 @@ sub confGmetad {
return ( 1, "" );
}
my @hostinfo = xCAT::Utils->determinehostname();
my @hostinfo = xCAT::NetworkUtils->determinehostname();
my $isSV = xCAT::Utils->isServiceNode();
my %iphash = ();
foreach (@hostinfo) { $iphash{$_} = 1; }
@ -627,7 +628,7 @@ sub deconfGmond {
}
# Identification of this node
my @hostinfo = xCAT::Utils->determinehostname();
my @hostinfo = xCAT::NetworkUtils->determinehostname();
my $isSV = xCAT::Utils->isServiceNode();
my %iphash = ();
foreach (@hostinfo) { $iphash{$_} = 1; }
@ -827,7 +828,7 @@ sub stop {
}
#identification of this node
my @hostinfo = xCAT::Utils->determinehostname();
my @hostinfo = xCAT::NetworkUtils->determinehostname();
my $isSV = xCAT::Utils->isServiceNode();
my %iphash = ();
foreach (@hostinfo) { $iphash{$_} = 1; }

View File

@ -11,6 +11,7 @@ use xCAT::NodeRange;
use xCAT::Table;
use xCAT::MsgUtils;
use xCAT::Utils;
use xCAT::TableUtils;
use xCAT_plugin::notification;
use xCAT_monitoring::montbhandler;
use Sys::Hostname;
@ -824,7 +825,7 @@ sub isMonServer {
if (ref($pHash) eq 'ARRAY') { return 0; }
my @hostinfo=xCAT::Utils->determinehostname();
my @hostinfo=xCAT::NetworkUtils->determinehostname();
my $isSV=xCAT::Utils->isServiceNode();
my %iphash=();
foreach(@hostinfo) {$iphash{$_}=1;}
@ -883,7 +884,7 @@ sub getNodeMonServerPair {
my %gnopts;
if (scalar (@nodes) == 1) { $gnopts{prefetchcache}=1; } #if only doing one server, it seems probable that this was a Postage type scenario
my $tabdata = $table2->getNodesAttribs(\@nodes,['monserver', 'servicenode', 'xcatmaster'],%gnopts);
my $sitemaster=xCAT::Utils->get_site_attribute('master');
my $sitemaster=xCAT::TableUtils->get_site_attribute('master');
foreach my $node (@nodes) {
my $monserver;
my $monmaster;
@ -967,7 +968,7 @@ sub getMonHierarchy {
foreach (@tmp3) {
$temp_hash3{$_->{node}}=$_;
}
my $sitemaster=xCAT::Utils->get_site_attribute('master');
my $sitemaster=xCAT::TableUtils->get_site_attribute('master');
if (@tmp1 > 0) {
foreach(@tmp1) {

View File

@ -15,6 +15,7 @@ use xCAT::GlobalDef;
use xCAT_monitoring::monitorctrl;
use xCAT::MsgUtils;
use xCAT::DBobjUtils;
use xCAT::TableUtils;
use Data::Dumper;
1;
@ -191,7 +192,7 @@ sub config {
my $localhostname=hostname();
#the identification of this node
my @hostinfo=xCAT::Utils->determinehostname();
my @hostinfo=xCAT::NetworkUtils->determinehostname();
my $isSN=xCAT::Utils->isServiceNode();
my %iphash=();
foreach(@hostinfo) {$iphash{$_}=1;}
@ -422,7 +423,7 @@ sub setup_nagios_cfg_sn {
#create ncsa the commands
my $ocsp_command="/usr/lib/nagios/plugins/eventhandler/submit_service_check_result";
my $ochp_command="/usr/lib/nagios/plugins/eventhandler/submit_host_check_result";
my $master=xCAT::Utils->get_site_Master();
my $master=xCAT::TableUtils->get_site_Master();
if (!$master) {
my $rc=`grep XCATMASTER /opt/xcat/xcatinfo`;
if ($rc && ($rc =~/^XCATMASTER=(.*)/)) {
@ -560,7 +561,7 @@ sub addNodes {
my $callback=shift;
print "nagiosmon.addNodes mon_nodes=@mon_nodes\n";
my @hostinfo=xCAT::Utils->determinehostname();
my @hostinfo=xCAT::NetworkUtils->determinehostname();
my %iphash=();
foreach(@hostinfo) {$iphash{$_}=1;}
my $localhostname=hostname();
@ -756,7 +757,7 @@ sub removeNodes {
my $callback=shift;
print "nagiosmon.removeNodes mon_nodes=@mon_nodes\n";
my @hostinfo=xCAT::Utils->determinehostname();
my @hostinfo=xCAT::NetworkUtils->determinehostname();
my %iphash=();
foreach(@hostinfo) {$iphash{$_}=1;}
my $localhostname=hostname();
@ -848,7 +849,7 @@ sub addGrandNodes {
my $callback=shift;
print "nagiosmon.addGrandNodes\n";
my @hostinfo=xCAT::Utils->determinehostname();
my @hostinfo=xCAT::NetworkUtils->determinehostname();
my %iphash=();
foreach(@hostinfo) {$iphash{$_}=1;}
my $localhostname=hostname();
@ -1058,7 +1059,7 @@ sub removeGrandNodes {
my $callback=shift;
print "nagiosmon.removeGrandNodes\n";
my @hostinfo=xCAT::Utils->determinehostname();
my @hostinfo=xCAT::NetworkUtils->determinehostname();
my %iphash=();
foreach(@hostinfo) {$iphash{$_}=1;}
my $localhostname=hostname();
@ -1156,7 +1157,7 @@ sub deconfig {
my $localhostname=hostname();
#the identification of this node
my @hostinfo=xCAT::Utils->determinehostname();
my @hostinfo=xCAT::NetworkUtils->determinehostname();
my $isSN=xCAT::Utils->isServiceNode();
my %iphash=();
foreach(@hostinfo) {$iphash{$_}=1;}
@ -1272,7 +1273,7 @@ sub startNodeStatusMon {
return (1, "");
}
my @hostinfo=xCAT::Utils->determinehostname();
my @hostinfo=xCAT::NetworkUtils->determinehostname();
my %iphash=();
foreach(@hostinfo) {$iphash{$_}=1;}
if (!$isSN) { $iphash{'noservicenode'}=1;}

View File

@ -135,7 +135,7 @@ sub start
}
#identification of this node
my @hostinfo=xCAT::Utils->determinehostname();
my @hostinfo=xCAT::NetworkUtils->determinehostname();
my $isSV=xCAT::Utils->isServiceNode();
my %iphash=();
foreach(@hostinfo) {$iphash{$_}=1;}
@ -299,7 +299,7 @@ sub stop
#identification of this node
my @hostinfo=xCAT::Utils->determinehostname();
my @hostinfo=xCAT::NetworkUtils->determinehostname();
my $isSV=xCAT::Utils->isServiceNode();
my %iphash=();
foreach(@hostinfo) {$iphash{$_}=1;}

View File

@ -96,7 +96,7 @@ sub start {
if ($scope) {
#demo how to get the children
my @hostinfo=xCAT::Utils->determinehostname();
my @hostinfo=xCAT::NetworkUtils->determinehostname();
my $isSV=xCAT::Utils->isServiceNode();
my %iphash=();
foreach(@hostinfo) {$iphash{$_}=1;}
@ -164,7 +164,7 @@ sub stop {
if ($scope) {
#demo how to get the children
my @hostinfo=xCAT::Utils->determinehostname();
my @hostinfo=xCAT::NetworkUtils->determinehostname();
my $isSV=xCAT::Utils->isServiceNode();
my %iphash=();
foreach(@hostinfo) {$iphash{$_}=1;}

View File

@ -10,6 +10,7 @@ use strict;
use IO::File;
use xCAT::Utils;
use xCAT::MsgUtils;
use xCAT::TableUtils;
use xCAT::NodeRange;
use xCAT_monitoring::monitorctrl;
use Sys::Hostname;
@ -382,7 +383,7 @@ sub configBMC {
my $ret_val=0;
#the identification of this node
my @hostinfo=xCAT::Utils->determinehostname();
my @hostinfo=xCAT::NetworkUtils->determinehostname();
my $isSV=xCAT::Utils->isServiceNode();
my %iphash=();
foreach(@hostinfo) {$iphash{$_}=1;}
@ -464,7 +465,7 @@ sub configBMC {
my $ref2=$masterhash{$_};
if (@$ref2==0) { next;}
my $nr2=join(',', @$ref2);
my @tmp_a=xCAT::Utils::toIP($_);
my @tmp_a=xCAT::NetworkUtils::toIP($_);
my $ptmp=$tmp_a[0];
if ($ptmp->[0]>0) {
xCAT::MsgUtils->message('S', "[mon]: Converting to IP: $ptmp->[1]\n");
@ -517,7 +518,7 @@ sub configMPA {
my $ret_text="";
#the identification of this node
my @hostinfo=xCAT::Utils->determinehostname();
my @hostinfo=xCAT::NetworkUtils->determinehostname();
my $isSV=xCAT::Utils->isServiceNode();
my %iphash=();
foreach(@hostinfo) {$iphash{$_}=1;}
@ -611,7 +612,7 @@ sub configMPA {
my $ref2=$masterhash{$_};
if (@$ref2==0) { next;}
my $nr2=join(',', @$ref2);
my @tmp_a=xCAT::Utils::toIP($_);
my @tmp_a=xCAT::NetworkUtils::toIP($_);
my $ptmp=$tmp_a[0];
if ($ptmp->[0]>0) {
xCAT::MsgUtils->message('S', "[mon]: Converting to IP: $ptmp->[1]\n");
@ -665,7 +666,7 @@ sub configSwitch {
my $ret_val=0;
#the identification of this node
my @hostinfo=xCAT::Utils->determinehostname();
my @hostinfo=xCAT::NetworkUtils->determinehostname();
my $isSV=xCAT::Utils->isServiceNode();
my %iphash=();
foreach(@hostinfo) {$iphash{$_}=1;}
@ -765,7 +766,7 @@ sub configSwitch {
my @a_temp=split(':',$pairs);
my $monserver=$a_temp[0];
my $master=$a_temp[1];
my @tmp_a=xCAT::Utils::toIP($master);
my @tmp_a=xCAT::NetworkUtils::toIP($master);
my $ptmp=$tmp_a[0];
if ($ptmp->[0]>0) {
xCAT::MsgUtils->message('S', "[mon]: Converting to IP: $ptmp->[1]\n");
@ -789,7 +790,7 @@ sub configSwitch {
my @a_temp=split(':',$pairs);
my $monserver=$a_temp[0];
my $master=$a_temp[1];
my @tmp_a=xCAT::Utils::toIP($master);
my @tmp_a=xCAT::NetworkUtils::toIP($master);
my $ptmp=$tmp_a[0];
if ($ptmp->[0]>0) {
xCAT::MsgUtils->message('S', "[mon]: Converting to IP: $ptmp->[1]\n");
@ -839,7 +840,7 @@ sub configSwitch {
sub configSNMP {
print "configSNMP called \n";
my $isSN=xCAT::Utils->isServiceNode();
my $master=xCAT::Utils->get_site_Master();
my $master=xCAT::TableUtils->get_site_Master();
my $cmd;
# now move /usr/share/snmp/snmptrapd.conf to /usr/share/snmp/snmptrapd.conf.orig
# if it exists.

View File

@ -301,7 +301,7 @@ sub getMonNodesStatus {
my $isSV=xCAT::Utils->isServiceNode();
#on a service node or on ms, get the nodes that has local host as the server node
my @hostinfo=xCAT::Utils->determinehostname();
my @hostinfo=xCAT::NetworkUtils->determinehostname();
my %iphash=();
foreach(@hostinfo) {$iphash{$_}=1;}
#if this is mn, include the ones that has no service nodes