Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 817613
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T02:01:14+00:00 2026-05-15T02:01:14+00:00

I want to be able to query a gearman server to determine how many

  • 0

I want to be able to query a gearman server to determine how many instances of a worker I have running (basically I want to make sure that RunTaskA is available and RunTaskB is available if there are no workers handling those tasks, I want to be able to send an alert out.

Is there any way to do this?

Also: Mad props if you know of a PHP way to query the gearman server.

Edit: I know about the PHP gearman extension that is available natively, but I am not looking for a task submission extension, I need something that allows me to query the gearman server and see how many workers are serving a specific task.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T02:01:15+00:00Added an answer on May 15, 2026 at 2:01 am
    class Waps_Gearman_Server {
    
        /**
         * @var string
         */
        protected $host = "127.0.0.1";
        /**
         * @var int
         */
        protected $port = 4730;
    
        /**
         * @param string $host
         * @param int $port
         */
        public function __construct($host=null,$port=null){
            if( !is_null($host) ){
                $this->host = $host;
            }
            if( !is_null($port) ){
                $this->port = $port;
            }
        }
    
        /**
         * @return array | null
         */
        public function getStatus(){
            $status = null;
            $handle = fsockopen($this->host,$this->port,$errorNumber,$errorString,30);
            if($handle!=null){
                fwrite($handle,"status\n");
                while (!feof($handle)) {
                    $line = fgets($handle, 4096);
                    if( $line==".\n"){
                        break;
                    }
                    if( preg_match("~^(.*)[ \t](\d+)[ \t](\d+)[ \t](\d+)~",$line,$matches) ){
                        $function = $matches[1];
                        $status['operations'][$function] = array(
                            'function' => $function,
                            'total' => $matches[2],
                            'running' => $matches[3],
                            'connectedWorkers' => $matches[4],
                        );
                    }
                }
                fwrite($handle,"workers\n");
                while (!feof($handle)) {
                    $line = fgets($handle, 4096);
                    if( $line==".\n"){
                        break;
                    }
                    // FD IP-ADDRESS CLIENT-ID : FUNCTION
                    if( preg_match("~^(\d+)[ \t](.*?)[ \t](.*?) : ?(.*)~",$line,$matches) ){
                        $fd = $matches[1];
                        $status['connections'][$fd] = array(
                            'fd' => $fd,
                            'ip' => $matches[2],
                            'id' => $matches[3],
                            'function' => $matches[4],
                        );
                    }
                }
                fclose($handle);
            }
    
            return $status;
        }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have some apache logs and i want to be able to query the
I want to be able to trim images, many of which are very long
I want to be able to user query strings in this fashion. Domain.com/controller/function?param=5&otherparam=10 In
I have a working LINQ to SQL model. I want to be able to
I want to be able to query or embed the version string set by
I have a Java object that I want to store in a local in-memory
I'm using LaTeX and BibTeX for an article, and I want to able to
Want to be able to provide a search interface for a collection of objects
I want to be able to email a report daily from a glpi database
I want to be able to open my website and use some kind of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.