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 303 2007-04-16 14:28:06Z bastiaans $ |
---|
23 | */ |
---|
24 | |
---|
25 | include_once "./libtoga.php"; |
---|
26 | |
---|
27 | if ( !empty( $_GET ) ) { |
---|
28 | extract( $_GET ); |
---|
29 | } |
---|
30 | |
---|
31 | $httpvars = new HTTPVariables( $HTTP_GET_VARS, $_GET ); |
---|
32 | $view = $httpvars->getHttpVar( "view" ); |
---|
33 | $clustername = $httpvars->getClusterName(); |
---|
34 | |
---|
35 | //printf("clustername = %s\n", $clustername ); |
---|
36 | if( isset($id) && ($id!='')) $filter[id]=$id; |
---|
37 | if( isset($state) && ($state!='')) $filter[state]=$state; |
---|
38 | if( isset($user) && ($user!='')) $filter[user]=$user; |
---|
39 | if( isset($queue) && ($queue!='')) $filter[queue]=$queue; |
---|
40 | |
---|
41 | function drawHostImage() { |
---|
42 | |
---|
43 | global $clustername, $hostname; |
---|
44 | |
---|
45 | $data_gatherer = new DataGatherer( $clustername ); |
---|
46 | $data_gatherer->parseXML(); |
---|
47 | |
---|
48 | if( $data_gatherer->isJobmonRunning() ) |
---|
49 | $ic = new HostImage( $data_gatherer, $clustername, $hostname ); |
---|
50 | else |
---|
51 | $ic = new EmptyImage(); |
---|
52 | |
---|
53 | $ic->draw(); |
---|
54 | } |
---|
55 | |
---|
56 | function drawSmallClusterImage() { |
---|
57 | |
---|
58 | global $clustername; |
---|
59 | |
---|
60 | $data_gatherer = new DataGatherer( $clustername ); |
---|
61 | $data_gatherer->parseXML(); |
---|
62 | |
---|
63 | if( $data_gatherer->isJobmonRunning() ) |
---|
64 | $ic = new ClusterImage( $clustername ); |
---|
65 | else |
---|
66 | $ic = new EmptyImage(); |
---|
67 | |
---|
68 | $ic->draw(); |
---|
69 | } |
---|
70 | |
---|
71 | function drawBigClusterImage() { |
---|
72 | |
---|
73 | global $filter, $clustername; |
---|
74 | |
---|
75 | $ic = new ClusterImage( $clustername ); |
---|
76 | |
---|
77 | if( isset( $filter ) ) { |
---|
78 | foreach( $filter as $filtername=>$filtervalue ) { |
---|
79 | //printf("filter %s,%s\n", $filtername, $filtervalue); |
---|
80 | switch( $filtername ) { |
---|
81 | |
---|
82 | case "id": |
---|
83 | $ic->setFilter( 'jobid', $filtervalue ); |
---|
84 | break; |
---|
85 | case "user": |
---|
86 | $ic->setFilter( 'owner', $filtervalue); |
---|
87 | break; |
---|
88 | case "queue": |
---|
89 | $ic->setFilter( 'queue', $filtervalue); |
---|
90 | break; |
---|
91 | case "state": |
---|
92 | $ic->setFilter( 'status', $filtervalue); |
---|
93 | break; |
---|
94 | default: |
---|
95 | break; |
---|
96 | } |
---|
97 | } |
---|
98 | } |
---|
99 | $ic->draw(); |
---|
100 | } |
---|
101 | |
---|
102 | switch( $view ) { |
---|
103 | |
---|
104 | case "small-clusterimage": |
---|
105 | |
---|
106 | drawSmallClusterImage(); |
---|
107 | |
---|
108 | break; |
---|
109 | |
---|
110 | case "big-clusterimage": |
---|
111 | |
---|
112 | drawBigClusterImage(); |
---|
113 | |
---|
114 | break; |
---|
115 | |
---|
116 | case "hostimage": |
---|
117 | |
---|
118 | drawHostImage(); |
---|
119 | |
---|
120 | break; |
---|
121 | |
---|
122 | default: |
---|
123 | |
---|
124 | break; |
---|
125 | } |
---|
126 | |
---|
127 | ?> |
---|