From e8cbd289167026a09bbda5d268029337cf270724 Mon Sep 17 00:00:00 2001 From: mxi1 Date: Thu, 10 Sep 2009 06:57:06 +0000 Subject: [PATCH] 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 --- xCAT-UI/js/xcat.js | 17 +++ xCAT-UI/lib/monitor_display.php | 169 +++++++++++++++++++++++++++--- xCAT-UI/monitor/flot_get_data.php | 62 +++++++++++ xCAT-UI/monitor/options.php | 79 +------------- xCAT-UI/monitor/setup.php | 7 +- xCAT-UI/monitor/stat_mon.php | 28 +---- 6 files changed, 239 insertions(+), 123 deletions(-) create mode 100644 xCAT-UI/monitor/flot_get_data.php diff --git a/xCAT-UI/js/xcat.js b/xCAT-UI/js/xcat.js index 891ba7083..35f89ad1b 100644 --- a/xCAT-UI/js/xcat.js +++ b/xCAT-UI/js/xcat.js @@ -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'); diff --git a/xCAT-UI/lib/monitor_display.php b/xCAT-UI/lib/monitor_display.php index db9455153..e8e665e96 100644 --- a/xCAT-UI/lib/monitor_display.php +++ b/xCAT-UI/lib/monitor_display.php @@ -136,6 +136,7 @@ echo << TOS2; insertButtons(array('label'=>$ns_tobe, 'id'=>'node_stat', 'onclick'=>"node_stat_control(\"$name\")")); + //TODO: change the function name of node_stat_control echo ''; echo ''; echo ''; @@ -454,35 +455,171 @@ function displayRMCMonshowAttr($attr) { echo ""; //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 ""; - $elements = explode(" ", $data); - echo ""; - $i = 0; - while($i < 7) { - echo $elements[$i],"\t"; - $i++; - } - echo ""; - echo "$elements[7]"; - //var_dump($elements); - echo ""; - - + echo "$time"; + echo "$val"; + echo ""; } + echo ""; echo ""; echo ""; } +function displayRMCMonshowGraph($value) { +//display the RMC Performance Data +echo << + +

The Graph View for RMC Resource

+
+
+ +TOS11; +} + +/* + * function displayOptionsForPlugin($plugin) + * ***************************************** + * when the user selects one plugin, the avaiable configuration options will display in
+ * TODO: for the non-rmcmon plugins, only the option "node/application status monitoring setting" is shown; + * + * the avaiable view options will also display in
, + * TODO: right now, it's only implemented for rmcmon plugin. + */ +function displayOptionsForPlugin($name) +{ + echo "
"; + echo "

Available Configurations for $name

"; + + echo ''; + echo ""; + + //set up the options for the plugin with the name "$name" + if($name == "rmcmon") { + //node status monitor, RMC events, RMC resources + echo ""; + echo ""; + echo ""; + echo ""; + + echo ""; + echo ""; + echo ""; + echo ""; + + echo ""; + echo ""; + echo ""; + echo ""; + + } else { + //there's only "node status monitoring" is enabled + echo ""; + echo ""; + echo ""; + echo ""; + } + + echo "
Node/Application Status Monitoring Setting"; + insertButtons(array('label'=>'Configure', 'id'=>'rmc_nodestatmon', 'onclick'=>'loadMainPage("monitor/stat_mon.php?name=rmcmon")')); + echo "
RMC Events Monitoring Setting"; + insertButtons(array('label'=>'Configure', 'id'=>'rmc_event', 'onclick'=>'loadMainPage("monitor/rmc_event_define.php")')); + echo "
RMC Resource Monitoring Setting"; + insertButtons(array('label'=>'Configure', 'id'=>'rmc_resource', 'onclick'=>'loadMainPage("monitor/rmc_resource_define.php")')); + echo "
Node/Application Status Monitoring Setting"; + insertButtons(array('label'=>'Configure', 'id'=>$name."_nodestatmon", 'onclick'=>"loadMainPage(\"monitor/stat_mon.php?name=$name\")")); + echo "
"; + + echo "
"; + + echo "
"; + echo "

View Options for $name

"; + //there should be many choices for the user to view the clusters' status +echo << + + + Monitor Items + Display Formats + + + +TOS1; + if($name == "rmcmon") { + #display two rows, one for RMC event, another for RMC Resource Performance monitoring. + echo ""; + echo "RMC Event Logs"; + echo ""; + insertButtons(array('label'=>'View in Text', 'id'=>'rmc_event_text', 'onclick'=>'loadMainPage("monitor/rmc_lsevent.php")')); + echo ""; + echo ""; + echo ""; + echo "RMC Resource Logs"; + echo ""; + 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 ""; + echo ""; + } + else { + echo "

There's no view functions for $name.

"; + } + + echo "
"; +} + +/* + * 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 "

",implode(' ',$errors), "

"; + 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. + ))); +} ?> diff --git a/xCAT-UI/monitor/flot_get_data.php b/xCAT-UI/monitor/flot_get_data.php new file mode 100644 index 000000000..f3ecb848a --- /dev/null +++ b/xCAT-UI/monitor/flot_get_data.php @@ -0,0 +1,62 @@ + 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 << diff --git a/xCAT-UI/monitor/options.php b/xCAT-UI/monitor/options.php index 981d47ff9..8308be129 100644 --- a/xCAT-UI/monitor/options.php +++ b/xCAT-UI/monitor/options.php @@ -9,82 +9,7 @@ require_once "$TOPDIR/lib/monitor_display.php"; $name = $_REQUEST['name']; -echo "
"; -echo "

Available Configurations for $name

"; +//display the "configure" and "view" options for the desired monitoring plugin +displayOptionsForPlugin($name); -echo ''; -echo ""; - -//set up the options for the plugin with the name "$name" -if($name == "rmcmon") { - //node status monitor, RMC events, RMC resources - echo ""; - echo ""; - echo ""; - echo ""; - - echo ""; - echo ""; - echo ""; - echo ""; - - echo ""; - echo ""; - echo ""; - echo ""; - -} else { - //there's only "node status monitoring" is enabled - echo ""; - echo ""; - echo ""; - echo ""; -} - -echo "
Node/Application Status Monitoring Setting"; - insertButtons(array('label'=>'Configure', 'id'=>'rmc_nodestatmon', 'onclick'=>'loadMainPage("monitor/stat_mon.php?name=rmcmon")')); - echo "
RMC Events Monitoring Setting"; - insertButtons(array('label'=>'Configure', 'id'=>'rmc_event', 'onclick'=>'loadMainPage("monitor/rmc_event_define.php")')); - echo "
RMC Resource Monitoring Setting"; - insertButtons(array('label'=>'Configure', 'id'=>'rmc_resource', 'onclick'=>'loadMainPage("monitor/rmc_resource_define.php")')); - echo "
Node/Application Status Monitoring Setting"; - insertButtons(array('label'=>'Configure', 'id'=>$name."_nodestatmon", 'onclick'=>"loadMainPage(\"monitor/stat_mon.php?name=$name\")")); - echo "
"; - -echo "
"; - -echo "
"; -echo "

View Options for $name

"; -//there should be many choices for the user to view the clusters' status -echo << - - - Monitor Items - Display Formats - - - -TOS1; -if($name == "rmcmon") { - #display two rows, one for RMC event, another for RMC Resource Performance monitoring. - echo ""; - echo "RMC Event Logs"; - echo ""; - insertButtons(array('label'=>'View in Text', 'id'=>'rmc_event_text', 'onclick'=>'loadMainPage("monitor/rmc_lsevent.php")')); - echo ""; - echo ""; - echo ""; - echo "RMC Resource Logs"; - echo ""; - 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 ""; - echo ""; -} -else { - echo "

There's no view functions for $name.

"; -} - -echo "
"; ?> diff --git a/xCAT-UI/monitor/setup.php b/xCAT-UI/monitor/setup.php index b53d4ed0a..63bba8b4a 100644 --- a/xCAT-UI/monitor/setup.php +++ b/xCAT-UI/monitor/setup.php @@ -1,7 +1,8 @@ '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 "

",implode(' ',$errors), "

"; - 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")')); ?>