mirror of
https://github.com/xcat2/xcat-core.git
synced 2025-05-31 01:56:39 +00:00
change code logic and format depending on comments come from colleagues
This commit is contained in:
parent
d2e469f919
commit
bb8e10cbac
@ -1,41 +1,42 @@
|
||||
#! /usr/bin/perl
|
||||
# IBM(c) 2016 EPL license http://www.eclipse.org/legal/epl-v10.html
|
||||
|
||||
#use lib "/home/probe/lib/perl";
|
||||
use lib "/opt/xcat/probe/lib/perl";
|
||||
use ProbeUtils;
|
||||
BEGIN { $::XCATROOT = $ENV{'XCATROOT'} ? $ENV{'XCATROOT'} : -d '/opt/xcat' ? '/opt/xcat' : '/usr'; }
|
||||
|
||||
use lib "$::XCATROOT/probe/lib/perl";
|
||||
use probe_utils;
|
||||
use File::Basename;
|
||||
use Getopt::Long;
|
||||
use Getopt::Long qw(:config no_ignore_case);
|
||||
|
||||
my $proname=basename("$0");
|
||||
my $proname = basename("$0");
|
||||
my $help;
|
||||
my $mnip;
|
||||
my $installnic;
|
||||
my $test;
|
||||
my $output="stdout";
|
||||
my $verbose=0;
|
||||
my $rst=0;
|
||||
my $output = "stdout";
|
||||
my $verbose = 0;
|
||||
my $rst = 0;
|
||||
|
||||
$::USAGE = "Usage:
|
||||
$proname -h
|
||||
$proname -t
|
||||
$proname [-m] <mnip> [-f] <outputfile> [-v]
|
||||
$proname [-n] <install_nic> [-V]
|
||||
|
||||
Description:
|
||||
After xcat installation, use this command to check if xcat has been installed correctly and is ready for use.
|
||||
|
||||
Options:
|
||||
-h : get usage information of $proname
|
||||
-t : to verify if $proname can work, reserve option for probe framework
|
||||
-m : specify current MN's IP address, if not specified, use master ip in site table
|
||||
-f : specify where should $proname pass its output to. if not specified, pass output to STDOUT by default.
|
||||
-v : output more information for debug
|
||||
-h : Get usage information of $proname
|
||||
-t : To verify if $proname can work, reserve option for probe framework
|
||||
-n : Required. Specify the network interface name of provision network
|
||||
-V : Output more information for debug
|
||||
";
|
||||
|
||||
sub returncmdoutput{
|
||||
my $rst=shift;
|
||||
sub returncmdoutput {
|
||||
my $rst = shift;
|
||||
chomp($rst);
|
||||
my @lines=split("[\n\r]", $rst);
|
||||
foreach my $line (@lines){
|
||||
ProbeUtils->send_msg("$output",0, "$line");
|
||||
my @lines = split("[\n\r]", $rst);
|
||||
foreach my $line (@lines) {
|
||||
probe_utils->send_msg("$output", "d", "$line");
|
||||
}
|
||||
}
|
||||
|
||||
@ -44,432 +45,507 @@ sub returncmdoutput{
|
||||
# main process
|
||||
#-------------------------------------
|
||||
if (
|
||||
!GetOptions("--help|h|?" => \$help,
|
||||
"t"=> \$test,
|
||||
"v"=> \$verbose,
|
||||
"f=s" => \$output,
|
||||
"m=s" => \$mnip))
|
||||
!GetOptions("--help|h" => \$help,
|
||||
"t" => \$test,
|
||||
"V" => \$verbose,
|
||||
"f=s" => \$output,
|
||||
"n=s" => \$installnic))
|
||||
{
|
||||
ProbeUtils->send_msg("$output",2, "Invalid parameter for $proname");
|
||||
ProbeUtils->send_msg("$output",0, "$::USAGE");
|
||||
probe_utils->send_msg("$output", "f", "Invalid parameter for $proname");
|
||||
probe_utils->send_msg("$output", "d", "$::USAGE");
|
||||
exit 1;
|
||||
}
|
||||
|
||||
if($help){
|
||||
if($output ne "stdout"){
|
||||
ProbeUtils->send_msg("$output",0, "$::USAGE");
|
||||
}else{
|
||||
print "$::USAGE";
|
||||
}
|
||||
exit 0;
|
||||
if ($help) {
|
||||
if ($output ne "stdout") {
|
||||
probe_utils->send_msg("$output", "d", "$::USAGE");
|
||||
} else {
|
||||
print "$::USAGE";
|
||||
}
|
||||
exit 0;
|
||||
}
|
||||
|
||||
if($test){
|
||||
ProbeUtils->send_msg("$output",3,"After xcat installation, use this command to check if xcat has been installed correctly and is ready for use. Before using this command , please install tftp, nslookup and wget commands ahead. The platform supported are redhat, sles and ubuntu.");
|
||||
exit 0;
|
||||
if ($test) {
|
||||
probe_utils->send_msg("$output", "o", "After xcat installation, use this command to check if xcat has been installed correctly and is ready for use. Before using this command , please install tftp, nslookup and wget commands ahead. The platform supported are redhat, sles and ubuntu.");
|
||||
exit 0;
|
||||
}
|
||||
|
||||
my $hostname=`hostname -s`;
|
||||
chomp($hostname);
|
||||
my $hostipaddr=`hostname -i`;
|
||||
chomp($hostipaddr);
|
||||
my $othername=`hostname -a`;
|
||||
chomp($othername);
|
||||
if (!defined($installnic)) {
|
||||
probe_utils->send_msg("$output", "f", "Option -n is required");
|
||||
probe_utils->send_msg("$output", "d", "$::USAGE");
|
||||
exit 1;
|
||||
}
|
||||
|
||||
ProbeUtils->send_msg("$output",0,"Short hostname of this server is $hostname") if($verbose);
|
||||
ProbeUtils->send_msg("$output",0,"The address of hostname $hostname is $hostipaddr") if($verbose);
|
||||
ProbeUtils->send_msg("$output",0,"The other names of $hostname is $othername") if($verbose && ($othername ne ""));
|
||||
my $msg = "NIC $installnic exists on current server";
|
||||
my $nics = `ip addr show 2>&1 | grep -E '^[1-9]' | cut -d: -f2 |grep $installnic`;
|
||||
if ($?) {
|
||||
probe_utils->send_msg("$output", "f", "$msg");
|
||||
probe_utils->send_msg("$output", "d", "Please use 'ip addr show' to check if there is NIC named $installnic on current server");
|
||||
exit 1;
|
||||
} else {
|
||||
probe_utils->send_msg("$output", "o", "$msg");
|
||||
}
|
||||
|
||||
my $msg="Sub process 'xcatd: SSL listener' is running";
|
||||
$msg = "Get ip address of NIC $installnic";
|
||||
my $mnip = `ip addr show |grep -A2 $installnic: | awk -F" " '/inet/ {print \$2}'|awk -F"/" '{print \$1}'`;
|
||||
chomp($mnip);
|
||||
if (!defined($mnip) || ($mnip eq "")) {
|
||||
probe_utils->send_msg("$output", "f", "$msg");
|
||||
probe_utils->send_msg("$output", "d", "Please use 'ip addr show' to check if there is ip assigned to $installnic");
|
||||
exit 1;
|
||||
} else {
|
||||
probe_utils->send_msg("$output", "d", "The IP of NIC $installnic is $mnip") if ($verbose);
|
||||
probe_utils->send_msg("$output", "o", "$msg");
|
||||
}
|
||||
|
||||
$msg = "Sub process 'xcatd: SSL listener' is running";
|
||||
my $xcatdproc = `ps aux|grep -v grep|grep xcatd`;
|
||||
chomp($xcatdproc);
|
||||
if($xcatdproc =~ /xcatd: SSL listener/){
|
||||
ProbeUtils->send_msg("$output",3,"$msg");
|
||||
}else{
|
||||
ProbeUtils->send_msg("$output",2,"$msg");
|
||||
$rst=1;
|
||||
if ($xcatdproc =~ /xcatd: SSL listener/) {
|
||||
probe_utils->send_msg("$output", "o", "$msg");
|
||||
} else {
|
||||
probe_utils->send_msg("$output", "f", "$msg");
|
||||
$rst = 1;
|
||||
}
|
||||
|
||||
$msg="Sub process 'xcatd: DB Access' is running";
|
||||
if($xcatdproc =~ /xcatd: DB Access/){
|
||||
ProbeUtils->send_msg("$output",3,"$msg");
|
||||
}else{
|
||||
ProbeUtils->send_msg("$output",2,"$msg");
|
||||
$rst=1;
|
||||
$msg = "Sub process 'xcatd: DB Access' is running";
|
||||
if ($xcatdproc =~ /xcatd: DB Access/) {
|
||||
probe_utils->send_msg("$output", "o", "$msg");
|
||||
} else {
|
||||
probe_utils->send_msg("$output", "f", "$msg");
|
||||
$rst = 1;
|
||||
}
|
||||
|
||||
$msg="Sub process 'xcatd: UDP listener' is running";
|
||||
if($xcatdproc =~ /xcatd: UDP listener/){
|
||||
ProbeUtils->send_msg("$output",3,"$msg");
|
||||
}else{
|
||||
ProbeUtils->send_msg("$output",2,"$msg");
|
||||
$rst=1;
|
||||
$msg = "Sub process 'xcatd: UDP listener' is running";
|
||||
if ($xcatdproc =~ /xcatd: UDP listener/) {
|
||||
probe_utils->send_msg("$output", "o", "$msg");
|
||||
} else {
|
||||
probe_utils->send_msg("$output", "f", "$msg");
|
||||
$rst = 1;
|
||||
}
|
||||
|
||||
$msg="Sub process 'xcatd: install monitor' is running";
|
||||
if($xcatdproc =~ /xcatd: install monitor/){
|
||||
ProbeUtils->send_msg("$output",3,"$msg");
|
||||
}else{
|
||||
ProbeUtils->send_msg("$output",2,"$msg");
|
||||
$rst=1;
|
||||
$msg = "Sub process 'xcatd: install monitor' is running";
|
||||
if ($xcatdproc =~ /xcatd: install monitor/) {
|
||||
probe_utils->send_msg("$output", "o", "$msg");
|
||||
} else {
|
||||
probe_utils->send_msg("$output", "f", "$msg");
|
||||
$rst = 1;
|
||||
}
|
||||
|
||||
$msg="Sub process 'xcatd: Discovery worker' is running";
|
||||
if($xcatdproc =~ /xcatd: Discovery worker/){
|
||||
ProbeUtils->send_msg("$output",3,"$msg");
|
||||
}else{
|
||||
ProbeUtils->send_msg("$output",2,"$msg");
|
||||
$rst=1;
|
||||
$msg = "Sub process 'xcatd: Discovery worker' is running";
|
||||
if ($xcatdproc =~ /xcatd: Discovery worker/) {
|
||||
probe_utils->send_msg("$output", "o", "$msg");
|
||||
} else {
|
||||
probe_utils->send_msg("$output", "f", "$msg");
|
||||
$rst = 1;
|
||||
}
|
||||
|
||||
$msg="Sub process 'xcatd: Command log writer' is running";
|
||||
if($xcatdproc =~ /xcatd: Command log writer/){
|
||||
ProbeUtils->send_msg("$output",3,"$msg");
|
||||
}else{
|
||||
ProbeUtils->send_msg("$output",1,"Sub process 'xcatd: Command log writer' isn't running");
|
||||
$msg = "Sub process 'xcatd: Command log writer' is running";
|
||||
if ($xcatdproc =~ /xcatd: Command log writer/) {
|
||||
probe_utils->send_msg("$output", "o", "$msg");
|
||||
} else {
|
||||
probe_utils->send_msg("$output", "w", "Sub process 'xcatd: Command log writer' isn't running");
|
||||
}
|
||||
exit 1 if($rst);
|
||||
|
||||
exit 1 if ($rst);
|
||||
|
||||
my $xcatdport=`tabdump site 2>&1 | awk -F',' '/xcatdport/ { gsub(/"/, "", \$2) ; print \$2 }'`;
|
||||
|
||||
my $xcatdport = `tabdump site 2>&1 | awk -F',' '/xcatdport/ { gsub(/"/, "", \$2) ; print \$2 }'`;
|
||||
chomp($xcatdport);
|
||||
ProbeUtils->send_msg("$output",0,"The port used by the xcatd daemon for client/server communication is $xcatdport") if($verbose);
|
||||
$msg="xcatd is listening on port $xcatdport";
|
||||
probe_utils->send_msg("$output", "d", "The port used by the xcatd daemon for client/server communication is $xcatdport") if ($verbose);
|
||||
$msg = "xcatd is listening on port $xcatdport";
|
||||
my $cmdoutput = `netstat -ant|grep LISTEN|grep $xcatdport`;
|
||||
if($?){
|
||||
ProbeUtils->send_msg("$output",2,"$msg");
|
||||
$rst=1;
|
||||
}else{
|
||||
ProbeUtils->send_msg("$output",3,"$msg");
|
||||
if ($?) {
|
||||
probe_utils->send_msg("$output", "f", "$msg");
|
||||
$rst = 1;
|
||||
} else {
|
||||
probe_utils->send_msg("$output", "o", "$msg");
|
||||
}
|
||||
|
||||
my $xcatiport=`tabdump site 2>&1| awk -F',' '/xcatiport/ { gsub(/"/, "", \$2) ; print \$2 }'`;
|
||||
my $xcatiport = `tabdump site 2>&1| awk -F',' '/xcatiport/ { gsub(/"/, "", \$2) ; print \$2 }'`;
|
||||
chomp($xcatiport);
|
||||
ProbeUtils->send_msg("$output",0,"The port used by xcatd to receive install status updates from nodes is $xcatiport") if($verbose);
|
||||
$msg="xcatd is listening on port $xcatiport";
|
||||
$cmdoutput = `netstat -ant|grep LISTEN|grep $xcatiport`;
|
||||
if($?){
|
||||
ProbeUtils->send_msg("$output",2,"$msg");
|
||||
$rst=1;
|
||||
}else{
|
||||
ProbeUtils->send_msg("$output",3,"$msg");
|
||||
probe_utils->send_msg("$output", "d", "The port used by xcatd to receive install status updates from nodes is $xcatiport") if ($verbose);
|
||||
$msg = "xcatd is listening on port $xcatiport";
|
||||
$cmdoutput = `netstat -antp | grep -i xcatd|grep LISTEN|grep $xcatiport`;
|
||||
if ($?) {
|
||||
probe_utils->send_msg("$output", "f", "$msg");
|
||||
$rst = 1;
|
||||
} else {
|
||||
probe_utils->send_msg("$output", "o", "$msg");
|
||||
}
|
||||
exit 1 if($rst);
|
||||
|
||||
$msg ="'lsxcatd -a' works";
|
||||
$cmdoutput=`lsxcatd -a 2>&1`;
|
||||
$rst=$?;
|
||||
returncmdoutput($cmdoutput) if($verbose);
|
||||
if($rst){
|
||||
ProbeUtils->send_msg("$output",2,"$msg");
|
||||
exit 1 if ($rst);
|
||||
|
||||
$msg = "'lsxcatd -a' works";
|
||||
$cmdoutput = `lsxcatd -a 2>&1`;
|
||||
$rst = $?;
|
||||
returncmdoutput($cmdoutput) if ($verbose);
|
||||
if ($rst) {
|
||||
probe_utils->send_msg("$output", "f", "$msg");
|
||||
exit $rst;
|
||||
}else{
|
||||
ProbeUtils->send_msg("$output",3,"$msg");
|
||||
} else {
|
||||
probe_utils->send_msg("$output", "o", "$msg");
|
||||
}
|
||||
|
||||
my $masteripinsite=`tabdump site | awk -F',' '/master/ { gsub(/"/, "", \$2) ; print \$2 }'`;
|
||||
my $masteripinsite = `tabdump site | awk -F',' '/master/ { gsub(/"/, "", \$2) ; print \$2 }'`;
|
||||
chomp($masteripinsite);
|
||||
ProbeUtils->send_msg("$output",0, "The value of 'master' in 'site' table is $masteripinsite") if($verbose);
|
||||
ProbeUtils->send_msg("$output",2, "There isn't 'master' definition in 'site' talbe") if($masteripinsite eq "");
|
||||
probe_utils->send_msg("$output", "d", "The value of 'master' in 'site' table is $masteripinsite") if ($verbose);
|
||||
probe_utils->send_msg("$output", "f", "There isn't 'master' definition in 'site' talbe") if ($masteripinsite eq "");
|
||||
|
||||
$msg="The value of 'master' in 'site' table is a IP address";
|
||||
if(ProbeUtils->isIpAddr("$masteripinsite")){
|
||||
ProbeUtils->send_msg("$output",3,"$msg");
|
||||
}else{
|
||||
ProbeUtils->send_msg("$output",2,"$msg");
|
||||
$msg = "The value of 'master' in 'site' table is a IP address";
|
||||
if (probe_utils->is_ip_addr("$masteripinsite")) {
|
||||
probe_utils->send_msg("$output", "o", "$msg");
|
||||
} else {
|
||||
probe_utils->send_msg("$output", "f", "$msg");
|
||||
exit 1;
|
||||
}
|
||||
|
||||
if($mnip){
|
||||
$msg="The IP passed by command line equals the value of 'master' in 'site' table";
|
||||
if($mnip eq $masteripinsite){
|
||||
ProbeUtils->send_msg("$output",3,"$msg");
|
||||
}else{
|
||||
ProbeUtils->send_msg("$output",2,"$msg");
|
||||
$rst=1;
|
||||
if ($mnip) {
|
||||
$msg = "The IP of $installnic equals the value of 'master' in 'site' table";
|
||||
if ($mnip eq $masteripinsite) {
|
||||
probe_utils->send_msg("$output", "o", "$msg");
|
||||
} else {
|
||||
probe_utils->send_msg("$output", "f", "$msg");
|
||||
$rst = 1;
|
||||
}
|
||||
}else{
|
||||
ProbeUtils->send_msg("$output",0,"Use the value of 'master' of 'site' table as MNIP") if($verbose);
|
||||
$mnip=$masteripinsite;
|
||||
}
|
||||
|
||||
ProbeUtils->send_msg("$output",0,"MNIP used in below checking is $mnip") if($verbose);
|
||||
|
||||
$msg="There is configuration in 'passwd' table for 'system' for node provision";
|
||||
my $passwd=`tabdump passwd |awk -F',' '/system/ { gsub(/"/, "", \$2); gsub(/"/, "", \$3); print \$2,\$3 }'`;
|
||||
chomp($passwd);
|
||||
my ($username, $pw)=split(" ", $passwd);
|
||||
if($username eq "" || $pw eq ""){
|
||||
ProbeUtils->send_msg("$output",0,"There isn't username or password for 'system' in 'passwd' table");
|
||||
ProbeUtils->send_msg("$output",2,"$msg");
|
||||
$rst=1;
|
||||
}else{
|
||||
ProbeUtils->send_msg("$output",3,"$msg");
|
||||
$msg = "IP $mnip of NIC $installnic is a static IP on current server";
|
||||
if (probe_utils->is_static_ip("$mnip", "$installnic")) {
|
||||
probe_utils->send_msg("$output", "o", "$msg");
|
||||
} else {
|
||||
probe_utils->send_msg("$output", "w", "IP $mnip of $installnic is not a static ip on current server");
|
||||
}
|
||||
|
||||
$msg="There is a network adapter on current server is configured by IP $mnip";
|
||||
my $nic=`ip addr show |grep -B2 $mnip|grep mtu|awk '{print \$2}'|sed -e 's/:\$//'`;
|
||||
chomp($nic);
|
||||
if("$nic" eq ""){
|
||||
ProbeUtils->send_msg("$output",2,"$msg");
|
||||
$rst=1;
|
||||
}else{
|
||||
ProbeUtils->send_msg("$output",0,"IP $mnip belongs to network adapter $nic") if($verbose);
|
||||
ProbeUtils->send_msg("$output",3,"$msg");
|
||||
}
|
||||
|
||||
$msg="IP $mnip is a static IP on current server";
|
||||
if(ProbeUtils->isStaticIp("$mnip", "$nic")){
|
||||
ProbeUtils->send_msg("$output",3,"$msg");
|
||||
}else{
|
||||
ProbeUtils->send_msg("$output",1,"IP $mnip is not a static ip on current server");
|
||||
}
|
||||
|
||||
$msg="$mnip belongs to one of networks defined in 'networks' table";
|
||||
my $networks=`tabdump networks|grep -v "^#"`;
|
||||
$networks=~s/\"//g;
|
||||
$msg = "$mnip belongs to one of networks defined in 'networks' table";
|
||||
my $networks = `tabdump networks|grep -v "^#"`;
|
||||
$networks =~ s/\"//g;
|
||||
my $netcnt = `echo "$networks"|wc -l`;
|
||||
my $hit=0;
|
||||
for(my $i=1;$i<$netcnt+1;$i++){
|
||||
my $line=`echo "$networks" |sed -n ${i}p |awk -F"," '{print \$2,\$3,\$4}'`;
|
||||
my $hit = 0;
|
||||
for (my $i = 1 ; $i < $netcnt + 1 ; $i++) {
|
||||
my $line = `echo "$networks" |sed -n ${i}p |awk -F"," '{print \$2,\$3,\$4}'`;
|
||||
chomp($line);
|
||||
if($line =~ /(.+) (.+) (.+)/){
|
||||
$hit=1 if(ProbeUtils->isIpBelongToNet("$1", "$2", $mnip) && ("$3" eq "$nic"));
|
||||
if ($line =~ /(.+) (.+) (.+)/) {
|
||||
$hit = 1 if (probe_utils->is_ip_belong_to_net("$1", "$2", $mnip) && ("$3" eq "$installnic"));
|
||||
}
|
||||
}
|
||||
if($hit){
|
||||
ProbeUtils->send_msg("$output",3,"$msg");
|
||||
}else{
|
||||
ProbeUtils->send_msg("$output",2,"$msg");
|
||||
$rst=1;
|
||||
if ($hit) {
|
||||
probe_utils->send_msg("$output", "o", "$msg");
|
||||
} else {
|
||||
probe_utils->send_msg("$output", "f", "$msg");
|
||||
$rst = 1;
|
||||
}
|
||||
|
||||
$msg="There is domain definition in 'site' table";
|
||||
my $domain=`tabdump site | awk -F',' '/domain/ { gsub(/"/, "", \$2) ; print \$2 }'`;
|
||||
$msg = "There is domain definition in 'site' table";
|
||||
my $domain = `tabdump site | awk -F',' '/domain/ { gsub(/"/, "", \$2) ; print \$2 }'`;
|
||||
chomp($domain);
|
||||
if($domain){
|
||||
ProbeUtils->send_msg("$output",0,"The value of 'domain' in 'site' table is $domain") if($verbose);
|
||||
ProbeUtils->send_msg("$output",3,"$msg");
|
||||
}else{
|
||||
ProbeUtils->send_msg("$output",2,"$msg");
|
||||
$rst=1;
|
||||
if ($domain) {
|
||||
probe_utils->send_msg("$output", "d", "The value of 'domain' in 'site' table is $domain") if ($verbose);
|
||||
probe_utils->send_msg("$output", "o", "$msg");
|
||||
} else {
|
||||
probe_utils->send_msg("$output", "f", "$msg");
|
||||
$rst = 1;
|
||||
}
|
||||
|
||||
$msg="There are /install and /install/postscripts directory on current server";
|
||||
if(-e "/install/postscripts/"){
|
||||
ProbeUtils->send_msg("$output",3,"$msg");
|
||||
}else{
|
||||
ProbeUtils->send_msg("$output",2,"$msg");
|
||||
$rst=1;
|
||||
$msg = "There is configuration in 'passwd' table for 'system' for node provision";
|
||||
my $passwd = `tabdump passwd |awk -F',' '/system/ { gsub(/"/, "", \$2); gsub(/"/, "", \$3); print \$2,\$3 }'`;
|
||||
chomp($passwd);
|
||||
my ($username, $pw) = split(" ", $passwd);
|
||||
if ($username eq "" || $pw eq "") {
|
||||
probe_utils->send_msg("$output", "f", "$msg");
|
||||
probe_utils->send_msg("$output", "d", "Please define username and password for 'system' in 'passwd' table");
|
||||
$rst = 1;
|
||||
} else {
|
||||
probe_utils->send_msg("$output", "o", "$msg");
|
||||
}
|
||||
|
||||
$msg="There is /tftpboot directory on current server";
|
||||
if(-e "/tftpboot/"){
|
||||
ProbeUtils->send_msg("$output",3,"$msg");
|
||||
}else{
|
||||
ProbeUtils->send_msg("$output",2,"$msg");
|
||||
$rst=1;
|
||||
my $installdir = `tabdump site 2>&1 | awk -F',' '/installdir/ { gsub(/"/, "", \$2) ; print \$2 }'`;
|
||||
chomp($installdir);
|
||||
probe_utils->send_msg("$output", "d", "The 'install' directory is set to $installdir in 'site' table on current server") if ($verbose);
|
||||
my $tftpdir = `tabdump site 2>&1 | awk -F',' '/tftpdir/ { gsub(/"/, "", \$2) ; print \$2 }'`;
|
||||
chomp($tftpdir);
|
||||
probe_utils->send_msg("$output", "d", "The 'tftp' directory is set to $tftpdir in 'site' talbe on current server") if ($verbose);
|
||||
|
||||
$msg = "There is $installdir directory on current server";
|
||||
if (-e "$installdir/postscripts/") {
|
||||
probe_utils->send_msg("$output", "o", "$msg");
|
||||
} else {
|
||||
probe_utils->send_msg("$output", "f", "$msg");
|
||||
$rst = 1;
|
||||
}
|
||||
|
||||
my $expected=10;
|
||||
$msg="The free space of / directory is more than $expected G";
|
||||
my $diskspace=`df -h|awk '{print \$4,\$6}'|grep -E "/\$"`;
|
||||
if($?){
|
||||
ProbeUtils->send_msg("$output",0,"There isn't any filesystem mount on / directory");
|
||||
ProbeUtils->send_msg("$output",2,"$msg");
|
||||
$rst=1;
|
||||
}else{
|
||||
$msg = "There is $tftpdir directory on current server";
|
||||
if (-e "$tftpdir") {
|
||||
probe_utils->send_msg("$output", "o", "$msg");
|
||||
} else {
|
||||
probe_utils->send_msg("$output", "f", "$msg");
|
||||
$rst = 1;
|
||||
}
|
||||
|
||||
my $expected = 10;
|
||||
$msg = "The free space of / directory is more than $expected G";
|
||||
my $diskspace = `df -h|awk '{print \$4,\$6}'|grep -E "/\$"`;
|
||||
if ($?) {
|
||||
probe_utils->send_msg("$output", "d", "There isn't any filesystem mount on / directory");
|
||||
probe_utils->send_msg("$output", "f", "$msg");
|
||||
$rst = 1;
|
||||
} else {
|
||||
chomp($diskspace);
|
||||
my ($size, $dir) = split(" ", $diskspace);
|
||||
$size=~s/G//g;
|
||||
ProbeUtils->send_msg("$output",0,"The free space of / is $size G") if($verbose);
|
||||
if($size<$expected){
|
||||
ProbeUtils->send_msg("$output",1,"The free space of / is less than $expected G");
|
||||
}else{
|
||||
ProbeUtils->send_msg("$output",3,"$msg");
|
||||
$size =~ s/G//g;
|
||||
probe_utils->send_msg("$output", "d", "The free space of / is $size G") if ($verbose);
|
||||
if ($size < $expected) {
|
||||
probe_utils->send_msg("$output", "w", "The free space of / is less than $expected G");
|
||||
} else {
|
||||
probe_utils->send_msg("$output", "o", "$msg");
|
||||
}
|
||||
}
|
||||
|
||||
$expected=1;
|
||||
$msg="The free space of /var directory is more than $expected G";
|
||||
$diskspace=`df -h|awk '{print \$4,\$6}'|grep -E "/var\$"`;
|
||||
if(!$?){
|
||||
$expected = 1;
|
||||
$msg = "The free space of /var directory is more than $expected G";
|
||||
$diskspace = `df -h|awk '{print \$4,\$6}'|grep -E "/var\$"`;
|
||||
if (!$?) {
|
||||
chomp($diskspace);
|
||||
my ($size, $dir) = split(" ", $diskspace);
|
||||
$size=~s/G//g;
|
||||
ProbeUtils->send_msg("$output",0,"The free space of /var is $size G") if($verbose);
|
||||
if($size<$expected){
|
||||
ProbeUtils->send_msg("$output",1,"The free space of /var is less than $expected G");
|
||||
}else{
|
||||
ProbeUtils->send_msg("$output",3,"$msg");
|
||||
$size =~ s/G//g;
|
||||
probe_utils->send_msg("$output", "d", "The free space of /var is $size G") if ($verbose);
|
||||
if ($size < $expected) {
|
||||
probe_utils->send_msg("$output", "w", "The free space of /var is less than $expected G");
|
||||
} else {
|
||||
probe_utils->send_msg("$output", "o", "$msg");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$expected=1;
|
||||
$msg="The free space of /tmp directory is more than $expected G";
|
||||
$diskspace=`df -h|awk '{print \$4,\$6}'|grep -E "/tmp\$"`;
|
||||
if(!$?){
|
||||
$expected = 1;
|
||||
$msg = "The free space of /tmp directory is more than $expected G";
|
||||
$diskspace = `df -h|awk '{print \$4,\$6}'|grep -E "/tmp\$"`;
|
||||
if (!$?) {
|
||||
chomp($diskspace);
|
||||
my ($size, $dir) = split(" ", $diskspace);
|
||||
$size=~s/G//g;
|
||||
ProbeUtils->send_msg("$output",0,"The free space of /tmp is $size G") if($verbose);
|
||||
if($size<$expected){
|
||||
ProbeUtils->send_msg("$output",1,"The free space of /tmp is less than $expected G");
|
||||
}else{
|
||||
ProbeUtils->send_msg("$output",3,"$msg");
|
||||
$size =~ s/G//g;
|
||||
probe_utils->send_msg("$output", "d", "The free space of /tmp is $size G") if ($verbose);
|
||||
if ($size < $expected) {
|
||||
probe_utils->send_msg("$output", "w", "The free space of /tmp is less than $expected G");
|
||||
} else {
|
||||
probe_utils->send_msg("$output", "o", "$msg");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$expected=10;
|
||||
$msg="The free space of /install directory is more than $expected G";
|
||||
$diskspace=`df -h|awk '{print \$4,\$6}'|grep -E "/install\$"`;
|
||||
if(!$?){
|
||||
$expected = 10;
|
||||
$msg = "The free space of $installdir directory is more than $expected G";
|
||||
$diskspace = `df -h|awk '{print \$4,\$6}'|grep -E "$installdir\$"`;
|
||||
if (!$?) {
|
||||
chomp($diskspace);
|
||||
my ($size, $dir) = split(" ", $diskspace);
|
||||
$size=~s/G//g;
|
||||
ProbeUtils->send_msg("$output",0,"The free space of /install is $size G") if($verbose);
|
||||
if($size<$expected){
|
||||
ProbeUtils->send_msg("$output",1,"The free space of /install is less than $expected G");
|
||||
}else{
|
||||
ProbeUtils->send_msg("$output",3,"$msg");
|
||||
$size =~ s/G//g;
|
||||
probe_utils->send_msg("$output", "d", "The free space of /install is $size G") if ($verbose);
|
||||
if ($size < $expected) {
|
||||
probe_utils->send_msg("$output", "w", "The free space of /install is less than $expected G");
|
||||
} else {
|
||||
probe_utils->send_msg("$output", "o", "$msg");
|
||||
}
|
||||
}
|
||||
|
||||
$msg="SELinux is disabled on current server";
|
||||
if(ProbeUtils->isSelinuxEnable()){
|
||||
ProbeUtils->send_msg("$output",2,"$msg");
|
||||
$rst=1;
|
||||
}else{
|
||||
ProbeUtils->send_msg("$output",3,"$msg");
|
||||
$msg = "SELinux is disabled on current server";
|
||||
if (probe_utils->is_selinux_enable()) {
|
||||
probe_utils->send_msg("$output", "f", "$msg");
|
||||
$rst = 1;
|
||||
} else {
|
||||
probe_utils->send_msg("$output", "o", "$msg");
|
||||
}
|
||||
|
||||
$msg="Firewall is closed on current server";
|
||||
if(ProbeUtils->isFirewallOpen()){
|
||||
ProbeUtils->send_msg("$output",2,"$msg");
|
||||
$rst=1;
|
||||
}else{
|
||||
ProbeUtils->send_msg("$output",3,"$msg");
|
||||
$msg = "Firewall is closed on current server";
|
||||
if (probe_utils->is_firewall_open()) {
|
||||
probe_utils->send_msg("$output", "f", "$msg");
|
||||
$rst = 1;
|
||||
} else {
|
||||
probe_utils->send_msg("$output", "o", "$msg");
|
||||
}
|
||||
|
||||
`which wget > /dev/null 2>&1`;
|
||||
if($?){
|
||||
ProbeUtils->send_msg("$output",1,"wget command isn't installed on current server, skip checking HTTP service");
|
||||
}else{
|
||||
$msg="HTTP service is ready on $mnip";
|
||||
if(ProbeUtils->isHttpReady("$mnip")){
|
||||
ProbeUtils->send_msg("$output",3,"$msg");
|
||||
}else{
|
||||
ProbeUtils->send_msg("$output",2,"$msg");
|
||||
$rst=1;
|
||||
if ($?) {
|
||||
probe_utils->send_msg("$output", "w", "wget tool isn't installed on current server, skip checking HTTP service.");
|
||||
probe_utils->send_msg("$output", "d", "Please do probe again after installing wget");
|
||||
} else {
|
||||
$msg = "HTTP service is ready on $mnip";
|
||||
if (probe_utils->is_http_ready("$mnip")) {
|
||||
probe_utils->send_msg("$output", "o", "$msg");
|
||||
} else {
|
||||
probe_utils->send_msg("$output", "f", "$msg");
|
||||
$rst = 1;
|
||||
}
|
||||
}
|
||||
|
||||
`which tftp > /dev/null 2>&1`;
|
||||
if($?){
|
||||
ProbeUtils->send_msg("$output",1,"tftp command isn't installed in current server, skip checking tftp service");
|
||||
}else{
|
||||
$msg="TFTP service is ready on $mnip";
|
||||
if(ProbeUtils->isTftpReady("$mnip")){
|
||||
ProbeUtils->send_msg("$output",3,"$msg");
|
||||
}else{
|
||||
ProbeUtils->send_msg("$output",2,"$msg");
|
||||
$rst =1;
|
||||
if ($?) {
|
||||
probe_utils->send_msg("$output", "w", "tftp tool isn't installed on current server, skip checking tftp service.");
|
||||
probe_utils->send_msg("$output", "d", "Please do probe again after installing tftp");
|
||||
} else {
|
||||
$msg = "TFTP service is ready on $mnip";
|
||||
if (probe_utils->is_tftp_ready("$mnip")) {
|
||||
probe_utils->send_msg("$output", "o", "$msg");
|
||||
} else {
|
||||
probe_utils->send_msg("$output", "f", "$msg");
|
||||
$rst = 1;
|
||||
}
|
||||
}
|
||||
|
||||
`which nslookup > /dev/null 2>&1`;
|
||||
if($?){
|
||||
ProbeUtils->send_msg("$output",1,"nslookup command isn't installed in current server, skip checking DNS service");
|
||||
}else{
|
||||
$msg="DNS server is ready on $mnip";
|
||||
ProbeUtils->send_msg("$output",0,"hostname used to check DNS is $hostname, domain used to check DNS is $domain") if($verbose);
|
||||
if(ProbeUtils->isDnsReady("$mnip","$hostname", "$domain")){
|
||||
ProbeUtils->send_msg("$output",3,"$msg");
|
||||
}else{
|
||||
ProbeUtils->send_msg("$output",2,"$msg");
|
||||
$rst =1;
|
||||
if ($?) {
|
||||
probe_utils->send_msg("$output", "w", "nslookup tool isn't installed in current server, skip checking DNS service.");
|
||||
probe_utils->send_msg("$output", "d", "Please do probe again after installing nslookup");
|
||||
} else {
|
||||
$msg = "DNS server is ready on $mnip";
|
||||
probe_utils->send_msg("$output", "d", "Domain used to check DNS is $domain") if ($verbose);
|
||||
|
||||
my $rc = 0;
|
||||
{ #very important brace to create a block
|
||||
my $tmp = `chdef xcatmntest groups=all ip=$mnip`;
|
||||
if ($?) {
|
||||
returncmdoutput($tmp) if ($verbose);
|
||||
probe_utils->send_msg("$output", "d", "Simulate a node by chdef failed") if ($verbose);
|
||||
$rc = 1;
|
||||
last;
|
||||
} else {
|
||||
probe_utils->send_msg("$output", "d", "Simulate a node xcatmntest<ip=$mnip> to do DNS test") if ($verbose);
|
||||
}
|
||||
|
||||
probe_utils->send_msg("$output", "d", "To do 'makehosts xcatmntest'") if ($verbose);
|
||||
$tmp = `makehosts xcatmntest`;
|
||||
if ($?) {
|
||||
returncmdoutput($tmp) if ($verbose);
|
||||
probe_utils->send_msg("$output", "d", "makehosts xcatmntest failed") if ($verbose);
|
||||
$rc = 1;
|
||||
`rmdef xcatmntest`;
|
||||
last;
|
||||
}
|
||||
|
||||
$tmp = `cat /etc/hosts |grep xcatmntest |grep $mnip`;
|
||||
if ($?) {
|
||||
probe_utils->send_msg("$output", "d", "makehosts failed to add test node xcatmntest to /etc/hosts") if ($verbose);
|
||||
$rc = 1;
|
||||
`rmdef xcatmntest`;
|
||||
last;
|
||||
}
|
||||
|
||||
probe_utils->send_msg("$output", "d", "To do 'makedns -n xcatmntest'") if ($verbose);
|
||||
$tmp = `makedns -V -n xcatmntest 2>&1`;
|
||||
if ($?) {
|
||||
returncmdoutput($tmp) if ($verbose);
|
||||
probe_utils->send_msg("$output", "d", "makedns -n xcatmntest failed") if ($verbose);
|
||||
$rc = 1;
|
||||
`makehosts -d xcatmntest && rmdef xcatmntest`;
|
||||
last;
|
||||
}
|
||||
|
||||
if (!probe_utils->is_dns_ready("$mnip", "xcatmntest", "$domain")) {
|
||||
probe_utils->send_msg("$output", "d", "nslookup xcatmntest $mnip failed");
|
||||
$rc = 1;
|
||||
`makehosts -d xcatmntest && rmdef xcatmntest`;
|
||||
last;
|
||||
}
|
||||
|
||||
probe_utils->send_msg("$output", "d", "Start to clear simulate information for DNS test") if ($verbose);
|
||||
$tmp = `makedns -d xcatmntest && makehosts -d xcatmntest && rmdef xcatmntest`;
|
||||
returncmdoutput($tmp) if ($verbose);
|
||||
}
|
||||
|
||||
if ($rc) {
|
||||
probe_utils->send_msg("$output", "f", "$msg");
|
||||
$rst = 1;
|
||||
} else {
|
||||
probe_utils->send_msg("$output", "o", "$msg");
|
||||
}
|
||||
}
|
||||
|
||||
my $os=ProbeUtils->getOS();
|
||||
my $leasefile="";
|
||||
$leasefile="/var/lib/dhcpd/dhcpd.leases" if($os =~ /redhat/i);
|
||||
$leasefile="/var/lib/dhcp/db/dhcpd.leases" if($os =~ /sles/i);
|
||||
$leasefile="/var/lib/dhcp/dhcpd.leases" if($os =~ /ubuntu/i);
|
||||
$msg="The size of $leasefile is less than 100M";
|
||||
my $filesizetmp=`du -sb $leasefile`;
|
||||
if($?){
|
||||
returncmdoutput($filesizetmp) if($verbose);
|
||||
ProbeUtils->send_msg("$output",2,"$msg");
|
||||
$rst=1;
|
||||
}else{
|
||||
chomp($filesizetmp);
|
||||
my ($size, $file) = split(" ", $filesizetmp);
|
||||
ProbeUtils->send_msg("$output",0,"The size of $leasefile is $size bytes") if($verbose);
|
||||
if($size > 104857600){
|
||||
ProbeUtils->send_msg("$output",1,"The size of $leasefile is more than 100M");
|
||||
}else{
|
||||
ProbeUtils->send_msg("$output",3,"$msg");
|
||||
}
|
||||
my $os = probe_utils->get_os();
|
||||
my $leasefile = "";
|
||||
$leasefile = "/var/lib/dhcpd/dhcpd.leases" if ($os =~ /redhat/i);
|
||||
$leasefile = "/var/lib/dhcp/db/dhcpd.leases" if ($os =~ /sles/i);
|
||||
$leasefile = "/var/lib/dhcp/dhcpd.leases" if ($os =~ /ubuntu/i);
|
||||
$msg = "The size of $leasefile is less than 100M";
|
||||
my $filesizetmp = `du -sb $leasefile`;
|
||||
if ($?) {
|
||||
returncmdoutput($filesizetmp) if ($verbose);
|
||||
probe_utils->send_msg("$output", "f", "$msg");
|
||||
$rst = 1;
|
||||
} else {
|
||||
chomp($filesizetmp);
|
||||
my ($size, $file) = split(" ", $filesizetmp);
|
||||
probe_utils->send_msg("$output", "d", "The size of $leasefile is $size bytes") if ($verbose);
|
||||
if ($size > 104857600) {
|
||||
probe_utils->send_msg("$output", "w", "The size of $leasefile is more than 100M");
|
||||
} else {
|
||||
probe_utils->send_msg("$output", "o", "$msg");
|
||||
}
|
||||
}
|
||||
|
||||
my $msg="DHCP service is ready on $mnip";
|
||||
my $rc=0;
|
||||
my $msg = "DHCP service is ready on $mnip";
|
||||
my $rc = 0;
|
||||
{ #very important brace to create a block
|
||||
my $tmp=`chdef xcatmntest groups=all ip=$mnip mac=aa:aa:aa:aa:aa:aa`;
|
||||
if($?){
|
||||
returncmdoutput($tmp) if($verbose);
|
||||
ProbeUtils->send_msg("$output",0,"Simulate a node by chdef failed") if($verbose);
|
||||
$rc=1;
|
||||
last;
|
||||
}else{
|
||||
ProbeUtils->send_msg("$output",0,"Simulate a node xcatmntest<ip=$mnip mac=aa:aa:aa:aa:aa:aa> to do dhcp test") if($verbose);
|
||||
}
|
||||
|
||||
$tmp=`makehosts xcatmntest`;
|
||||
if($?){
|
||||
returncmdoutput($tmp) if($verbose);
|
||||
ProbeUtils->send_msg("$output",0,"makehosts xcatmntest failed") if($verbose);
|
||||
$rc=1;
|
||||
`rmdef xcatmntest`;
|
||||
last;
|
||||
my $tmp = `chdef xcatmntest groups=all ip=$mnip mac=aa:aa:aa:aa:aa:aa`; if ($?) {
|
||||
returncmdoutput($tmp) if ($verbose);
|
||||
probe_utils->send_msg("$output", "d", "Simulate a node by chdef failed") if ($verbose);
|
||||
$rc = 1;
|
||||
last;
|
||||
} else {
|
||||
probe_utils->send_msg("$output", "d", "Simulate a node xcatmntest<ip=$mnip mac=aa:aa:aa:aa:aa:aa> to do dhcp test") if ($verbose);
|
||||
}
|
||||
|
||||
probe_utils->send_msg("$output", "d", "To do 'makehosts xcatmntest'") if ($verbose);
|
||||
$tmp = `makehosts xcatmntest`;
|
||||
if ($?) {
|
||||
returncmdoutput($tmp) if ($verbose);
|
||||
probe_utils->send_msg("$output", "d", "makehosts xcatmntest failed") if ($verbose);
|
||||
$rc = 1;
|
||||
`rmdef xcatmntest`;
|
||||
last;
|
||||
}
|
||||
|
||||
$tmp = `cat /etc/hosts |grep xcatmntest |grep $mnip`;
|
||||
if ($?) {
|
||||
probe_utils->send_msg("$output", "d", "makehosts failed to add test node xcatmntest to /etc/hosts") if ($verbose);
|
||||
$rc = 1;
|
||||
`rmdef xcatmntest`;
|
||||
last;
|
||||
}
|
||||
|
||||
probe_utils->send_msg("$output", "d", "To do 'makedhcp xcatmntest'") if ($verbose);
|
||||
$tmp = `makedhcp xcatmntest 2>&1`;
|
||||
if($?){
|
||||
returncmdoutput($tmp) if($verbose);
|
||||
ProbeUtils->send_msg("$output",0,"makedhcp xcatmntest failed") if($verbose);
|
||||
$rc=1;
|
||||
if ($?) {
|
||||
returncmdoutput($tmp) if ($verbose);
|
||||
probe_utils->send_msg("$output", "d", "makedhcp xcatmntest failed") if ($verbose);
|
||||
$rc = 1;
|
||||
`makehosts -d xcatmntest && rmdef xcatmntest`;
|
||||
last;
|
||||
}
|
||||
}
|
||||
|
||||
probe_utils->send_msg("$output", "d", "To do 'makedhcp -q xcatmntest'") if ($verbose);
|
||||
$tmp = `makedhcp -q xcatmntest`;
|
||||
if($?){
|
||||
returncmdoutput($tmp) if($verbose);
|
||||
ProbeUtils->send_msg("$output",0,"makedhcp -q xcatmntest failed") if($verbose);
|
||||
$rc=1;
|
||||
`makedhcp -d xcatmntest && makehosts -d xcatmntest && rmdef xcatmntest`;
|
||||
if ($?) {
|
||||
returncmdoutput($tmp) if ($verbose);
|
||||
probe_utils->send_msg("$output", "d", "makedhcp -q xcatmntest failed") if ($verbose);
|
||||
$rc = 1;
|
||||
`makedhcp -d xcatmntest && makehosts -d xcatmntest && rmdef xcatmntest`;
|
||||
last;
|
||||
}
|
||||
chomp($tmp);
|
||||
if($tmp !~ /xcatmntest: ip-address = $mnip, hardware-address = aa:aa:aa:aa:aa:aa/){
|
||||
returncmdoutput($tmp) if($verbose);
|
||||
ProbeUtils->send_msg("$output",0,"DHCP server's reply is wrong") if($verbose);
|
||||
$rc=1;
|
||||
`makedhcp -d xcatmntest && makehosts -d xcatmntest && rmdef xcatmntest`;
|
||||
if ($tmp !~ /xcatmntest: ip-address = $mnip, hardware-address = aa:aa:aa:aa:aa:aa/) {
|
||||
returncmdoutput($tmp) if ($verbose);
|
||||
probe_utils->send_msg("$output", "d", "DHCP server's reply is wrong") if ($verbose);
|
||||
$rc = 1;
|
||||
`makedhcp -d xcatmntest && makehosts -d xcatmntest && rmdef xcatmntest`;
|
||||
last;
|
||||
}
|
||||
|
||||
ProbeUtils->send_msg("$output",0,"Start to clear simulate information for dhcp test") if($verbose);
|
||||
$tmp=`makedhcp -d xcatmntest && makehosts -d xcatmntest && rmdef xcatmntest`;
|
||||
returncmdoutput($tmp) if($verbose);
|
||||
}
|
||||
|
||||
probe_utils->send_msg("$output", "d", "Start to clear simulate information for dhcp test") if ($verbose);
|
||||
$tmp = `makedhcp -d xcatmntest && makehosts -d xcatmntest && rmdef xcatmntest`;
|
||||
returncmdoutput($tmp) if ($verbose);
|
||||
}
|
||||
if($rc){
|
||||
ProbeUtils->send_msg("$output",2,"$msg");
|
||||
$rst=1;
|
||||
}else{
|
||||
ProbeUtils->send_msg("$output",3,"$msg");
|
||||
if ($rc) {
|
||||
probe_utils->send_msg("$output", "f", "$msg");
|
||||
probe_utils->send_msg("$output", "d", "please run 'makedhcp -n' if never run it before.");
|
||||
$rst = 1;
|
||||
} else {
|
||||
probe_utils->send_msg("$output", "o", "$msg");
|
||||
}
|
||||
exit $rst ;
|
||||
exit $rst;
|
||||
|
Loading…
x
Reference in New Issue
Block a user