Last active
April 2, 2019 05:07
-
-
Save wwwted/12ea4454ba8207dba365f0370c928908 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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