diff --git a/.gitignore b/.gitignore index 0e1cc8e..0547d62 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ 2011* +loadbot/do_all.sh +loadbot/testservers diff --git a/Makefile b/Makefile index 7a58f37..f6e4425 100644 --- a/Makefile +++ b/Makefile @@ -4,3 +4,7 @@ all: mkdir $(DATESTAMP) inventory/inventory.sh $(DATESTAMP) cd cpu; make + +prep: + cat loadbot/testservers |xargs -n 1 --replace=BLAH scp loadbot/prep.pl BLAH: + cat loadbot/testservers |xargs -n 1 --replace=BLAH ssh BLAH ./prep.pl diff --git a/loadbot/init_all.sh b/loadbot/init_all.sh new file mode 100755 index 0000000..41ba4da --- /dev/null +++ b/loadbot/init_all.sh @@ -0,0 +1,32 @@ +#!/bin/bash -x + +#SELECT droplets.name, sizes.memory, vnics.vif as vname, ip_addresses.ip, images.name, servers.name from droplets +# JOIN sizes +# ON droplets.size_id = sizes.id +# JOIN vnics +# ON droplets.id = vnics.droplet_id +# JOIN ip_addresses +# ON vnics.ip_address_id = ip_addresses.id +# JOIN images +# ON droplets.image_id = images.id +# JOIN servers +# ON droplets.server_id = servers.id +# WHERE droplets.is_active=1; + +# cat /tmp/junk |awk '{print $8}' + + +# run this once when you have a new collection of test servers +rm .ssh/known_hosts +cat testservers |xargs -n 1 --replace=BLAH echo ./ssh.pl BLAH root dopass \$1 > do_all.sh +bash -x do_all.sh "echo >> /etc/hosts" +bash -x do_all.sh "echo 69.55.54.144 loadbot >> /etc/hosts" +bash -x do_all.sh "restorecon -R /root/.ssh/" + +echo "now copy prep.pl over to each server. this should be fast (no resolution delays)" +sleep 3 +cat testservers |xargs -n 1 --replace=BLAH scp prep.pl BLAH: + +echo "now run prep.pl" +sleep 3 +cat testservers |xargs -n 1 --replace=BLAH ssh BLAH ./prep.pl diff --git a/loadbot/loadbot.pl b/loadbot/loadbot.pl new file mode 100755 index 0000000..899fc3c --- /dev/null +++ b/loadbot/loadbot.pl @@ -0,0 +1,5 @@ +#!/usr/bin/perl + +use strict; + +system ""; diff --git a/loadbot/prep.pl b/loadbot/prep.pl new file mode 100755 index 0000000..0e19de5 --- /dev/null +++ b/loadbot/prep.pl @@ -0,0 +1,47 @@ +#!/usr/bin/perl + +use strict; + +print "Running on " . `hostname`; + +my $return = system("screen -list"); +print "screen RETURN: $return\n"; + +if ($return eq "-1") { + if (-e "/etc/gentoo-release") { + system "emerge app-misc/screen"; + } else { + system "yum install screen -y"; + system "cat /etc/redhat-release"; + } + system "ifconfig"; +} + +my $return = system("bc --version"); +print "bc RETURN: $return\n"; + +if ($return eq "-1") { + if (-e "/etc/gentoo-release") { + system "emerge bc"; + } elsif (-e "/etc/redhat-release") { + system "yum install bc -y"; + } else { + system "apt-get install bc"; + } + system "ifconfig"; +} + +my $return = system("git --version"); +print "git RETURN: $return\n"; +exit; + +if ($return eq "-1") { + if (-e "/etc/gentoo-release") { + system "emerge git"; + } elsif (-e "/etc/redhat-release") { + system "yum install git -y"; + } else { + system "apt-get install git"; + } + system "ifconfig"; +} diff --git a/loadbot/ssh.pl b/loadbot/ssh.pl new file mode 100755 index 0000000..a85f7f3 --- /dev/null +++ b/loadbot/ssh.pl @@ -0,0 +1,61 @@ +#!/usr/bin/perl +# +# A Simple Terminal Resizing Example +# GPL version 2. See the COPYING file +# +# This script is a simple example of how handle terminal +# window resize events (transmitted via the WINCH signal) +# -- Jeff Carr +# + +if( ! defined $ARGV[0] ) { + print "Usage: ssh.pl host \n"; + exit; +} + +my ($host, $username, $password, @commands) = @ARGV; +$username = $ENV{USER} if $username eq ""; + +use Expect; +use IO::Pty; + +my $spawn = new Expect; +$spawn->raw_pty(1); + +# This gets the size of your terminal window +$spawn->slave->clone_winsize_from(\*STDIN); + +my $PROMPT; + +# This function traps WINCH signals and passes them on +sub winch { + my $signame = shift; + my $pid = $spawn->pid; + $shucks++; + print "count $shucks,pid $pid, SIG$signame\n"; + $spawn->slave->clone_winsize_from(\*STDIN); + kill WINCH => $spawn->pid if $spawn->pid; +} +$SIG{WINCH} = \&winch; # best strategy + +$spawn=Expect->spawn("ssh $username\@$host \"@commands\""); +# log everything if you want +$spawn->log_file("/tmp/autossh.log.$$"); + +my $PROMPT = '[\]\$\>\#]\s$'; +my $ret = $spawn->expect(15, + [ qr/\(yes\/no\)\?\s*$/ => sub { $spawn->send("yes\n"); exp_continue; } ], + [ qr/assword:\s*$/ => sub { $spawn->send("$password\n"); } ], + [ qr/ogin:\s*$/ => sub { $spawn->send("$username\n"); exp_continue; } ], + [ qr/REMOTE HOST IDEN/ => sub { print "FIX: .ssh/known_hosts\n"; exp_continue; } ], + [ qr/$PROMPT/ => sub { $spawn->send("echo Now try window resizing\n"); } ], +); + +# Send a winch single on startup +winch(); + +# Hand over control +my $return = $spawn->interact(); +print "ssh $host returned=$return\n"; +sleep 1 if ! defined @commands; +exit;