~ubuntu-branches/ubuntu/vivid/drizzle/vivid-proposed

« back to all changes in this revision

Viewing changes to tests/randgen/lib/GenTest/Reporter/MemoryUsage.pm

  • Committer: Package Import Robot
  • Author(s): Tobias Frost
  • Date: 2013-08-22 20:18:31 UTC
  • mto: (20.1.1 sid)
  • mto: This revision was merged to the branch mainline in revision 21.
  • Revision ID: package-import@ubuntu.com-20130822201831-gn3ozsh7o7wmc5tk
Tags: upstream-7.2.3
ImportĀ upstreamĀ versionĀ 7.2.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# This program is free software; you can redistribute it and/or modify
2
 
# it under the terms of the GNU General Public License as published by
3
 
# the Free Software Foundation; version 2 of the License.
4
 
#
5
 
# This program is distributed in the hope that it will be useful, but
6
 
# WITHOUT ANY WARRANTY; without even the implied warranty of
7
 
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
8
 
# General Public License for more details.
9
 
#
10
 
# You should have received a copy of the GNU General Public License
11
 
# along with this program; if not, write to the Free Software
12
 
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
13
 
# USA
14
 
 
15
 
package GenTest::Reporter::MemoryUsage;
16
 
 
17
 
require Exporter;
18
 
@ISA = qw(GenTest::Reporter);
19
 
 
20
 
use strict;
21
 
use GenTest;
22
 
use GenTest::Constants;
23
 
use GenTest::Result;
24
 
use GenTest::Reporter;
25
 
use GenTest::Executor::MySQL;
26
 
 
27
 
use DBI;
28
 
 
29
 
sub monitor {
30
 
        my $reporter = shift;
31
 
 
32
 
        system('ps -Ffyl -p '.$reporter->serverInfo('pid'));
33
 
 
34
 
        my $dsn = $reporter->dsn();
35
 
        my $dbh = DBI->connect($dsn);
36
 
 
37
 
        if (defined $dbh) {
38
 
                my ($total_rows, $total_data, $total_indexes) = $dbh->selectrow_array("
39
 
                        SELECT SUM(TABLE_ROWS) , SUM(DATA_LENGTH) , SUM(INDEX_LENGTH)
40
 
                        FROM INFORMATION_SCHEMA.TABLES
41
 
                        WHERE TABLE_SCHEMA NOT IN ('information_schema','mysql','performance_schema')
42
 
                ");
43
 
 
44
 
                say("Total_rows: $total_rows; total_data: $total_data; total_indexes: $total_indexes"); 
45
 
        }
46
 
 
47
 
        return STATUS_OK;
48
 
}
49
 
 
50
 
sub type {
51
 
        return REPORTER_TYPE_PERIODIC ;
52
 
}
53
 
 
54
 
1;