[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 329 2007-04-22 13:36:26Z bastiaans $ |
---|
[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 | |
---|
| 33 | global $_SESSION; |
---|
| 34 | |
---|
| 35 | session_start(); |
---|
| 36 | |
---|
| 37 | if( isset( $_SESSION["data"] ) ) { |
---|
| 38 | $myxml_data = &$_SESSION["data"]; |
---|
| 39 | } else { |
---|
| 40 | $myxml_data = 0; |
---|
| 41 | } |
---|
| 42 | |
---|
| 43 | if( !$myxml_data ) { |
---|
| 44 | $ds = new DataSource(); |
---|
| 45 | $myxml_data = $ds->getData(); |
---|
| 46 | |
---|
[329] | 47 | //print_f( "%s\n", $myxml_data ); |
---|
[326] | 48 | } |
---|
| 49 | return $myxml_data; |
---|
| 50 | } |
---|
| 51 | |
---|
| 52 | |
---|
[117] | 53 | $httpvars = new HTTPVariables( $HTTP_GET_VARS, $_GET ); |
---|
[110] | 54 | $view = $httpvars->getHttpVar( "view" ); |
---|
[111] | 55 | $clustername = $httpvars->getClusterName(); |
---|
[110] | 56 | |
---|
[163] | 57 | //printf("clustername = %s\n", $clustername ); |
---|
[124] | 58 | if( isset($id) && ($id!='')) $filter[id]=$id; |
---|
| 59 | if( isset($state) && ($state!='')) $filter[state]=$state; |
---|
| 60 | if( isset($user) && ($user!='')) $filter[user]=$user; |
---|
| 61 | if( isset($queue) && ($queue!='')) $filter[queue]=$queue; |
---|
[122] | 62 | |
---|
[303] | 63 | function drawHostImage() { |
---|
| 64 | |
---|
[326] | 65 | global $clustername, $hostname, $data_gatherer; |
---|
[303] | 66 | |
---|
[326] | 67 | $ds = new DataSource(); |
---|
| 68 | $myxml_data = $ds->getData(); |
---|
[303] | 69 | |
---|
[326] | 70 | $data_gatherer = new DataGatherer( $clustername ); |
---|
| 71 | |
---|
| 72 | $data_gatherer->parseXML( $myxml_data ); |
---|
| 73 | |
---|
[303] | 74 | if( $data_gatherer->isJobmonRunning() ) |
---|
| 75 | $ic = new HostImage( $data_gatherer, $clustername, $hostname ); |
---|
| 76 | else |
---|
| 77 | $ic = new EmptyImage(); |
---|
| 78 | |
---|
| 79 | $ic->draw(); |
---|
| 80 | } |
---|
| 81 | |
---|
[110] | 82 | function drawSmallClusterImage() { |
---|
| 83 | |
---|
[326] | 84 | global $clustername, $data_gatherer; |
---|
[164] | 85 | |
---|
[326] | 86 | $ds = new DataSource(); |
---|
| 87 | $myxml_data = $ds->getData(); |
---|
[298] | 88 | |
---|
[326] | 89 | $data_gatherer = new DataGatherer( $clustername ); |
---|
| 90 | |
---|
| 91 | $data_gatherer->parseXML( $myxml_data ); |
---|
| 92 | |
---|
[305] | 93 | if( $data_gatherer->isJobmonRunning() ) { |
---|
[326] | 94 | $ic = new ClusterImage( $myxml_data, $clustername ); |
---|
[305] | 95 | $ic->setSmall(); |
---|
| 96 | } else { |
---|
[298] | 97 | $ic = new EmptyImage(); |
---|
[305] | 98 | } |
---|
[298] | 99 | |
---|
[110] | 100 | $ic->draw(); |
---|
| 101 | } |
---|
| 102 | |
---|
| 103 | function drawBigClusterImage() { |
---|
| 104 | |
---|
[163] | 105 | global $filter, $clustername; |
---|
[122] | 106 | |
---|
[326] | 107 | $myxml_data = checkSessionData(); |
---|
| 108 | |
---|
| 109 | $ic = new ClusterImage( $myxml_data, $clustername ); |
---|
[305] | 110 | $ic->setBig(); |
---|
[122] | 111 | |
---|
[300] | 112 | if( isset( $filter ) ) { |
---|
| 113 | foreach( $filter as $filtername=>$filtervalue ) { |
---|
| 114 | //printf("filter %s,%s\n", $filtername, $filtervalue); |
---|
| 115 | switch( $filtername ) { |
---|
| 116 | |
---|
| 117 | case "id": |
---|
| 118 | $ic->setFilter( 'jobid', $filtervalue ); |
---|
| 119 | break; |
---|
| 120 | case "user": |
---|
| 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 | } |
---|
[124] | 132 | } |
---|
[122] | 133 | } |
---|
[114] | 134 | $ic->draw(); |
---|
[110] | 135 | } |
---|
| 136 | |
---|
| 137 | switch( $view ) { |
---|
| 138 | |
---|
| 139 | case "small-clusterimage": |
---|
| 140 | |
---|
| 141 | drawSmallClusterImage(); |
---|
| 142 | |
---|
| 143 | break; |
---|
| 144 | |
---|
| 145 | case "big-clusterimage": |
---|
| 146 | |
---|
| 147 | drawBigClusterImage(); |
---|
| 148 | |
---|
| 149 | break; |
---|
| 150 | |
---|
[303] | 151 | case "hostimage": |
---|
| 152 | |
---|
| 153 | drawHostImage(); |
---|
| 154 | |
---|
| 155 | break; |
---|
| 156 | |
---|
[110] | 157 | default: |
---|
| 158 | |
---|
| 159 | break; |
---|
| 160 | } |
---|
| 161 | |
---|
| 162 | ?> |
---|