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