Skip to content

Instantly share code, notes, and snippets.

@SemanticallyNull
Created May 11, 2015 16:51
Show Gist options
  • Save SemanticallyNull/9571bacadf2da7f47f5e to your computer and use it in GitHub Desktop.
Save SemanticallyNull/9571bacadf2da7f47f5e to your computer and use it in GitHub Desktop.
Beanstalk CLI queue monitor in PHP
{
"name": "queuemon",
"description": "Beanstalk CLI queue monitor",
"require": {
"pda/pheanstalk": "^3.0"
}
}
<?php
require(__DIR__ . "/vendor/autoload.php");
use Pheanstalk\Pheanstalk;
$pheanstalk = new Pheanstalk('127.0.0.1');
$mask = "|%-15.15s |%-10.10s |%-10.10s |%-10.10s |\n";
printf($mask, 'queue', 'ready', 'reserved', 'workers');
while(true) {
$tubes = $pheanstalk->listTubes();
foreach($tubes as $tube) {
$ts = $pheanstalk->statsTube($tube);
printf($mask, $tube, $ts['current-jobs-ready'], $ts['current-jobs-reserved'], $ts['current-watching']);
}
sleep(1);
echo "\033[".count($tubes)."A";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment