title;
$module = &$toppage->module;
$strings = &$toppage->strings;
$errors = &$toppage->errors;
$giislist = &$toppage->giislist;
// Header table
$toppage->tabletop("".$toptitle."
","");
if ( $debug ) {
ob_end_flush();
ob_implicit_flush();
}
$tlim = 10;
$tout = 15;
if($debug) dbgmsg("
:::> ".$errors["101"].$tlim.$errors["102"].$tout.$errors["103"]." <:::
");
// Arrays defining the attributes to be returned
$lim = array( "dn", SEL_NAME, SEL_ANAM, SEL_CURL, SEL_BURL, SEL_TYPE, SEL_FREE, SEL_TOTA );
// ldapsearch filter strings for clusters and queues
$filstr = "(objectclass=".OBJ_STEL.")";
// Top GIIS server: get all from the pre-defined list
$ngiis = count($giislist);
$ts1 = time(); $gentries = recursive_giis_info($giislist,"nordugrid-SE",$errors,$debug);
$ts2 = time(); if($debug) dbgmsg("
".$errors["106"].$ngiis." (".($ts2-$ts1).$errors["104"].")
");
$nc = count($gentries);
if ( !$nc ) {
// NO SITES FOUND!
$errno = "1";
echo "
".$errors[$errno]."\n";
return $errno;
}
$dsarray = array ();
$hnarray = array ();
$sitetag = array (); /* a tag to skip duplicated entries */
for ( $k = 0; $k < $nc; $k++ ) {
$clhost = $gentries[$k]["host"];
$clport = $gentries[$k]["port"];
$ldapuri = "ldap://".$clhost.":".$clport;
$clconn = ldap_connect($ldapuri);
if ( $clconn && !$sitetag[$clhost] ) {
array_push($dsarray,$clconn);
array_push($hnarray,$clhost);
$sitetag[$clhost] = 1; /* filtering tag */
if ($debug==2) dbgmsg("$k - $clhost:$clport ");
}
}
$nhosts = count($dsarray);
if ( !$nhosts ) {
// NO SITES REPLY...
$errno = "2";
echo "
".$errors[$errno]."\n";
return $errno;
}
// Search all SEs
$ts1 = time();
$srarray = @ldap_search($dsarray,DN_LOCAL,$filstr,$lim,0,0,$tlim,LDAP_DEREF_NEVER);
$ts2 = time(); if($debug) dbgmsg("
".$errors["124"]." (".($ts2-$ts1).$errors["104"].")
");
$ctable = new LmTableSp($module,$toppage->$module);
// Loop on SEs
$senum = 0;
$space = 0;
$capacity = 0;
for ( $ids = 0; $ids < $nhosts; $ids++ ) {
$sr = $srarray[$ids];
$ds = $dsarray[$ids];
$hn = $hnarray[$ids]; /* host name, for debugging */
if ($ds && $sr) {
$entries = @ldap_get_entries($ds,$sr);
$nclusters = $entries["count"]; /* May be several SEs! */
if ( !$nclusters ) continue;
for ( $i = 0; $i < $nclusters; $i++) {
$senum++;
$curdn = $entries[$i]["dn"];
$curname = $entries[$i][SEL_NAME][0];
$curalias = $entries[$i][SEL_ANAM][0];
$curspace = ( $entries[$i][SEL_FREE][0] ) ? $entries[$i][SEL_FREE][0] : 0;
// $curcapacity = ( $entries[$i][SEL_TOTA][0] ) ? $entries[$i][SEL_TOTA][0] : $errors["407"];
$curcapacity = ( $entries[$i][SEL_TOTA][0] ) ? $entries[$i][SEL_TOTA][0] : $curspace;
$cururl = ( $entries[$i][SEL_BURL][0] ) ? $entries[$i][SEL_BURL][0] : $entries[$i][SEL_CURL][0];
$curtype = $entries[$i][SEL_TYPE][0];
$clstring = popup("clusdes.php?host=$curname&port=$curport&isse=1&debug=$debug",700,620,1,$lang,$debug);
$curspace = intval($curspace/1000);
$occupancy = 1; // by default, all occupied
$space += $curspace;
// if ( $curcapacity != $errors["407"] ) {
if ( $curcapacity != 0 ) {
$curcapacity = intval($curcapacity/1000);
$occupancy = ($curcapacity - $curspace)/$curcapacity;
$capacity += $curcapacity;
}
$tstring = $curspace."/".$curcapacity;
$tlen = strlen($tstring);
if ($tlen<11) {
$nspaces = 11 - $tlen;
for ( $is = 0; $is < $nspaces; $is++ ) $tstring .= " ";
}
$tstring = urlencode($tstring);
if ($debug==2) dbgmsg("$senum: $curname at $hn
");
if ( strlen($curalias) > 15 ) $curalias = substr($curalias,0,15) . ">";
// $clstring = popup("clusdes.php?host=$curname&port=2135",700,620,1,$lang,$debug);
$rowcont[] = "$senum";
$rowcont[] = " $curalias";
$rowcont[] = "";
// $rowcont[] = $curcapacity.$errors["408"];
// $rowcont[] = $curspace.$errors["408"];
$rowcont[] = "$curname";
$rowcont[] = "$cururl";
$rowcont[] = "$curtype";
$ctable->addrow($rowcont);
$rowcont = array ();
}
}
$entries = array();
$jentries = array();
$gentries = array();
}
$occupancy = ($capacity - $space)/$capacity;
$tstring = $space."/".$capacity;
$ctable->addspacer("#ffcc33");
$rowcont[] = " ";
$rowcont[] = "".$errors["405"]."";
$rowcont[] = "";
//$rowcont[] = "$capacity".$errors["408"]."";
//$rowcont[] = "$space".$errors["408"]."";
$rowcont[] = " ";
$rowcont[] = " ";
$rowcont[] = " ";
$ctable->addrow($rowcont, "#ffffff");
$ctable->close();
return 0;
// Done
$toppage->close();
?>