source: trunk/web2/addons/job_monarch/image.php @ 566

Last change on this file since 566 was 563, checked in by ramonb, 15 years ago

web2/addons/job_monarch/image.php:

  • added query search option for node filtering

web2/addons/job_monarch/jobstore.php:

  • also search nodes and jobid with query

web2/addons/job_monarch/js/jobgrid.js:

  • added load event to datastore to trigger clusterimage reload and include any searchfield query

web2/addons/job_monarch/libtoga.php:

  • added query filter for clusterimage node filtering
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 329 2007-04-22 13:36:26Z bastiaans $
23 */
24
25ini_set("memory_limit","200M");
26set_time_limit(0);
27
28include_once "./libtoga.php";
29
30if ( !empty( $_GET ) ) {
31        extract( $_GET );
32}
33
34function checkSessionData() {
35
36        global $_SESSION;
37
38        session_start();
39
40        if( isset( $_SESSION["data"] ) ) {
41                $myxml_data     = &$_SESSION["data"];
42        } else {
43                $myxml_data     = 0;
44        }
45
46        if( !$myxml_data ) {
47                $ds             = new DataSource();
48                $myxml_data     = $ds->getData();
49
50                //print_f( "%s\n", $myxml_data );
51        }
52        return $myxml_data;
53}
54
55
56$httpvars = new HTTPVariables( $HTTP_GET_VARS, $_GET );
57$view = $httpvars->getHttpVar( "view" );
58$host = $httpvars->getHttpVar( "host" );
59$query = $httpvars->getHttpVar( "query" );
60$clustername = $httpvars->getClusterName();
61
62if( isset($jid) && ($jid!='')) $filter[jid]=$jid;
63if( isset($state) && ($state!='')) $filter[state]=$state;
64if( isset($owner) && ($owner!='')) $filter[owner]=$owner;
65if( isset($queue) && ($queue!='')) $filter[queue]=$queue;
66if( isset($host) && ($host!='')) $filter[host]=$host;
67if( isset($query) && ($query!='')) $filter[query]=$query;
68//printf("host = %s\n", $filter[host] );
69
70function drawHostImage() {
71
72        global $clustername, $hostname, $data_gatherer;
73
74        $ds             = new DataSource();
75        $myxml_data     = $ds->getData();
76
77        $data_gatherer  = new DataGatherer( $clustername );
78
79        $data_gatherer->parseXML( $myxml_data );
80
81        if( $data_gatherer->isJobmonRunning() )
82                $ic = new HostImage( $data_gatherer, $clustername, $hostname );
83        else
84                $ic = new EmptyImage();
85
86        $ic->draw();
87}
88
89function drawSmallClusterImage() {
90
91        global $clustername, $data_gatherer;
92
93        $ds             = new DataSource();
94        $myxml_data     = $ds->getData();
95
96        $data_gatherer  = new DataGatherer( $clustername );
97
98        $data_gatherer->parseXML( $myxml_data );
99
100        if( $data_gatherer->isJobmonRunning() ) {
101                $ic = new ClusterImage( $myxml_data, $clustername );
102                $ic->setSmall();
103        } else {
104                $ic = new EmptyImage();
105        }
106
107        $ic->draw();
108}
109
110function drawBigClusterImage() {
111
112        global $filter, $clustername;
113
114        $myxml_data     = checkSessionData();
115
116        $ic = new ClusterImage( $myxml_data, $clustername );
117        $ic->setBig();
118
119        if( isset( $filter ) ) {
120                foreach( $filter as $filtername=>$filtervalue ) {
121                        //printf("filter %s,%s\n", $filtername, $filtervalue);
122                        switch( $filtername ) {
123
124                                case "jid":
125                                        $ic->setFilter( 'jobid', $filtervalue );
126                                        break;
127                                case "owner":
128                                        $ic->setFilter( 'owner', $filtervalue);
129                                        break;
130                                case "queue":
131                                        $ic->setFilter( 'queue', $filtervalue);
132                                        break;
133                                case "state":
134                                        $ic->setFilter( 'status', $filtervalue);
135                                        break;
136                                case "host":
137                                        $ic->setFilter( 'host', $filtervalue);
138                                        break;
139                                case "query":
140                                        $ic->setFilter( 'query', $filtervalue);
141                                        break;
142                                default:
143                                        break;
144                        }
145                }
146        }
147        $ic->draw();
148}
149
150switch( $view ) {
151
152        case "small-clusterimage":
153
154                drawSmallClusterImage();
155               
156                break;
157
158        case "big-clusterimage":
159
160                drawBigClusterImage();
161       
162                break;
163
164        case "hostimage":
165
166                drawHostImage();
167       
168                break;
169
170        default:
171
172                break;
173}
174
175?>
Note: See TracBrowser for help on using the repository browser.