- 论坛徽章:
- 0
|
本帖最后由 zhlong8 于 2012-11-19 22:22 编辑
我使用程序想取- mysql> show global status;
- +------------------------------------------+--------------+
- | Variable_name | Value |
- +------------------------------------------+--------------+
- | Aborted_clients | 19 |
- | Aborted_connects | 3 |
- | Binlog_cache_disk_use | 0 |
- | Binlog_cache_use | 4 |
- | Binlog_stmt_cache_disk_use | 29 |
- | Binlog_stmt_cache_use | 614410 |
- | Bytes_received | 6737567730 |
复制代码 我的目标是:Aborted_clients 与Aborted_connects 的值
之后我让它们相加,输出
程序如下
#!/usr/bin/perl
#use strict;
#use warnings;
use DBI;
my $dsn="DBI:mysql:mysql:localhost";
my $username="root";
my $password="11111";
my %conn_attrs=(RaiseError=> 1, PrintError => 1, AutoCommit =>1);
my $dbh=DBI->connect($dsn,$username,$password,\%conn_attrs);
#my $sth=$dbh->prepare("select user,host,password from user;");
my $sth=$dbh->prepare("show global status");
$sth->execute();
while(my @arr=$sth->fetchrow_array()){
print "Variable_name:$arr[0]\n";
print "Value:$arr[1]\n";
#print "user2:$arr->{password}\n\n";
}
$sth->finish();
$dbh->disconnect();
|
|