source: trunk/web/addons/job_monarch/image.php @ 434

Last change on this file since 434 was 329, checked in by bastiaans, 17 years ago

web/addons/job_monarch/conf.php:

  • added SORTBY_HOSTNAME, SORT_ORDER, SORT_XLABEL, SORT_YLABEL

web/addons/job_monarch/image.php:

  • removed debug statement

web/addons/job_monarch/libtoga.php:

  • added x, y sorting if SORTBY_HOSTNAME is set
  • added array_rem to remove value from array
  • added cmp function for sorting of nodes according to SORTBY_HOSTNAME x, y setting
  • Property svn:keywords set to Id
File size: 3.3 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 329 2007-04-22 13:36:26Z bastiaans $
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                $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                //print_f( "%s\n", $myxml_data );
48        }
49        return $myxml_data;
50}
51
52
53$httpvars = new HTTPVariables( $HTTP_GET_VARS, $_GET );
54$view = $httpvars->getHttpVar( "view" );
55$clustername = $httpvars->getClusterName();
56
57//printf("clustername = %s\n", $clustername );
58if( isset($id) && ($id!='')) $filter[id]=$id;
59if( isset($state) && ($state!='')) $filter[state]=$state;
60if( isset($user) && ($user!='')) $filter[user]=$user;
61if( isset($queue) && ($queue!='')) $filter[queue]=$queue;
62
63function drawHostImage() {
64
65        global $clustername, $hostname, $data_gatherer;
66
67        $ds             = new DataSource();
68        $myxml_data     = $ds->getData();
69
70        $data_gatherer  = new DataGatherer( $clustername );
71
72        $data_gatherer->parseXML( $myxml_data );
73
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
82function drawSmallClusterImage() {
83
84        global $clustername, $data_gatherer;
85
86        $ds             = new DataSource();
87        $myxml_data     = $ds->getData();
88
89        $data_gatherer  = new DataGatherer( $clustername );
90
91        $data_gatherer->parseXML( $myxml_data );
92
93        if( $data_gatherer->isJobmonRunning() ) {
94                $ic = new ClusterImage( $myxml_data, $clustername );
95                $ic->setSmall();
96        } else {
97                $ic = new EmptyImage();
98        }
99
100        $ic->draw();
101}
102
103function drawBigClusterImage() {
104
105        global $filter, $clustername;
106
107        $myxml_data     = checkSessionData();
108
109        $ic = new ClusterImage( $myxml_data, $clustername );
110        $ic->setBig();
111
112        if( isset( $filter ) ) {
113                foreach( $filter as $filtername=>$filtervalue ) {
114                        //printf("filter %s,%s\n", $filtername, $filtervalue);
115                        switch( $filtername ) {
116
117                                case "id":
118                                        $ic->setFilter( 'jobid', $filtervalue );
119                                        break;
120                                case "user":
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.