From e340e5f478eedc8c74fbdbabd746e2ccb14ea5b9 Mon Sep 17 00:00:00 2001 From: Alexey Plekhanov Date: Fri, 6 Jan 2017 22:36:32 +0100 Subject: [PATCH] Initial commit --- .gitignore | 4 ++++ beanstalkd | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ composer.json | 16 ++++++++++++++++ 3 files changed, 69 insertions(+) create mode 100644 .gitignore create mode 100755 beanstalkd create mode 100644 composer.json 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"] +}