1 | <?php |
---|
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 | * |
---|
22 | * SVN $Id: image.php 718 2013-03-21 20:44:55Z ramonb $ |
---|
23 | */ |
---|
24 | |
---|
25 | include_once "./libtoga.php"; |
---|
26 | |
---|
27 | if ( !empty( $_GET ) ) { |
---|
28 | extract( $_GET ); |
---|
29 | } |
---|
30 | |
---|
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 | |
---|
47 | } |
---|
48 | return $myxml_data; |
---|
49 | } |
---|
50 | |
---|
51 | |
---|
52 | $httpvars = new HTTPVariables( $HTTP_GET_VARS, $_GET ); |
---|
53 | $view = $httpvars->getHttpVar( "j_view" ); |
---|
54 | $clustername = $httpvars->getClusterName(); |
---|
55 | |
---|
56 | if( isset($id) && ($id!='')) $filter['id']=$id; |
---|
57 | if( isset($state) && ($state!='')) $filter['state']=$state; |
---|
58 | if( isset($owner) && ($owner!='')) $filter['owner']=$owner; |
---|
59 | if( isset($queue) && ($queue!='')) $filter['queue']=$queue; |
---|
60 | |
---|
61 | function drawHostImage() { |
---|
62 | |
---|
63 | global $clustername, $hostname, $data_gatherer; |
---|
64 | |
---|
65 | $ds = new DataSource(); |
---|
66 | $myxml_data = $ds->getData(); |
---|
67 | |
---|
68 | $data_gatherer = new DataGatherer( $clustername ); |
---|
69 | |
---|
70 | $data_gatherer->parseXML( $myxml_data ); |
---|
71 | |
---|
72 | if( $data_gatherer->isJobmonRunning() ) |
---|
73 | $ic = new HostImage( $data_gatherer, $clustername, $hostname ); |
---|
74 | else |
---|
75 | $ic = new EmptyImage(); |
---|
76 | |
---|
77 | $ic->draw(); |
---|
78 | } |
---|
79 | |
---|
80 | function drawSmallClusterImage() { |
---|
81 | |
---|
82 | global $clustername, $data_gatherer; |
---|
83 | |
---|
84 | $ds = new DataSource(); |
---|
85 | $myxml_data = $ds->getData(); |
---|
86 | |
---|
87 | $data_gatherer = new DataGatherer( $clustername ); |
---|
88 | |
---|
89 | $data_gatherer->parseXML( $myxml_data ); |
---|
90 | |
---|
91 | if( $data_gatherer->isJobmonRunning() ) { |
---|
92 | $ic = new ClusterImage( $myxml_data, $clustername ); |
---|
93 | $ic->setSmall(); |
---|
94 | } else { |
---|
95 | $ic = new EmptyImage(); |
---|
96 | } |
---|
97 | |
---|
98 | $ic->draw(); |
---|
99 | } |
---|
100 | |
---|
101 | function drawBigClusterImage() { |
---|
102 | |
---|
103 | global $filter, $clustername; |
---|
104 | |
---|
105 | $myxml_data = checkSessionData(); |
---|
106 | |
---|
107 | $ic = new ClusterImage( $myxml_data, $clustername ); |
---|
108 | $ic->setBig(); |
---|
109 | |
---|
110 | if( isset( $filter ) ) { |
---|
111 | foreach( $filter as $filtername=>$filtervalue ) { |
---|
112 | switch( $filtername ) { |
---|
113 | |
---|
114 | case "id": |
---|
115 | $ic->setFilter( 'jobid', $filtervalue ); |
---|
116 | break; |
---|
117 | case "owner": |
---|
118 | $ic->setFilter( 'owner', $filtervalue); |
---|
119 | break; |
---|
120 | case "queue": |
---|
121 | $ic->setFilter( 'queue', $filtervalue); |
---|
122 | break; |
---|
123 | case "state": |
---|
124 | $ic->setFilter( 'status', $filtervalue); |
---|
125 | break; |
---|
126 | default: |
---|
127 | break; |
---|
128 | } |
---|
129 | } |
---|
130 | } |
---|
131 | $ic->draw(); |
---|
132 | } |
---|
133 | |
---|
134 | switch( $view ) { |
---|
135 | |
---|
136 | case "small-clusterimage": |
---|
137 | |
---|
138 | drawSmallClusterImage(); |
---|
139 | |
---|
140 | break; |
---|
141 | |
---|
142 | case "big-clusterimage": |
---|
143 | |
---|
144 | drawBigClusterImage(); |
---|
145 | |
---|
146 | break; |
---|
147 | |
---|
148 | case "hostimage": |
---|
149 | |
---|
150 | drawHostImage(); |
---|
151 | |
---|
152 | break; |
---|
153 | |
---|
154 | default: |
---|
155 | |
---|
156 | break; |
---|
157 | } |
---|
158 | |
---|
159 | ?> |
---|