aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/plugin/postgresql.php
blob: bca39f96e01d97bd80659e60947775e36f516de2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<?php

# Collectd Postgresql plugin
require_once 'modules/collectd.inc.php';

## LAYOUT
# postgresql-[instance]/pg_blks-heap_hit.rrd
# postgresql-[instance]/pg_blks-heap_read.rrd
# postgresql-[instance]/pg_blks-idx_hit.rrd
# postgresql-[instance]/pg_blks-idx_read.rrd
# postgresql-[instance]/pg_blks-tidx_hit.rrd
# postgresql-[instance]/pg_blks-tidx_read.rrd
# postgresql-[instance]/pg_blks-toast_hit.rrd
# postgresql-[instance]/pg_blks-toast_read.rrd
# postgresql-[instance]/pg_db_size.rrd
# postgresql-[instance]/pg_n_tup_c-del.rrd
# postgresql-[instance]/pg_n_tup_c-hot_upd.rrd
# postgresql-[instance]/pg_n_tup_c-ins.rrd
# postgresql-[instance]/pg_n_tup_c-upd.rrd

switch($_GET['t']) {
        case 'pg_db_size':
                require_once 'type/GenericStacked.class.php';
                $obj = new Type_GenericStacked($CONFIG);
                $obj->width = $width;
                $obj->heigth = $heigth;
                $obj->ds_names = array(
                        'value' => 'Size',
                );
                $obj->colors = array(
                        'value' => '0000ff',
                );
                $obj->rrd_title = sprintf('DB Size %s',
                        !empty($obj->args['pinstance']) ? $obj->args['pinstance'] : '');
                $obj->rrd_vertical = 'Size';
                $obj->rrd_format = '%5.1lf%s';
        break;
        case 'pg_blks':
                require_once 'type/GenericStacked.class.php';
                $obj = new Type_GenericStacked($CONFIG);
                $obj->width = $width;
                $obj->heigth = $heigth;
                $obj->generate_colors();

                $obj->rrd_title = sprintf('%s/%s', $obj->args['pinstance'], $obj->args['type']);
                $obj->rrd_vertical = 'Ops per second';
                $obj->rrd_format = '%5.1lf%s';
        break;
        case 'pg_n_tup_c':
                require_once 'type/GenericStacked.class.php';
                $obj = new Type_GenericStacked($CONFIG);
                $obj->width = $width;
                $obj->heigth = $heigth;
                $obj->generate_colors();

                $obj->rrd_title = sprintf('%s/%s', $obj->args['pinstance'], $obj->args['type']);
                $obj->rrd_vertical = 'Ops per second';
                $obj->rrd_format = '%5.1lf%s';
        break;

}


collectd_flush($obj->identifiers);
$obj->rrd_graph();