Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexey Plekhanov committed Jan 6, 2017
0 parents commit e340e5f
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
dist
vendor
phar-composer.phar
composer.lock
49 changes: 49 additions & 0 deletions beanstalkd
Original file line number Diff line number Diff line change
@@ -0,0 +1,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);
}
16 changes: 16 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "alexsoft/munin-beanstalk",
"type": "library",
"require": {
"pda/pheanstalk": "^3.1"
},
"license": "MIT",
"authors": [
{
"name": "Alex Plekhanov",
"email": "[email protected]"
}
],
"minimum-stability": "stable",
"bin": ["beanstalkd"]
}

0 comments on commit e340e5f

Please sign in to comment.