-
Notifications
You must be signed in to change notification settings - Fork 0
/
beanstalkd
executable file
·49 lines (37 loc) · 1.17 KB
/
beanstalkd
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
#!/usr/bin/env php
<?php
require "vendor/autoload.php";
$pheanstalk = new \Pheanstalk\Pheanstalk('localhost', 11300);
$states = ['ready', 'reserved', 'urgent', 'delayed', 'buried'];
$tubes = $pheanstalk->listTubes();
sort($tubes);
$graphTitle = 'Beanstalkd jobs';
$graphVlabel = 'count';
if ($argc > 1) {
if ($argv[1] === 'config') {
$configString = [];
foreach ($tubes as $tube) {
$configString[] = 'multigraph job_count_' . $tube;
$configString[] = 'graph_title ' . $graphTitle . ' (' . $tube . ')';
$configString[] = 'graph_category beanstalk';
$configString[] = 'graph_order ' . implode(' ', $states);
$configString[] = 'graph_vlabel ' . $graphVlabel;
foreach ($states as $state) {
$configString[] = $state . '.label ' . ucfirst($state);
}
}
echo implode("\n", $configString);
exit(0);
}
} else {
$dataString = [];
foreach ($tubes as $tube) {
$stats = $pheanstalk->statsTube($tube);
$dataString[] = 'multigraph job_count_' . $tube;
foreach ($states as $state) {
$dataString[] = $state . '.value ' . $stats['current-jobs-' . $state];
}
}
echo implode("\n", $dataString);
exit(0);
}