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 708 2013-03-21 17:27:15Z 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 | //print_f( "%s\n", $myxml_data ); |
---|
48 | } |
---|
49 | return $myxml_data; |
---|
50 | } |
---|
51 | |
---|
52 | |
---|
53 | $httpvars = new HTTPVariables( $HTTP_GET_VARS, $_GET ); |
---|
54 | $view = $httpvars->getHttpVar( "j_view" ); |
---|
55 | $clustername = $httpvars->getClusterName(); |
---|
56 | |
---|
57 | //printf("clustername = %s\n", $clustername ); |
---|
58 | if( isset($f_id) && ($f_id!='')) $filter[f_id]=$id; |
---|
59 | if( isset($f_state) && ($f_state!='')) $filter[f_state]=$state; |
---|
60 | if( isset($f_user) && ($f_user!='')) $filter[f_user]=$user; |
---|
61 | if( isset($f_queue) && ($f_queue!='')) $filter[f_queue]=$queue; |
---|
62 | |
---|
63 | function drawHostImage() { |
---|
64 | |
---|
65 | global $clustername, $hostname, $data_gatherer; |
---|
66 | |
---|
67 | $ds = new DataSource(); |
---|
68 | $myxml_data = $ds->getData(); |
---|
69 | |
---|
70 | $data_gatherer = new DataGatherer( $clustername ); |
---|
71 | |
---|
72 | $data_gatherer->parseXML( $myxml_data ); |
---|
73 | |
---|
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 | |
---|
82 | function drawSmallClusterImage() { |
---|
83 | |
---|
84 | global $clustername, $data_gatherer; |
---|
85 | |
---|
86 | $ds = new DataSource(); |
---|
87 | $myxml_data = $ds->getData(); |
---|
88 | |
---|
89 | $data_gatherer = new DataGatherer( $clustername ); |
---|
90 | |
---|
91 | $data_gatherer->parseXML( $myxml_data ); |
---|
92 | |
---|
93 | if( $data_gatherer->isJobmonRunning() ) { |
---|
94 | $ic = new ClusterImage( $myxml_data, $clustername ); |
---|
95 | $ic->setSmall(); |
---|
96 | } else { |
---|
97 | $ic = new EmptyImage(); |
---|
98 | } |
---|
99 | |
---|
100 | $ic->draw(); |
---|
101 | } |
---|
102 | |
---|
103 | function drawBigClusterImage() { |
---|
104 | |
---|
105 | global $filter, $clustername; |
---|
106 | |
---|
107 | $myxml_data = checkSessionData(); |
---|
108 | |
---|
109 | $ic = new ClusterImage( $myxml_data, $clustername ); |
---|
110 | $ic->setBig(); |
---|
111 | |
---|
112 | if( isset( $filter ) ) { |
---|
113 | foreach( $filter as $filtername=>$filtervalue ) { |
---|
114 | //printf("filter %s,%s\n", $filtername, $filtervalue); |
---|
115 | switch( $filtername ) { |
---|
116 | |
---|
117 | case "f_id": |
---|
118 | $ic->setFilter( 'jobid', $filtervalue ); |
---|
119 | break; |
---|
120 | case "f_user": |
---|
121 | $ic->setFilter( 'owner', $filtervalue); |
---|
122 | break; |
---|
123 | case "f_queue": |
---|
124 | $ic->setFilter( 'queue', $filtervalue); |
---|
125 | break; |
---|
126 | case "f_state": |
---|
127 | $ic->setFilter( 'status', $filtervalue); |
---|
128 | break; |
---|
129 | default: |
---|
130 | break; |
---|
131 | } |
---|
132 | } |
---|
133 | } |
---|
134 | $ic->draw(); |
---|
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 | |
---|
151 | case "hostimage": |
---|
152 | |
---|
153 | drawHostImage(); |
---|
154 | |
---|
155 | break; |
---|
156 | |
---|
157 | default: |
---|
158 | |
---|
159 | break; |
---|
160 | } |
---|
161 | |
---|
162 | ?> |
---|