From 0e722a0e289632dea51d709a0a05c9012cb2e0a8 Mon Sep 17 00:00:00 2001 From: mxi1 Date: Wed, 18 Nov 2009 09:34:27 +0000 Subject: [PATCH] new monitor style is introduced git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@4605 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-UI/css/monitor.css | 128 ++++++++++++++++ xCAT-UI/js/loading.js | 5 +- xCAT-UI/js/monitor.js | 134 ++++++++++++++++ xCAT-UI/js/xcat.js | 55 ------- xCAT-UI/js/xcatauth.js | 2 +- xCAT-UI/lib/display.php | 1 + xCAT-UI/lib/monitor_display.php | 103 ++++--------- xCAT-UI/monitor/control_node_stat.php | 38 ----- xCAT-UI/monitor/monlist.php | 89 +++++++++-- xCAT-UI/monitor/oldmonlist.php | 22 +++ xCAT-UI/monitor/options.php | 210 +++++++++++++++++++++++++- xCAT-UI/monitor/plugin_desc.php | 31 ---- xCAT-UI/monitor/setup.php | 163 ++++++++++++-------- xCAT-UI/monitor/stat_mon.php | 20 --- 14 files changed, 701 insertions(+), 300 deletions(-) create mode 100644 xCAT-UI/js/monitor.js delete mode 100644 xCAT-UI/monitor/control_node_stat.php create mode 100644 xCAT-UI/monitor/oldmonlist.php delete mode 100644 xCAT-UI/monitor/plugin_desc.php delete mode 100644 xCAT-UI/monitor/stat_mon.php diff --git a/xCAT-UI/css/monitor.css b/xCAT-UI/css/monitor.css index e69de29bb..3b01e044c 100644 --- a/xCAT-UI/css/monitor.css +++ b/xCAT-UI/css/monitor.css @@ -0,0 +1,128 @@ +/*The css style for the new monlist web page*/ +.pluginstat +{ + position: relative; + width: 170px; + height: 48px; + float: left; + padding: 5px; +} + +.pluginstat .lef +{ + padding: 8px 0px 8px 0px; + width: 16px; + height: 16px; + position: relative; + float: left; + display: inline; +} +.pluginstat .mid +{ + font-size: 1em; + float: left; + position: relative; + display: block; + color: black; +} + +.pluginstat .rig +{ + width: 32px; + height: 32px; + float: right; + background-image: url("../img/monplugin.png"); +} + +/*The list of monitor plugins*/ +#plist +{ + float: left; + width: 180px; + padding-left: 15px; +} + +#settings +{ + display: block; + width: 725px; + float: left; + text-align: left; + font-size: 1em; +} + +.fg-button { + outline: 0; + margin: 0 4px 0 0; + padding: .4em 1em; + text-decoration:none !important; + cursor:pointer; + position: relative; + text-align: center; +} + +.fg-buttonset {float: left;} +.fg-buttonset-single .fg-button {margin-right: -3px} + +#nrtree-input { + float: left; + width: 25%; + min-width: 125px; + min-height: 255px; + border-right: 1px solid orange; + z-index: 1; +} + +#stat1 { + padding-left: 10px; + padding-right: 10px; + width: 65%; + float: right; +} + +fieldset { + padding: 0 15px 3em; + border: 0; +} + +.custom-radio { position: relative;} + +/* input, label positioning */ +.custom-radio input { + position: absolute; + left: 2px; + top: 3px; + margin: 0; + z-index: 0; +} +.custom-radio label { + display: block; + position: relative; + z-index: 1; + font-size: 1.3em; + padding-right: 1em; + line-height: 1; + padding: .5em 0 .5em 30px; + margin: 0 0 .3em; + cursor: pointer; +} + +.custom-radio label {background: url(../img/radiobutton.gif) no-repeat;} + +.custom-radio label { + background-position: -10px -14px; +} + +.custom-radio label.hover, +.custom-radio label.focus { + background-position: -10px -114px; +} + +.custom-radio label.checked { + background-position: -10px -214px; +} + +.custom-radio label.focus { + outline: 1px dotted #ccc; +} + diff --git a/xCAT-UI/js/loading.js b/xCAT-UI/js/loading.js index 1b2d74e80..28e44837c 100644 --- a/xCAT-UI/js/loading.js +++ b/xCAT-UI/js/loading.js @@ -79,7 +79,7 @@ LoadBar.prototype.loaded = function(file) { //load the reset button to try one more time! //$(document).ready(function () { injs(); - document.getElementById("wrapper").style.display = "none"; + //document.getElementById("wrapper").style.display = "none"; //}); } }; @@ -105,7 +105,8 @@ var xStart = function(){ myBar.addScript("jquery.tablesorter.js"); myBar.addScript("jquery.flot.js"); myBar.addScript("excanvas.js"); - myBar.addScript("noderangetree.js"); + myBar.addScript("noderangetree.js"); + myBar.addScript("monitor.js"); myBar.addScript("xcat.js"); myBar.addScript("xcatauth.js"); myBar.addScript("config.js"); diff --git a/xCAT-UI/js/monitor.js b/xCAT-UI/js/monitor.js new file mode 100644 index 000000000..3e2fc9937 --- /dev/null +++ b/xCAT-UI/js/monitor.js @@ -0,0 +1,134 @@ + + +jQuery.fn.customInput = function(){//from http://www.filamentgroup.com/examples/customInput/customInput.jquery.js + $(this).each(function(i){ + if($(this).is('[type=checkbox],[type=radio]')){ + var input = $(this); + + // get the associated label using the input's id + var label = $('label[for='+input.attr('id')+']'); + + //get type, for classname suffix + var inputType = (input.is('[type=checkbox]')) ? 'checkbox' : 'radio'; + + // wrap the input + label in a div + $('
').insertBefore(input).append(input, label); + + // find all inputs in this set using the shared name attribute + var allInputs = $('input[name='+input.attr('name')+']'); + + // necessary for browsers that don't support the :hover pseudo class on labels + label.hover( + function(){ + $(this).addClass('hover'); + if(inputType == 'checkbox' && input.is(':checked')){ + $(this).addClass('checkedHover'); + } + }, + function(){ $(this).removeClass('hover checkedHover'); } + ); + + //bind custom event, trigger it, bind click,focus,blur events + input.bind('updateState', function(){ + if (input.is(':checked')) { + if (input.is(':radio')) { + allInputs.each(function(){ + $('label[for='+$(this).attr('id')+']').removeClass('checked'); + }); + }; + label.addClass('checked'); + } + else { label.removeClass('checked checkedHover checkedFocus'); } + + }) + .trigger('updateState') + .click(function(){ + $(this).trigger('updateState'); + }) + .focus(function(){ + label.addClass('focus'); + if(inputType == 'checkbox' && input.is(':checked')){ + $(this).addClass('checkedFocus'); + } + }) + .blur(function(){ label.removeClass('focus checkedFocus'); }); + } + }); +}; + +function monPluginSetStat() +{ + $('.fg-button:not(.ui-state-disabled)') + .hover( + function() { + $(this).addClass('ui-state-hover'); + }, + function() { + $(this).removeClass('ui-state-hover'); + } + ) + .click( + function() { +// if($(this).hasClass("ui-state-active")) { + var plugin=$('.pluginstat.ui-state-active').attr('id'); + var todo = $(this).html(); + //$("#settings").tabs('select',2); + //for the noderange, we have to check the
with id "nrtree-input", and also the 'custom-nr' textarea + var value = ""; + //we check the textarea firstly, + value = $("#custom-nr").val(); + //then, if the textarea is empty, we have to get the selection from nrtree + if(!value) { + var i=0; + var node_selected = nrtree.selected_arr; + for(; i< node_selected.length; i++) { + value += node_selected[i].attr('id'); + } + //remove the "," at the front + value = value.substr(1); + } + //get the value for "node status monitoring" + + //$("#feedback").html(value); //used for debug + if(value == "") {value="all";} + $.post("monitor/setup.php",{name:plugin,action:todo,nm:$("#stat1 form fieldset input:checked").attr('value'),nr:value},function(data) { + if(data=='successful') { + //update the status of the selected plugin + //reload the tabs for enable/disable + var tmp = $("#"+plugin).children(); + $.get("monitor/options.php",{name:plugin,opt:"status"},function(stat){ + if(stat == "Disabled") { + $(tmp[1]).html(plugin+"
"+stat); + $(tmp[0].firstChild).removeClass("ui-icon-circle-check").addClass("ui-icon-circle-close"); + $("#settings").tabs('url',3,'monitor/options.php?name='+plugin+'&opt=enable').tabs("load",3); + }else { + $(tmp[1]).html(plugin+"
"+stat); + $(tmp[0].firstChild).removeClass("ui-icon-circle-close").addClass("ui-icon-circle-check"); + $("#settings").tabs('url',3,'monitor/options.php?name='+plugin+'&opt=disable').tabs("load",3); + } + }) + } + }); + } +// } + ); +} + +function nodemonSetStat() +{ + //enable/disable buttons for setting of the Node monitoring status + $("#nodemonset .fg-buttonset .fg-button").hover(function() { + $(this).addClass("ui-state-hover"); + },function() { + $(this).removeClass("ui-state-hover"); + }).click(function(){ + //TODO + }); +} +function appmonSetStat() +{ + //TODO +} + +// for the progress bar +myBar.loaded('monitor.js'); \ No newline at end of file diff --git a/xCAT-UI/js/xcat.js b/xCAT-UI/js/xcat.js index 41ed7aaa5..652720e30 100644 --- a/xCAT-UI/js/xcat.js +++ b/xCAT-UI/js/xcat.js @@ -384,30 +384,6 @@ function init_rmc_ositree() { }); } -//node_stat_control() can enable/disable nodestatmon for the selected plugin -function node_stat_control(plugin) -{ - //get the label of the button - var action = $("#node_stat span").text(); - if(action=='Enable') { - //enable node_stat_monitor - $.get("monitor/control_node_stat.php",{name:plugin, action:"enable"},function(data) { - if(data=='successful') { - //change the label to "Disable" - $("#node_stat span").text("Disable"); - } - }); - }else if(action=='Disable') { - //disable node_stat_monitor - $.get("monitor/control_node_stat.php",{name:plugin, action:"disable"},function(data) { - if(data=='successful') { - //change the label to "enable" - $("#node_stat span").text("Enable"); - } - }) - //then, change the label to "Enable"" - } -} function goto_next() //TODO: change the function name! it's too silly now! @@ -476,37 +452,6 @@ function showRMCAttrib() } } - -function showPluginOptions() -{ - //for monlist.php, when the user clicks the radiobox, the available options for the plugin will display - $("input[@name=plugins]").click(function() { - //when one radiobox is selected, the #options
is show available options to the user - //at first, hide the
named with "#plugin_desc" - if($("#plugin_desc").css("display") == "block") { - $("#plugin_desc").hide("slow"); - } - var plugin = $(this).attr('value'); - $.get("monitor/options.php", {name:plugin},function(data) { - $("#options").html(data); - }); - }); -} - - -//TODO: remove it -function showPluginDescription() -{ - $(".description").click(function(){ - if($("#plugin_desc").css("display") == "none") { - $("#plugin_desc").show(); - } - $.get("monitor/plugin_desc.php", {name: $(this).text()}, function(data){ - $("#plugin_desc").html(data); - }) - }); -} - //TODO: when mouse hover the list of monitor plugins, the .ListLine_hover style will //be applied on the , function hoverOnMonlist() diff --git a/xCAT-UI/js/xcatauth.js b/xCAT-UI/js/xcatauth.js index 7c0728a1b..be6fdd17b 100644 --- a/xCAT-UI/js/xcatauth.js +++ b/xCAT-UI/js/xcatauth.js @@ -59,7 +59,7 @@ function openDialog(){ background: "#2e2e2e url(img/auth.gif) repeat", opacity: 1.0 }, - height: 250, + height: 275, width: 350, autoOpen: true, buttons: { diff --git a/xCAT-UI/lib/display.php b/xCAT-UI/lib/display.php index fd627cf98..dfd555574 100644 --- a/xCAT-UI/lib/display.php +++ b/xCAT-UI/lib/display.php @@ -544,6 +544,7 @@ echo <<Monitor Events/Performances by Plugins, such as RMC...
  • This is still UNDER DEVELOPMENT.
  • +

    New_style Monitor

    EOS; } diff --git a/xCAT-UI/lib/monitor_display.php b/xCAT-UI/lib/monitor_display.php index 34e7f9545..289441ead 100644 --- a/xCAT-UI/lib/monitor_display.php +++ b/xCAT-UI/lib/monitor_display.php @@ -100,52 +100,6 @@ TOS9; return 0; } -function display_stat_mon_table($args) -{ - //create one table to disable or enable node/application monitoring - //the argument $args are one array like this: - //{ 'xcatmon' => { - // 'nodestat' => 'Enabled', - // 'appstat' => 'Disabled', - // }, - //}; - // - - echo '
    '; - foreach($args as $key => $value) { - $name = $key; - - if($value{'nodestat'} == 'Enabled') { - $ns_tobe = 'Disable'; - } else { - $ns_tobe = 'Enable'; - } - if($value{'appstat'} == 'Enabled') { - $as_tobe = 'Disable'; - } else { - $as_tobe = 'Enable'; - } - - } - echo "

    Node/Application Status Monitoring for $name

    "; -echo << - -Node Status Monitoring - -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 ''; - echo 'Application Status Monitoring'; - echo ''; - insertButtons(array('label'=>$as_tobe, 'id'=>'app_stat', 'onclick'=>'show_monshow_data()')); - echo ''; - echo ''; - echo '
    '; -} function displayStatus() { @@ -532,40 +486,41 @@ TOS1; echo "
    "; } -/* - * function displayNodeAppStatus($name) - * ************************************ - * to display the web page "Node/Application Status Monitoring" - * +/*displayMList() will display the list of monitor plugins + * For the new style monitor list */ -function displayNodeAppStatus($name) +function displayMList() { - displayMapper(array('home'=>'main.php', 'monitor'=>'monitor/monlist.php', 'Node Status Setup'=> '')); - 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), "

    "; + $xml = docmd("monls", "", array('-a')); + 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"; - } + + foreach($xml->children() as $response) foreach ($response->children() as $data) { + list($name, $stat, $nodemon) = preg_split("/\s+/", $data); + //create .pluginstat class for each plugin + echo "
    "; + //TODO: I have to make it beautiful + createPluginStatElem($name, $stat, $nodemon); + echo "
    "; + echo ""; } - display_stat_mon_table(array("$name"=> - array( - 'nodestat'=>$ns, - 'appstat'=>'Disabled', //currently application status monitoring is not supported by xCAT monitor Arch. - ))); + return 0; +} + +function createPluginStatElem($name, $stat, $nodemon) +{ + if($nodemon) { + echo "
    "; + echo "
    $name
    Enabled
    "; + }else { + echo "
    "; + echo "
    $name
    Disabled
    "; + } + echo "
    "; + } ?> diff --git a/xCAT-UI/monitor/control_node_stat.php b/xCAT-UI/monitor/control_node_stat.php deleted file mode 100644 index 02c54a773..000000000 --- a/xCAT-UI/monitor/control_node_stat.php +++ /dev/null @@ -1,38 +0,0 @@ -",implode(' ', $errors), "

    "; - exit; - } -}else if($action == 'disable') { - //chtab name=$name monitoring.nodestatmon='' - $xml=docmd("webrun",'', array("chtab name=$name monitoring.nodestatmon=no")); - if(getXmlErrors($xml,$errors)) { - echo "

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

    "; - exit; - } -} - -echo "successful"; -?> diff --git a/xCAT-UI/monitor/monlist.php b/xCAT-UI/monitor/monlist.php index 8247318a8..432f6c506 100644 --- a/xCAT-UI/monitor/monlist.php +++ b/xCAT-UI/monitor/monlist.php @@ -1,22 +1,83 @@ 'main.php', 'monitor' =>'')); +displayMapper(array('home'=>'main.php', 'new_monitor' =>'')); -displayTips(array("Click the name of each plugin, you can get the plugin's description.", - "Select one plugin, choose the options for set up monitoring ", - "Click the button \"Start\", \"Stop\" or \"Restart\" to setup monitoring plugin")); +?> + -?> \ No newline at end of file +
    + +
    + +
    diff --git a/xCAT-UI/monitor/oldmonlist.php b/xCAT-UI/monitor/oldmonlist.php new file mode 100644 index 000000000..8247318a8 --- /dev/null +++ b/xCAT-UI/monitor/oldmonlist.php @@ -0,0 +1,22 @@ +'main.php', 'monitor' =>'')); + +displayTips(array("Click the name of each plugin, you can get the plugin's description.", + "Select one plugin, choose the options for set up monitoring ", + "Click the button \"Start\", \"Stop\" or \"Restart\" to setup monitoring plugin")); + + +//TODO: change the view style; +//Change all the "Actions/Description/Configurations/Views" to Tabs +//And, list all the monitoring plugins under the tree? Not sure now. +displayMonTable(); + +insertDiv("options"); + +?> \ No newline at end of file diff --git a/xCAT-UI/monitor/options.php b/xCAT-UI/monitor/options.php index 8308be129..605d1fbea 100644 --- a/xCAT-UI/monitor/options.php +++ b/xCAT-UI/monitor/options.php @@ -8,8 +8,214 @@ require_once "$TOPDIR/lib/display.php"; require_once "$TOPDIR/lib/monitor_display.php"; $name = $_REQUEST['name']; - +$option = $_REQUEST['opt']; //display the "configure" and "view" options for the desired monitoring plugin -displayOptionsForPlugin($name); + +//displayOptionsForPlugin($name); + +switch ($option) { + case "status": + //return the status of the plugin with "$name" as name + updatePluginStat($name); + break; + case "enable": + case "disable": + //enable/disable the plugin + //show all the node/range in the cluster + //and also provide one textarea to allow the user to type + showNRTreeInput(); + showPluginStat($name, $option); + break; + case "conf": + //show all the options for configuration + showPluginConf($name); + break; + case "view": + //show all the options for view + showPluginView($name); + break; + case "desc": + //show all the description of the plugin + default: + showPluginDesc($name); + break; +} + +function showPluginConf($name) +{ + //TODO +//echo << +//

    All the options for configuration are here.

    +//

    choose the options to update them

    +//
    +// +//TOS11; + echo "
    "; +echo << + $(function() { + $("#accordion").accordion({autoHeight: false}); + }); + +

    Application Monitor Setting

    +
    +
    + The configuration for application status monitoring + has not been implemented; We will consider it later! +
    +
    +

    The monsetting table Setting

    +
    +
    +

    Press the following buttons to enable/disable the settings

    +

    In order to make it effect, turn to the "Enable/Disable" tab for the plugin

    +
    +
    +TOS10; + echo "
    "; +} + +function showPluginView($name) +{ + //TODO +} + +function updatePluginStat($name) +{ + $xml = docmd("monls", "", array("$name")); + foreach($xml->children() as $response) foreach($response->children() as $data) { + $result = preg_split("/\s+/", $data); + if($result[0] == $name && $result[1] == "not-monitored") { + echo "Disabled"; + }else { + echo "Enabled"; + } + } +} + +function showPluginDesc($name) +{ + //TODO: many "return" keys are missed in the response. + //We have to figure them out + $xml = docmd("monls"," ", array("$name", "-d")); + if (getXmlErrors($xml, $errors)) { + echo "

    monls failed: ", implode(' ',$errors), "

    \n"; + exit; + } + + + $information = ""; + foreach ($xml->children() as $response) foreach ($response->children() as $data) { + $information .="

    $data

    "; + } + echo $information; +} + +/* + * changePluginStat($name) + * which is used to enable/disable the selected plugin, + * and which return whether they're sucessful or not + */ +function showPluginStat($name, $opt) +{ + //display the nrtree here + //let the user choose node/noderange to enable/disable monitor plugin + echo "
    "; + echo "
    "; +echo << + monPluginSetStat(); + $('input').customInput(); + +TOS1; + if($opt == 'enable') { + //monadd: xcatmon has special options + //moncfg + //"moncfg rmcmon -r" is necessary for rmcmon + //monstart + echo "

    The $name Plugin is in Disabled status

    "; + echo "

    You can Press the Following button to change its status

    "; + echo "

    Select the noderange from the right tree

    "; + echo "

    OR: you can type the noderange in the following area

    "; + echo "
    "; + + insertNRTextEntry(); + echo "

    When you are trying to enable the plugin

    would you like to support node status monitoring?

    "; + insertRadioBtn(); + insertButtonSet("Enable","Disable", 0); + }else if($opt == 'disable') { + //monstop + //mondecfg + echo "

    The $name Plugin is in Enabled status

    "; + echo "

    You can Press the Following button to change its status

    "; + echo "

    Select the noderange from the right tree

    "; + echo "

    OR: you can type the noderange in the following area

    "; + echo "
    "; + insertNRTextEntry(); + echo "

    When you are trying to enable the plugin

    would you like to support node status monitoring?

    "; + insertRadioBtn(); + insertButtonSet("Enable","Disable", 1); + } + echo ""; +} + +function insertRadioBtn() +{ + //to provide the choose to support "-n"(node status monitoring) +echo << +
    + + + + +
    + +TOS21; +} + +function insertNRTextEntry() +{ + echo ""; +} + +function insertButtonSet($state1, $state2, $default) +{ + echo ""; + echo "
    "; + if($default == 0) { + echo ""; + echo ""; + }else { + echo ""; + echo ""; + } + echo "
    "; +} + +function showNRTreeInput() +{ + echo "
    "; +echo << + $(function() { + nrtree = new tree_component(); // -Tree begin + nrtree.init($("#nrtree-input"),{ + rules: { multiple: "Ctrl" }, + ui: { animation: 250 }, + callback : { onchange : printtree }, + data : { + type : "json", + async : "true", + url: "noderangesource.php" + } + }); //Tree finish + }); + +TOS3; + echo "
    "; +} ?> diff --git a/xCAT-UI/monitor/plugin_desc.php b/xCAT-UI/monitor/plugin_desc.php deleted file mode 100644 index 46991fbd6..000000000 --- a/xCAT-UI/monitor/plugin_desc.php +++ /dev/null @@ -1,31 +0,0 @@ -monls failed: ", implode(' ',$errors), "

    \n"; - exit; -} - -$information = ""; - -foreach ($xml->children() as $response) foreach ($response->children() as $data) { - $information .= str_replace("\n", "
    ", $data);; - $information .= "\n
    "; - //print_r($data); -} -echo "

    "; -echo $information; -echo "

    "; -?> - diff --git a/xCAT-UI/monitor/setup.php b/xCAT-UI/monitor/setup.php index 0702d1e71..7a5391e85 100644 --- a/xCAT-UI/monitor/setup.php +++ b/xCAT-UI/monitor/setup.php @@ -2,7 +2,7 @@ /* * setup.php - * perform the "monstart", "monadd" and "monstop" actions for selected monitoring plugins + * to perform the "monstart" and "monstop" actions for the monitoring plugins */ if(!isset($TOPDIR)) { $TOPDIR="..";} @@ -14,82 +14,119 @@ require_once "$TOPDIR/lib/monitor_display.php"; $name = $_REQUEST['name']; $action = $_REQUEST['action']; -//read the "monitoring" table to see whether node status monitoring is enable or not -//$xml = docmd("webrun", "", array("gettab name=$name monitoring.nodestatmon")); -//if(getXmlErrors($xml, $errors)) { -// echo "

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

    "; -// exit; -//} -// -//foreach($xml->children() as $response) foreach($response->children() as $data) -//{ -// $nodemonstat = $data; -//} -switch($action) { - case "stop": - monstop($name); - break; - case "restart": - monrestart($name); - break; - case "start": - monstart($name); - break; - default: - break; -} +$nm = $_REQUEST['nm'];//node status monitoring: yes or no +$noderange = $_REQUEST['nr']; -function monstop($plugin) -{ - $xml = docmd("monstop", "", array("$plugin","-r")); - return 0; -} - -function monrestart($plugin) -{ - $xml = docmd("monstop", "", array("$plugin", "-r")); +if($action == "Disable") { + //FIXIT: it seems rmcmon has sth wrong with monstop + //The var $noderange can't work + $xml = docmd("monstop", " ", array("$name", "$noderange" , "-r")); if(getXmlErrors($xml, $errors)) { echo "

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

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

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

    "; + echo "

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

    "; exit; } - - $xml = docmd("monstart", "", array("$plugin", "-r")); - return 0; -} - -function monstart($plugin) -{ - //Before running "monstart", the command "monls" is used to check - $xml = docmd("monls","", NULL); + echo "successful"; +}else if($action == "Enable") { + //at first, check "-n" + if($nm == "yes") { + $xml=docmd("monrm", "", array("$name")); + $xml = docmd("monadd", "", array("$name", "-n")); + } else if($nm == "no") { + $xml = docmd("monrm", "", array("$name")); + $xml = docmd("monadd", "", array("$name")); + } + //then, moncfg + $xml = docmd("moncfg", " ", array("$name", "$noderange")); if(getXmlErrors($xml, $errors)) { - echo "

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

    "; + echo "

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

    "; exit; } - $has_plugin = false; - if(count($xml->children()) != 0) { - foreach($xml->children() as $response) foreach($response->children() as $data) { - $arr = preg_split("/\s+/", $data); - if($arr[0] == $plugin) { - $has_plugin = true; - } - } - } - if($has_plugin == false) { - //if $has_plugin == false, that means the plugin is not added into the monitoring table - $xml = docmd("monadd",'', array("$plugin")); + //special case for rmcmon + if($name == "rmcmon") { + $xml = docmd("moncfg", " ", array("$name", "$noderange", "-r")); if(getXmlErrors($xml, $errors)) { - echo "

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

    "; + echo "

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

    "; exit; } } - //we have to make sure that the plugin is added in the "monitoring" table - $xml = docmd("monstart", "", array("$plugin", "-r")); - return 0; + $xml = docmd("monstart", " ", array("$name", "$noderange", "-r")); + if(getXmlErrors($xml, $errors)) { + echo "

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

    "; + exit; + } + echo "successful"; } -?> +//switch($action) { +// case "stop": +// monstop($name); +// break; +// case "restart": +// monrestart($name); +// break; +// case "start": +// monstart($name); +// break; +// default: +// break; +//} +// +//function monstop($plugin) +//{ +// $xml = docmd("monstop", "", array("$plugin","-r")); +// return 0; +//} +// +//function monrestart($plugin) +//{ +// $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) +//{ +// //Before running "monstart", the command "monls" is used to check +// $xml = docmd("monls","", NULL); +// if(getXmlErrors($xml, $errors)) { +// echo "

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

    "; +// exit; +// } +// $has_plugin = false; +// if(count($xml->children()) != 0) { +// foreach($xml->children() as $response) foreach($response->children() as $data) { +// $arr = preg_split("/\s+/", $data); +// if($arr[0] == $plugin) { +// $has_plugin = true; +// } +// } +// } +// if($has_plugin == false) { +// //if $has_plugin == false, that means the plugin is not added into the monitoring table +// $xml = docmd("monadd",'', array("$plugin")); +// if(getXmlErrors($xml, $errors)) { +// echo "

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

    "; +// exit; +// } +// } +// //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 deleted file mode 100644 index 01c5c033e..000000000 --- a/xCAT-UI/monitor/stat_mon.php +++ /dev/null @@ -1,20 +0,0 @@ -