Perl Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesPerl Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old June 8th, 2001, 08:02 AM
Pieter Migo Pieter Migo is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2001
Location: netherlands
Posts: 0 Pieter Migo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to Pieter Migo
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

Reply With Quote
  #2  
Old June 8th, 2001, 09:23 AM
Pieter Migo Pieter Migo is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2001
Location: netherlands
Posts: 0 Pieter Migo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to Pieter Migo
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>";
}

Reply With Quote
  #3  
Old June 12th, 2001, 09:00 AM
footinmouth footinmouth is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2001
Location: North Vancouver, BC, Canada
Posts: 44 footinmouth User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 8
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

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPerl Programming > return show status info through perl


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway