From ace55166f48d1d570a53b5b52e5896f15e8d97f6 Mon Sep 17 00:00:00 2001 From: mxi1 Date: Thu, 13 Aug 2009 06:45:39 +0000 Subject: [PATCH] The code for "define events/performance" and "monitor setup" is here. git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@3990 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-UI/css/main.css | 98 +++++++++- xCAT-UI/js/xcat.js | 49 +++++ xCAT-UI/lib/monitor_display.php | 245 ++++++++++++++++++++---- xCAT-UI/monitor/makecondresp.php | 24 +++ xCAT-UI/monitor/monstart.php | 11 +- xCAT-UI/monitor/osi_source.php | 32 ++-- xCAT-UI/monitor/rmc_event_define.php | 16 +- xCAT-UI/monitor/rmc_resource_attr.php | 53 +++++ xCAT-UI/monitor/rmc_resource_define.php | 32 ++++ xCAT-UI/monitor/setup.php | 73 +++++++ xCAT-UI/monitor/stat_mon.php | 2 +- xCAT-UI/monitor/updateCondRespTable.php | 59 ++++++ xCAT-UI/monitor/updateMonList.php | 48 +++++ 13 files changed, 677 insertions(+), 65 deletions(-) create mode 100644 xCAT-UI/monitor/makecondresp.php create mode 100644 xCAT-UI/monitor/rmc_resource_attr.php create mode 100644 xCAT-UI/monitor/rmc_resource_define.php create mode 100644 xCAT-UI/monitor/setup.php create mode 100644 xCAT-UI/monitor/updateCondRespTable.php create mode 100644 xCAT-UI/monitor/updateMonList.php diff --git a/xCAT-UI/css/main.css b/xCAT-UI/css/main.css index ece578ddb..3dd224374 100644 --- a/xCAT-UI/css/main.css +++ b/xCAT-UI/css/main.css @@ -315,12 +315,106 @@ padding:10px 2px; margin: 0; padding: 0; font-size: 8pt; - paddint-right: 0; + padding-right: 0; } #ositree { float: left; width: auto; + min-height: 255px; border-right: 1px dotted #555; -} \ No newline at end of file + min-width: 130px; + /*display: none;*/ +} + +#tips { + margin-right: 10px; + margin-left: 10px; + padding: 10px; + width: 900px; + text-align: left; + display: block; + border-bottom: 1px dotted #555; + /*display: none;*/ +} + +#monlist_table { + margin-right: 30px; + margin-left: 30px; + width: 850px; + padding: 10px; + float: left; + display: block; +} + +#condresp { + width: 770px; + margin: 10px; + padding: 10px; + float: left; + display: block; + border-bottom: 1px dotted #555; +} + +#assocaition { + margin: 10px; + padding: 10px; + float:left; + display: block; + width: 720px; +} +#avail_cond { + width: 275px; + margin: 5px; + padding: 10px; + float: left; + background-color: #ffee33; +} + +#avail_cond tbody { + height: 640px; + overflow-y: scroll; + overflow-x: hide; +} + +#condition .ui-selecting {background: #FECA40;} +#condition .ui-selected { background: #F39814; color: white; } +#condition {list-style-type: none; margin: 0; padding: 0;} + +#avail_resp { + width: 425px; + margin: 5px; + padding: 10px; + float: left; + background-color: #eeffee; +} + +#avail_resp tbody { + height: 640px; + overflow-y: scroll; + overflow-x: hide; +} + +#monsetting_tips { + width: 888px; + margin: 5px; + padding: 5px; + float: left; +} + +#rmcSrcList { + width: 420px; + margin: 5px; + padding: 5px; + float: left; + background-color:silver; +} + +#rmcScrAttr { + width: 420px; + margin: 5px; + padding: 5px; + float: left; + background-color:silver; +} diff --git a/xCAT-UI/js/xcat.js b/xCAT-UI/js/xcat.js index a9b778918..6ef7891b4 100644 --- a/xCAT-UI/js/xcat.js +++ b/xCAT-UI/js/xcat.js @@ -369,8 +369,10 @@ function node_stat_control(plugin) } function goto_next() +//TODO: change the function name! it's too silly now! { var str = location.href; + //TODO:one bug is here. var plugin=str.slice(str.indexOf("name")+5);//get the argument from "?name=xxxxx" if(plugin == "rmcmon") { loadMainPage("monitor/rmc_event_define.php"); @@ -381,5 +383,52 @@ function goto_next() } } +function mkCondResp() +{ + //get the name of the selected condition + //then, get the response in "checked" status + //then, run the command "mkcondresp" + var cond_val = $('input[@name=conditions][@checked]').val(); + if(cond_val) { + //get the response in "checked" status + var resps_obj = $('input[@name=responses][@checked]'); + if(resps_obj) { + $.each(resps_obj,function(i,n) { + //i is the index + //n is the content + //TODO:add one new php file to handle "mkcondresp" command + $.get("monitor/makecondresp.php", {cond: cond_val, resp: n.value}, function(data) { + $("#devstatus").html(data); + }); + }); + $("#association").load("monitor/updateCondRespTable.php"); + } + } +} + +function showRMCAttrib() +{ + var class_val = $('input[@name=classGrp][@checked]').val(); + if(class_val) { + $.get("monitor/rmc_resource_attr.php", {name: class_val}, function(data) { + $("#rmcScrAttr").html(data); + }); + } +} + +function monsetupAction(plugin, action_val) +{ + //plugin = the name of plugin + //action = "start" or "stop" or "restart" + $.get("monitor/setup.php", {name: plugin, action: action_val}, function(data) { + + + $.get("monitor/updateMonList.php", {}, function(data) { + $("#monlist").html(data); + }); + + }); +} + // load progress bar myBar.loaded('xcat.js'); diff --git a/xCAT-UI/lib/monitor_display.php b/xCAT-UI/lib/monitor_display.php index 4d251f06b..182bf148e 100644 --- a/xCAT-UI/lib/monitor_display.php +++ b/xCAT-UI/lib/monitor_display.php @@ -40,6 +40,18 @@ function displayMapper_mon($mapper) echo "$name"; echo "$stat"; if(isset($nodemonstatus)) { echo "Enabled";}else {echo "Disabled";} + echo ""; + $name_str = "\"$name\""; + if($stat == "monitored") { + $act_str = "\"stop\""; + insertButtons(array('label'=>'Stop', 'id'=>'stop', 'onclick'=>"monsetupAction($name_str, $act_str)")); + $act_str = "\"restart\""; + insertButtons(array('label'=>'Restart', 'id'=>'restart', 'onclick'=>"monsetupAction($name_str, $act_str)")); + }else { + $act_str = "\"start\""; + insertButtons(array('label' => 'Start', 'id'=>'start', 'onclick' => "monsetupAction($name_str, $act_str)")); + } + echo ""; echo " "; $ooe++; $line++; @@ -58,7 +70,7 @@ function displayTips($tips) //} echo '

Tips:

'; foreach ($tips as $tip) { - echo "
  • $tip
  • "; + echo "

    $tip

    "; echo "\n"; } echo '
    '; @@ -84,6 +96,7 @@ function displayMonTable() Plug-in Name Status Node Status Monitoring + Action TOS1; @@ -142,7 +155,7 @@ TOS2; function displayStatus() { //tell the user that the current interface is not done yet... - echo "

    This interface is still under development -use accordingly.

    "; + echo "

    This interface is still under development -use accordingly.

    "; } function displayOSITree() @@ -172,50 +185,216 @@ echo <<State + TOS5; - //$xml = docmd("webrun", "", array("lscondresp")); - //if(getXmlErrors($xml,$errors)) { - //echo "

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

    "; - //exit; - //} + $xml = docmd("webrun", "", array("lscondresp")); + if(getXmlErrors($xml,$errors)) { + echo "

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

    "; + exit; + } //get all the condition&response associations for RMC -echo << - -NodeReachability_H -UpdatexCATNodeStatus -hv8plus01.ppd.pok.ibm.com -Not active - - -NodeReachability -UpdatexCATNodeStatus -hv8plus01.ppd.pok.ibm.com -Not active - - - - -TOS6; + foreach ($xml->children() as $response) foreach($response->children() as $data) { + //get the data from xcatd + $association = explode("=", $data); + + $ooe = 0; + $line = 0; + foreach($association as $elem) { + $ooe = $ooe%2; + //the format should be + //"NodeReachability"\t"EmailRootOffShift"\t"hv8plus01.ppd.pok.ibm.com"\t"Active" + $record = explode("\"", $elem); + $cond = $record[1]; + $resp = $record[3]; + $node = $record[5]; + $state = $record[7]; + echo ""; + echo "$cond"; + echo "$resp"; + echo "$node"; + echo "$state"; + echo ""; + $ooe++; + $line++; + } + } + echo ""; return 0; } -function displayCond($noderange) +function displayCond() { //the user selects one node/noderange from the #ositree div - echo '
    '; - echo 'Available Conditions'; - - echo '
    '; +echo << +Available Conditions + + + + + + + + +COND; + $xml = docmd("webrun", '', array("lscondition")); + foreach($xml->children() as $response) foreach($response->children() as $data) { + //get the data from xcatd + $conditions = explode("=", $data); + } + $ooe = 0; + $line = 0; + foreach($conditions as $elem) { + $ooe = $ooe%2; + echo ""; + echo ""; + echo ""; + echo ""; + $ooe++; + $line++; + } + echo "
    Conditions
    $elem
    "; return 0; + } function displayResp() { - echo '
    '; - echo 'Available Response'; - echo '
    '; +echo << +Available Response + + + + + + + + +RESP; + $xml=docmd("webrun", '', array("lsresponse")); + $ooe=0; + $line=0; + foreach($xml->children() as $response) foreach($response->children() as $data) { + $responses = explode("=", $data); + } + foreach($responses as $elem) { + $ooe = $ooe%2; + echo ""; + echo ""; + echo ""; + echo ""; + $ooe++; + $line++; + } + echo '
    Response
    $elem
    '; return 0; } +function displayCondResp() +{ + echo '
    '; + displayAssociation(); + displayCond(); + displayResp(); + insertButtons(array('label'=>'Add', id=>'addAssociation', 'onclick'=>'mkCondResp()')); + insertButtons(array('label'=>'Cancel', id=>'cancel_op', 'onclick'=>'')); + echo '
    '; + displayStatus(); +} + +function displayMonsetting() +//TODO: copied from the function displayTable() from display.php, need update +{ + echo "
    "; + echo "

    $tab

    \n"; + insertButtons(array('label' => 'Save','id' => 'saveit'), + array('label' => 'Cancel', 'id' => 'reset') + ); + $xml = docmd('tabdump', '', array("monsetting")); + $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"; +} + +function displayRMCRsrc() +{ +echo <<Available RMC Resources + + + + + + + + +TOS0; + $xml = docmd("webrun", "", array("lsrsrc")); + if(getXmlErrors($xml,$errors)) { + echo "

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

    "; + exit; + } + foreach($xml->children() as $response) foreach($response->children() as $data) { + //get all the class name + $classes = explode("=", $data); + } + $ooe = 0; + $line = 0; + foreach($classes as $class) { + $ooe = $ooe%2; + echo ""; + echo ""; + echo ""; + echo ""; + $ooe++; + $line++; + } + + echo "
    Class Name
    $class
    "; + return 0; +} + +function displayRMCAttr() +{ + echo "

    Select the RMC Resource, you will see all its available attributes here.

    "; +} + ?> diff --git a/xCAT-UI/monitor/makecondresp.php b/xCAT-UI/monitor/makecondresp.php new file mode 100644 index 000000000..a9d3f20b5 --- /dev/null +++ b/xCAT-UI/monitor/makecondresp.php @@ -0,0 +1,24 @@ +",implode(' ', $errors), "

    "; + exit; +} + +echo "

    $resp

    "; + +?> diff --git a/xCAT-UI/monitor/monstart.php b/xCAT-UI/monitor/monstart.php index 25c3e5eeb..52759b818 100644 --- a/xCAT-UI/monitor/monstart.php +++ b/xCAT-UI/monitor/monstart.php @@ -13,7 +13,14 @@ require_once "$TOPDIR/lib/monitor_display.php"; $name = $_REQUEST['name']; -echo $name; -return 0; +//echo $name; +displayMapper_mon(array('home'=>'main.php', 'monitor'=>'monitor/monlist.php')); + +displayTips(array("")); + + +displayStatus(); + +insertButtons(array('label' => 'Next', 'id'=> 'next', 'onclick'=>'')); ?> diff --git a/xCAT-UI/monitor/osi_source.php b/xCAT-UI/monitor/osi_source.php index c3bdb95f8..d17ca6a01 100644 --- a/xCAT-UI/monitor/osi_source.php +++ b/xCAT-UI/monitor/osi_source.php @@ -12,23 +12,29 @@ require_once "$TOPDIR/lib/display.php"; require_once "$TOPDIR/js/jsonwrapper.php"; //get all the groups -$xml=docmd("lsdef","",array("-t", "group")); +//$xml=docmd("lsdef","",array("-t", "group")); +//if(getXmlErrors($xml,$errors)) { +// echo "

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

    "; +// exit; +//} +//$groups = array(); +//$jdata = array(); +//foreach($xml->children() as $response) foreach($response->children() as $data) { + //all the groups are stored into $groups +// array_push($groups, $data); +//} + +$xml = docmd("lsdef","",array("-t", "node", "-w", "nodetype=~osi")); if(getXmlErrors($xml,$errors)) { - echo "

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

    "; + echo "

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

    "; exit; } -$groups = array(); -$jdata = array(); -foreach($xml->children() as $response) foreach($response->children() as $data) { - //all the groups are stored into $groups - //TODO - array_push($groups, $data); -} -//foreach($groups as $group) { - //$xml = docmd("lsdef","",array("-t", "node", "-w", "nodetype=~osi")) -//} -//print_r($groups); +$host = system("hostname|cut -f 1 -d \".\""); + +//print_r($groups); +//TODO: +//rebuild the jsTree //echo json_encode($jdata); echo << - -'main.php', 'monitor'=>'monitor/monlist.php')); displayTips(array( @@ -24,18 +21,9 @@ displayTips(array( "then, click \"Save\" to create condition/response associations." )); displayOSITree(); -?> -
    - - -
    +displayCondResp(); -'Next', id=>'next', 'onclick'=>'')); +insertButtons(array('label'=>'Next', id=>'next', 'onclick'=>'loadMainPage("monitor/rmc_resource_define.php")')); ?> diff --git a/xCAT-UI/monitor/rmc_resource_attr.php b/xCAT-UI/monitor/rmc_resource_attr.php new file mode 100644 index 000000000..f1bc2f164 --- /dev/null +++ b/xCAT-UI/monitor/rmc_resource_attr.php @@ -0,0 +1,53 @@ +",implode(' ', $errors), "

    "; + exit; +} + +foreach($xml->children() as $response) foreach($response->children() as $data) { + $attrs = explode("=", $data); +} + +$ooe = 0; +$line = 0; +echo<<Available Attributes for $class + + + + + + + +EOS0; + +foreach($attrs as $attr) { + $ooe = $ooe%2; + echo ""; + echo ""; + echo ""; + $ooe++; + $line++; +} + +echo "
    Class Name
    $attr
    "; +?> diff --git a/xCAT-UI/monitor/rmc_resource_define.php b/xCAT-UI/monitor/rmc_resource_define.php new file mode 100644 index 000000000..f3d813302 --- /dev/null +++ b/xCAT-UI/monitor/rmc_resource_define.php @@ -0,0 +1,32 @@ +'main.php', 'monitor'=>'monitor/monlist.php')); + +displayTips(array("All the available RMC resources are listed here;", + "Edit this table to define the RMC performance monitoring;", + "Select the RMC resource, you can get all the available attributes.")); + +displayMonsetting(); + +?> + +
    +
    +
    +
    + + +
    +'Next', 'id'=>'next', 'onclick'=>'loadMainPage("monitor/monlist.php");')); +?> diff --git a/xCAT-UI/monitor/setup.php b/xCAT-UI/monitor/setup.php new file mode 100644 index 000000000..c51985877 --- /dev/null +++ b/xCAT-UI/monitor/setup.php @@ -0,0 +1,73 @@ +",implode(' ', $errors), "

    "; + exit; +} + +foreach($xml->children() as $response) foreach($response->children() as $data) +{ + $nodemonstat = $data; +} +switch($action) { + case "stop": + monstop($name, $nmstat); + break; + case "restart": + monrestart($name, $nmstat); + break; + case "start": + monstart($name, $nmstat); + break; + default: + break; +} + +function monstop($plugin, $nmstat) +{ + $xml = docmd("monstop", "", array("$plugin","-r")); + return 0; +} + +function monrestart($plugin, $nmstat) +{ + $xml = docmd("monstop", "", array("$plugin", "-r")); + if(getXmlErrors($xml, $errors)) { + echo "

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

    "; + exit; + } + $xml = docmd("moncfg", "", array("$plugin", "-r")); + if(getXmlErrors($xml, $errors)) { + echo "

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

    "; + exit; + } + + $xml = docmd("monstart", "", array("$plugin", "-r")); + return 0; +} + +function monstart($plugin, $nmstat) +{ + //before starting the $plugin, + //we have to make sure that the plugin is added in the "monitoring" table + $xml = docmd("monstart", "", array("$plugin", "-r")); + return 0; +} + +?> diff --git a/xCAT-UI/monitor/stat_mon.php b/xCAT-UI/monitor/stat_mon.php index 2b1cf2954..d3ac95d75 100644 --- a/xCAT-UI/monitor/stat_mon.php +++ b/xCAT-UI/monitor/stat_mon.php @@ -42,5 +42,5 @@ display_stat_mon_table(array("$name"=> displayStatus(); -insertButtons(array('label'=>'Next', id=>'next', 'onclick'=>'goto_next()')); +insertButtons(array('label'=>'Next', id=>'next', 'onclick'=>'loadMainPage("monitor/monlist.php")')); ?> diff --git a/xCAT-UI/monitor/updateCondRespTable.php b/xCAT-UI/monitor/updateCondRespTable.php new file mode 100644 index 000000000..126a02d63 --- /dev/null +++ b/xCAT-UI/monitor/updateCondRespTable.php @@ -0,0 +1,59 @@ +Available Condition/Response Associations + + + + + + + + + + +TOS5; + $xml = docmd("webrun", "", array("lscondresp")); + if(getXmlErrors($xml,$errors)) { + echo "

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

    "; + exit; + } + //get all the condition&response associations for RMC + foreach ($xml->children() as $response) foreach($response->children() as $data) { + //get the data from xcatd + $association = explode("=", $data); + + $ooe = 0; + $line = 0; + foreach($association as $elem) { + $ooe = $ooe%2; + //the format should be + //"NodeReachability"\t"EmailRootOffShift"\t"hv8plus01.ppd.pok.ibm.com"\t"Active" + $record = explode("\"", $elem); + $cond = $record[1]; + $resp = $record[3]; + $node = $record[5]; + $state = $record[7]; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + $ooe++; + $line++; + } + } + echo "
    ConditionResponseNodeState
    $cond$resp$node$state
    "; + +?> diff --git a/xCAT-UI/monitor/updateMonList.php b/xCAT-UI/monitor/updateMonList.php new file mode 100644 index 000000000..d9628203e --- /dev/null +++ b/xCAT-UI/monitor/updateMonList.php @@ -0,0 +1,48 @@ +",implode(' ', $errors), "

    "; + exit; + } + #then, parse the xml data + $ooe = 0; + $line = 0; + foreach($xml->children() as $response) foreach($response->children() as $data) { + list($name, $stat, $nodemonstatus) = preg_split("/\s+/", $data); + $ooe = $ooe%2; + echo ""; + echo ""; + echo "$name"; + echo "$stat"; + if(isset($nodemonstatus)) { echo "Enabled";}else {echo "Disabled";} + echo ""; + $name_str = "\"$name\""; + if($stat == "monitored") { + $act_str = "\"stop\""; + insertButtons(array('label'=>'Stop', 'id'=>'stop', 'onclick'=>"monsetupAction($name_str, $act_str)")); + $act_str = "\"restart\""; + insertButtons(array('label'=>'Restart', 'id'=>'restart', 'onclick'=>"monsetupAction($name_str, $act_str)")); + }else { + $act_str = "\"start\""; + insertButtons(array('label' => 'Start', 'id'=>'start', 'onclick' => "monsetupAction($name_str, $act_str)")); + } + echo ""; + echo " "; + $ooe++; + $line++; + //echo "$name$stat$name"; + } + +?>