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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
|
<?php
# Collectd Memcached plugin
# Details on http://github.com/octo/collectd/blob/master/src/memcached.c
require_once 'conf/common.inc.php';
require_once 'inc/collectd.inc.php';
## LAYOUT
# df-cache.rrd
# memcached_command-(flush|get|set).rrd
# memcached_connections-current.rrd
# memcached_items-current.rrd
# memcached_octets.rrd
# memcached_ops-(evictions|hits|misses).rrd
# percent-hitratio.rrd
# ps_count.rrd
# ps_cputime.rrd
switch(GET('t')) {
# df-cache.rrd
case 'df':
require_once 'type/Default.class.php';
$obj = new Type_Default($CONFIG);
$obj->data_sources = array('used', 'free');
$obj->order = array('used', 'free');
$obj->ds_names = array(
'used' => 'Used',
'free' => 'Free',
);
$obj->colors = array(
'used' => '00e000',
'free' => '0000ff',
);
$obj->rrd_title = 'Memcached Memory Usage';
$obj->rrd_vertical = 'bytes';
break;
# memcached_command-(flush|get|set).rrd
case 'memcached_command':
require_once 'type/GenericStacked.class.php';
$obj = new Type_GenericStacked($CONFIG);
$obj->order = array('flush', 'get', 'set');
$obj->ds_names = array(
'flush' => 'Flush',
'get' => 'Get',
'set' => 'Set',
);
$obj->colors = array(
'flush' => '00e000',
'get' => '0000ff',
'set' => 'ffb000',
);
$obj->rrd_title = 'Memcached Commands';
$obj->rrd_vertical = 'Commands';
break;
# memcached_connections-current.rrd
case 'memcached_connections':
require_once 'type/Default.class.php';
$obj = new Type_Default($CONFIG);
$obj->data_sources = array('value');
$obj->ds_names = array(
'value' => 'Connections',
);
$obj->colors = array(
'percent' => '00b000',
);
$obj->rrd_title = 'Memcached Number of Connections';
$obj->rrd_vertical = 'Connections';
break;
# memcached_items-current.rrd
case 'memcached_items':
require_once 'type/Default.class.php';
$obj = new Type_Default($CONFIG);
$obj->data_sources = array('value');
$obj->ds_names = array(
'value ' => 'Items',
);
$obj->colors = array(
'value' => '00b000',
);
$obj->rrd_title = 'Number of Items in Memcached';
$obj->rrd_vertical = 'Items';
break;
# memcached_octets.rrd
case 'memcached_octets':
require_once 'type/Default.class.php';
$obj = new Type_Default($CONFIG);
$obj->data_sources = array('rx', 'tx');
$obj->order = array('rx', 'tx');
$obj->ds_names = array(
'rx' => 'Receive',
'tx' => 'Transmit',
);
$obj->colors = array(
'rx' => '0000ff',
'tx' => '00b000',
);
$obj->rrd_title = 'Memcached Network Traffic';
$obj->rrd_vertical = ucfirst($CONFIG['network_datasize']);
$obj->scale = $CONFIG['network_datasize'] == 'bits' ? 8 : 1;
break;
# memcached_ops-(evictions|hits|misses).rrd
case 'memcached_ops':
require_once 'type/GenericStacked.class.php';
$obj = new Type_GenericStacked($CONFIG);
$obj->order = array('evictions', 'hits', 'misses');
$obj->ds_names = array(
'evictions' => 'Evictions',
'hits' => 'Hits',
'misses' => 'Misses',
);
$obj->colors = array(
'evictions' => '00e000',
'hits' => '0000ff',
'misses' => 'ffb000',
);
$obj->rrd_title = 'Memcached Operations';
$obj->rrd_vertical = 'Commands';
break;
# percent-hitratio.rrd
case 'percent':
require_once 'type/Default.class.php';
$obj = new Type_Default($CONFIG);
$obj->data_sources = array('percent');
$obj->ds_names = array(
'percent ' => 'Percentage',
);
$obj->colors = array(
'percent' => '00e000',
);
$obj->rrd_title = 'Memcached Hits/Gets Ratio';
$obj->rrd_vertical = 'Percent';
break;
# ps_count.rrd
case 'ps_count':
require_once 'type/Default.class.php';
$obj = new Type_Default($CONFIG);
$obj->data_sources = array('threads');
$obj->order = array('threads');
$obj->ds_names = array(
'threads' => 'Threads',
);
$obj->colors = array(
'threads' => '00b000',
);
$obj->rrd_title = 'Memcached number of Threads';
$obj->rrd_vertical = 'Threads';
break;
# ps_cputime.rrd
case 'ps_cputime':
require_once 'type/Default.class.php';
$obj = new Type_Default($CONFIG);
$obj->data_sources = array('user', 'syst');
$obj->order = array('user', 'syst');
$obj->ds_names = array(
'user' => 'User',
'syst' => 'System',
);
$obj->colors = array(
'user' => '00e000',
'syst' => '0000ff',
);
$obj->rrd_title = 'CPU Time consumed by the memcached process';
$obj->rrd_vertical = 'Time';
break;
}
$obj->width = $width;
$obj->heigth = $heigth;
$obj->rrd_format = '%5.1lf%s';
collectd_flush($obj->identifiers);
$obj->rrd_graph();
|