source: branches/1.1/web/addons/job_monarch/image.php @ 934

Last change on this file since 934 was 765, checked in by ramonb, 11 years ago
  • Property svn:keywords set to Id
File size: 3.7 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: image.php 765 2013-03-28 11:21:53Z ramonb $
23 */
24
25include_once "./libtoga.php";
26
27if ( !empty( $_GET ) ) {
28        extract( $_GET );
29}
30
31function checkSessionData() {
32
33    global $_SESSION;
34
35    session_start();
36
37    if( isset( $_SESSION["data"] ) ) 
38    {
39        $myxml_data    = &$_SESSION["data"];
40    } 
41    else 
42    {
43        $myxml_data    = null;
44    }
45
46    if( $myxml_data == null ) 
47    {
48        $ds             = new DataSource();
49        $myxml_data     = $ds->getData();
50    }
51    return $myxml_data;
52}
53
54
55$httpvars = new HTTPVariables( $HTTP_GET_VARS, $_GET );
56$view = $httpvars->getHttpVar( "j_view" );
57$clustername = $httpvars->getClusterName();
58
59if( isset($id) && ($id!='')) $filter['id']=$id;
60if( isset($state) && ($state!='')) $filter['state']=$state;
61if( isset($owner) && ($owner!='')) $filter['owner']=$owner;
62if( isset($queue) && ($queue!='')) $filter['queue']=$queue;
63
64function drawHostImage() {
65
66    global $clustername, $hostname, $data_gatherer;
67
68    $ds             = new DataSource();
69    $myxml_data     = $ds->getData();
70
71    $data_gatherer    = new DataGatherer( $clustername );
72
73    $data_gatherer->parseXML( $myxml_data );
74
75    if( $data_gatherer->isJobmonRunning() )
76        $ic = new HostImage( $data_gatherer, $clustername, $hostname );
77    else
78        $ic = new EmptyImage();
79
80    $ic->draw();
81}
82
83function drawSmallClusterImage() {
84
85    global $clustername, $data_gatherer;
86
87    $ds             = new DataSource();
88    $myxml_data     = $ds->getData();
89
90    $data_gatherer    = new DataGatherer( $clustername );
91
92    $data_gatherer->parseXML( $myxml_data );
93
94    if( $data_gatherer->isJobmonRunning() ) {
95        $ic = new ClusterImage( $myxml_data, $clustername );
96        $ic->setSmall();
97    } else {
98        $ic = new EmptyImage();
99    }
100
101    $ic->draw();
102}
103
104function drawBigClusterImage() {
105
106    global $filter, $clustername;
107
108    $myxml_data    = checkSessionData();
109
110    $ic = new ClusterImage( $myxml_data, $clustername );
111    $ic->setBig();
112
113    if( isset( $filter ) ) {
114        foreach( $filter as $filtername=>$filtervalue ) {
115            switch( $filtername ) {
116
117                case "id":
118                    $ic->setFilter( 'jobid', $filtervalue );
119                    break;
120                case "owner":
121                    $ic->setFilter( 'owner', $filtervalue);
122                    break;
123                case "queue":
124                    $ic->setFilter( 'queue', $filtervalue);
125                    break;
126                case "state":
127                    $ic->setFilter( 'status', $filtervalue);
128                    break;
129                default:
130                    break;
131            }
132        }
133    }
134    $ic->draw();
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
151    case "hostimage":
152
153        drawHostImage();
154   
155        break;
156
157    default:
158
159        break;
160}
161
162?>
Note: See TracBrowser for help on using the repository browser.