检查系统挂载and 集群配置文件指定的挂载数量 是否相等 and rc.local是否对头, perl已经年外没有学习了, 差不多都忘记了。
#!/usr/bin/perl
use POSIX qw( strftime);
my $time = strftime("%Y-%m-%d %H:%M:%S", localtime(time));
my $day = strftime("%Y-%m-%d", localtime(time));
@mi=`df -hP |grep -P mi/midata`;
@ms=`df -hP|grep -P "ms/msdata"`;
$h=`hostname`;
chomp $h;
print "$h \n";
open (ONE,"<","/home/richmail/newconf/hosts.conf") or die "not $!";
#open (ONE,"<","/root/hosts.conf") or die "not $!";
my $test;
my $IP=`grep IPADDR /etc/sysconfig/network-scripts/ifcfg-bond0 | awk -F \= '{print \$2}'`;
my $label;
chomp $IP;
while (<ONE>) {
if($count>3){
last;
}
if ($_=~/^ip\s?=\s?\Q$IP\E$/){
print "$_ $.\n";
$label++;
next;
}
elsif($_=~/^[^#]*ip\s?=\s?.*/ && $label==1 ){
print "next ip is:$_";
last;
}
elsif($_=~/^msNodeVolWeight\s?=\s?(.*)/ && $label==1 )
{
print "$_ $.\n";
@logfile=split /,/,$1;
$count++;
next;
}
elsif($_=~/^miNOdeVolWeight\s?=\s?(.*)/ && $label==1 )
{
print "$_ $.\n";
@logfile_mi=split /,/,$1;
$count++;
next;
}
elsif($_=~/msNodeWeight=/ && $label==1 ){
print $_;
$count++;
next;
}
else {next;}
}
close ONE;
printf "MS vol:@logfile total:%5d\n",$#logfile+1;
printf "MI vol:@logfile_mi total:%5d\n",$#logfile_mi+1;
if($#mi+1 == $#logfile_mi+1){
printf "MI df == vol hosts.conf\n";
}
else
{
print "ERR $h $IP [$time] MS MOUNT WRONG\n"
}
if($#ms+1 == $#logfile+1){
printf "MS df == vol hosts.conf\n";
}else
{
print "ERR $h $IP [$time] MS MOUNT WRONG\n";
}
print "###################################################\n";
print "##################DF -HP###########################\n";
print "###################################################\n";
foreach my $t (@mi){
chomp $t;
#172.16.183.135:/vx/f_rmail_mi15_01 300G 146G 145G 51% /nfsdata/mi/midata_01
#if($t=~/(^\d+\.\d+\.\d+\.\d+:.*)\s+(\d+[A-Za-z])\s+(\d+[A-Za-z])\s+(\d+[A-Za-z])\s+(\d+%)\s+(.*)/)
if($t=~/(^\d+\.\d+\.\d+\.\d+:.*)\s+([\d\.]+[A-Za-z])\s+([\d\.]+[A-Za-z])\s+([\d\.]+[A-Za-z])\s+([\d\.]+%)\s+(.*)/)
{
$a=$1;
$b=$6;
$a=~s/\s+//;
$b=~s/\s+//;
push (@tmp_arr,"$a $b");
#print "$a $b\n";
print "$t\n";
$hash_01{"$a $b"}=1;
}
}
foreach my $t (@ms){
chomp $t ;
#172.16.183.131:/vx/s_rmail_ms15_03 2.0T 1.9T 203G 91% /nfsdata/ms/msdata_03
#print $t."\n";
if($t=~/(^\d+\.\d+\.\d+\.\d+:.*)\s+([\d\.]+[A-Za-z])\s+([\d\.]+[A-Za-z])\s+([\d\.]+[A-Za-z])\s+([\d\.]+%)\s+(.*)/)
{
#print "$1 $6\n" ;
$a=$1;
$b=$6;
$a=~s/\s+//g;
$b=~s/\s+//g;
push (@tmp_arr,"$a $b");
$hash_01{"$a $b"}=1;
print "$t\n";
}
}
print "###################################################\n";
print "##################ARR DF -HP#######################\n";
print "###################################################\n";
foreach my $t_a (@tmp_arr){
print "$t_a \n";
}
print "###################################################\n";
print "#####compare with Rc.local########################\n";
@rc=`cat /etc/rc.local |grep -v "^#"|grep -P "mi/mi|ms/ms" |awk '{print \$0}'`;
foreach my $r (@rc){
chomp $r;
#mount -o rsize=32768,wsize=32768,tcp,noatime,timeo=22,retrans=5 172.16.183.135:/vx/f_rmail_mi15_01 /nfsdata/mi/midata_01
if($r=~/(\d+\.\d+\.\d+\.\d+:.*)\s+(\/nfsdata\/.*)/){
$a=$1;
$b=$2;
$a=~s/\s+//g;
$b=~s/\s+//g;
#print "$a $b\n";
if($hash_01{"$a $b"}){
print "$a $b\n";
}
else {
print "ERR $h $IP [$time] $a $b found from rc.local ,but not found from df -hP\n";
}
}
}
/home/scripts/check_mount.pl z-1-01 ip=172.16.171.1 3209 miNOdeVolWeight=1,1 3213 msNodeWeight=0 msNodeVolWeight=1,0,0,0,0,0,1,0,0 3216 next ip is:ip=172.16.171.2 MS vol:1 0 0 0 0 0 1 0 0 total: 9 MI vol:1 1 total: 2 MI df == vol hosts.conf MS df == vol hosts.conf ################################################### ##################DF -HP########################### ################################################### 172.16.231.127:/vx/f_rmail_mi60_01 550G 268G 265G 51% /nfsdata/mi/midata_01 172.16.231.129:/vx/f_rmail_mi60_02 550G 269G 264G 51% /nfsdata/mi/midata_02 172.16.171.116:/vx/s_rmail_ms60_01 3.0T 3.0T 50G 99% /nfsdata/ms/msdata_01 172.16.231.121:/vx/s_rmail_ms60_02 3.0T 2.9T 191G 94% /nfsdata/ms/msdata_02 172.16.231.121:/vx/s_rmail_ms60_03 3.0T 2.9T 185G 94% /nfsdata/ms/msdata_03 172.16.231.135:/vx/s_rmail_ms60_07 3.0T 3.0T 6.9G 100% /nfsdata/ms/msdata_3_256_007 172.16.43.216:/NFS/s_rmail_ms60_04 2.0T 1.9T 123G 95% /nfsdata/ms/msdata_04 172.16.43.215:/NFS/s_rmail_ms60_06 2.0T 1.9T 124G 94% /nfsdata/ms/msdata_06 172.16.183.138:/vx/f_rmail_ms60_09 2.1T 2.0T 120G 95% /nfsdata/ms/msdata_3_256_009 172.16.43.212:/NFS/s_rmail_ms60_05 2.0T 1.8T 220G 90% /nfsdata/ms/msdata_05 172.16.43.211:/NFS/s_rmail_ms60_08 2.0T 2.0T 96G 96% /nfsdata/ms/msdata_3_256_008 ################################################### ##################ARR DF -HP####################### ################################################### 172.16.231.127:/vx/f_rmail_mi60_01 /nfsdata/mi/midata_01 172.16.231.129:/vx/f_rmail_mi60_02 /nfsdata/mi/midata_02 172.16.171.116:/vx/s_rmail_ms60_01 /nfsdata/ms/msdata_01 172.16.231.121:/vx/s_rmail_ms60_02 /nfsdata/ms/msdata_02 172.16.231.121:/vx/s_rmail_ms60_03 /nfsdata/ms/msdata_03 172.16.231.135:/vx/s_rmail_ms60_07 /nfsdata/ms/msdata_3_256_007 172.16.43.216:/NFS/s_rmail_ms60_04 /nfsdata/ms/msdata_04 172.16.43.215:/NFS/s_rmail_ms60_06 /nfsdata/ms/msdata_06 172.16.183.138:/vx/f_rmail_ms60_09 /nfsdata/ms/msdata_3_256_009 172.16.43.212:/NFS/s_rmail_ms60_05 /nfsdata/ms/msdata_05 172.16.43.211:/NFS/s_rmail_ms60_08 /nfsdata/ms/msdata_3_256_008 ################################################### #####compare with Rc.local######################## 172.16.231.127:/vx/f_rmail_mi60_01 /nfsdata/mi/midata_01 172.16.231.129:/vx/f_rmail_mi60_02 /nfsdata/mi/midata_02 172.16.171.116:/vx/s_rmail_ms60_01 /nfsdata/ms/msdata_01 172.16.231.121:/vx/s_rmail_ms60_02 /nfsdata/ms/msdata_02 172.16.231.121:/vx/s_rmail_ms60_03 /nfsdata/ms/msdata_03 172.16.43.216:/NFS/s_rmail_ms60_04 /nfsdata/ms/msdata_04 172.16.43.212:/NFS/s_rmail_ms60_05 /nfsdata/ms/msdata_05 172.16.43.215:/NFS/s_rmail_ms60_06 /nfsdata/ms/msdata_06 172.16.231.135:/vx/s_rmail_ms60_07 /nfsdata/ms/msdata_3_256_007 172.16.43.211:/NFS/s_rmail_ms60_08 /nfsdata/ms/msdata_3_256_008 172.16.183.138:/vx/f_rmail_ms60_09 /nfsdata/ms/msdata_3_256_009
|
请发表评论