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: index.php 527 2008-06-27 13:37:31Z ramonb $ |
---|
23 | */ |
---|
24 | |
---|
25 | //ini_set("memory_limit","200M"); |
---|
26 | ini_set("memory_limit","1G"); |
---|
27 | set_time_limit(0); |
---|
28 | |
---|
29 | |
---|
30 | $my_dir = getcwd(); |
---|
31 | |
---|
32 | global $r, $range; |
---|
33 | |
---|
34 | include_once "./libtoga.php"; |
---|
35 | |
---|
36 | if ( !empty( $_GET ) ) |
---|
37 | { |
---|
38 | extract( $_GET ); |
---|
39 | } |
---|
40 | |
---|
41 | global $GANGLIA_PATH; |
---|
42 | chdir( $GANGLIA_PATH ); |
---|
43 | |
---|
44 | include_once "./class.TemplatePower.inc.php"; |
---|
45 | chdir( $my_dir ); |
---|
46 | |
---|
47 | $httpvars = new HTTPVariables( $HTTP_GET_VARS, $_GET ); |
---|
48 | $clustername = $httpvars->getClusterName(); |
---|
49 | $view = $httpvars->getHttpVar( "view" ); |
---|
50 | |
---|
51 | global $mySession, $myData, $myXML; |
---|
52 | |
---|
53 | //printf( "c %s\n", $clustername ); |
---|
54 | |
---|
55 | $mySession = new SessionHandler( $clustername ); |
---|
56 | $mySession->checkSession(); |
---|
57 | |
---|
58 | $session = &$mySession->getSession(); |
---|
59 | $myXML = $session['data']; |
---|
60 | |
---|
61 | $myData = new DataGatherer( $clustername ); |
---|
62 | $myData->parseXML( $myXML ); |
---|
63 | |
---|
64 | $mySession->updatePollInterval( $myData->getPollInterval() ); |
---|
65 | $mySession->endSession(); |
---|
66 | |
---|
67 | $filter = array(); |
---|
68 | |
---|
69 | if( !isset($view) ) $view = "overview"; |
---|
70 | if( !isset($sortorder) ) $sortorder = "asc"; |
---|
71 | if( !isset($sortby) ) $sortby = "id"; |
---|
72 | |
---|
73 | if( isset( $filterorder ) && ($filterorder!='') ) |
---|
74 | { |
---|
75 | $myfilter_fields = explode( ",", $filterorder ); |
---|
76 | } |
---|
77 | else |
---|
78 | { |
---|
79 | if( isset($queue) && ($queue!='')) $filter['queue']=$queue; |
---|
80 | if( isset($state) && ($state!='')) $filter['state']=$state; |
---|
81 | if( isset($user) && ($user!='')) $filter['user']=$user; |
---|
82 | if( isset($id) && ($id!='')) $filter['id']=$id; |
---|
83 | } |
---|
84 | |
---|
85 | // Fill filter array in order they were picked by user |
---|
86 | if( isset($myfilter_fields) ) |
---|
87 | { |
---|
88 | foreach( $myfilter_fields as $myfilter ) |
---|
89 | { |
---|
90 | switch( $myfilter ) |
---|
91 | { |
---|
92 | case "queue": |
---|
93 | $filter['queue']=$queue; |
---|
94 | break; |
---|
95 | case "state": |
---|
96 | $filter['state']=$state; |
---|
97 | break; |
---|
98 | case "user": |
---|
99 | $filter['user']=$user; |
---|
100 | break; |
---|
101 | case "id": |
---|
102 | $filter['id']=$id; |
---|
103 | break; |
---|
104 | } |
---|
105 | } |
---|
106 | } |
---|
107 | |
---|
108 | function epochToDatetime( $epoch ) |
---|
109 | { |
---|
110 | return strftime( "%d-%m-%Y %H:%M:%S", $epoch ); |
---|
111 | } |
---|
112 | |
---|
113 | |
---|
114 | function makeFooter() |
---|
115 | { |
---|
116 | global $tpl, $version, $parsetime, $monarchversion; |
---|
117 | |
---|
118 | $tpl->gotoBlock( "_ROOT" ); |
---|
119 | $tpl->assign("webfrontend-version",$version["webfrontend"]); |
---|
120 | $tpl->assign("monarch-version", $monarchversion); |
---|
121 | |
---|
122 | if ($version["gmetad"]) |
---|
123 | { |
---|
124 | $tpl->assign("webbackend-component", "gmetad"); |
---|
125 | $tpl->assign("webbackend-version",$version["gmetad"]); |
---|
126 | } |
---|
127 | else if ($version["gmond"]) |
---|
128 | { |
---|
129 | $tpl->assign("webbackend-component", "gmond"); |
---|
130 | $tpl->assign("webbackend-version", $version["gmond"]); |
---|
131 | } |
---|
132 | |
---|
133 | $tpl->assign("parsetime", sprintf("%.4f", $parsetime) . "s"); |
---|
134 | } |
---|
135 | |
---|
136 | function includeSearchpage() |
---|
137 | { |
---|
138 | global $tpl; |
---|
139 | |
---|
140 | $tpl->assignInclude( "main", "templates/search.tpl" ); |
---|
141 | } |
---|
142 | |
---|
143 | function includeOverview() |
---|
144 | { |
---|
145 | global $tpl; |
---|
146 | |
---|
147 | $tpl->assignInclude( "main", "templates/overview.tpl" ); |
---|
148 | } |
---|
149 | |
---|
150 | function includeHostPage() |
---|
151 | { |
---|
152 | global $tpl; |
---|
153 | |
---|
154 | $tpl->assignInclude( "main", "templates/host_view.tpl" ); |
---|
155 | } |
---|
156 | |
---|
157 | $tpl = new TemplatePower( "templates/index.tpl" ); |
---|
158 | |
---|
159 | $tpl->assignInclude( "header", "templates/header.tpl" ); |
---|
160 | |
---|
161 | if( isset( $h ) and $h != '' ) |
---|
162 | { |
---|
163 | $hostname = $h; |
---|
164 | } |
---|
165 | $ic = new ClusterImage( $myData, $clustername ); |
---|
166 | $ic->setBig(); |
---|
167 | $ic->setNoimage(); |
---|
168 | $ic->draw(); |
---|
169 | |
---|
170 | //printf("%s\n", $ic->getImagemapArea() ); |
---|
171 | |
---|
172 | |
---|
173 | switch( $view ) |
---|
174 | { |
---|
175 | case "overview": |
---|
176 | |
---|
177 | //includeOverview(); |
---|
178 | break; |
---|
179 | |
---|
180 | case "search": |
---|
181 | |
---|
182 | //includeSearchPage(); |
---|
183 | break; |
---|
184 | |
---|
185 | case "host": |
---|
186 | |
---|
187 | //includeHostPage(); |
---|
188 | break; |
---|
189 | |
---|
190 | default: |
---|
191 | |
---|
192 | //includeOverview(); |
---|
193 | break; |
---|
194 | } |
---|
195 | |
---|
196 | $tpl->assignInclude( "footer", "templates/footer.tpl" ); |
---|
197 | $tpl->prepare(); |
---|
198 | |
---|
199 | $longtitle = "Batch Report :: Powered by Job Monarch!"; |
---|
200 | $title = "Batch Report"; |
---|
201 | $tpl->assign("cluster_url", rawurlencode($clustername) ); |
---|
202 | $tpl->assign("cluster", $clustername ); |
---|
203 | |
---|
204 | session_start(); |
---|
205 | $tpl->assign( "session_name", session_name() ); |
---|
206 | $tpl->assign( "session_id", session_id() ); |
---|
207 | |
---|
208 | $rjqj_str .= "./graph.php?z=small&c=$clustername&g=job_report&r=$range&st=$cluster[LOCALTIME]"; |
---|
209 | |
---|
210 | $tpl->assign( "rjqj_graph", $rjqj_str ); |
---|
211 | $tpl->assign( "uue_clustername", rawurlencode($clustername) ); |
---|
212 | |
---|
213 | $tpl->assign( "node_area_map", $ic->getImagemapArea() ); |
---|
214 | |
---|
215 | switch( $view ) |
---|
216 | { |
---|
217 | case "overview": |
---|
218 | |
---|
219 | //include "./overview.php"; |
---|
220 | //makeOverview(); |
---|
221 | break; |
---|
222 | |
---|
223 | case "search": |
---|
224 | |
---|
225 | //include "./search.php"; |
---|
226 | //makeSearchPage(); |
---|
227 | break; |
---|
228 | |
---|
229 | case "host": |
---|
230 | |
---|
231 | //include "./host_view.php"; |
---|
232 | //makeHostView(); |
---|
233 | break; |
---|
234 | |
---|
235 | default: |
---|
236 | |
---|
237 | //makeOverview(); |
---|
238 | break; |
---|
239 | } |
---|
240 | |
---|
241 | makeFooter(); |
---|
242 | $tpl->printToScreen(); |
---|
243 | ?> |
---|