From 1a19bf038983f76580a37573372c1c3a872e1201 Mon Sep 17 00:00:00 2001 From: linggao Date: Tue, 2 Feb 2010 17:58:28 +0000 Subject: [PATCH] added searching for port number in /etc/services for applications that do not have port number specified in monsetting table for appstatus monitoring git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@5118 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-server/lib/xcat/plugins/nodestat.pm | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/xCAT-server/lib/xcat/plugins/nodestat.pm b/xCAT-server/lib/xcat/plugins/nodestat.pm index f9a3b5b12..796a7e2d0 100644 --- a/xCAT-server/lib/xcat/plugins/nodestat.pm +++ b/xCAT-server/lib/xcat/plugins/nodestat.pm @@ -174,7 +174,18 @@ sub preprocess_request #add port number in if nothing is specified if (exists($default_ports{$app})) { $apps{$app}->{'port'} = $default_ports{$app}; } else { - print "need to get the port number form /etc/services\n"; + my $p=`grep "^$app" /etc/services`; + if ($? == 0) { + my @a_list=sort(split('\n', $p)); + my @a_temp=split('/',$a_list[0]); + my @a=split(' ', $a_temp[0]); + $apps{$app}->{'port'}=$a[1]; + } else { + my $rsp={}; + $rsp->{data}->[0]= "Cannot find port number for application $app. Please either specify a port number or a command in monsetting table for $app.";; + xCAT::MsgUtils->message("I", $rsp, $cb); + return (0); + } } }