[110] | 1 | <?php |
---|
[225] | 2 | /* |
---|
| 3 | * |
---|
| 4 | * This file is part of Jobmonarch |
---|
| 5 | * |
---|
| 6 | * Copyright (C) 2006 Ramon Bastiaans |
---|
| 7 | * |
---|
| 8 | * Jobmonarch is free software; you can redistribute it and/or modify |
---|
| 9 | * it under the terms of the GNU General Public License as published by |
---|
| 10 | * the Free Software Foundation; either version 2 of the License, or |
---|
| 11 | * (at your option) any later version. |
---|
| 12 | * |
---|
| 13 | * Jobmonarch is distributed in the hope that it will be useful, |
---|
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 16 | * GNU General Public License for more details. |
---|
| 17 | * |
---|
| 18 | * You should have received a copy of the GNU General Public License |
---|
| 19 | * along with this program; if not, write to the Free Software |
---|
| 20 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
---|
| 21 | * |
---|
[231] | 22 | * SVN $Id: image.php 765 2013-03-28 11:21:53Z ramonb $ |
---|
[225] | 23 | */ |
---|
| 24 | |
---|
[110] | 25 | include_once "./libtoga.php"; |
---|
| 26 | |
---|
[122] | 27 | if ( !empty( $_GET ) ) { |
---|
| 28 | extract( $_GET ); |
---|
| 29 | } |
---|
| 30 | |
---|
[326] | 31 | function checkSessionData() { |
---|
| 32 | |
---|
[718] | 33 | global $_SESSION; |
---|
[326] | 34 | |
---|
[718] | 35 | session_start(); |
---|
[326] | 36 | |
---|
[765] | 37 | if( isset( $_SESSION["data"] ) ) |
---|
| 38 | { |
---|
[718] | 39 | $myxml_data = &$_SESSION["data"]; |
---|
[765] | 40 | } |
---|
| 41 | else |
---|
| 42 | { |
---|
| 43 | $myxml_data = null; |
---|
[718] | 44 | } |
---|
[326] | 45 | |
---|
[765] | 46 | if( $myxml_data == null ) |
---|
| 47 | { |
---|
[718] | 48 | $ds = new DataSource(); |
---|
| 49 | $myxml_data = $ds->getData(); |
---|
| 50 | } |
---|
| 51 | return $myxml_data; |
---|
[326] | 52 | } |
---|
| 53 | |
---|
| 54 | |
---|
[117] | 55 | $httpvars = new HTTPVariables( $HTTP_GET_VARS, $_GET ); |
---|
[708] | 56 | $view = $httpvars->getHttpVar( "j_view" ); |
---|
[111] | 57 | $clustername = $httpvars->getClusterName(); |
---|
[110] | 58 | |
---|
[710] | 59 | if( isset($id) && ($id!='')) $filter['id']=$id; |
---|
| 60 | if( isset($state) && ($state!='')) $filter['state']=$state; |
---|
[711] | 61 | if( isset($owner) && ($owner!='')) $filter['owner']=$owner; |
---|
[710] | 62 | if( isset($queue) && ($queue!='')) $filter['queue']=$queue; |
---|
[122] | 63 | |
---|
[303] | 64 | function drawHostImage() { |
---|
| 65 | |
---|
[718] | 66 | global $clustername, $hostname, $data_gatherer; |
---|
[303] | 67 | |
---|
[718] | 68 | $ds = new DataSource(); |
---|
| 69 | $myxml_data = $ds->getData(); |
---|
[303] | 70 | |
---|
[718] | 71 | $data_gatherer = new DataGatherer( $clustername ); |
---|
[326] | 72 | |
---|
[718] | 73 | $data_gatherer->parseXML( $myxml_data ); |
---|
[326] | 74 | |
---|
[718] | 75 | if( $data_gatherer->isJobmonRunning() ) |
---|
| 76 | $ic = new HostImage( $data_gatherer, $clustername, $hostname ); |
---|
| 77 | else |
---|
| 78 | $ic = new EmptyImage(); |
---|
[303] | 79 | |
---|
[718] | 80 | $ic->draw(); |
---|
[303] | 81 | } |
---|
| 82 | |
---|
[110] | 83 | function drawSmallClusterImage() { |
---|
| 84 | |
---|
[718] | 85 | global $clustername, $data_gatherer; |
---|
[164] | 86 | |
---|
[718] | 87 | $ds = new DataSource(); |
---|
| 88 | $myxml_data = $ds->getData(); |
---|
[298] | 89 | |
---|
[718] | 90 | $data_gatherer = new DataGatherer( $clustername ); |
---|
[326] | 91 | |
---|
[718] | 92 | $data_gatherer->parseXML( $myxml_data ); |
---|
[326] | 93 | |
---|
[718] | 94 | if( $data_gatherer->isJobmonRunning() ) { |
---|
| 95 | $ic = new ClusterImage( $myxml_data, $clustername ); |
---|
| 96 | $ic->setSmall(); |
---|
| 97 | } else { |
---|
| 98 | $ic = new EmptyImage(); |
---|
| 99 | } |
---|
[298] | 100 | |
---|
[718] | 101 | $ic->draw(); |
---|
[110] | 102 | } |
---|
| 103 | |
---|
| 104 | function drawBigClusterImage() { |
---|
| 105 | |
---|
[718] | 106 | global $filter, $clustername; |
---|
[122] | 107 | |
---|
[718] | 108 | $myxml_data = checkSessionData(); |
---|
[326] | 109 | |
---|
[718] | 110 | $ic = new ClusterImage( $myxml_data, $clustername ); |
---|
| 111 | $ic->setBig(); |
---|
[122] | 112 | |
---|
[718] | 113 | if( isset( $filter ) ) { |
---|
| 114 | foreach( $filter as $filtername=>$filtervalue ) { |
---|
| 115 | switch( $filtername ) { |
---|
[300] | 116 | |
---|
[718] | 117 | case "id": |
---|
| 118 | $ic->setFilter( 'jobid', $filtervalue ); |
---|
| 119 | break; |
---|
| 120 | case "owner": |
---|
| 121 | $ic->setFilter( 'owner', $filtervalue); |
---|
| 122 | break; |
---|
| 123 | case "queue": |
---|
| 124 | $ic->setFilter( 'queue', $filtervalue); |
---|
| 125 | break; |
---|
| 126 | case "state": |
---|
| 127 | $ic->setFilter( 'status', $filtervalue); |
---|
| 128 | break; |
---|
| 129 | default: |
---|
| 130 | break; |
---|
| 131 | } |
---|
| 132 | } |
---|
| 133 | } |
---|
| 134 | $ic->draw(); |
---|
[110] | 135 | } |
---|
| 136 | |
---|
| 137 | switch( $view ) { |
---|
| 138 | |
---|
[718] | 139 | case "small-clusterimage": |
---|
[110] | 140 | |
---|
[718] | 141 | drawSmallClusterImage(); |
---|
| 142 | |
---|
| 143 | break; |
---|
[110] | 144 | |
---|
[718] | 145 | case "big-clusterimage": |
---|
[110] | 146 | |
---|
[718] | 147 | drawBigClusterImage(); |
---|
| 148 | |
---|
| 149 | break; |
---|
[110] | 150 | |
---|
[718] | 151 | case "hostimage": |
---|
[303] | 152 | |
---|
[718] | 153 | drawHostImage(); |
---|
| 154 | |
---|
| 155 | break; |
---|
[303] | 156 | |
---|
[718] | 157 | default: |
---|
[110] | 158 | |
---|
[718] | 159 | break; |
---|
[110] | 160 | } |
---|
| 161 | |
---|
| 162 | ?> |
---|