Commit 6657f68b874f0a99f9df1fa68bf61035bca188b2
1 parent
710dc325
Exists in
master
and in
112 other branches
monitor impex services
Showing
4 changed files
with
65 additions
and
30 deletions
Show diff stats
php/RemoteDataCenter/RemoteDataCenterClass.php
@@ -6,7 +6,7 @@ | @@ -6,7 +6,7 @@ | ||
6 | */ | 6 | */ |
7 | abstract class RemoteDataCenterClass | 7 | abstract class RemoteDataCenterClass |
8 | { | 8 | { |
9 | - protected $url = null, $treeXML = null; | 9 | + protected $url = null, $WSDL = null, $treeXML = null; |
10 | 10 | ||
11 | protected $needsArgs = false; | 11 | protected $needsArgs = false; |
12 | protected $hasAccessUrl = false; | 12 | protected $hasAccessUrl = false; |
@@ -84,5 +84,24 @@ abstract class RemoteDataCenterClass | @@ -84,5 +84,24 @@ abstract class RemoteDataCenterClass | ||
84 | foreach ($missionNodes as $missionNode) | 84 | foreach ($missionNodes as $missionNode) |
85 | $this->dataCenter->appendChild($missionNode); | 85 | $this->dataCenter->appendChild($missionNode); |
86 | } | 86 | } |
87 | + | ||
88 | + public function monitor() | ||
89 | + { | ||
90 | + $ch = curl_init($this->url."/".$this->WSDL); | ||
91 | + curl_setopt($ch, CURLOPT_TIMEOUT, 3); | ||
92 | + curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 3); | ||
93 | + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); | ||
94 | + $data = curl_exec($ch); | ||
95 | + $httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE); | ||
96 | + curl_close($ch); | ||
97 | + | ||
98 | + if($httpcode >= 200 && $httpcode < 300) | ||
99 | + { | ||
100 | + return true; | ||
101 | + } else | ||
102 | + { | ||
103 | + return false; | ||
104 | + } | ||
105 | + } | ||
87 | } | 106 | } |
88 | ?> | 107 | ?> |
php/classes/AmdaAction.php
@@ -354,11 +354,10 @@ class AmdaAction | @@ -354,11 +354,10 @@ class AmdaAction | ||
354 | case 'remoteSimuParam' : | 354 | case 'remoteSimuParam' : |
355 | 355 | ||
356 | $globalStart = null; | 356 | $globalStart = null; |
357 | - | 357 | + $service_down = false; |
358 | $isSimulation = true; | 358 | $isSimulation = true; |
359 | 359 | ||
360 | - if ($child->getAttribute('isAddable')) | ||
361 | - //if ($id == 'spase://IMPEX/SimulationModel/FMI/GUMICS' ) | 360 | + if ($child->getAttribute('isAddable')) // 'spase://IMPEX/SimulationModel/FMI/GUMICS' |
362 | { | 361 | { |
363 | $isLeaf = false; | 362 | $isLeaf = false; |
364 | $isAddable = true; | 363 | $isAddable = true; |
@@ -366,7 +365,11 @@ class AmdaAction | @@ -366,7 +365,11 @@ class AmdaAction | ||
366 | 365 | ||
367 | if ($child->tagName == 'dataCenter') | 366 | if ($child->tagName == 'dataCenter') |
368 | { | 367 | { |
369 | - if ($child->getAttribute('isSimulation')) break; | 368 | + if ($child->getAttribute('isSimulation')) |
369 | + { | ||
370 | + $service_down = !($child->getAttribute('available')); | ||
371 | + break; | ||
372 | + } | ||
370 | else | 373 | else |
371 | { | 374 | { |
372 | $skip = true; | 375 | $skip = true; |
@@ -431,14 +434,7 @@ class AmdaAction | @@ -431,14 +434,7 @@ class AmdaAction | ||
431 | if ($info && !$isSimulation) | 434 | if ($info && !$isSimulation) |
432 | { | 435 | { |
433 | $info = str_replace(';', "<br/>Time Range: ", $info); | 436 | $info = str_replace(';', "<br/>Time Range: ", $info); |
434 | - } | ||
435 | - | ||
436 | - if ($child->tagName == 'dataset') | ||
437 | - { | ||
438 | - /*if ($child->hasAttribute('dataStart') && $child->hasAttribute('dataStop')) | ||
439 | - $info .= "Time Range: ".$child->getAttribute('dataStart')."-".$child->getAttribute('dataStop')."<br/>"; */ | ||
440 | - // $info .= "Time Range: ".$dataStart"-".$dataStop."<br/>"; | ||
441 | - } | 437 | + } |
442 | 438 | ||
443 | if (($child->tagName == 'parameter') || ($child->tagName == 'component')) | 439 | if (($child->tagName == 'parameter') || ($child->tagName == 'component')) |
444 | { | 440 | { |
@@ -480,21 +476,28 @@ class AmdaAction | @@ -480,21 +476,28 @@ class AmdaAction | ||
480 | } | 476 | } |
481 | else | 477 | else |
482 | { | 478 | { |
483 | - if ($child->tagName == 'dataCenter') | ||
484 | - $restricted = ($child->getAttribute('available') != "1"); | ||
485 | - else | ||
486 | - $restricted = false; | ||
487 | - | 479 | +// if ($child->tagName == 'dataCenter') |
480 | +// { | ||
481 | +// $restricted = ($child->getAttribute('available') != "1"); | ||
482 | +// } | ||
483 | +// else | ||
484 | +// $restricted = false; | ||
485 | +// | ||
488 | if ($id == 'CDAWEB' || $id == 'THEMIS'|| $id == 'MAPSKP' || $id == 'VEXGRAZ') | 486 | if ($id == 'CDAWEB' || $id == 'THEMIS'|| $id == 'MAPSKP' || $id == 'VEXGRAZ') |
489 | $restricted = FALSE; | 487 | $restricted = FALSE; |
490 | 488 | ||
491 | - if ($restricted) | ||
492 | - $info .= "<br/><b>Open soon !</b>"; | ||
493 | - | 489 | +// if ($restricted) |
490 | +// $info .= "<br/><b>Open soon !</b>"; | ||
491 | +// | ||
492 | + | ||
494 | if ($child->tagName == 'dataset') | 493 | if ($child->tagName == 'dataset') |
494 | + { | ||
495 | $nonavailable = ($child->getAttribute('disabled')); | 495 | $nonavailable = ($child->getAttribute('disabled')); |
496 | + } | ||
496 | else | 497 | else |
498 | + { | ||
497 | $nonavailable = false; | 499 | $nonavailable = false; |
500 | + } | ||
498 | 501 | ||
499 | if ($nonavailable) | 502 | if ($nonavailable) |
500 | $info .= "<br/><b>Not available yet</b>"; | 503 | $info .= "<br/><b>Not available yet</b>"; |
@@ -556,10 +559,16 @@ class AmdaAction | @@ -556,10 +559,16 @@ class AmdaAction | ||
556 | 559 | ||
557 | if (!$specialNode && !$skip) | 560 | if (!$specialNode && !$skip) |
558 | { | 561 | { |
559 | - if ($child->hasAttribute('desc')) | 562 | + if ($child->hasAttribute('desc')) |
560 | $info = $child->getAttribute('desc'); | 563 | $info = $child->getAttribute('desc'); |
564 | + | ||
565 | + if ($isSimulation && $service_down) | ||
566 | + { | ||
567 | + $info = "<b>Service is currently down</b>"; | ||
568 | + } | ||
569 | + | ||
561 | $childrenToReturn[] = array('text' => $name, 'id' => $id, 'nodeType' => $nodeType, 'info' => $info, | 570 | $childrenToReturn[] = array('text' => $name, 'id' => $id, 'nodeType' => $nodeType, 'info' => $info, |
562 | - 'help' => $help, 'leaf' => $isLeaf, 'isParameter' => $isParameter); | 571 | + 'help' => $help, 'leaf' => $isLeaf, 'isParameter' => $isParameter); |
563 | } | 572 | } |
564 | } | 573 | } |
565 | // if $childrenToReturn we have to return [] | 574 | // if $childrenToReturn we have to return [] |
php/classes/UserMgr.php
@@ -216,6 +216,7 @@ class UserMgr | @@ -216,6 +216,7 @@ class UserMgr | ||
216 | if ($base->hasAttribute('isSimulation')) | 216 | if ($base->hasAttribute('isSimulation')) |
217 | { | 217 | { |
218 | $baseId = $base->getAttribute('xml:id'); | 218 | $baseId = $base->getAttribute('xml:id'); |
219 | + | ||
219 | $baseXml = new DomDocument("1.0"); | 220 | $baseXml = new DomDocument("1.0"); |
220 | // no data base description ; skip this data base | 221 | // no data base description ; skip this data base |
221 | if (!file_exists(RemoteData.$baseId.'/base.xml')) continue; | 222 | if (!file_exists(RemoteData.$baseId.'/base.xml')) continue; |
@@ -240,11 +241,15 @@ class UserMgr | @@ -240,11 +241,15 @@ class UserMgr | ||
240 | $gumicsSimuReg->appendChild($node); | 241 | $gumicsSimuReg->appendChild($node); |
241 | } | 242 | } |
242 | } | 243 | } |
243 | - } | 244 | + } |
245 | + // Check if WebService is ON | ||
246 | + $center = new $baseId(); | ||
247 | + $myBase->setAttribute('available',$center->monitor()); | ||
248 | + | ||
244 | $myRootElement->appendChild($myBase); | 249 | $myRootElement->appendChild($myBase); |
245 | } | 250 | } |
246 | - } | ||
247 | - | 251 | + } |
252 | + | ||
248 | return $myRemoteBases->save(USERWSDIR.'RemoteParams.xml'); | 253 | return $myRemoteBases->save(USERWSDIR.'RemoteParams.xml'); |
249 | } | 254 | } |
250 | 255 | ||
@@ -272,10 +277,11 @@ class UserMgr | @@ -272,10 +277,11 @@ class UserMgr | ||
272 | foreach ($bases as $base) | 277 | foreach ($bases as $base) |
273 | { | 278 | { |
274 | $baseId = $base->getAttribute('xml:id'); | 279 | $baseId = $base->getAttribute('xml:id'); |
280 | + if ($base->getAttribute('isSimulation')) continue; | ||
281 | + | ||
275 | $notAvailable = (array_search($baseId,$availableMis) === FALSE); | 282 | $notAvailable = (array_search($baseId,$availableMis) === FALSE); |
276 | - $base->setAttribute('available',!$notAvailable); | ||
277 | - | ||
278 | - if ($base->getAttribute('isSimulation')) continue; | 283 | + $base->setAttribute('available',!$notAvailable); |
284 | + | ||
279 | // Update Info on External Data Sets in UserTree.xml for everything except IMPEX | 285 | // Update Info on External Data Sets in UserTree.xml for everything except IMPEX |
280 | $dataSets = $base->getElementsByTagName("dataset"); | 286 | $dataSets = $base->getElementsByTagName("dataset"); |
281 | if ($dataSets->length > 0) | 287 | if ($dataSets->length > 0) |
php/config.php
@@ -129,9 +129,10 @@ putenv("DDPATH=".DDRES_DIR); | @@ -129,9 +129,10 @@ putenv("DDPATH=".DDRES_DIR); | ||
129 | // PHP classes | 129 | // PHP classes |
130 | define('XMLPATH', IHM_SRC_DIR.'php/XML/'); | 130 | define('XMLPATH', IHM_SRC_DIR.'php/XML/'); |
131 | define('CLASSPATH', IHM_SRC_DIR.'php/classes/'); | 131 | define('CLASSPATH', IHM_SRC_DIR.'php/classes/'); |
132 | +define('REMOTE_CLASSPATH', IHM_SRC_DIR.'php/RemoteDataCenter/'); | ||
132 | define('OLD_CLASSPATH', IHM_SRC_DIR.'php/old_amda/'); | 133 | define('OLD_CLASSPATH', IHM_SRC_DIR.'php/old_amda/'); |
133 | 134 | ||
134 | -set_include_path(".:".CLASSPATH.":".OLD_CLASSPATH); | 135 | +set_include_path(".:".CLASSPATH.":".REMOTE_CLASSPATH.":".OLD_CLASSPATH); |
135 | 136 | ||
136 | if (!function_exists('__autoload')) | 137 | if (!function_exists('__autoload')) |
137 | { | 138 | { |