';
displayRMCRsrc();
diff --git a/xCAT-UI/monitor/rmc_source.php b/xCAT-UI/monitor/rmc_source.php
index b9ea7fff5..8db54446f 100644
--- a/xCAT-UI/monitor/rmc_source.php
+++ b/xCAT-UI/monitor/rmc_source.php
@@ -12,42 +12,41 @@ require_once "$TOPDIR/js/jsonwrapper.php";
$id = $_GET['id'];
}
if ($id == "0") {
- $id = '/.*';
+ echo '[{"data":"cluster","attributes":{"id":",cluster","rel":"node"}},{"data":"summary","attributes":{"id":",summary","rel":"node"}},{"data":"lpar","attributes":{"id":",lpar","rel":"group"},"state":"closed"}]';
} else {
$id=preg_replace('/^,/','',$id);
- }
- $rvals=docmd('extnoderange',$id,array('subgroups'));
- $parents=array();
- $root=1;
- if ($id == '/.*') {
- $id=',';
- } else {
- $parents=split("@",$id);
- $id=",$id@";
- $root=0;
- }
- //unset($rvals->xcatresponse->serverdone[0]);
- $numsubgroups=count($rvals->xcatresponse->intersectinggroups);
- $numnodes=count($rvals->xcatresponse->node);
- $jdata=array();
- if ($numnodes >= $numsubgroups) { #If there are few enough subgroups to be helpful filters, add them in
- foreach ($rvals->xcatresponse->intersectinggroups as $group) {
- if (! in_array("$group",$parents)) {
- $jdata[]= array("data"=>"$group",
- "attributes"=>array("id"=>"$id$group",
- "rel"=>'group'),
- "state"=>'closed');
- }
-
+ $rvals=docmd('extnoderange',$id,array('subgroups'));
+ $parents=array();
+ $root=1;
+ if ($id == '/.*') {
+ $id=',';
+ } else {
+ $parents=split("@",$id);
+ $id=",$id@";
+ $root=0;
}
- } #If there were more groups than nodes, leave the signal to noise ratio down
- if ($root==0) {
- foreach ($rvals->xcatresponse->node as $node) {
- $jdata[] = array("data"=>"$node",
- "attributes"=>array("id"=>",$node",
- "rel"=>'node'));
+ //unset($rvals->xcatresponse->serverdone[0]);
+ $numsubgroups=count($rvals->xcatresponse->intersectinggroups);
+ $numnodes=count($rvals->xcatresponse->node);
+ $jdata=array();
+ if ($numnodes >= $numsubgroups) { #If there are few enough subgroups to be helpful filters, add them in
+ foreach ($rvals->xcatresponse->intersectinggroups as $group) {
+ if (! in_array("$group",$parents)) {
+ $jdata[]= array("data"=>"$group",
+ "attributes"=>array("id"=>"$id$group",
+ "rel"=>'group'),
+ "state"=>'closed');
+ }
+
+ }
+ } #If there were more groups than nodes, leave the signal to noise ratio down
+ if ($root==0) {
+ foreach ($rvals->xcatresponse->node as $node) {
+ $jdata[] = array("data"=>"$node",
+ "attributes"=>array("id"=>",$node",
+ "rel"=>'node'));
+ }
+ }
+ echo json_encode($jdata);
}
- }
-# header('Content-type: text/html');
- echo json_encode($jdata);
?>
diff --git a/xCAT-UI/monitor/setup.php b/xCAT-UI/monitor/setup.php
index 63bba8b4a..5509d2683 100644
--- a/xCAT-UI/monitor/setup.php
+++ b/xCAT-UI/monitor/setup.php
@@ -16,37 +16,37 @@ $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;
-}
+//$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, $nmstat);
+ monstop($name);
break;
case "restart":
- monrestart($name, $nmstat);
+ monrestart($name);
break;
case "start":
- monstart($name, $nmstat);
+ monstart($name);
break;
default:
break;
}
-function monstop($plugin, $nmstat)
+function monstop($plugin)
{
$xml = docmd("monstop", "", array("$plugin","-r"));
return 0;
}
-function monrestart($plugin, $nmstat)
+function monrestart($plugin)
{
$xml = docmd("monstop", "", array("$plugin", "-r"));
if(getXmlErrors($xml, $errors)) {
@@ -63,9 +63,31 @@ function monrestart($plugin, $nmstat)
return 0;
}
-function monstart($plugin, $nmstat)
+function monstart($plugin)
{
- //TODO:before starting the $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;