The following warnings occurred:
Warning [2] count(): Parameter must be an array or an object that implements Countable - Line: 802 - File: showthread.php PHP 7.2.24-0ubuntu0.18.04.1 (Linux)
File Line Function
/showthread.php 802 errorHandler->error



Current time: 11-22-2019, 10:07 AM Hello There, Guest! (LoginRegister)

Post Reply 
 
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Number of Jobs in queue
06-12-2012, 12:01 PM
Post: #1
Number of Jobs in queue
Hi
I looked around for a script that would return the number of jobs on a queue for each location, but I couldn't find one.

So I just wrote up this quick script that others may find useful.

PHP Code:
<?php
/**
 Returns the number of jobs in the queue for each location
*/
chdir('..');
include 
'common.inc';

$locations parse_ini_file('./settings/locations.ini'true);
BuildLocations($locations);

header ('Content-type: text/xml');
echo 
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
echo 
"<response>\n";
echo 
"<statusCode>200</statusCode>\n";
echo 
"<statusText>Ok</statusText>\n";
echo 
"<data>\n";
$processed = array();
foreach (
$locations as $key => $loc) {
    
//no local directory? Then there's nothing to query
    
if (!isset($loc['localDir'])) continue;
    if ((
$pos =  strpos($key':')) !== false) {
        
$key substr($key$pos);
    }
    if (isset(
$processed[$key])) continue;
    
    
$processed[$key] = true;
    
    
$jobs count(scandir($loc['localDir'])) - 2//subtract directories from final count
    
echo "<location>\n";
        echo 
"<id>$key</id>";
        echo 
"<jobs>$jobs</jobs>";
    echo 
"</location>\n";
}
echo 
"</data>\n";
echo 
"</response>\n"

It needs to be placed in the work directory
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Number of Jobs in queue - krytie - 06-12-2012 12:01 PM
RE: Number of Jobs in queue - pmeenan - 06-12-2012, 12:11 PM

Forum Jump:


User(s) browsing this thread: 1 Guest(s)