EOS1; # # # # # # # # # # # # # # # # # # # # # # # # } function displayBody() { echo <<
xCAT
LOADING
0%

 
 
 
EOS5; } function displayFooter() { echo "
 
"; // # use system() to get the xCAT Web version; echo ""; # comment out if statement to fix refresh but of logout. if(!isAuthenticated()){ insertLogin(); } echo << EOS3; } // Create the bread crumb links. The mapper arg is a hash of label/url pairs, where // the final url is usually ''. function displayMapper($mapper) { echo "
"; $first = 1; foreach ($mapper as $key => $value) { if (!$first) { echo " / "; } $first = 0; if (!strlen($value)) { echo $key; } else { if ($value == 'main.php') { $href = '#'; } else { $href = "#$value"; } echo "$key"; } } echo "
"; } function displayTabMain(){ displayMapper(array('home'=>'main.php', 'config' =>'')); /* echo << home / config
MAPPER; */ echo <<

Configuration Menu

xCAT is configured by several tables. Each of the tables below tweeks a setting in xCAT. Click on a table below to configure xCAT EOS; $xml = docmd('tabdump', '', array('-d')); foreach($xml->children() as $response) foreach($response->children() as $line){ list($tabName, $descr) = split(":", $line, 2); echo "

$tabName$descr

\n"; } echo << EOS; } function displayTab($tab){ displayMapper(array('home'=>'main.php', 'config' =>'config.php', "$tab"=>'')); /* echo << home / config / $tab MAPPER; */ echo "
"; echo "

$tab

\n"; insertButtons(array('label' => 'Save','id' => 'saveit'), array('label' => 'Cancel', 'id' => 'reset') ); $xml = docmd('tabdump', '', array($tab)); $headers = getTabHeaders($xml); if(!is_array($headers)){ die("

Can't find header line in $tab

"); } echo "\n"; #echo "
\n"; echo ""; echo "\n"; # extra cell for the red x #echo "\n"; # extra cell for the red x foreach($headers as $colHead) {echo ""; } echo "\n"; # close header row echo ""; $tableWidth = count($headers); $ooe = 0; $item = 0; $line = 0; $editable = array(); foreach($xml->children() as $response) foreach($response->children() as $arr){ $arr = (string) $arr; if(ereg("^#", $arr)){ $editable[$line++][$item] = $arr; continue; } $cl = "ListLine$ooe"; $values = splitTableFields($arr); # X row echo ""; foreach($values as $v){ echo ""; $editable[$line][$item++] = $v; } echo "\n"; $line++; $item = 0; $ooe = 1 - $ooe; } echo "
$colHead
$v
\n"; $_SESSION["editable-$tab"] = & $editable; # save the array so we can access it in the next call of this file or change.php echo "

"; insertButtons(array('label' => 'Add Row', 'id' => 'newrow')); echo "

\n"; ?> 1) echo ""; foreach (func_get_args() as $button) { $otherattrs = @$button['otherattrs']; $id = @$button['id']; if (!empty($id)) { $id = "id=$id"; } $onclick = @$button['onclick']; if (!empty($onclick)) { $onclick = "onclick='$onclick'"; } # if ($num > 1) echo ""; } #if ($num > 1) echo "
"; echo "{$button['label']}"; # if ($num > 1) echo "
\n"; I hate tables!!! } // $errors should be an array with errors function displayErrors($errors){ echo "

Changes to table failed! ", implode(' ',$errors), ",

\n"; } function displaySuccess($tab){ echo "

Changes to $tab have been saved.

\n"; } function displayAlert($a){ echo << alert('hi!' + '$a'); EOS7; } // Functions to control display of trees and control functions function displayCtrlPage($cmd){ displayMapper(array('home'=>'main.php', 'control' =>'')); echo "
"; echo "
Noderange:
"; echo "
Action: $cmd
"; echo "
\n"; echo "
\n"; //displayControlTables($cmd); } function displayNrTree(){ echo <<

Please select a node or noderange on the left.

You can use ctrl-click to select more than one node grouping,

or expand the noderanges to select individual nodes.

EOS; } function displayControlTables($cmd){ echo <<
  • Power
  • Inventory
  • Environmentals
  • Event Logs
  • Beacon Light
  • EOSS; } function displayRangeList($nr, $cmd){ echo "
    "; if($cmd == ""){ displayCommands($nr); return; } if(substr($cmd,0,6) == 'rpower'){ $array = explode('rpower', $cmd); controlRunCmd($nr, 'rpower', $array[1]); }elseif(substr($cmd,0,4) == 'rinv'){ $array = explode('rinv', $cmd); controlRunCmd($nr, 'rinv', $array[1]); }elseif(substr($cmd,0,7) == 'rvitals'){ $array = explode('rvitals', $cmd); controlRunCmd($nr, 'rvitals', $array[1]); }elseif(substr($cmd,0,7) == 'rbeacon'){ $array = explode('rbeacon', $cmd); controlRunCmd($nr, 'rbeacon', $array[1]); }else{ echo "I don't recognize the command: $cmd"; } echo "
    "; } function displayCommands($nr){ echo <<Please select an action to perform on noderange $nr

    Power

    Inventory

    Vitals

    Beacon

    Remote Commands

    • Run a command on all nodes

    Event Log

    • View Event Log
    • Clear Event Log

    Set Boot Order

    • Set Boot Order
    EOF; } function controlRunCmd($nr, $cmd, $subcmd){ echo << $(document).ready(function() { $("#tableForCtrl").dataTable({ "bLengthChange": true, "bFilter": true, "bSort": true, "iDisplayLength": 50 }); }); JS00; echo "
    "; $rvals = docmd($cmd, $nr, array($subcmd)); #print_r($rvals); $headers = attributesOfNodes($rvals,$cmd); #echo "

    Headers:
    "; #print_r($headers); $nh = mkNodeHash($rvals,$cmd); #echo "


    "; echo ""; echo ""; echo ""; echo ""; foreach ($headers as $head){ echo ""; } echo ""; echo ""; foreach($nh as $n => $vals){ echo "\n"; #echo ""; echo ""; foreach($headers as $h){ if($vals[$h] == ''){ echo " "; }else{ #echo ""; echo ""; } } echo ""; } echo ""; echo "
    Node$head
    $n$n" . $vals[$h] . "" . $vals[$h] . "
    "; echo "
    "; } // Main page display function displayMainPage() { echo <<

    Control

    • Power nodes off/on
    • Collect hardware information
    • Run Command on All Nodes

    Configure

    • Edit xCAT Tables
    EOS; # echo "
      "; # $tables = getTabNames(); # foreach($tables as $t){ # echo "
    • $t
    • "; # } # echo "
    "; echo <<Provision
    • Provision node

    Syslog

    • Show syslog Entries

    Monitor

    • Set up xCAT Monitoring Plug-in
    • This is still UNDER DEVELOPMENT.
    EOS; } // Monitoring page stuff. Right now its just the syslog monitor function displayLogTable(){ if(($line = getLastLine('')) === 0){ return; }; displayMapper(array('home'=>'main.php', 'syslog' =>'')); echo <<

    Syslog Entries

    Stop Updates | Start Updates

    EOS; $time = logToTable($line); echo <<
    Date Time Host SubSystem Message
    EOS; } // Given a Line from Syslog formats into a table. function logToTable($line){ list($month,$date,$time,$host,$subsys,$message) = preg_split('/\s+/', $line, 6); if($message == ''){ echo "no entry"; return; } echo << $month $date $time $host EOS; if($subsys == 'last'){ $message = $subsys . " " . $message; $subsys = " "; } echo <<$subsys $message FOO; return; } // provision page stuff ## here is where we provision nodes. # m - method (install or netboot) # o - OS (centos5.3, etc) # a - arch (x86, x86_64) # p - profile (compute, or user defined) function displayProvisionPage($m,$o,$a,$p){ displayMapper(array('home'=>'main.php', 'provision' =>'')); echo "
    "; echo "
    Noderange:
    "; echo "
    Operating System: $o
    "; echo "
    Architecture: $a
    "; echo "
    Install Method: $m
    "; echo "
    Profile: $p
    "; echo "
    \n"; echo "\n"; } function displayInstallList($nr, $m,$o,$a,$p){ if($m == ""){ displayProvisionOps($nr); return; } echo "installing $m $o $a $p
    "; } function displayProvisionOps($nr){ echo <<

    Please select an OS to install on the noderange $nr

    EOF; } function getHostName() { if($_SERVER['SERVER_SOFTWARE'] == 'IBM_HTTP_Server') { return exec("hostname"); }else { return exec("hostname --long"); } } function getCPUInfo() { #check the var $_SERVER['SERVER_SOFTWARE'] to determine the server's os type #if its value is "IBM_HTTP_Server", the server will be treated as AIX if($_SERVER['SERVER_SOFTWARE'] == 'IBM_HTTP_Server') { return exec("lscfg -vp |wc -l");#on AIX, the command can show processor count }else { return exec("cat /proc/cpuinfo |grep -i processor |wc -l"); } } function getMemInfo() { if($_SERVER['SERVER_SOFTWARE'] == 'IBM_HTTP_Server') {#AIX $str = exec("lsattr -El sys0 |grep realmem"); $arr = preg_split('/\s+/', $str); return $arr[1]; }else { $str = exec("cat /proc/meminfo |grep MemTotal"); $arr = preg_split('/[:\s]+/', $str); return $arr[1]; } } function getNetworksInfo() { #the command is "lsdef -t network -i net,mask,mgtifname" in the sever end; #display the net, mask and mgtifname in one small table echo ""; echo ""; echo ""; echo ""; echo ""; $xml = docmd("tabdump", "", array("networks")); foreach($xml->children() as $response) foreach($response->children() as $data) { if(strstr($data[0], '#') != FALSE) { continue; } else { #print_r($data); $arr = split(",", $data); echo ""; echo ""; echo ""; echo ""; echo ""; } } echo ""; echo "
    NetworkNetmaskMgtIfName
    ".$arr[1]."".$arr[2]."".$arr[3]."
    "; } function summary_general() { $hostname = getHostName(); $cpus = getCPUInfo(); $mem = getMemInfo(); #TODO echo << Hostname $hostname Processors $cpus Memory $mem KB Networks INFO0; getNetworksInfo(); echo << INFO1; } /* * showNodeStat() * will show the number of nodes in the cluster * and also show their status */ function showNodeStat() { $xml=docmd("rpower", "all", array("stat")); $stat_arr = array(); foreach($xml->children() as $response){ #parse the xml tree #print_r($response); if($response->errorcode == 0) { #echo $response->node->name, $response->node->data->contents; $key = $response->node->name; $stat_arr["$key"] = $response->node->data->contents; } } echo "
    "; echo "
    "; echo ""; $stat_num = array("Operating" => 0, "Running" => 0, "Not Activated" => 0, "Open Firmware" => 0); foreach ($stat_arr as $k => $v) { $stat_num["$v"] ++; } echo ""; echo ""; echo ""; echo ""; echo "
    Operating", $stat_num["Operating"], "
    Running",$stat_num["Running"],"
    Not Activated",$stat_num["Not Activated"],"
    Open Firmware",$stat_num["Open Firmware"],"
    "; #add two buttons here: show/hide the detailed status in stat_table #TODO: move them to the proper positions echo "
    "; echo ""; echo ""; echo "
    "; echo ""; echo << $(function() { $("#show").click(function() { if($(this).is(".ui-state-active")) { loadNodeStatus(); $(this).removeClass("ui-state-active"); $("#hide").addClass("ui-state-active"); } }); $("#hide").click(function() { if($(this).is(".ui-state-active")) { $("#p_stat_table").hide(); $(this).removeClass("ui-state-active"); $("#show").addClass("ui-state-active"); } }); }); /* var data=[ {label: "Operating", data: 3 }, {label: "Running", data: 4 }, {label: "Not Activated", data: 12 }, {label: "Open Firmware", data: 1 } ]; */ var options = { series: { pie: { show: true } } }; $.ajax({ url: "rpowerstat.php", type: 'POST', data: "type=json", dataType: 'json', success: function(data) { $.plot($("#chart0"), data, options); } }); /* "rpowerstat.php", {type:"json"}, function(data) { $.plot($("#chart0"), data, options); }); */
    GRAPH0; echo ""; echo "
    "; echo "
    "; echo "
    "; echo "
    "; } /* showMonSum() * will show the summary information of monitor plugins. * */ function showMonSum() { $xml = docmd("monls", "", array("-a")); echo "
    "; #print_r($xml); echo "
    "; echo ""; echo ""; foreach($xml->children() as $response) foreach($response->children() as $data){ list($name, $stat, $nodemon) = preg_split("/\s+/", $data); echo ""; echo ""; if($nodemon) { echo ""; }else { echo ""; } echo ""; echo ""; } echo ""; echo "
    PluginsStatusNodeStatSupport
    $name$statEnabledDisabled
    "; echo "
    "; } function showxCATInfo() { echo "
    "; #$ret = shell_exec("rpm -qa |grep xCAT");/* there's no newline character in the string */ /* * xCAT-UI-2.4-snap200912080702 xCAT-client-2.4-snap200912180657 perl-xCAT-2.4-snap200912240801 xCAT-rmc-2.4-snap200912051911 xCAT-2.4-snap200912240802 xCAT-server-2.4-snap200912190921 * */ #$rpms = preg_split("/\n/", $ret); echo ""; $ret = shell_exec("rpm -q xCAT"); if($ret) { $verstr = substr($ret, 5); echo ""; echo ""; echo ""; } $ret = shell_exec("rpm -q xCAT-server"); if($ret) { $verstr = substr($ret, 12); echo ""; echo ""; echo ""; } $ret = shell_exec("rpm -q xCAT-client"); if($ret) { $verstr = substr($ret, 12); echo ""; echo ""; echo ""; } $ret = shell_exec("rpm -q perl-xCAT"); if($ret) { $verstr = substr($ret, 10); echo ""; echo ""; echo ""; } $ret = shell_exec("rpm -q xCAT-rmc"); if($ret) { $verstr = substr($ret,9); echo ""; echo ""; echo ""; } $ret = shell_exec("rpm -q xCAT-UI"); if($ret) { $verstr = substr($ret,8); echo ""; echo ""; echo ""; } echo '
    xCAT$verstr
    xCAT-server$verstr
    xCAT-client$verstr
    perl-xCAT$verstr
    xCAT-rmc$verstr
    xCAT-UI$verstr
    '; echo "
    "; } function showUpdateRow($RpmName){ $ret = shell_exec("rpm -q " . $RpmName); $aRpm = explode("\n",$ret); foreach ($aRpm as $TempRpm) { if($TempRpm){ $verstr= substr($TempRpm, strlen($RpmName) + 1); echo (""); echo (""); echo ("" . $RpmName . ""); echo ("" . $verstr . ""); echo (""); } } } function showUpdateInfo() { echo "
    "; echo ""; echo ""; echo ""; echo ""; echo ""; showUpdateRow("xCAT-client"); showUpdateRow("perl-xCAT"); showUpdateRow("xCAT-server"); showUpdateRow("xCAT"); showUpdateRow("xCAT-rmc"); showUpdateRow("xCAT-UI"); echo '
    Package NameVersion
    '; } ?>