|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
return show status info through perl
I would like to get some info from the mysql show status command, but I get stuck in grabbing the info.
Can anyone give me a hint? $dbh_ka = DBI->connect("DBI:mysql:database=$db_ka;host=$host_ka", $user_ka, $password_ka, {RaiseError=>1, AutoCommit => 1}); $sth = $dbh_ka->prepare("show status"); $sth->execute; while (my $ref=$sth->fetchrow_hashref()){ $Running_threads = $ref->{'Running_threads'}; print $Running_threads; } print $ref; my $rc = $dbh_ka->disconnect; thanks for helping me! rgds Pieter |
|
#2
|
|||
|
|||
|
ok posting to my own question
might be interesting for other users.\ $dbh_ka = DBI->connect("DBI:mysql:database=$db_ka;host=$host_ka", $user_ka, $password_ka, {RaiseError=>1, AutoCommit => 1}); $sth = $dbh_ka->prepare("show status"); $sth->execute; my $table = $sth->fetchall_arrayref; my ($i, $j); for $i (0 .. $#{$table}) { for $j (0 .. $#{$table->[$i]}){ print "$table->[$i][$j]\t"; } print "<br>"; } |
|
#3
|
|||
|
|||
|
And ...
#!c:/perl/bin/perl
use DBI; print "Content-type: text/html\n\n"; ## data-base config $host="127.0.0.1"; $database="mysql"; $table="db"; $user="root"; $mysqlpassword=""; $dbh = DBI->connect("DBI:mysql:database=$database;host=$host","$user","$mysqlpassword",{'RaiseError'=>1}); print "<html><body>\n"; @jenni = ("SHOW DATABASES", "SHOW TABLES FROM mysql", "SHOW COLUMNS FROM mysql.db", "SHOW INDEX FROM mysql.db", "SHOW STATUS", "SHOW VARIABLES", "SHOW PROCESSLIST"); foreach $jenni(@jenni) { print "<br>Section = $jenni<br>\n<br>\n"; $sth = $dbh->prepare("$jenni"); ## go jenni go if (!$sth) { die "Error:" . $dbh->errstr . "\n"; } if (!$sth->execute) { die "Error:" . $sth->errstr . "\n"; } my $table = $sth->fetchall_arrayref; my ($i, $j); for $i (0 .. $#{$table}) { for $j (0 .. $#{$table->[$i]}){ print "$table->[$i][$j]\n"; } print "<br>\n"; } } print "</body></html>\n"; $sth->finish; $dbh->disconnect();
__________________
Thanks Foot in Mouth ver 1.2.5 Onion |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Perl Programming > return show status info through perl |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|