[532] | 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: index.php 527 2008-06-27 13:37:31Z ramonb $ |
---|
| 23 | */ |
---|
| 24 | |
---|
[648] | 25 | //ini_set("memory_limit","200M"); |
---|
| 26 | ini_set("memory_limit","1G"); |
---|
[532] | 27 | set_time_limit(0); |
---|
| 28 | |
---|
| 29 | |
---|
| 30 | $my_dir = getcwd(); |
---|
| 31 | |
---|
| 32 | global $r, $range; |
---|
| 33 | |
---|
| 34 | include_once "./libtoga.php"; |
---|
| 35 | |
---|
[592] | 36 | if ( !empty( $_GET ) ) |
---|
| 37 | { |
---|
[532] | 38 | extract( $_GET ); |
---|
| 39 | } |
---|
| 40 | |
---|
| 41 | global $GANGLIA_PATH; |
---|
| 42 | chdir( $GANGLIA_PATH ); |
---|
| 43 | |
---|
| 44 | include_once "./class.TemplatePower.inc.php"; |
---|
| 45 | chdir( $my_dir ); |
---|
| 46 | |
---|
[648] | 47 | $httpvars = new HTTPVariables( $HTTP_GET_VARS, $_GET ); |
---|
| 48 | $clustername = $httpvars->getClusterName(); |
---|
| 49 | $view = $httpvars->getHttpVar( "view" ); |
---|
[532] | 50 | |
---|
[648] | 51 | global $mySession, $myData, $myXML; |
---|
| 52 | |
---|
| 53 | //printf( "c %s\n", $clustername ); |
---|
| 54 | |
---|
| 55 | $mySession = new SessionHandler( $clustername ); |
---|
| 56 | $mySession->checkSession(); |
---|
| 57 | |
---|
| 58 | $session = &$mySession->getSession(); |
---|
| 59 | $myXML = $session['data']; |
---|
| 60 | |
---|
| 61 | $myData = new DataGatherer( $clustername ); |
---|
| 62 | $myData->parseXML( $myXML ); |
---|
| 63 | |
---|
| 64 | $mySession->updatePollInterval( $myData->getPollInterval() ); |
---|
| 65 | $mySession->endSession(); |
---|
| 66 | |
---|
[532] | 67 | $filter = array(); |
---|
| 68 | |
---|
| 69 | if( !isset($view) ) $view = "overview"; |
---|
| 70 | if( !isset($sortorder) ) $sortorder = "asc"; |
---|
| 71 | if( !isset($sortby) ) $sortby = "id"; |
---|
| 72 | |
---|
[592] | 73 | if( isset( $filterorder ) && ($filterorder!='') ) |
---|
| 74 | { |
---|
[532] | 75 | $myfilter_fields = explode( ",", $filterorder ); |
---|
| 76 | } |
---|
[592] | 77 | else |
---|
| 78 | { |
---|
| 79 | if( isset($queue) && ($queue!='')) $filter['queue']=$queue; |
---|
| 80 | if( isset($state) && ($state!='')) $filter['state']=$state; |
---|
| 81 | if( isset($user) && ($user!='')) $filter['user']=$user; |
---|
| 82 | if( isset($id) && ($id!='')) $filter['id']=$id; |
---|
| 83 | } |
---|
[532] | 84 | |
---|
| 85 | // Fill filter array in order they were picked by user |
---|
[592] | 86 | if( isset($myfilter_fields) ) |
---|
| 87 | { |
---|
| 88 | foreach( $myfilter_fields as $myfilter ) |
---|
| 89 | { |
---|
| 90 | switch( $myfilter ) |
---|
| 91 | { |
---|
[532] | 92 | case "queue": |
---|
[592] | 93 | $filter['queue']=$queue; |
---|
[532] | 94 | break; |
---|
| 95 | case "state": |
---|
[592] | 96 | $filter['state']=$state; |
---|
[532] | 97 | break; |
---|
| 98 | case "user": |
---|
[592] | 99 | $filter['user']=$user; |
---|
[532] | 100 | break; |
---|
| 101 | case "id": |
---|
[592] | 102 | $filter['id']=$id; |
---|
[532] | 103 | break; |
---|
| 104 | } |
---|
| 105 | } |
---|
| 106 | } |
---|
| 107 | |
---|
[592] | 108 | function epochToDatetime( $epoch ) |
---|
| 109 | { |
---|
[532] | 110 | return strftime( "%d-%m-%Y %H:%M:%S", $epoch ); |
---|
| 111 | } |
---|
| 112 | |
---|
| 113 | |
---|
[592] | 114 | function makeFooter() |
---|
| 115 | { |
---|
[532] | 116 | global $tpl, $version, $parsetime, $monarchversion; |
---|
| 117 | |
---|
| 118 | $tpl->gotoBlock( "_ROOT" ); |
---|
| 119 | $tpl->assign("webfrontend-version",$version["webfrontend"]); |
---|
| 120 | $tpl->assign("monarch-version", $monarchversion); |
---|
| 121 | |
---|
[592] | 122 | if ($version["gmetad"]) |
---|
| 123 | { |
---|
[532] | 124 | $tpl->assign("webbackend-component", "gmetad"); |
---|
| 125 | $tpl->assign("webbackend-version",$version["gmetad"]); |
---|
[592] | 126 | } |
---|
| 127 | else if ($version["gmond"]) |
---|
| 128 | { |
---|
[532] | 129 | $tpl->assign("webbackend-component", "gmond"); |
---|
| 130 | $tpl->assign("webbackend-version", $version["gmond"]); |
---|
| 131 | } |
---|
| 132 | |
---|
| 133 | $tpl->assign("parsetime", sprintf("%.4f", $parsetime) . "s"); |
---|
| 134 | } |
---|
| 135 | |
---|
[592] | 136 | function includeSearchpage() |
---|
| 137 | { |
---|
[532] | 138 | global $tpl; |
---|
| 139 | |
---|
| 140 | $tpl->assignInclude( "main", "templates/search.tpl" ); |
---|
| 141 | } |
---|
| 142 | |
---|
[592] | 143 | function includeOverview() |
---|
| 144 | { |
---|
[532] | 145 | global $tpl; |
---|
| 146 | |
---|
| 147 | $tpl->assignInclude( "main", "templates/overview.tpl" ); |
---|
| 148 | } |
---|
| 149 | |
---|
[592] | 150 | function includeHostPage() |
---|
| 151 | { |
---|
[532] | 152 | global $tpl; |
---|
| 153 | |
---|
| 154 | $tpl->assignInclude( "main", "templates/host_view.tpl" ); |
---|
| 155 | } |
---|
| 156 | |
---|
| 157 | $tpl = new TemplatePower( "templates/index.tpl" ); |
---|
| 158 | |
---|
| 159 | $tpl->assignInclude( "header", "templates/header.tpl" ); |
---|
| 160 | |
---|
[592] | 161 | if( isset( $h ) and $h != '' ) |
---|
| 162 | { |
---|
[532] | 163 | $hostname = $h; |
---|
| 164 | } |
---|
[648] | 165 | $ic = new ClusterImage( $myData, $clustername ); |
---|
| 166 | $ic->setBig(); |
---|
| 167 | $ic->setNoimage(); |
---|
| 168 | $ic->draw(); |
---|
[532] | 169 | |
---|
[648] | 170 | //printf("%s\n", $ic->getImagemapArea() ); |
---|
| 171 | |
---|
| 172 | |
---|
[592] | 173 | switch( $view ) |
---|
| 174 | { |
---|
[532] | 175 | case "overview": |
---|
| 176 | |
---|
[648] | 177 | //includeOverview(); |
---|
[532] | 178 | break; |
---|
| 179 | |
---|
| 180 | case "search": |
---|
| 181 | |
---|
[648] | 182 | //includeSearchPage(); |
---|
[532] | 183 | break; |
---|
| 184 | |
---|
| 185 | case "host": |
---|
| 186 | |
---|
[648] | 187 | //includeHostPage(); |
---|
[532] | 188 | break; |
---|
| 189 | |
---|
| 190 | default: |
---|
| 191 | |
---|
[648] | 192 | //includeOverview(); |
---|
[532] | 193 | break; |
---|
| 194 | } |
---|
| 195 | |
---|
| 196 | $tpl->assignInclude( "footer", "templates/footer.tpl" ); |
---|
| 197 | $tpl->prepare(); |
---|
| 198 | |
---|
| 199 | $longtitle = "Batch Report :: Powered by Job Monarch!"; |
---|
| 200 | $title = "Batch Report"; |
---|
| 201 | $tpl->assign("cluster_url", rawurlencode($clustername) ); |
---|
| 202 | $tpl->assign("cluster", $clustername ); |
---|
| 203 | |
---|
[648] | 204 | session_start(); |
---|
| 205 | $tpl->assign( "session_name", session_name() ); |
---|
| 206 | $tpl->assign( "session_id", session_id() ); |
---|
| 207 | |
---|
| 208 | $rjqj_str .= "./graph.php?z=small&c=$clustername&g=job_report&r=$range&st=$cluster[LOCALTIME]"; |
---|
| 209 | |
---|
| 210 | $tpl->assign( "rjqj_graph", $rjqj_str ); |
---|
| 211 | $tpl->assign( "uue_clustername", rawurlencode($clustername) ); |
---|
| 212 | |
---|
| 213 | $tpl->assign( "node_area_map", $ic->getImagemapArea() ); |
---|
| 214 | |
---|
[592] | 215 | switch( $view ) |
---|
| 216 | { |
---|
[532] | 217 | case "overview": |
---|
| 218 | |
---|
[648] | 219 | //include "./overview.php"; |
---|
| 220 | //makeOverview(); |
---|
[532] | 221 | break; |
---|
| 222 | |
---|
| 223 | case "search": |
---|
| 224 | |
---|
[648] | 225 | //include "./search.php"; |
---|
| 226 | //makeSearchPage(); |
---|
[532] | 227 | break; |
---|
| 228 | |
---|
| 229 | case "host": |
---|
| 230 | |
---|
[648] | 231 | //include "./host_view.php"; |
---|
| 232 | //makeHostView(); |
---|
[532] | 233 | break; |
---|
| 234 | |
---|
| 235 | default: |
---|
| 236 | |
---|
[648] | 237 | //makeOverview(); |
---|
[532] | 238 | break; |
---|
| 239 | } |
---|
| 240 | |
---|
| 241 | makeFooter(); |
---|
| 242 | $tpl->printToScreen(); |
---|
| 243 | ?> |
---|