-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Alexey Plekhanov
committed
Jan 6, 2017
0 parents
commit e340e5f
Showing
3 changed files
with
69 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
dist | ||
vendor | ||
phar-composer.phar | ||
composer.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"] | ||
} |