start RRDserver when monstart and stop when monstop

git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@3696 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
ellen56 2009-07-03 11:13:07 +00:00
parent c3ccf97554
commit 9d7e10065e
3 changed files with 49 additions and 7 deletions

View File

@ -173,6 +173,9 @@ sub start {
xCAT::Utils->runcmd("$::XCATROOT/sbin/rmcmon/rmcmetrixmon init $rsrc $rname $attrlist $minute", 0);
}
}
if(xCAT::Utils->isServiceNode()){
xCAT::Utils->runcmd("$::XCATROOT/sbin/rmcmon/rmcmetrixmon init rrdserver", 0);
}
if ($scope) {
#get a list of managed nodes
$result=`/usr/bin/lsrsrc-api -s IBM.MngNode::::Name 2>&1`;
@ -273,7 +276,10 @@ sub stop {
my $localhostname=hostname();
system("$::XCATROOT/sbin/rmcmon/rmcmetrixmon clean");
xCAT::Utils->runcmd("$::XCATROOT/sbin/rmcmon/rmcmetrixmon clean", 0);
if(xCAT::Utils->isServiceNode()){
xCAT::Utils->runcmd("$::XCATROOT/sbin/rmcmon/rmcmetrixmon clean rrdserver", 0);
}
my $result;
chomp(my $pid= `/bin/ps -ef | /bin/grep rmcd | /bin/grep -v grep | /bin/awk '{print \$2}'`);
if ($pid){
@ -328,6 +334,7 @@ sub stop {
#the identification of this node
my @hostinfo=xCAT::Utils->determinehostname();
my $isSV=xCAT::Utils->isServiceNode();
my %iphash=();
foreach(@hostinfo) {$iphash{$_}=1;}
if (!$isSV) { $iphash{'noservicenode'}=1;}

View File

@ -115,6 +115,7 @@ if($cmd eq 'init'){
if ($ARGV[1] eq 'rrdserver'){
$code = xCAT_monitoring::rrdutil::start_RRD_server('13900', "/var/rrd/");
&err_handle($code, "can't start RRD server");
exit 0;
}
$minute = $ARGV[4];
$crontime = &getcrontime($minute);
@ -127,6 +128,12 @@ if($cmd eq 'init'){
&err_handle($code, $msg);
}
} elsif ($cmd eq 'clean'){
if ($ARGV[1] eq 'rrdserver'){
$code = xCAT_monitoring::rrdutil::stop_RRD_server();
&err_handle($code, "can't stop RRD server");
exit 0;
}
$msg = `rm -rf /var/rrd/*`;
&err_handle($?, $msg);
@tabs = `/usr/bin/crontab -l 2>/dev/null;`;

View File

@ -33,17 +33,30 @@ sub start_RRD_server
my @old = ();
my @new = ();
my $offset = 0;
my $found = 0;
@old = xCAT::Utils->runcmd("cat /etc/services", -2);
push @new, "rrdsrv $port/tcp #RRD server";
foreach (@old) {
if ($_ =~ /rrdsrv/){
splice(@old, $offset, 1, @new);
if(!$found){
splice(@old, $offset, 1, @new);
$found = 1;
} else {
splice(@old, $offset, 1);
}
} else {
$offset++;
}
}
if(!$found){
push @old, @new;
}
open FILE, ">/etc/services.new" or return -1;
print FILE @old;
foreach (@old){
print FILE "$_\n";
}
close FILE;
$cmd = "mv -f /etc/services.new /etc/services";
xCAT::Utils->runcmd($cmd, -2);
@ -59,16 +72,27 @@ sub start_RRD_server
@new = ();
@old = xCAT::Utils->runcmd("cat /etc/inetd.conf", -2);
$offset = 0;
$found = 0;
push @new, "rrdsrv stream tcp no wait root /usr/bin/rrdtool rrdtool - $dir";
foreach (@old) {
if ($_ =~ /rrdsrv/){
splice(@old, $offset, 1, @new);
if(!$found){
splice(@old, $offset, 1, @new);
$found = 1;
} else {
splice(@old, $offset, 1);
}
} else {
$offset++;
}
}
if(!$found){
push @old, @new;
}
open FILE, ">/etc/inetd.conf.new" or return -1;
print FILE @old;
foreach (@old){
print FILE "$_\n";
}
close FILE;
xCAT::Utils->runcmd("mv -f /etc/inetd.conf.new /etc/inetd.conf", -2);
@ -105,7 +129,9 @@ sub stop_RRD_server
}
}
open FILE, ">/etc/services.new" or return -1;
print FILE @old;
foreach (@old){
print FILE "$_\n";
}
close FILE;
xCAT::Utils->runcmd("mv -f /etc/services.new /etc/services", -1);
@ -120,7 +146,9 @@ sub stop_RRD_server
}
}
open FILE, ">/etc/inetd.conf.new" or return -1;
print FILE @old;
foreach (@old){
print FILE "$_\n";
}
close FILE;
xCAT::Utils->runcmd("mv -f /etc/inetd.conf.new /etc/inetd.conf", -2);
if(xCAT::Utils->isAIX()){