Changeset 720 for branches/0.4/web/addons/job_monarch/host_view.php
- Timestamp:
- 03/21/13 21:53:01 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/0.4/web/addons/job_monarch/host_view.php
r719 r720 25 25 include_once "./libtoga.php"; 26 26 27 //$tpl = new TemplatePower( "templates/host_view.tpl" ); 28 //$tpl->assignInclude("extra", "templates/host_extra.tpl"); 29 //$tpl->prepare(); 30 31 function datetimeToEpoch( $datetime ) { 32 33 //printf("datetime = %s\n", $datetime ); 27 function datetimeToEpoch( $datetime ) 28 { 29 34 30 $datetime_fields = explode( ' ', $datetime ); 35 31 … … 51 47 $seconds = $time_fields[2]; 52 48 53 //printf( "hours = %s minutes = %s seconds = %s\n", $hours, $minutes, $seconds );54 55 49 $timestamp = mktime( $hours, $minutes, $seconds, $months, $days, $years ); 56 57 //printf( "timestamp = %s\n", $timestamp );58 50 59 51 return $timestamp; 60 52 } 61 53 62 function makeHostView() { 54 function makeHostView() 55 { 63 56 64 57 global $tpl, $metrics, $clustername, $hostname; … … 67 60 global $job_start, $job_stop; 68 61 69 //print_r( $metrics );70 71 //printf( "c %s\n", $clustername );72 73 62 $trd = new TarchRrdGraph( $clustername, $hostname ); 74 63 $rrdirs = $trd->getRrdDirs( $period_start, $period_stop ); … … 100 89 101 90 $hosts_up = $hosts_up[$hostname]; 102 //print_r( $hosts_up );103 91 104 92 $tpl->assign("cluster", $clustername); … … 108 96 $tpl->assign("range",$range); 109 97 110 if( !is_numeric( $period_start ) ) { 98 if( !is_numeric( $period_start ) ) 99 { 111 100 $period_start = datetimeToEpoch( $period_start ); 112 101 } 113 if( !is_numeric( $period_stop ) ) { 102 if( !is_numeric( $period_stop ) ) 103 { 114 104 $period_stop = datetimeToEpoch( $period_stop ); 115 105 } … … 122 112 $cluster_url=rawurlencode($clustername); 123 113 $tpl->assign("cluster_url", $cluster_url); 124 //$tpl->assign("graphargs", "h=$hostname&$get_metric_string&st=$cluster[LOCALTIME]&job_start=$job_start&job_stop=$job_stop&period_start=$period_start&period_stop=$period_stop");125 114 $tpl->assign("graphargs", "h=$hostname&$get_metric_string&job_start=$job_start&job_stop=$job_stop&period_start=$period_start&period_stop=$period_stop"); 126 115 … … 128 117 $tpl->assign("node_view","./?p=2&c=$cluster_url&h=$hostname"); 129 118 130 //# No reason to go on if this node is down.131 //if ($hosts_down)132 // {133 // $tpl->printToScreen();134 // return;135 // }136 137 119 $tpl->assign("ip", $hosts_up[IP]); 138 120 139 121 foreach ($mymetrics as $name => $v) 140 141 142 143 144 145 146 147 148 149 150 151 continue;152 else153 {154 //$graphargs = "c=$cluster_url&h=$hostname&v=$v[VAL]&m=$name"155 // ."&z=medium&st=$cluster[LOCALTIME]&job_start=$job_start&job_stop=$job_stop&period_start=$period_start&period_stop=$period_stop";156 122 { 123 if ($v[TYPE] == "string" or $v[TYPE]=="timestamp" or $always_timestamp[$name]) 124 { 125 # Long gmetric name/values will disrupt the display here. 126 if ($v[SOURCE] == "gmond") $s_metrics[$name] = $v; 127 } 128 elseif ($v[SLOPE] == "zero" or $always_constant[$name]) 129 { 130 $c_metrics[$name] = $v; 131 } 132 else if ($reports[$metric]) 133 { 134 continue; 135 } 136 else 137 { 138 $graphargs = "c=$cluster_url&h=$hostname&m=$name" 157 139 ."&z=medium&job_start=$job_start&job_stop=$job_stop&period_start=$period_start&period_stop=$period_stop"; 158 # Adding units to graph 2003 by Jason Smith <smithj4@bnl.gov>. 159 if ($v[UNITS]) { 160 $encodeUnits = rawurlencode($v[UNITS]); 161 $graphargs .= "&vl=$encodeUnits"; 162 } 163 $g_metrics[$name][graph] = $graphargs; 164 } 165 } 140 # Adding units to graph 2003 by Jason Smith <smithj4@bnl.gov>. 141 if ($v[UNITS]) 142 { 143 $encodeUnits = rawurlencode($v[UNITS]); 144 $graphargs .= "&vl=$encodeUnits"; 145 } 146 $g_metrics[$name][graph] = $graphargs; 147 } 148 } 166 149 # Add the uptime metric for this host. Cannot be done in ganglia.php, 167 150 # since it requires a fully-parsed XML tree. The classic contructor problem. … … 178 161 # Show string metrics 179 162 if (is_array($s_metrics)) 180 181 182 183 184 $tpl->newBlock("string_metric_info");185 $tpl->assign("name", $name);186 if( $v[TYPE]=="timestamp" or $always_timestamp[$name])187 {188 $tpl->assign("value", date("r", $v[VAL]));189 }190 else191 {192 $tpl->assign("value", "$v[VAL] $v[UNITS]");193 }194 195 163 { 164 ksort($s_metrics); 165 foreach ($s_metrics as $name => $v ) 166 { 167 $tpl->newBlock("string_metric_info"); 168 $tpl->assign("name", $name); 169 if( $v[TYPE]=="timestamp" or $always_timestamp[$name]) 170 { 171 $tpl->assign("value", date("r", $v[VAL])); 172 } 173 else 174 { 175 $tpl->assign("value", "$v[VAL] $v[UNITS]"); 176 } 177 } 178 } 196 179 197 180 # Show constant metrics. 198 181 if (is_array($c_metrics)) 199 200 201 202 203 $tpl->newBlock("const_metric_info");204 $tpl->assign("name", $name);205 $tpl->assign("value", "$v[VAL] $v[UNITS]");206 207 182 { 183 ksort($c_metrics); 184 foreach ($c_metrics as $name => $v ) 185 { 186 $tpl->newBlock("const_metric_info"); 187 $tpl->assign("name", $name); 188 $tpl->assign("value", "$v[VAL] $v[UNITS]"); 189 } 190 } 208 191 209 192 # Show graphs. 210 193 if (is_array($g_metrics)) 211 212 213 214 215 216 194 { 195 ksort($g_metrics); 196 197 $i = 0; 198 foreach ( $g_metrics as $name => $v ) 199 { 217 200 $tpl->newBlock("vol_metric_info"); 218 201 $tpl->assign("graphargs", $v[graph]); 219 202 $tpl->assign("alt", "$hostname $name"); 220 203 if($i++ %2) 221 $tpl->assign("br", "<BR>"); 204 { 205 $tpl->assign("br", "<BR>"); 206 } 222 207 } 223 208 } 224 209 } 225 210 226 //$tpl->printToScreen();227 211 ?>
Note: See TracChangeset
for help on using the changeset viewer.