|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* @file |
|
5
|
|
|
* Munin plugin for Beanstalkd Command Rate monitoring |
|
6
|
|
|
* |
|
7
|
|
|
* @author: Frédéric G. MARAND <[email protected]> |
|
8
|
|
|
* @copyright (c) 2014-2018 Ouest Systèmes Informatiques (OSInet) |
|
9
|
|
|
* @license Apache License 2.0 or later |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
namespace OSInet\Beanstalkd\Munin; |
|
13
|
|
|
|
|
14
|
|
|
class CommandRatePlugin extends BasePlugin |
|
15
|
|
|
{ |
|
16
|
|
|
public $cmds = [ |
|
17
|
|
|
['put', 'cmd-put', 'Put'], |
|
18
|
|
|
['reserve', 'cmd-reserve', 'Reserve'], |
|
19
|
|
|
['reserve_timeout', 'cmd-reserve-with-timeout', 'Reserve with timeout'], |
|
20
|
|
|
['delete', 'cmd-delete', 'Delete'], |
|
21
|
|
|
['touch', 'cmd-touch', 'Touch'], |
|
22
|
|
|
['release', 'cmd-release', 'Release'], |
|
23
|
|
|
['bury', 'cmd-bury', 'Bury'], |
|
24
|
|
|
]; |
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* {@inheritdoc} |
|
28
|
|
|
*/ |
|
29
|
|
|
public function config() |
|
30
|
|
|
{ |
|
31
|
|
|
$ret = "graph_title Command Rate\n" |
|
32
|
|
|
. 'graph_vlabel Commands per ${graph_period}' . "\n" |
|
33
|
|
|
. "graph_category Beanstalk\n" |
|
34
|
|
|
. "graph_args --lower-limit 0\n" |
|
35
|
|
|
. "graph_scale no\n"; |
|
36
|
|
|
|
|
37
|
|
|
foreach ($this->cmds as $cmd) { |
|
38
|
|
|
list($name, , $label) = $cmd; |
|
39
|
|
|
$ret .= sprintf("cmd_%s.label %s\n", $name, $label) |
|
40
|
|
|
. sprintf("cmd_%s.type DERIVE\n", $name) |
|
41
|
|
|
. sprintf("cmd_%s.min 0\n", $name); |
|
42
|
|
|
} |
|
43
|
|
|
return $ret; |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* {@inheritdoc} |
|
48
|
|
|
*/ |
|
49
|
|
|
public function data() |
|
50
|
|
|
{ |
|
51
|
|
|
$stats = $this->server->stats(); |
|
52
|
|
|
$ret = ''; |
|
53
|
|
|
foreach ($this->cmds as $cmd) { |
|
54
|
|
|
list($name, $counter,) = $cmd; |
|
55
|
|
|
$ret .= sprintf("cmd_%s.value %d\n", $name, $stats[$counter]); |
|
56
|
|
|
} |
|
57
|
|
|
return $ret; |
|
58
|
|
|
} |
|
59
|
|
|
} |
|
60
|
|
|
|