source: branches/0.3/web/addons/job_monarch/image.php @ 688

Last change on this file since 688 was 688, checked in by ramonb, 11 years ago
  • more new ganglia-web compatibility fixes
  • Property svn:keywords set to Id
File size: 3.3 KB
RevLine 
[110]1<?php
[225]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 *
[231]22 * SVN $Id: image.php 688 2012-11-28 15:36:05Z ramonb $
[225]23 */
24
[110]25include_once "./libtoga.php";
26
[122]27if ( !empty( $_GET ) ) {
28        extract( $_GET );
29}
30
[326]31function 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
[329]47                //print_f( "%s\n", $myxml_data );
[326]48        }
49        return $myxml_data;
50}
51
52
[117]53$httpvars = new HTTPVariables( $HTTP_GET_VARS, $_GET );
[110]54$view = $httpvars->getHttpVar( "view" );
[111]55$clustername = $httpvars->getClusterName();
[110]56
[163]57//printf("clustername = %s\n", $clustername );
[688]58if( isset($f_id) && ($f_id!='')) $filter[f_id]=$id;
59if( isset($f_state) && ($f_state!='')) $filter[f_state]=$state;
60if( isset($f_user) && ($f_user!='')) $filter[f_user]=$user;
61if( isset($f_queue) && ($f_queue!='')) $filter[f_queue]=$queue;
[122]62
[303]63function drawHostImage() {
64
[326]65        global $clustername, $hostname, $data_gatherer;
[303]66
[326]67        $ds             = new DataSource();
68        $myxml_data     = $ds->getData();
[303]69
[326]70        $data_gatherer  = new DataGatherer( $clustername );
71
72        $data_gatherer->parseXML( $myxml_data );
73
[303]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
[110]82function drawSmallClusterImage() {
83
[326]84        global $clustername, $data_gatherer;
[164]85
[326]86        $ds             = new DataSource();
87        $myxml_data     = $ds->getData();
[298]88
[326]89        $data_gatherer  = new DataGatherer( $clustername );
90
91        $data_gatherer->parseXML( $myxml_data );
92
[305]93        if( $data_gatherer->isJobmonRunning() ) {
[326]94                $ic = new ClusterImage( $myxml_data, $clustername );
[305]95                $ic->setSmall();
96        } else {
[298]97                $ic = new EmptyImage();
[305]98        }
[298]99
[110]100        $ic->draw();
101}
102
103function drawBigClusterImage() {
104
[163]105        global $filter, $clustername;
[122]106
[326]107        $myxml_data     = checkSessionData();
108
109        $ic = new ClusterImage( $myxml_data, $clustername );
[305]110        $ic->setBig();
[122]111
[300]112        if( isset( $filter ) ) {
113                foreach( $filter as $filtername=>$filtervalue ) {
114                        //printf("filter %s,%s\n", $filtername, $filtervalue);
115                        switch( $filtername ) {
116
[688]117                                case "f_id":
[300]118                                        $ic->setFilter( 'jobid', $filtervalue );
119                                        break;
[688]120                                case "f_user":
[300]121                                        $ic->setFilter( 'owner', $filtervalue);
122                                        break;
[688]123                                case "f_queue":
[300]124                                        $ic->setFilter( 'queue', $filtervalue);
125                                        break;
[688]126                                case "f_state":
[300]127                                        $ic->setFilter( 'status', $filtervalue);
128                                        break;
129                                default:
130                                        break;
131                        }
[124]132                }
[122]133        }
[114]134        $ic->draw();
[110]135}
136
137switch( $view ) {
138
139        case "small-clusterimage":
140
141                drawSmallClusterImage();
142               
143                break;
144
145        case "big-clusterimage":
146
147                drawBigClusterImage();
148       
149                break;
150
[303]151        case "hostimage":
152
153                drawHostImage();
154       
155                break;
156
[110]157        default:
158
159                break;
160}
161
162?>
Note: See TracBrowser for help on using the repository browser.