aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/plugin/vserver.php
blob: 57687e37538100b92fcdb76c5969d83cfa5c2b04 (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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
<?php

# Collectd VServer plugin

require_once 'conf/common.inc.php';
require_once 'type/GenericIO.class.php';
require_once 'type/GenericStacked.class.php';
require_once 'inc/collectd.inc.php';

# LAYOUT
# vserver-XXXX
# vserver-XXXX/if_octets-inet6.rrd
# vserver-XXXX/if_octets-inet.rrd
# vserver-XXXX/if_octets-other.rrd
# vserver-XXXX/if_octets-unix.rrd
# vserver-XXXX/if_octets-unspec.rrd
# vserver-XXXX/load.rrd
# vserver-XXXX/vs_memory-anon.rrd
# vserver-XXXX/vs_memory-rss.rrd
# vserver-XXXX/vs_memory-vml.rrd
# vserver-XXXX/vs_memory-vm.rrd
# vserver-XXXX/vs_processes.rrd
# vserver-XXXX/vs_threads-onhold.rrd
# vserver-XXXX/vs_threads-running.rrd
# vserver-XXXX/vs_threads-total.rrd
# vserver-XXXX/vs_threads-uninterruptable.rrd

$obj = new Type_Default($CONFIG);

switch($obj->args['type']) {
    case 'load':
            require_once "plugin/load.php";
            break;
    case 'vs_memory':
            $obj = new Type_GenericStacked($CONFIG);
            $obj->order = array('vm', 'vml', 'rss', 'anon');
            # http://oldwiki.linux-vserver.org/Memory+Allocation
            $obj->ds_names = array(
                    'vm' => "Virtual memory pages",
                    'vml' => "Pages locked into memory",
                    'rss' => "Resident set size",
                    'anon' => "Anonymous memory pages",
            );
            $obj->colors = array(
                    'vm' => '00e000',
                    'vml' => '0000ff',
                    'rss' => 'ffb000',
                    'anon' => 'ff00ff',
                    );
            $obj->width = $width;
            $obj->heigth = $heigth;

            $obj->rrd_title = sprintf('Memory utilization on Vserver %s', $obj->args['pinstance']);
            $obj->rrd_vertical = 'Bytes';
            $obj->rrd_format = '%5.1lf%s';

            collectd_flush($obj->identifiers);
            $obj->rrd_graph();
            break;
    case 'vs_threads':
            $obj = new Type_GenericStacked($CONFIG);
            $obj->order = array('running', 'uninterruptable', 'onhold', 'total');
            # http://linux-vserver.org/ProcFS
            $obj->ds_names = array(
                    'onhold' => "Number of threads on hold",
                    'running' => "Number of running threads",
                    'total' => "Total number of threads",
                    'uninterruptable' => "Number of uninterruptible threads",
            );
            $obj->colors = array(
                    'onhold' => '00e000',
                    'running' => '0000ff',
                    'total' => 'ffb000',
                    'uninterruptable' => 'ff00ff',
                    );
            $obj->width = $width;
            $obj->heigth = $heigth;

            $obj->rrd_title = sprintf('Threads on Vserver %s', $obj->args['pinstance']);
            $obj->rrd_vertical = 'Numbers';
            $obj->rrd_format = '%5.1lf%s';

            collectd_flush($obj->identifiers);
            $obj->rrd_graph();
            break;
    case 'if_octets':
            $obj->data_sources = array('rx', 'tx');
            $obj->ds_names = array(
                    'inet-rx' => 'IPv4 Receive',
                    'inet-tx' => 'IPv4 Transmit',
                    'inet6-rx' => 'IPv6 Receive',
                    'inet6-tx' => 'IPv6 Transmit',
                    );
            $obj->colors = array(
                    'inet-rx'   => '0000ff',
                    'inet-tx'   => '00b000',
                    'inet6-rx'  => 'e0e0e0',
                    'inet6-tx'  => 'ffb000',
                    'other-rx'  => 'ff00ff',
                    'other-tx'  => 'a000a0',
                    'unix-rx'   => '00e000',
                    'unix-tx'   => '0080ff',
                    'unspec-rx' => 'ff0000',
                    'unspec-tx' => '000080',
                    );
            $obj->rrd_title = sprintf('Traffic on Vserver %s', $obj->args['pinstance']);
            $obj->rrd_vertical = 'Bytes per second';
            $obj->width = $width;
            $obj->heigth = $heigth;
            $obj->rrd_format = '%5.1lf%s';

            collectd_flush($obj->identifiers);
            $obj->rrd_graph();
            break;
    case 'vs_processes':
            $obj->data_sources = array('value');
            $obj->ds_names = array(
                    'value' => 'Processes',
            );
            $obj->rrd_title = sprintf('Processes on Vserver %s', $obj->args['pinstance']);
            $obj->rrd_vertical = 'Processes';

            $obj->width = $width;
            $obj->heigth = $heigth;
            $obj->rrd_format = '%5.1lf%s';

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

    default:
            die('Not implemented yet.');
            break;
}
?>