Skip to content

Instantly share code, notes, and snippets.

@wwwted
Last active April 2, 2019 05:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wwwted/12ea4454ba8207dba365f0370c928908 to your computer and use it in GitHub Desktop.
Save wwwted/12ea4454ba8207dba365f0370c928908 to your computer and use it in GitHub Desktop.
#!/opt/csw/bin/perl
use DBI;
my $host="192.168.1.233";
my $port="3306";
my $user="ted";
my $pwd="ted";
my $wait;
my @dbhs;
my ($no_cons,$wait) = @ARGV;
if (not defined $no_cons) {
die "Need number of connections to try!\n ./$0 <no of db connectons> [time to sleep]\n";
}
if (not defined $wait) {
$wait=10;
}
foreach my $i (1..$no_cons) {
my $dbh = DBI->connect("dbi:mysql:test;host=$host;port=$port", $user, $pwd);
next unless $dbh;
push @dbhs, $dbh;
}
sleep($wait);
foreach (@dbhs) {
$_->disconnect();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment