source: trunk/web/addons/job_monarch/index.php

Last change on this file was 648, checked in by ramonb, 13 years ago

job_monarch/overview.php,
job_monarch/index.php:

  • old code cleanup

job_monarch/index.php,
job_monarch/image.php,
job_monarch/jobstore.php

  • rewrote session handling

job_monarch/image.php:

job_monarch/templates/header.tpl:

  • add session to clusterimage
  • (temp?) disabled pie chart

job_monarch/libtoga.php:

  • wrote new SessionHandler? class to handle all sessions
  • DataSource? now uses interactive port so can retrieve only relevant XML
  • disable XML_OPTION_CASE_FOLDING to speed up xml parsing
  • use jobmond poll interval to only reload XML when useful
  • use strpos instead of strstr, should be faster xml parsing
  • dont parse XML in ClusterImage? anymore, instead supply DataGather? object


job_monarch/conf.php:

  • use interactive gmetad port now
File size: 5.0 KB
Line 
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");
26ini_set("memory_limit","1G");
27set_time_limit(0);
28
29
30$my_dir = getcwd();
31
32global $r, $range;
33
34include_once "./libtoga.php";
35
36if ( !empty( $_GET ) )
37{
38        extract( $_GET );
39}
40
41global $GANGLIA_PATH;
42chdir( $GANGLIA_PATH );
43
44include_once "./class.TemplatePower.inc.php";
45chdir( $my_dir );
46
47$httpvars       = new HTTPVariables( $HTTP_GET_VARS, $_GET );
48$clustername    = $httpvars->getClusterName();
49$view           = $httpvars->getHttpVar( "view" );
50
51global $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
69if( !isset($view) ) $view = "overview";
70if( !isset($sortorder) ) $sortorder = "asc";
71if( !isset($sortby) ) $sortby = "id";
72
73if( isset( $filterorder ) && ($filterorder!='') )
74{
75        $myfilter_fields = explode( ",", $filterorder );
76}
77else
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
86if( 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
108function epochToDatetime( $epoch )
109{
110        return strftime( "%d-%m-%Y %H:%M:%S", $epoch );
111}
112
113
114function 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
136function includeSearchpage() 
137{
138        global $tpl;
139
140        $tpl->assignInclude( "main", "templates/search.tpl" );
141}
142
143function includeOverview() 
144{
145        global $tpl;
146
147        $tpl->assignInclude( "main", "templates/overview.tpl" );
148}
149
150function 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
161if( 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
173switch( $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
204session_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
215switch( $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
241makeFooter();
242$tpl->printToScreen();
243?>
Note: See TracBrowser for help on using the repository browser.