ASNMTAP
view release on metacpan or search on metacpan
applications/htmlroot/cgi-bin/admin/generateConfig.pl view on Meta::CPAN
$compareText .= '<br><FONT COLOR="#99CC99"> ['. $_id .'] '. $commands {$server} {REMOVE} {$_id} {command} .'</FONT>' if ( $debug eq 'T' );
$commands {$server} {CRONTAB} {++$_id} {auto} = 0;
$commands {$server} {CRONTAB} {$_id} {label} = '-l';
$commands {$server} {CRONTAB} {$_id} {active} = $active;
$commands {$server} {CRONTAB} {$_id} {command} = "$SSHCOMMAND $connectArguments $SSHLOGONNAME\@$server DELETE ". $ASNMTAP_PATH { substr ($type, -1, 1) } { $server } .'/applications/'. ( ($type eq 'CM' or $type eq 'DM') ? 'master' : 'slave' ...
$compareText .= '<br><FONT COLOR="#99CC99"> ['. $_id .'] '. $commands {$server} {CRONTAB} {$_id} {command} .'</FONT>' if ( $debug eq 'T' );
$commands {$server} {REMOVE} {++$_id} {auto} = 0;
$commands {$server} {REMOVE} {$_id} {label} = '-m';
$commands {$server} {REMOVE} {$_id} {active} = $active;
$commands {$server} {REMOVE} {$_id} {command} = "$SSHCOMMAND $connectArguments $SSHLOGONNAME\@$server rm ". $ASNMTAP_PATH { substr ($type, -1, 1) } { $server } .'/applications/'. ( ($type eq 'CM' or $type eq 'DM') ? 'master' : 'slave' ) ."/...
$compareText .= '<br><FONT COLOR="#99CC99"> ['. $_id .'] '. $commands {$server} {REMOVE} {$_id} {command} .'</FONT>' if ( $debug eq 'T' );
$commands {$server} {REMOVE} {++$_id} {auto} = 0;
$commands {$server} {REMOVE} {$_id} {label} = '-n';
$commands {$server} {REMOVE} {$_id} {active} = $active;
$commands {$server} {REMOVE} {$_id} {command} = "$SSHCOMMAND $connectArguments $SSHLOGONNAME\@$server rm ". $ASNMTAP_PATH { substr ($type, -1, 1) } { $server } .'/applications/'. ( ($type eq 'CM' or $type eq 'DM') ? 'master' : 'slave' ) ."/...
$compareText .= '<br><FONT COLOR="#99CC99"> ['. $_id .'] '. $commands {$server} {REMOVE} {$_id} {command} .'</FONT>' if ( $debug eq 'T' );
$todo = 1;
}
} elsif ( $compareView =~ /^Files generated\// ) {
($path, $generated, $installed, $compareDiff) = do_compare_diff ($compareView, 3, $details, $debug);
if ($details) {
$compareText = "File '$generated' changed into the generated configuration.";
} else {
my (undef, $servername, $filename) = split (/\//, $generated, 3);
($type, $activeServer, $server) = split (/-/, $servername, 3);
my $active = ( ( $type =~ /^[CD]${activeServer}$/ ) ? 1 : 0 );
# Replace 'distributed.citap.be:/opt/asnmtap/applications/slave/asnmtap-display.sh' with '/opt/asnmtap/applications/tmp/$CONFIGDIR/generated/DS-[SM]-distributed.citap.be/slave/asnmtap-display.sh'
# <----- $server ---->:$APPLICATIONPATH/<------ $filename -----> $APPLICATIONPATH/tmp/ /<---------------------- $generated ---------------------->
$commands {$server} {SCP} {++$_id} {auto} = 1;
$commands {$server} {SCP} {$_id} {label} = '=a';
$commands {$server} {SCP} {$_id} {active} = $active;
$commands {$server} {SCP} {$_id} {command} = "$SCPCOMMAND $connectArguments $APPLICATIONPATH/tmp/$CONFIGDIR/$generated $SSHLOGONNAME\@$server:". $ASNMTAP_PATH { substr ($type, -1, 1) } { $server } ."/applications/$filename";
$compareText .= '<FONT COLOR="#99CC99"> ['. $_id .'] '. $commands {$server} {SCP} {$_id} {command} .'</FONT>' if ( $debug eq 'T' );
if (($filename =~ /^etc\/DisplayCT-[\w-]+$/) or ($filename =~ /^etc\/CollectorCT-[\w-]+$/)) {
$filename =~ s/etc\///g;
$commands {$server} {RELOAD} {++$_id} {auto} = 1;
$commands {$server} {RELOAD} {$_id} {label} = '=b';
$commands {$server} {RELOAD} {$_id} {active} = $active;
$commands {$server} {RELOAD} {$_id} {command} = "$SSHCOMMAND $connectArguments $SSHLOGONNAME\@$server ". $ASNMTAP_PATH { substr ($type, -1, 1) } { $server } .'/applications/'. ( ($type eq 'CM' or $type eq 'DM') ? 'master' : 'slave' ) ."/$...
$compareText .= '<br><FONT COLOR="#99CC99"> ['. $_id .'] '. $commands {$server} {RELOAD} {$_id} {command} .'</FONT>' if ( $debug eq 'T' );
} elsif (($filename =~ /^(slave|master)\/asnmtap-display.sh$/) or ($filename =~ /^(slave|master)\/asnmtap-collector.sh$/)) {
$commands {$server} {TODO} {++$_id} {auto} = 0;
$commands {$server} {TODO} {$_id} {label} = '=c';
$commands {$server} {TODO} {$_id} {active} = $active;
$commands {$server} {TODO} {$_id} {command} = "'$filename' ?";
$compareText .= '<br><FONT COLOR="yellow"> ['. $_id .'] '. $commands {$server} {TODO} {$_id} {command} .'</FONT>' if ( $debug eq 'T' );
} elsif (($filename =~ /^(slave|master)\/DisplayCT-[\w-]+\.sh$/) or ($filename =~ /^(slave|master)\/CollectorCT-[\w-]+\.sh$/)) {
$commands {$server} {START} {++$_id} {auto} = 0;
$commands {$server} {START} {$_id} {label} = '=d';
$commands {$server} {START} {$_id} {active} = $active;
$commands {$server} {START} {$_id} {command} = "$SSHCOMMAND $connectArguments $SSHLOGONNAME\@$server ". $ASNMTAP_PATH { substr ($type, -1, 1) } { $server } .'/applications/'. ( ($type eq 'CM' or $type eq 'DM') ? 'master' : 'slave' ) ."/$f...
$compareText .= '<br><FONT COLOR="#99CC99"> ['. $_id .'] '. $commands {$server} {START} {$_id} {command} .'</FONT>' if ( $debug eq 'T' );
# } elsif ( $filename =~ /^master\/rsync-mirror-failover-[\w\-.]+.conf$/ or $filename =~ /^slave\/rsync-mirror-failover-[\w\-.]+.conf$/) {
# deze bestanden worden reeds gecopieerd door middel van bovenstaande SCP in deze sectie
}
}
} elsif ( $compareView =~ /^diff: installed: No such file or directory/ ) {
$compareText = "The installed configuration doesn't exist.";
} elsif ( $compareView =~ /^diff: generated: No such file or directory/ ) {
$compareText = "The generated configuration doesn't exist.";
} else {
$compareText = "<b>Under construction:</b> < $compareView >";
}
unless ( $details ) { $compareText = "<b>$compareText</b>" if (defined $compareText and ($todo or (defined $activeServer and $type =~ /^[CD]${activeServer}$/))); }
$statusMessage .= "\n <tr bgcolor=\"$COLORSTABLE{STARTBLOCK}\"><td>$compareView</td></tr>" if ($details or $debug eq 'T');
$statusMessage .= "\n <tr bgcolor=\"$COLORSTABLE{NOBLOCK}\"><td>$compareDiff</td></tr>" if (defined $compareDiff);
$statusMessage .= "\n <tr bgcolor=\"$COLORSTABLE{ENDBLOCK}\"><td>$compareText</td></tr>" if (defined $compareText);
}
}
my ($commandsToExecute, $commandsExecuted, $commandsTODO) = ( $_id, 0 );
foreach my $_servers ( sort keys %commands ) {
my $_server = $commands {$_servers};
$commandsTODO .= "\n <tr bgcolor=\"$COLORSTABLE{NOBLOCK}\"><td>$_servers</td></tr>";
my $exitCurrentServer = 0;
foreach my $type ( 'TODO', 'SCP', 'CHMOD', 'RELOAD', 'STOP', 'START', 'CRONTAB', 'REMOVE' ) {
next if ( $exitCurrentServer );
$commandsTODO .= "\n <tr bgcolor=\"$COLORSTABLE{STARTBLOCK}\"><td>$type</td></tr>";
my $_type = $_server->{$type};
foreach my $_id ( keys %$_type ) {
next if ( $exitCurrentServer );
my $auto = ( ( exists $_type->{$_id}{auto} and $_type->{$_id}{auto} ) ? $_type->{$_id}{auto} : 0 );
my $label = ( ( exists $_type->{$_id}{label} and $_type->{$_id}{label} ) ? $_type->{$_id}{label} : '??' );
my $active = ( ( exists $_type->{$_id}{active} and $_type->{$_id}{active} ) ? $_type->{$_id}{active} : 0 );
my $command = ( ( exists $_type->{$_id}{command} and $_type->{$_id}{command} ) ? $_type->{$_id}{command} : '' );
unless ( defined $command ) {
my $prefix = ( ( $debug eq 'T' ) ? "E) '$label' [$_id] " : '' );
$commandsTODO .= "\n <tr bgcolor=\"$COLORSTABLE{ENDBLOCK}\"><td><FONT COLOR=\"red\">${prefix}${command}</FONT></td></tr>";
} elsif ( $type !~ /^(?:RELOAD|STOP|START)$/ or ( $type =~ /^(?:RELOAD|STOP|START)$/ and $active ) ) {
if ( $Cauto == 1 and $auto == 1 ) {
my $color = 'red';
my @capture = `$command 2>&1`;
my $exit_value = $? >> 8;
my $signal_num = $? & 127;
my $dumped_core = $? & 128;
$commandsTODO .= "\n <tr bgcolor=\"$COLORSTABLE{STARTBLOCK}\"><td><FONT COLOR=\"white\">$exit_value - $signal_num - $dumped_core - ". join('<br>', @capture) ."</FONT></td></tr>" if ( $debug eq 'T' );
if ( $exit_value == 0 && $signal_num == 0 && $dumped_core == 0 ) {
my ($lineNumber, $proccessNextLine) = (0, 0);
foreach my $capture ( @capture ) {
$capture =~ s/\r$//g;
$capture =~ s/\n$//g;
next unless ( defined $capture and ! $exitCurrentServer );
$lineNumber++;
( run in 0.716 second using v1.01-cache-2.11-cpan-39bf76dae61 )