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

Last change on this file since 758 was 718, checked in by ramonb, 11 years ago
  • cleanup
  • Property svn:keywords set to Id
File size: 3.6 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 718 2013-03-21 20:44:55Z ramonb $
[225]23 */
24
[110]25include_once "./libtoga.php";
26
[122]27if ( !empty( $_GET ) ) {
28        extract( $_GET );
29}
30
[326]31function checkSessionData() {
32
[718]33    global $_SESSION;
[326]34
[718]35    session_start();
[326]36
[718]37    if( isset( $_SESSION["data"] ) ) {
38        $myxml_data    = &$_SESSION["data"];
39    } else {
40        $myxml_data    = 0;
41    }
[326]42
[718]43    if( !$myxml_data ) {
44        $ds             = new DataSource();
45        $myxml_data     = $ds->getData();
[326]46
[718]47    }
48    return $myxml_data;
[326]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
[718]63    global $clustername, $hostname, $data_gatherer;
[303]64
[718]65    $ds             = new DataSource();
66    $myxml_data     = $ds->getData();
[303]67
[718]68    $data_gatherer    = new DataGatherer( $clustername );
[326]69
[718]70    $data_gatherer->parseXML( $myxml_data );
[326]71
[718]72    if( $data_gatherer->isJobmonRunning() )
73        $ic = new HostImage( $data_gatherer, $clustername, $hostname );
74    else
75        $ic = new EmptyImage();
[303]76
[718]77    $ic->draw();
[303]78}
79
[110]80function drawSmallClusterImage() {
81
[718]82    global $clustername, $data_gatherer;
[164]83
[718]84    $ds             = new DataSource();
85    $myxml_data     = $ds->getData();
[298]86
[718]87    $data_gatherer    = new DataGatherer( $clustername );
[326]88
[718]89    $data_gatherer->parseXML( $myxml_data );
[326]90
[718]91    if( $data_gatherer->isJobmonRunning() ) {
92        $ic = new ClusterImage( $myxml_data, $clustername );
93        $ic->setSmall();
94    } else {
95        $ic = new EmptyImage();
96    }
[298]97
[718]98    $ic->draw();
[110]99}
100
101function drawBigClusterImage() {
102
[718]103    global $filter, $clustername;
[122]104
[718]105    $myxml_data    = checkSessionData();
[326]106
[718]107    $ic = new ClusterImage( $myxml_data, $clustername );
108    $ic->setBig();
[122]109
[718]110    if( isset( $filter ) ) {
111        foreach( $filter as $filtername=>$filtervalue ) {
112            switch( $filtername ) {
[300]113
[718]114                case "id":
115                    $ic->setFilter( 'jobid', $filtervalue );
116                    break;
117                case "owner":
118                    $ic->setFilter( 'owner', $filtervalue);
119                    break;
120                case "queue":
121                    $ic->setFilter( 'queue', $filtervalue);
122                    break;
123                case "state":
124                    $ic->setFilter( 'status', $filtervalue);
125                    break;
126                default:
127                    break;
128            }
129        }
130    }
131    $ic->draw();
[110]132}
133
134switch( $view ) {
135
[718]136    case "small-clusterimage":
[110]137
[718]138        drawSmallClusterImage();
139       
140        break;
[110]141
[718]142    case "big-clusterimage":
[110]143
[718]144        drawBigClusterImage();
145   
146        break;
[110]147
[718]148    case "hostimage":
[303]149
[718]150        drawHostImage();
151   
152        break;
[303]153
[718]154    default:
[110]155
[718]156        break;
[110]157}
158
159?>
Note: See TracBrowser for help on using the repository browser.