the code for "view by graph" is added

git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@4116 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
mxi1 2009-09-10 06:57:06 +00:00
parent 28722ca267
commit e8cbd28916
6 changed files with 239 additions and 123 deletions

View File

@ -565,5 +565,22 @@ function handle_tips() {
});
}
function rmc_monshow_draw_by_flot(value)
{
//collecting data from "monshow" command,
//then, draw by the jQuery-plugin: flot
//http://groups.google.com/group/flot-graphs/browse_thread/thread/93358c68d44412a4?pli=1
var options = {
xaxis: {
mode: 'time'
},
lines: {show: true, fill: true}
};
$.getJSON("monitor/flot_get_data.php", {attr: value}, function(data) {
$.plot($("#placeholder"),data, options);
});
}
// load progress bar
myBar.loaded('xcat.js');

View File

@ -136,6 +136,7 @@ echo <<<TOS2
<td>
TOS2;
insertButtons(array('label'=>$ns_tobe, 'id'=>'node_stat', 'onclick'=>"node_stat_control(\"$name\")"));
//TODO: change the function name of node_stat_control
echo '</td>';
echo '</tr>';
echo '<tr class="ListLine1">';
@ -454,35 +455,171 @@ function displayRMCMonshowAttr($attr) {
echo "<tbody>";
//get all the data by the command "monshow"
$xml = docmd("monshow", "", array("rmcmon", "-s", "-t", "10", "-a", "$attr"));
$xml = docmd("monshow", "", array("rmcmon", "-s", "-t", "60", "-a", "$attr"));
//the error handling is skipped
$index = 0;
foreach($xml->children() as $response) foreach($response->children() as $data) {
//handle the data here
//skip the first 3 lines
if($index++ < 3) {
//skip the first 2 lines
if($index++ < 2) {
continue;
}
//then, parse "date" & "value"
$arr = preg_split("/\s+/", $data);
array_pop($arr);
$val = array_pop($arr);
$time = implode(" ", $arr);
echo "<tr>";
$elements = explode(" ", $data);
echo "<td>";
$i = 0;
while($i < 7) {
echo $elements[$i],"\t";
$i++;
}
echo "</td>";
echo "<td>$elements[7]</td>";
//var_dump($elements);
echo "</tr>";
echo "<td>$time</td>";
echo "<td>$val</td>";
echo "</tr>";
}
echo "</tbody>";
echo "</table>";
echo "</div>";
}
function displayRMCMonshowGraph($value) {
//display the RMC Performance Data
echo <<<TOS11
<div>
<script type="text/javascript">
rmc_monshow_draw_by_flot("$value");
</script>
<p><b>The Graph View for RMC Resource</b></p>
<div id='placeholder' style='width:600px;height:300px'>
</div>
</div>
TOS11;
}
/*
* function displayOptionsForPlugin($plugin)
* *****************************************
* when the user selects one plugin, the avaiable configuration options will display in <div id='monconfig'>
* TODO: for the non-rmcmon plugins, only the option "node/application status monitoring setting" is shown;
*
* the avaiable view options will also display in <div id='monview'>,
* TODO: right now, it's only implemented for rmcmon plugin.
*/
function displayOptionsForPlugin($name)
{
echo "<div id='monconfig'>";
echo "<p>Available Configurations for <b>$name</b></p>";
echo '<table id="tabTable" class="tabTable" cellspacing="1">';
echo "<tbody>";
//set up the options for the plugin with the name "$name"
if($name == "rmcmon") {
//node status monitor, RMC events, RMC resources
echo "<tr class='ListLine0' id='row0'>";
echo "<td>Node/Application Status Monitoring Setting</td>";
echo "<td>";
insertButtons(array('label'=>'Configure', 'id'=>'rmc_nodestatmon', 'onclick'=>'loadMainPage("monitor/stat_mon.php?name=rmcmon")'));
echo "</td>";
echo "</tr>";
echo "<tr class='ListLine1' id='row1'>";
echo "<td>RMC Events Monitoring Setting</td>";
echo "<td>";
insertButtons(array('label'=>'Configure', 'id'=>'rmc_event', 'onclick'=>'loadMainPage("monitor/rmc_event_define.php")'));
echo "</td>";
echo "</tr>";
echo "<tr class='ListLine0' id='row2'>";
echo "<td>RMC Resource Monitoring Setting</td>";
echo "<td>";
insertButtons(array('label'=>'Configure', 'id'=>'rmc_resource', 'onclick'=>'loadMainPage("monitor/rmc_resource_define.php")'));
echo "</td>";
echo "</tr>";
} else {
//there's only "node status monitoring" is enabled
echo "<tr class='ListLine0' id='row0'>";
echo "<td>Node/Application Status Monitoring Setting</td>";
echo "<td>";
insertButtons(array('label'=>'Configure', 'id'=>$name."_nodestatmon", 'onclick'=>"loadMainPage(\"monitor/stat_mon.php?name=$name\")"));
echo "</td>";
echo "</tr>";
}
echo "</tbody></table>";
echo "</div>";
echo "<div id='monview'>";
echo "<p>View Options for <b>$name</b></p>";
//there should be many choices for the user to view the clusters' status
echo <<<TOS1
<table id="view_tab" class="tabTable" cellspacing="1">
<thead>
<tr class='colHeaders'>
<td>Monitor Items</td>
<td>Display Formats</td>
</tr>
</thead>
<tbody>
TOS1;
if($name == "rmcmon") {
#display two rows, one for RMC event, another for RMC Resource Performance monitoring.
echo "<tr class='ListLine0' id='row0'>";
echo "<td>RMC Event Logs</td>";
echo "<td>";
insertButtons(array('label'=>'View in Text', 'id'=>'rmc_event_text', 'onclick'=>'loadMainPage("monitor/rmc_lsevent.php")'));
echo "</td>";
echo "</tr>";
echo "<tr class='ListLine1' id='row1'>";
echo "<td>RMC Resource Logs</td>";
echo "<td>";
insertButtons(array('label'=>'View in Text', 'id'=>'rmc_resrc_text', 'onclick'=>'loadMainPage("monitor/rmc_monshow.php")'));
insertButtons(array('label'=>'View in Graphics', 'id'=>'rmc_resrc_graph', 'onclick'=>''));
echo "</td>";
echo "</tr>";
}
else {
echo "<p>There's no view functions for $name.</p>";
}
echo "</tbody></table></div>";
}
/*
* function displayNodeAppStatus($name)
* ************************************
* to display the web page "Node/Application Status Monitoring"
*
*/
function displayNodeAppStatus($name)
{
displayMapper(array('home'=>'main.php', 'monitor'=>''));
displayTips(array(
"Enable/disable Node/App Status Monitoring by clicking the button",
"In order to take affect, you have to START/RESTART the desired plugin"));
//get the current status for "node-status-monitor"
$xml = docmd("monls", ' ', array($name));
if(getXmlErrors($xml,$errors)) {
echo "<p class=Error>",implode(' ',$errors), "</p>";
exit;
}
#then, parse the xml data
foreach($xml->children() as $response) foreach($response->children() as $data) {
list($n, $stat, $nodemonstatus) = preg_split("/\s+/",$data);
if(isset($nodemonstatus)) {
$ns = "Enabled";
}else {
$ns = "Disabled";
}
}
display_stat_mon_table(array("$name"=>
array(
'nodestat'=>$ns,
'appstat'=>'Disabled', //currently application status monitoring is not supported by xCAT monitor Arch.
)));
}
?>

View File

@ -0,0 +1,62 @@
<?php
if(!isset($TOPDIR)) { $TOPDIR="..";}
require_once "$TOPDIR/lib/security.php";
require_once "$TOPDIR/lib/functions.php";
require_once "$TOPDIR/lib/display.php";
require_once "$TOPDIR/lib/monitor_display.php";
//get the data from "monshow" command
$attr = $_REQUEST['attr'];
$xml = docmd("monshow", "", array("rmcmon","-t", "60", "-s", "-a", "$attr"));
/*
*
SimpleXMLElement Object
(
[xcatresponse] => SimpleXMLElement Object
(
[data] => Array
(
[0] => hv8plus01.ppd.pok.ibm.com-summary:
[1] => PctTotalTimeUser
[2] => Wed Sep 9 23:20:00 2009 0.0090
[3] => Wed Sep 9 23:21:00 2009 0.0097
[4] => Wed Sep 9 23:22:00 2009 0.0081
[5] => Wed Sep 9 23:23:00 2009 0.0081
[6] => Wed Sep 9 23:24:00 2009 0.0072
)
)
)
*/
$index = 0;
echo "[{label: \"$attr\", data: [";
foreach ($xml->children() as $response) foreach($response->children() as $data)
{
//remove the first 2 lines.
if($index++ < 2) {
continue;
}
//then, parse "date" & "value"
$arr = preg_split("/\s+/", $data);
array_pop($arr);
$val = array_pop($arr);
$time = implode(" ", $arr);
$timestamp = strtotime($time);
$timestamp .=1000;
if($index++==2) {
echo "[$timestamp,$val]";
} else {
echo ",[$timestamp,$val]";
}
}
echo "]}]";
//echo <<<TOS1
//[{label: "PctTotalTimeUser", data: [[1251776160000,0.0080],[1251777600000,0.0075],[1251779040000,0.0081],[1251780480000,0.0080],[1251781920000,0.0083],[1251783360000,0.0080],[1251784800000,0.0083],[1251786240000,0.0073],[1251787680000,0.0081],[1251789120000,0.0083],[1251790560000,0.0080],[1251792000000,0.0075],[1251793440000,0.0081],[1251794880000,0.0080],[1251796320000,0.0082],[1251797760000,0.0081],[1251799200000,0.0074],[1251800640000,0.0080],[1251802080000,0.0080],[1251803520000,0.0083],[1251804960000,0.0080],[1251806400000,0.0076],[1251807840000,0.0080],[1251809280000,0.0081],[1251810720000,0.0083],[1251812160000,0.0080],[1251813600000,0.0076],[1251815040000,0.0080],[1251816480000,0.0081],[1251817920000,0.0081],[1251819360000,0.0080],[1251820800000,0.0075],[1251822240000,0.0081],[1251823680000,0.0080],[1251825120000,0.0083],[1251826560000,0.0080],[1251828000000,0.0082],[1251829440000,0.0073],[1251830880000,0.0080],[1251832320000,0.0083],[1251833760000,0.0079],[1251835200000,0.0075],[1251836640000,0.0082],[1251838080000,0.0081],[1251839520000,0.0084],[1251840960000,0.0087],[1251842400000,0.0082],[1251843840000,0.0080],[1251845280000,0.0081],[1251846720000,0.0082],[1251848160000,0.0081],[1251849600000,0.0076],[1251851040000,0.0081],[1251852480000,0.0082],[1251853920000,0.0082],[1251855360000,0.0082],[1251856800000,0.0081],[1251858240000,0.0073],[1251859680000,0.0080],[1251861120000,0.0082],[1251862560000,0.0080],[1251864000000,0.0076],[1251865440000,0.0080],[1251866880000,0.0080],[1251868320000,0.0083],[1251869760000,0.0080],[1251871200000,0.0075],[1251872640000,0.0080],[1251874080000,0.0080],[1251875520000,0.0083],[1251876960000,0.0080],[1251878400000,0.0075],[1251879840000,0.0081],[1251881280000,0.0080],[1251882720000,0.0081],[1251884160000,0.0080],[1251885600000,0.0082],[1251887040000,0.0073],[1251888480000,0.0081],[1251889920000,0.0082],[1251891360000,0.0079],[1251892800000,0.0075],[1251894240000,0.0081],[1251895680000,0.0081],[1251897120000,0.0081],[1251898560000,0.0081],[1251900000000,0.0083],[1251901440000,0.0073],[1251902880000,0.0081],[1251904320000,0.0083],[1251905760000,0.0081],[1251907200000,0.0082],[1251908640000,0.0074],[1251910080000,0.0081],[1251911520000,0.0084],[1251912960000,0.0081],[1251914400000,0.0082],[1251915840000,0.0075],[1251917280000,0.0081],[1251918720000,0.0082],[1251920160000,0.0081],[1251921600000,0.0076],[1251923040000,0.0082],[1251924480000,0.0080],[1251925920000,0.0083],[1251927360000,0.0086],[1251928800000,0.0075],[1251930240000,0.0087],[1251931680000,0.0081],[1251933120000,0.0082],[1251934560000,0.0081],[1251936000000,0.0077],[1251937440000,0.0081],[1251938880000,0.0081],[1251940320000,0.0082],[1251941760000,0.0079],[1251943200000,0.0081],[1251944640000,0.0073],[1251946080000,0.0081],[1251947520000,0.0081],[1251948960000,0.0080],[1251950400000,0.0075],[1251951840000,0.0080],[1251953280000,0.0080],[1251954720000,0.0083],[1251956160000,0.0080],[1251957600000,0.0075],[1251959040000,0.0081],[1251960480000,0.0080],[1251961920000,0.0083],[1251963360000,0.0080],[1251964800000,0.0076],[1251966240000,0.0080],[1251967680000,0.0079],[1251969120000,0.0083],[1251970560000,0.0079],[1251972000000,0.0076],[1251973440000,0.0080],[1251974880000,0.0080],[1251976320000,0.0082],[1251977760000,0.0080],[1251979200000,0.0082],[1251980640000,0.0073],[1251982080000,0.0080],[1251983520000,0.0083],[1251984960000,0.0080],[1251986400000,0.0074],[1251987840000,0.0080],[1251989280000,0.0081],[1251990720000,0.0082]]}]
//TOS1;
?>

View File

@ -9,82 +9,7 @@ require_once "$TOPDIR/lib/monitor_display.php";
$name = $_REQUEST['name'];
echo "<div id='monconfig'>";
echo "<p>Available Configurations for <b>$name</b></p>";
//display the "configure" and "view" options for the desired monitoring plugin
displayOptionsForPlugin($name);
echo '<table id="tabTable" class="tabTable" cellspacing="1">';
echo "<tbody>";
//set up the options for the plugin with the name "$name"
if($name == "rmcmon") {
//node status monitor, RMC events, RMC resources
echo "<tr class='ListLine0' id='row0'>";
echo "<td>Node/Application Status Monitoring Setting</td>";
echo "<td>";
insertButtons(array('label'=>'Configure', 'id'=>'rmc_nodestatmon', 'onclick'=>'loadMainPage("monitor/stat_mon.php?name=rmcmon")'));
echo "</td>";
echo "</tr>";
echo "<tr class='ListLine1' id='row1'>";
echo "<td>RMC Events Monitoring Setting</td>";
echo "<td>";
insertButtons(array('label'=>'Configure', 'id'=>'rmc_event', 'onclick'=>'loadMainPage("monitor/rmc_event_define.php")'));
echo "</td>";
echo "</tr>";
echo "<tr class='ListLine0' id='row2'>";
echo "<td>RMC Resource Monitoring Setting</td>";
echo "<td>";
insertButtons(array('label'=>'Configure', 'id'=>'rmc_resource', 'onclick'=>'loadMainPage("monitor/rmc_resource_define.php")'));
echo "</td>";
echo "</tr>";
} else {
//there's only "node status monitoring" is enabled
echo "<tr class='ListLine0' id='row0'>";
echo "<td>Node/Application Status Monitoring Setting</td>";
echo "<td>";
insertButtons(array('label'=>'Configure', 'id'=>$name."_nodestatmon", 'onclick'=>"loadMainPage(\"monitor/stat_mon.php?name=$name\")"));
echo "</td>";
echo "</tr>";
}
echo "</tbody></table>";
echo "</div>";
echo "<div id='monview'>";
echo "<p>View Options for <b>$name</b></p>";
//there should be many choices for the user to view the clusters' status
echo <<<TOS1
<table id="view_tab" class="tabTable" cellspacing="1">
<thead>
<tr class='colHeaders'>
<td>Monitor Items</td>
<td>Display Formats</td>
</tr>
</thead>
<tbody>
TOS1;
if($name == "rmcmon") {
#display two rows, one for RMC event, another for RMC Resource Performance monitoring.
echo "<tr class='ListLine0' id='row0'>";
echo "<td>RMC Event Logs</td>";
echo "<td>";
insertButtons(array('label'=>'View in Text', 'id'=>'rmc_event_text', 'onclick'=>'loadMainPage("monitor/rmc_lsevent.php")'));
echo "</td>";
echo "</tr>";
echo "<tr class='ListLine1' id='row1'>";
echo "<td>RMC Resource Logs</td>";
echo "<td>";
insertButtons(array('label'=>'View in Text', 'id'=>'rmc_resrc_text', 'onclick'=>'loadMainPage("monitor/rmc_monshow.php")'));
insertButtons(array('label'=>'View in Graphics', 'id'=>'rmc_resrc_graph', 'onclick'=>''));
echo "</td>";
echo "</tr>";
}
else {
echo "<p>There's no view functions for $name.</p>";
}
echo "</tbody></table></div>";
?>

View File

@ -1,7 +1,8 @@
<?php
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
/*
* setup.php
* perform the "monstart", "monadd" and "monstop" actions for selected monitoring plugins
*/
if(!isset($TOPDIR)) { $TOPDIR="..";}

View File

@ -13,34 +13,8 @@ require_once "$TOPDIR/lib/monitor_display.php";
//get the name of the selected plug-in
$name = $_REQUEST['name'];
displayMapper(array('home'=>'main.php', 'monitor'=>''));
displayTips(array(
"Enable/disable Node/App Status Monitoring by clicking the button",
"In order to take affect, you have to START/RESTART the desired plugin"));
//get the current status for "node-status-monitor"
$xml = docmd("monls", ' ', array($name));
if(getXmlErrors($xml,$errors)) {
echo "<p class=Error>",implode(' ',$errors), "</p>";
exit;
}
#then, parse the xml data
foreach($xml->children() as $response) foreach($response->children() as $data) {
list($n, $stat, $nodemonstatus) = preg_split("/\s+/",$data);
if(isset($nodemonstatus)) {
$ns = "Enabled";
}else {
$ns = "Disabled";
}
}
display_stat_mon_table(array("$name"=>
array(
'nodestat'=>$ns,
'appstat'=>'Disabled', //currently application status monitoring is not supported by xCAT monitor Arch.
)));
displayNodeAppStatus($name);
displayStatus();
//insertButtons(array('label'=>'Next', id=>'next', 'onclick'=>'loadMainPage("monitor/monlist.php")'));
?>