source: branches/0.4/web/addons/job_monarch/image.php @ 714

Last change on this file since 714 was 714, checked in by ramonb, 11 years ago
  • more cleanup
  • Property svn:keywords set to Id
File size: 3.2 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 714 2013-03-21 20:25:19Z 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
47        }
48        return $myxml_data;
49}
50
51
[117]52$httpvars = new HTTPVariables( $HTTP_GET_VARS, $_GET );
[708]53$view = $httpvars->getHttpVar( "j_view" );
[111]54$clustername = $httpvars->getClusterName();
[110]55
[710]56if( isset($id) && ($id!='')) $filter['id']=$id;
57if( isset($state) && ($state!='')) $filter['state']=$state;
[711]58if( isset($owner) && ($owner!='')) $filter['owner']=$owner;
[710]59if( isset($queue) && ($queue!='')) $filter['queue']=$queue;
[122]60
[303]61function drawHostImage() {
62
[326]63        global $clustername, $hostname, $data_gatherer;
[303]64
[326]65        $ds             = new DataSource();
66        $myxml_data     = $ds->getData();
[303]67
[326]68        $data_gatherer  = new DataGatherer( $clustername );
69
70        $data_gatherer->parseXML( $myxml_data );
71
[303]72        if( $data_gatherer->isJobmonRunning() )
73                $ic = new HostImage( $data_gatherer, $clustername, $hostname );
74        else
75                $ic = new EmptyImage();
76
77        $ic->draw();
78}
79
[110]80function drawSmallClusterImage() {
81
[326]82        global $clustername, $data_gatherer;
[164]83
[326]84        $ds             = new DataSource();
85        $myxml_data     = $ds->getData();
[298]86
[326]87        $data_gatherer  = new DataGatherer( $clustername );
88
89        $data_gatherer->parseXML( $myxml_data );
90
[305]91        if( $data_gatherer->isJobmonRunning() ) {
[326]92                $ic = new ClusterImage( $myxml_data, $clustername );
[305]93                $ic->setSmall();
94        } else {
[298]95                $ic = new EmptyImage();
[305]96        }
[298]97
[110]98        $ic->draw();
99}
100
101function drawBigClusterImage() {
102
[163]103        global $filter, $clustername;
[122]104
[326]105        $myxml_data     = checkSessionData();
106
107        $ic = new ClusterImage( $myxml_data, $clustername );
[305]108        $ic->setBig();
[122]109
[300]110        if( isset( $filter ) ) {
111                foreach( $filter as $filtername=>$filtervalue ) {
112                        switch( $filtername ) {
113
[710]114                                case "id":
[300]115                                        $ic->setFilter( 'jobid', $filtervalue );
116                                        break;
[711]117                                case "owner":
[300]118                                        $ic->setFilter( 'owner', $filtervalue);
119                                        break;
[710]120                                case "queue":
[300]121                                        $ic->setFilter( 'queue', $filtervalue);
122                                        break;
[710]123                                case "state":
[300]124                                        $ic->setFilter( 'status', $filtervalue);
125                                        break;
126                                default:
127                                        break;
128                        }
[124]129                }
[122]130        }
[114]131        $ic->draw();
[110]132}
133
134switch( $view ) {
135
136        case "small-clusterimage":
137
138                drawSmallClusterImage();
139               
140                break;
141
142        case "big-clusterimage":
143
144                drawBigClusterImage();
145       
146                break;
147
[303]148        case "hostimage":
149
150                drawHostImage();
151       
152                break;
153
[110]154        default:
155
156                break;
157}
158
159?>
Note: See TracBrowser for help on using the repository browser.