title;
$module = &$toppage->module;
$strings = &$toppage->strings;
$errors = &$toppage->errors;
// Header table
$toppage->tabletop("","".$toptitle." $host");
//TODO add translation string here
echo "
[Scroll down to queues/shares table]
";
// Array defining the attributes to be returned
$qlim = array( QUE_NAME, QUE_QUED, QUE_GQUE, QUE_PQUE, QUE_LQUE, QUE_RUNG, QUE_GRUN,
QUE_ASCP, QUE_MAXT, QUE_MINT, QUE_STAT );
// ldapsearch filter strings for cluster and queues
$qfilter = "(objectclass=".OBJ_QUEU.")";
$dn = DN_LOCAL;
if ($schema == "GLUE2") {
$qlim = array( GQUE_NAME, GQUE_MAPQ, GQUE_STAT, GQUE_RUNG, GQUE_MAXR, GQUE_LQUE, GQUE_LRUN,
GQUE_PQUE, GQUE_QUED, GQUE_MAXQ, GQUE_MINT, GQUE_MAXT, GQUE_ENVK );
$elim = array( EENV_ID, EENV_LCPU, EENV_PCPU, EENV_TINS );
// ldapsearch filter strings for Shares and ExecutionEnvironments
$qfilter = "(objectclass=".GOBJ_QUEU.")";
$efilter = "(objectclass=".GOBJ_EENV.")";
$dn = DN_GLUE;
}
if ( $debug ) {
ob_end_flush();
ob_implicit_flush();
}
$tlim = 15;
$tout = 20;
if( $debug ) dbgmsg(":::> ".$errors["101"].$tlim.$errors["102"].$tout.$errors["103"]." <:::
");
// establish connection to the requested LDAP server
$chost = $host;
if ( $isse ) $chost=substr(strstr($host,":"),1);
$ldapuri = "ldap://".$chost.":".$port;
$ds = ldap_connect($ldapuri);
if ($ds) {
// If contact OK, search for clusters
$ts1 = time();
if ( $isse ) {
$exclude = array(SEL_USER);
if ( $dn == DN_LOCAL ) $thisdn = ldap_nice_dump($strings,$ds,SEL_NAME."=".$host.",".$dn,$exclude);
/**
* Storage not supported in GLUE2
* if ( $dn == DN_GLUE ) {
* $querydn = SEL_NAME."=".$host.":arex,GLUE2GroupID=services,".DN_GLUE;//TODO: change SEL_NAME
* $thisdn = ldap_nice_dump($strings,$ds,$querydn,$exclude);
* }
*/
// if it is a cluster
} else {
if ( $dn == DN_LOCAL ) $thisdn = ldap_nice_dump($strings,$ds,CLU_NAME."=".$host.",".$dn);
if ( $dn == DN_GLUE ) {
$querydn = "GLUE2ServiceID=urn:ogf:ComputingService:".$host.":arex,GLUE2GroupID=services,".DN_GLUE;
$thisdn = ldap_nice_dump($strings,$ds,$querydn);
}
}
$ts2 = time(); if($debug) dbgmsg("
".$errors["109"]." (".($ts2-$ts1).$errors["104"].")
");
if ( strlen($thisdn) < 4 && $debug ) dbgmsg("".$errors["129"].$thisdn."
");
echo "
";
// Loop on queues/shares (if everything works)
if ($thisdn != 1 && !$isse) {
$ts1 = time();
$qsr = @ldap_search($ds,$dn,$qfilter,$qlim,0,0,$tlim,LDAP_DEREF_NEVER);
// Only for GLUE2, search ExecutionEnvironments
if ( $dn == DN_GLUE ) $esr = @ldap_search($ds,$dn,$efilter,$elim,0,0,$tlim,LDAP_DEREF_NEVER);
$ts2 = time(); if($debug) dbgmsg("
".$errors["110"]." (".($ts2-$ts1).$errors["104"].")
");
// Fall back to conventional LDAP
// if (!$qsr) $qsr = @ldap_search($ds,$dn,$qfilter,$qlim,0,0,$tlim,LDAP_DEREF_NEVER);
}
// only for GLUE2, store executionenvironments in $envs for later use
if (($dn == DN_GLUE ) && ($esr) ) {
$nematch = @ldap_count_entries($ds,$esr);
if ($nematch > 0) {
$envs = array();
// TODO: If there are valid entries, save them in an array for later use, reorder with ID as primary key
$eentries = @ldap_get_entries($ds,$esr);
$nenvs = $eentries["count"];
for ($k=0; $k<$nenvs+1; $k++) {
$envs[$eentries[$k][EENV_ID][0]] = array(
EENV_LCPU => $eentries[$k][EENV_LCPU][0],
EENV_PCPU => $eentries[$k][EENV_PCPU][0],
EENV_TINS => $eentries[$k][EENV_TINS][0]
);
}
} else {
// TODO: add error strings to errors file, for translation
//if($debug) dbgmsg("
".$errors["TODO-ERR1"]."
");
if($debug) dbgmsg("
No ExecutionEnvironments found
");
}
}
if ($qsr) {
// If search returned, check that there are valid entries
$nqmatch = @ldap_count_entries($ds,$qsr);
if ($nqmatch > 0) {
// If there are valid entries, tabulate results
$qentries = @ldap_get_entries($ds,$qsr);
$nqueues = $qentries["count"];
// HTML table initialisation
echo "";
$qtable = new LmTableSp($module,$toppage->$module,$schema);
// loop on the rest of attributes
// some sorting, diversified depending on schema
if ($dn == DN_LOCAL) {
define("CMPKEY",QUE_MAXT);
usort($qentries,"quetcmp");
} elseif ($dn == DN_GLUE) {
// suprisingly, sorting buy dn did the trick for queues...
usort($qentries,"dncmp");
} else {
// TODO: add error strings to errors file, for translation
//if($debug) dbgmsg("
".$errors["TODO-ERR2"]."
");
if($debug) dbgmsg("
Sorting of queues/shares failed
");
}
for ($k=1; $k<$nqueues+1; $k++) {
if ( $dn == DN_LOCAL ) {
$qname = $qentries[$k][QUE_NAME][0];
$qstatus = $qentries[$k][QUE_STAT][0];
// $queued = @$qentries[$k][QUE_QUED][0];
$queued = @($qentries[$k][QUE_QUED][0]) ? ($entries[$k][QUE_QUED][0]) : 0; /* deprecated since 0.5.38 */
$locque = @($qentries[$k][QUE_LQUE][0]) ? ($qentries[$k][QUE_LQUE][0]) : 0; /* new since 0.5.38 */
$run = @($qentries[$k][QUE_RUNG][0]) ? ($qentries[$k][QUE_RUNG][0]) : 0;
$cpumin = @($qentries[$k][QUE_MINT][0]) ? $qentries[$k][QUE_MINT][0] : "0";
$cpumax = @($qentries[$k][QUE_MAXT][0]) ? $qentries[$k][QUE_MAXT][0] : ">";
$cpu = @($qentries[$k][QUE_ASCP][0]) ? $qentries[$k][QUE_ASCP][0] : "N/A";
$gridque = @($qentries[$k][QUE_GQUE][0]) ? $qentries[$k][QUE_GQUE][0] : "0";
$gmque = @($qentries[$k][QUE_PQUE][0]) ? ($qentries[$k][QUE_PQUE][0]) : 0; /* new since 0.5.38 */
$gridrun = @($qentries[$k][QUE_GRUN][0]) ? $qentries[$k][QUE_GRUN][0] : "0";
$quewin = popup("quelist.php?host=$host&port=$port&qname=$qname&schema=$schema",750,430,6,$lang,$debug);
}
if ( $dn == DN_GLUE ) {
$qname = $qentries[$k][GQUE_NAME][0];
$mapque = $qentries[$k][GQUE_MAPQ][0];
$qstatus = $qentries[$k][GQUE_STAT][0];
// Queued
$queued = @($qentries[$k][GQUE_QUED][0]) ? ($qentries[$k][GQUE_QUED][0]) : 0;
$locque = @($qentries[$k][GQUE_LQUE][0]) ? ($qentries[$k][GQUE_LQUE][0]) : 0;
$gridque = $queued - $locque;
if ( $gridque < 0 ) $gridque = 0;
$gmque = @($qentries[$k][GQUE_PQUE][0]) ? ($qentries[$k][GQUE_PQUE][0]) : 0;
// Running
$run = @($qentries[$k][GQUE_RUNG][0]) ? ($qentries[$k][GQUE_RUNG][0]) : 0;
$locrun = @($qentries[$k][GQUE_LRUN][0]) ? ($qentries[$k][GQUE_LRUN][0]) : 0;
$gridrun = $run - $locrun;
if ( $gridrun < 0 ) $gridrun = 0;
// Limits
$cpumin = @($qentries[$k][GQUE_MINT][0]) ? $qentries[$k][GQUE_MINT][0] : "0";
$cpumax = @($qentries[$k][GQUE_MAXT][0]) ? $qentries[$k][GQUE_MAXT][0] : ">";
// related execenv
$qenvkey = @($qentries[$k][GQUE_ENVK][0]) ? $qentries[$k][GQUE_ENVK][0] : "";
// use ExecutionEnvironment TotalInstances, LogicalCPUs when available to calculate cpus
// use mapping between queues and execenvs
$env = $envs[$qenvkey];
$cpu = $env[EENV_LCPU] * $env[EENV_TINS];
if (!$cpu) $cpu = "N/A";
// This below TODO
$quewin = popup("quelist.php?host=$host&port=$port&qname=$qname&schema=$schema",750,430,6,$lang,$debug);
}
$gridque = $gridque + $gmque;
if ( $queued == 0 ) $queued = $locque + $gridque;
// filling the table
$qrowcont[] = "$qname";
if ( !empty($mapque) ) {
$qrowcont[] = "$mapque";
}
$qrowcont[] = "$qstatus";
$qrowcont[] = "$cpumin – $cpumax";
$qrowcont[] = "$cpu";
$qrowcont[] = "$run (".$errors["402"].": $gridrun)";
$qrowcont[] = "$queued (".$errors["402"].": $gridque)";
$qtable->addrow($qrowcont);
$qrowcont = array ();
}
$qtable->close();
}
else {
$errno = 8;
echo "
".$errors["8"]."\n";
return $errno;
}
}
elseif ( !$isse ) {
$errno = 5;
echo "
".$errors["5"]."\n";
return $errno;
}
@ldap_free_result($qsr);
@ldap_close($ds);
return 0;
}
else {
$errno = 6;
echo "
".$errors[$errno]."\n";
return $errno;
}
// Done
$toppage->close();
?>