mirror of
https://github.com/duncs/clusterssh.git
synced 2025-07-03 09:53:23 +00:00
Add "send random number" menu option
Add a new option in the send menu to send a random integer from 0 to 1023 to each host. This can be used to spread load across resources or delay the activation of commands to spread load across time. e.g. sleep $(( [random] % 10)) && fetch http://srv-$(( [random] % 5 )).small.server/file
This commit is contained in:
parent
b374754129
commit
bc45e0cac7
1 changed files with 17 additions and 0 deletions
|
@ -592,6 +592,15 @@ sub send_text_to_all_servers {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub send_variable_text_to_all_servers($&) {
|
||||||
|
my($self, $code) = @_;
|
||||||
|
|
||||||
|
foreach my $svr ( keys(%servers) ) {
|
||||||
|
$self->send_text( $svr, $code->($svr) )
|
||||||
|
if ( $servers{$svr}{active} == 1 );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
sub send_resizemove($$$$$) {
|
sub send_resizemove($$$$$) {
|
||||||
my ( $self, $win, $x_pos, $y_pos, $x_siz, $y_siz ) = @_;
|
my ( $self, $win, $x_pos, $y_pos, $x_siz, $y_siz ) = @_;
|
||||||
|
|
||||||
|
@ -1869,6 +1878,14 @@ sub populate_send_menu {
|
||||||
. $self->config->{macro_newline} );
|
. $self->config->{macro_newline} );
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
$menus{send}->command(
|
||||||
|
-label => 'Random Number',
|
||||||
|
-command => sub {
|
||||||
|
$self->send_variable_text_to_all_servers(
|
||||||
|
sub { int(rand(1024)) }
|
||||||
|
),
|
||||||
|
},
|
||||||
|
);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$self->debug(
|
$self->debug(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue