same small fixes, update short summary

This commit is contained in:
jmann 2012-06-05 13:54:03 +02:00 committed by Thomas Schoebel-Theuer
parent 1bfe46ee1a
commit eef8878205
1 changed files with 50 additions and 48 deletions

View File

@ -1,7 +1,7 @@
#!/usr/bin/perl -w #!/usr/bin/perl -w
# (c) 2012 Joerg Mann / 1&1 Internet AG # (c) 2012 Joerg Mann / 1&1 Internet AG
# #
# $Id: 1cfc331c2f2dbd3c929c666e4fcc518f78b38c73 $ # $Id: 7925d898464c836d5dbf76d2b6d3fed2413f6034 $
# last update at Tue Apr 10 17:20:32 CEST 2012 by joerg.mann@1und1.de # last update at Tue Apr 10 17:20:32 CEST 2012 by joerg.mann@1und1.de
# TODO: # TODO:
@ -20,7 +20,7 @@ use Date::Language;
use POSIX qw(strftime); use POSIX qw(strftime);
### defaults ### defaults
my $version = "0.067t"; my $version = "0.067u";
my $alife_timeout = "99"; # sec my $alife_timeout = "99"; # sec
my $is_tty = 0; my $is_tty = 0;
my $mars_dir = '/mars'; my $mars_dir = '/mars';
@ -403,15 +403,13 @@ sub check_mars_warn {
if ( open (MARS_WARN, "< /proc/sys/mars/warnings") ) { if ( open (MARS_WARN, "< /proc/sys/mars/warnings") ) {
my $mars_warn = ""; my $mars_warn = "";
while ( <MARS_WARN> ) { while ( <MARS_WARN> ) {
my $mars_w_time = $_; if ( m/^(\d+\.\d+)/ ) {
$mars_w_time =~ s/ MARS_WARN.*//; s/^(\d+\.\d+)/strftime("%a %b %e %H:%M:%S %Y:", localtime($1))/e;
$mars_w_time =~ s/\n//g; } else {
if ( $mars_w_time eq '' ) { $mars_w_time = time(); } $_ = localtime(0) . ': ' . $_;
$mars_w_time = strftime "%a %b %e %H:%M:%S %Y", localtime $mars_w_time; }
my $mars_w_text = $_; s/MARS_WARN\s+//;
$mars_w_text =~ s/.*MARS_WARN //; $mars_warn = "$mars_warn\t$_";
$mars_w_text =~ s/ //g;
$mars_warn = "\t$mars_w_time:$mars_w_text";
} }
close MARS_WARN; close MARS_WARN;
if ( $mars_warn ne "" ) { print_warn "-> MARS WARNINGS:\n", 'red'; print "$mars_warn" } if ( $mars_warn ne "" ) { print_warn "-> MARS WARNINGS:\n", 'red'; print "$mars_warn" }
@ -424,17 +422,13 @@ sub check_mars_error {
if ( open (MARS_ERROR, "< /proc/sys/mars/errors") ) { if ( open (MARS_ERROR, "< /proc/sys/mars/errors") ) {
my $mars_error = ""; my $mars_error = "";
while ( <MARS_ERROR> ) { while ( <MARS_ERROR> ) {
$_ =~ s/cannot open logfile.*/xxx/; if ( m/^(\d+\.\d+)/ ) {
my $mars_e_time = $_; s/^(\d+\.\d+)/strftime("%a %b %e %H:%M:%S %Y:", localtime($1))/e;
if ( "$mars_e_time" eq "xxx\n" ) { next; } } else {
$mars_e_time =~ s/ MARS_ERROR.*//; $_ = localtime(0) . ': ' . $_;
$mars_e_time =~ s/\n//g; }
if ( $mars_e_time eq '' ) { $mars_e_time = time(); } s/MARS_ERROR\s+//;
$mars_e_time = strftime "%a %b %e %H:%M:%S %Y", localtime $mars_e_time; $mars_error = "$mars_error\t$_";
my $mars_e_text = $_;
$mars_e_text =~ s/.*MARS_ERROR //;
$mars_e_text =~ s/ //g;
$mars_error = "\t$mars_e_time:$mars_e_text";
} }
close MARS_ERROR; close MARS_ERROR;
if ( $mars_error ne "" ) { print_warn "-> MARS ERRORS:\n", 'red'; print "$mars_error" } if ( $mars_error ne "" ) { print_warn "-> MARS ERRORS:\n", 'red'; print "$mars_error" }
@ -479,7 +473,7 @@ while(1) {
# marsadm # marsadm
my $MAVersion = qx"marsadm --version"; my $MAVersion = qx"marsadm version";
print_warn "MARS Admin - $MAVersion",'blue'; print_warn "MARS Admin - $MAVersion",'blue';
@ -517,9 +511,11 @@ while(1) {
foreach my $res (@resources) { foreach my $res (@resources) {
my $ResPartner = 0; my $ResPartner = 0;
my $ResInReplay = 0; my $ResInReplay = 0;
my $ResInReplayE = 0; my $ResInReplaySum = 0;
my $ResInReplayPar = 0;
my $ResInSync = 0; my $ResInSync = 0;
my $ResInSyncE = 0; my $ResInSyncSum = 0;
my $ResInSyncPar = 0;
my $res_name = $res; my $res_name = $res;
$res_name =~ s/^resource-//; $res_name =~ s/^resource-//;
if ( $params->{'resource'} ) { if ( $params->{'resource'} ) {
@ -548,9 +544,10 @@ while(1) {
res_insync => \$ResInSync, res_insync => \$ResInSync,
res_AULogfile => "", res_AULogfile => "",
); );
$ResInReplayE = $ResInReplay; $ResInReplaySum = $ResInReplay;
$ResInSyncE = $ResInSync; $ResInReplayPar = 1;
# TODO: short modus ... bug empty ... $ResInSyncSum = $ResInSync;
$ResInSyncPar = 1;
# not joined ... # not joined ...
if ( $ResPartner eq 1) { if ( $ResPartner eq 1) {
@ -572,9 +569,14 @@ while(1) {
res_AULogfile => $ActualUsedLogfile, res_AULogfile => $ActualUsedLogfile,
); );
} }
$ResInReplayE = $ResInReplayE + $ResInReplay; if ($ResInReplay != 100) {
$ResInSyncE = $ResInSyncE + $ResInSync; $ResInReplaySum = $ResInReplaySum + $ResInReplay;
# TODO: short modus ... bug empty ... $ResInReplayPar = $ResInReplayPar + 1;
}
if ($ResInSync != 100) {
$ResInSyncSum = $ResInSyncSum + $ResInSync;
$ResInSyncPar = $ResInSyncPar + 1;
}
} }
@ -585,20 +587,20 @@ while(1) {
if ( $params->{'long'} ) { print_warn " -> modus for $res_name is standalone ($ResPartner node)\n",'bold'; } if ( $params->{'long'} ) { print_warn " -> modus for $res_name is standalone ($ResPartner node)\n",'bold'; }
} else { } else {
print_warn " -> modus for $res_name is cluster ($ResPartner nodes), ",'bold'; print_warn " -> modus for $res_name is cluster ($ResPartner nodes), ",'bold';
$ResInReplayE = sprintf("%.2f", $ResInReplayE / $ResPartner ); $ResInReplaySum = sprintf("%.2f", $ResInReplaySum / $ResInReplayPar );
$ResInSyncE = sprintf("%.2f", $ResInSyncE / $ResPartner ); $ResInSyncSum = sprintf("%.2f", $ResInSyncSum / $ResInSyncPar );
print_warn "ClusterSummaryx: ", 'black'; print_warn "ClusterSummary: ", 'black';
if ( $ResInReplayE eq "100.00" ) { if ( $ResInReplaySum eq "100.00" ) {
print_warn "in replay ($ResInReplayE%),", 'green'; print_warn "in replay ($ResInReplaySum%),", 'green';
} elsif ( $ResInReplayE eq "0.00" ) { } elsif ( $ResInReplaySum eq "0.00" ) {
print_warn "inaktiv ($ResInReplayE%),", 'red'; print_warn "inaktiv ($ResInReplaySum%),", 'red';
} else { } else {
print_warn "not in replay ($ResInReplayE%),", 'red'; print_warn "not in replay ($ResInReplaySum%),", 'red';
} }
if ( $ResInSyncE eq "100.00" ) { if ( $ResInSyncSum eq "100.00" ) {
print_warn " in sync ($ResInSyncE%)\n", 'green'; print_warn " in sync ($ResInSyncSum%)\n", 'green';
} else { } else {
print_warn " not in sync ($ResInSyncE%)\n", "red"; print_warn " not in sync ($ResInSyncSum%)\n", "red";
} }
} }