diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..8ddbf32 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +dist +vendor +phar-composer.phar +composer.lock \ No newline at end of file diff --git a/beanstalkd b/beanstalkd new file mode 100755 index 0000000..d22bae1 --- /dev/null +++ b/beanstalkd @@ -0,0 +1,49 @@ +#!/usr/bin/env php +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); +} diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..fb21ac0 --- /dev/null +++ b/composer.json @@ -0,0 +1,16 @@ +{ + "name": "alexsoft/munin-beanstalk", + "type": "library", + "require": { + "pda/pheanstalk": "^3.1" + }, + "license": "MIT", + "authors": [ + { + "name": "Alex Plekhanov", + "email": "alex@plekhanov.us" + } + ], + "minimum-stability": "stable", + "bin": ["beanstalkd"] +}