From bbdd2d949c4f1dc8db02dcc184d651f534a7b2a5 Mon Sep 17 00:00:00 2001 From: Panos Date: Wed, 8 Dec 2010 00:29:48 -0500 Subject: [PATCH] A new version of the column configuration interface including two new default columns (date_created and uptime) and correct updating of the person configuration tags --- planetlab/nodes/nodes.php | 78 +++++++++-- planetlab/slices/slice.php | 17 ++- plekit/php/columns.php | 177 +++++++++++++++++++------ plekit/php/updateColumn.php | 83 +++++++++++- plekit/php/updateConfiguration.php | 13 +- plekit/table/columns.js | 202 +++++++++++++++++++++-------- 6 files changed, 453 insertions(+), 117 deletions(-) diff --git a/planetlab/nodes/nodes.php b/planetlab/nodes/nodes.php index 7800b31..30d69a7 100644 --- a/planetlab/nodes/nodes.php +++ b/planetlab/nodes/nodes.php @@ -72,7 +72,7 @@ function node_status ($node) { } -$first_time_configuration = 'false'; +$first_time_configuration = false; if (plc_is_admin()) $default_configuration = "ID:f|hostname:f|ST:f|AU:f"; @@ -82,6 +82,9 @@ else //$extra_default = "LCN|DN|R|L|OS|MS|SN"; $column_configuration = ""; $slice_column_configuration = ""; +$show_configuration = ""; +$show_columns_message = '1'; + $PersonTags=$api->GetPersonTags (array('person_id'=>$plc->person['person_id'])); //print_r($PersonTags); @@ -91,6 +94,11 @@ foreach ($PersonTags as $ptag) { $column_configuration = $ptag['value']; $conf_tag_id = $ptag['person_tag_id']; } + if ($ptag['tagname'] == 'showconf') + { + $show_configuration = $ptag['value']; + $show_tag_id = $ptag['person_tag_id']; + } } //print("column configuration = ".$column_configuration); @@ -98,6 +106,7 @@ foreach ($PersonTags as $ptag) { $nodesconf_exists = false; if ($column_configuration == "") { + $first_time_configuration = true; $column_configuration = "nodes;default"; $nodesconf_exists = true; } @@ -134,7 +143,7 @@ else //print("full configuration = ".$full_configuration); // fetch nodes -$node_fixed_columns=array('hostname','node_type','site_id','node_id','boot_state','last_contact','interface_ids','peer_id', 'slice_ids'); +$node_fixed_columns=array('node_type','site_id','boot_state','last_contact','interface_ids','peer_id', 'slice_ids'); $fix_columns = array(); if (plc_is_admin()) @@ -150,10 +159,14 @@ $visibletags->columns(); $tag_columns = $visibletags->headers(); $extra_columns = array(); -$extra_columns[]=array('tagname'=>'sitename', 'header'=>'SN', 'type'=>'string', 'title'=>'Site name', 'fetched'=>true); -$extra_columns[]=array('tagname'=>'domain', 'header'=>'DN', 'type'=>'string', 'title'=>'Toplevel domain name', 'fetched'=>true); -$extra_columns[]=array('tagname'=>'ipaddress', 'header'=>'IP', 'type'=>'string', 'title'=>'IP Address', 'fetched'=>true); -$extra_columns[]=array('tagname'=>'fcdistro', 'header'=>'OS', 'type'=>'string', 'title'=>'Operating system', 'fetched'=>false); +$extra_columns[]=array('tagname'=>'sitename', 'header'=>'SN', 'type'=>'string', 'title'=>'Site name', 'fetched'=>true, 'source'=>'myplc'); +$extra_columns[]=array('tagname'=>'domain', 'header'=>'DN', 'type'=>'string', 'title'=>'Toplevel domain name', 'fetched'=>true, 'source'=>'myplc'); +$extra_columns[]=array('tagname'=>'ipaddress', 'header'=>'IP', 'type'=>'string', 'title'=>'IP Address', 'fetched'=>true, 'source'=>'myplc'); +$extra_columns[]=array('tagname'=>'fcdistro', 'header'=>'OS', 'type'=>'string', 'title'=>'Operating system', 'fetched'=>false, 'source'=>'myplc'); +$extra_columns[]=array('tagname'=>'uptime', 'header'=>'UT', 'source'=>'comon', 'type'=>'sortAlphaNumericTop', 'title'=>'Continuous uptime until now', 'fetched'=>false); +$extra_columns[]=array('tagname'=>'date_created', 'header'=>'DA', 'source'=>'myplc', 'type'=>'date', 'title'=>'Date added', 'fetched'=>false); +//$extra_columns[]=array('tagname'=>'hopcount', 'header'=>'HC', 'source'=>'tophat', 'type'=>'sortAlphaNumericTop', 'title'=>'Hop count from reference node', 'fetched'=>false); + $ConfigureColumns =new PlekitColumns($full_configuration, $fix_columns, $tag_columns, $extra_columns); @@ -217,8 +230,23 @@ if ($person_id) { } // go +//print("getting nodes ".$node_columns); +//print_r($node_columns); $nodes=$api->GetNodes($node_filter,$node_columns); +//print("

GOT NODES

"); +//print_r($nodes); + +$ConfigureColumns->fetch_live_data($nodes); + +$show_conf = explode(";",$show_configuration); +foreach ($show_conf as $ss) { + if ($ss =="columns") + $show_columns_message = '0'; +} + + + // build site_ids - interface_ids $site_ids=array(); $interface_ids=array(); @@ -293,21 +321,40 @@ $info_header[$short]=array('type'=>$type,'title'=>$long, 'label'=>'?', 'header'= //$info_header["?"] = "none"; $headers = array_merge($ConfigureColumns->get_headers(),$info_header); -//print("

HEADERS"); -//print_r($headers); +if ($first_time_configuration) +$column_conf_visible = '1'; +else +$column_conf_visible = '0'; $toggle_nodes=new PlekitToggle('nodes-column-configuration', "Node table layout", - array('visible'=>'1')); + array('visible'=>$column_conf_visible, 'info_div'=>'note_columns_div')); $toggle_nodes->start(); print("

"); print(""); print(""); print(""); +print(""); +print(""); print(""); print("
"); -//print(""); print(""); + +if ($show_columns_message == '0') +$note_display = "display:none;"; +else +$note_display = ""; + + +print << +
+This tab allows you to customize the columns in the node tables, below. Information on the nodes comes from a variety of monitoring sources. If you, as either a user or a provider of monitoring data, would like to see additional columns made available, please send us your request in mail to support@myslice.info. You can find more information about the MySlice project at http://trac.myslice.info. +hide message permanently +
+ +EOF; + $ConfigureColumns->configuration_panel_html(true); $ConfigureColumns->javascript_init(); $toggle_nodes->end(); @@ -339,12 +386,15 @@ foreach ($nodes as $node) { if (plc_is_admin()) $table->cell(l_node_t($node_id,$node_id)); $table->cell (l_node_t($node_id,$hostname)); $peers->cell ($table,$peer_id); - //$table->cell (topdomain($hostname)); + + //prefetch some columns $node['domain'] = topdomain($hostname); - //$table->cell (l_site_t($site_id,$login_base)); $node['sitename'] = l_site_t($site_id,$login_base); - //$table->cell (l_interface_t($interface_id,$ip),array('only-if'=> !$peer_id)); - $node['ipaddress'] = l_interface_t($interface_id,$ip); + if ($interface_id) + $node['ipaddress'] = l_interface_t($interface_id,$ip); + else + $node['ipaddress'] = "n/a"; + list($label,$class) = Node::status_label_class_($node); $table->cell ($label,array('class'=>$class)); //$table->cell (count($node['slice_ids'])); diff --git a/planetlab/slices/slice.php b/planetlab/slices/slice.php index d65e147..3975fbb 100644 --- a/planetlab/slices/slice.php +++ b/planetlab/slices/slice.php @@ -1,5 +1,7 @@ columns(); $tag_columns = $visibletags->headers(); -// extra columns that are not tags (for the moment not sorted correctly) - $extra_columns = array(); $extra_columns[]=array('tagname'=>'sitename', 'header'=>'SN', 'type'=>'string', 'title'=>'Site name', 'fetched'=>true); $extra_columns[]=array('tagname'=>'domain', 'header'=>'DN', 'type'=>'string', 'title'=>'Toplevel domain name', 'fetched'=>true); $extra_columns[]=array('tagname'=>'ipaddress', 'header'=>'IP', 'type'=>'string', 'title'=>'IP Address', 'fetched'=>true); $extra_columns[]=array('tagname'=>'fcdistro', 'header'=>'OS', 'type'=>'string', 'title'=>'Operating system', 'fetched'=>false); +$extra_columns[]=array('tagname'=>'uptime', 'header'=>'UT', 'source'=>'comon', 'type'=>'sortAlphaNumericTop', 'title'=>'Continuous uptime until now', 'fetched'=>false); +$extra_columns[]=array('tagname'=>'date_created', 'header'=>'DA', 'source'=>'myplc', 'type'=>'date', 'title'=>'Date added', 'fetched'=>false); + //Get user's column configuration @@ -513,6 +516,8 @@ $node_columns=array_merge($node_fixed_columns,$visiblecolumns); //print_r($node_columns); $all_nodes=$api->GetNodes(NULL,$node_columns); +$ConfigureColumns->fetch_live_data($all_nodes); + //print("
person show configuration = ".$show_configuration); $show_conf = explode(";",$show_configuration); @@ -707,7 +712,7 @@ $note_display = ""; print <<
-This tab allows you to customize the columns in the node tables, below. Information on the nodes comes from a variety of monitoring sources. If you, as either a user or a provider of monitoring data, would like to see additional columns made available, please send us your request in mail to devel@planet-lab.org +This tab allows you to customize the columns in the node tables, below. Information on the nodes comes from a variety of monitoring sources. If you, as either a user or a provider of monitoring data, would like to see additional columns made available, please send us your request in mail to support@myslice.info. You can find more information about the MySlice project at http://trac.myslice.info. hide message permanently
@@ -795,8 +800,10 @@ $table->cell($node['node_id'], array('display'=>'none')); //extra columns $node['domain'] = topdomain($hostname); $node['sitename'] = l_site_t($node['site_id'],$site_hash[$node['site_id']]); -$node['ipaddress'] = l_interface_t($interface_id,$ip); - +if ($interface_id) + $node['ipaddress'] = l_interface_t($interface_id,$ip); + else + $node['ipaddress'] = "n/a"; //foreach ($visiblecolumns as $tagname) $table->cell($node[$tagname]); $ConfigureColumns->cells($table, $node); diff --git a/plekit/php/columns.php b/plekit/php/columns.php index 89404e5..fbe6142 100644 --- a/plekit/php/columns.php +++ b/plekit/php/columns.php @@ -20,12 +20,17 @@ var $fix_columns = array(); var $tag_columns = array(); var $extra_columns = array(); +var $comon_live_data = ""; +var $tophat_live_data = ""; +var $live_data = array(); + var $table_ids; var $HopCount = array(); function PlekitColumns ($column_configuration, $fix_columns, $tag_columns, $extra_columns=NULL, $this_table_headers=NULL) { + if ($column_configuration != NULL) { $this->fix_columns = $fix_columns; $this->tag_columns = $tag_columns; $this->extra_columns = $extra_columns; @@ -41,6 +46,7 @@ var $HopCount = array(); $this->parse_configuration($column_configuration); $this->visible_headers = $this->get_visible(); + } //print("

VISIBLE

"); //print_r($this->visible_headers); @@ -58,7 +64,7 @@ INFO function prepare_headers() { foreach ($this->fix_columns as $column) { -$this->all_headers[$column['header']]=array('header'=>$column['header'],'type'=>$column['type'],'tagname'=>$column['tagname'],'title'=>$column['title'], 'description'=>$column['title'], 'label'=>$column['header'], 'fixed'=>true, 'visible'=>false); +$this->all_headers[$column['header']]=array('header'=>$column['header'],'type'=>$column['type'],'tagname'=>$column['tagname'],'title'=>$column['title'], 'description'=>$column['title'], 'label'=>$column['header'], 'fixed'=>true, 'visible'=>false, 'source'=>'myplc'); } $tmp_headers = array(); @@ -70,13 +76,13 @@ else $headerId = $column['header']; //$this->all_headers[$headerId]=array('header'=>$headerId,'type'=>$column['type'],'tagname'=>$column['tagname'],'title'=>$column['title'], 'description'=>$column['title'], 'label'=>$column['header'],'visible'=>false); -$tmp_headers[$headerId]=array('header'=>$headerId,'type'=>$column['type'],'tagname'=>$column['tagname'],'title'=>$column['title'], 'description'=>$column['title'], 'label'=>$column['header'],'visible'=>false); +$tmp_headers[$headerId]=array('header'=>$headerId,'type'=>$column['type'],'tagname'=>$column['tagname'],'title'=>$column['title'], 'description'=>$column['title'], 'label'=>$column['header'],'visible'=>false, 'source'=>'myplc'); } if ($this->extra_columns) foreach ($this->extra_columns as $column) { //$this->all_headers[$column['header']]=array('header'=>$column['header'],'type'=>$column['type'],'tagname'=>$column['tagname'],'title'=>$column['title'], 'description'=>$column['title'], 'label'=>$column['header'], 'fetched'=>$column['fetched'],'visible'=>false); -$tmp_headers[$column['header']]=array('header'=>$column['header'],'type'=>$column['type'],'tagname'=>$column['tagname'],'title'=>$column['title'], 'description'=>$column['title'], 'label'=>$column['header'], 'fetched'=>$column['fetched'], 'visible'=>false); +$tmp_headers[$column['header']]=array('header'=>$column['header'],'type'=>$column['type'],'tagname'=>$column['tagname'],'title'=>$column['title'], 'description'=>$column['title'], 'label'=>$column['header'], 'fetched'=>$column['fetched'], 'visible'=>false, 'source'=>$column['source']); usort ($tmp_headers, create_function('$col1,$col2','return strcmp($col1["label"],$col2["label"]);')); } @@ -115,11 +121,11 @@ return ""; function node_tags() { - $fetched_tags = array('node_id'); + $fetched_tags = array('node_id','hostname'); foreach ($this->all_headers as $h) { - if ($h['visible'] == true && $h['tagname'] != "" && !$h['fetched']) + if ($h['visible'] == true && $h['tagname'] != "" && !$h['fetched'] && $h['source']=="myplc") $fetched_tags[] = $h['tagname']; } @@ -179,6 +185,7 @@ function parse_configuration($column_configuration) { $columns_conf = explode("|", $column_configuration); + foreach ($columns_conf as $c) { $conf = explode(":",$c); @@ -186,7 +193,24 @@ function parse_configuration($column_configuration) { if ($conf[0] == "default") continue; + if (!$this->all_headers[$conf[0]]) + continue; + $this->all_headers[$conf[0]]['visible']=true; + + if ($this->all_headers[$conf[0]]['source'] == "comon") + $this->comon_live_data.=",".$this->all_headers[$conf[0]]['tagname']; + + if ($this->all_headers[$conf[0]]['source'] == "tophat") + { + $this->reference_node = $conf[1]; + print ("ref node in configuration = ".$conf[1]); + $this->reference_node = "planetlab-europe-07.ipv6.lip6.fr"; + $this->all_headers[$conf[0]]['refnode']=$this->reference_node; + //$threshold = explode(",",$conf[1]); + //$this->all_headers[$conf[0]]['threshold']=$threshold; + } + //print("

-".$conf[0]."-should be visible now - ".$this->all_headers[$conf[0]]['visible']); //print_r($this->all_headers[$conf[0]]); @@ -200,14 +224,6 @@ function parse_configuration($column_configuration) { $threshold = explode(",",$conf[1]); $this->all_headers[$conf[0]]['threshold']=$threshold; } - else if ($this->inTypeD($conf[0])) - { - $this->reference_node = $conf[1]; - $this->reference_node = "planetlab-europe-07.ipv6.lip6.fr"; - $this->all_headers[$conf[0]]['refnode']=$this->reference_node; - $threshold = explode(",",$conf[1]); - $this->all_headers[$conf[0]]['threshold']=$threshold; - } else if ($this->inTypeA($conf[0])) { $exclude_list = explode(",",$conf[1]); @@ -220,6 +236,7 @@ function parse_configuration($column_configuration) { } */ } + } @@ -232,46 +249,110 @@ CELLS */ -function getHopCount($ref_node, $planetlab_nodes) -{ +function convert_data($value, $data_type) { + + if ($value == "" || $value == null || $value == "n/a" || $value == "None") + return "n/a"; + + if ($data_type == "string") + return $value; + + if ($data_type == "date") + return date("Y-m-d", $value); + + if ($data_type == "uptime") + return (int)((int) $value / 86400); + + return ((int) ($value * 10))/10; + +} + +function getHopCount($ref_node, $planetlab_nodes) { + + $tophat_auth = array( 'AuthMethod' => 'password', 'Username' => 'guest', 'AuthString' => 'guest'); + $tophat_api = new TopHatAPI($tophat_auth); + + $traceroute = $tophat_api->Get('traceroute', 'latest', array('src_hostname' => $ref_node, 'dst_hostname' => $planetlab_nodes), array('dst_hostname', 'hop_count') ); + + $hopcount = array(); + + if ($traceroute) foreach ($traceroute as $t) + $hopcount[$t['dst_hostname']]=$t['hop_count']; + + return $hopcount; +} + +function comon_query_nodes($requested_data) { + //$base_url = 'http://comon.cs.princeton.edu/status/tabulator.cgi?forma=nameonly&'; + $base_url = "http://comon.cs.princeton.edu/status/tabulator.cgi?table=table_nodeviewshort&format=formatcsv&dumpcols='name"; + + $url = $base_url.$requested_data."'"; + + //print ("retriecing comon data for url ".$url); + + $sPattern = '\', \''; + $sReplace = '|'; -$tophat_auth = array( 'AuthMethod' => 'password', 'Username' => 'guest', 'AuthString' => 'guest'); -$tophat_api = new TopHatAPI($tophat_auth); + if( false == ($str=file_get_contents($url))) + return ''; -$traceroute = $tophat_api->Get('traceroute', 'latest', array('src_hostname' => $ref_node, 'dst_hostname' => $planetlab_nodes), array('dst_hostname', 'hop_count') ); + $result=preg_replace( $sPattern, $sReplace, $str ); + $sPattern = '/\s+/'; + $sReplace = ';'; + $result=preg_replace( $sPattern, $sReplace, $result ); -$hopcount = array(); + $comon_data = explode(";", $result); + $cl = array(); + $comon_values = array(); + + foreach ($comon_data as $cd) { + $cc = explode("|", $cd); + if ($cc[0] == "name") { + $cl = $cc; + } + $comon_values[$cc[0]] = array(); + $cindex=1; + foreach ($cl as $cltag) { + if ($cltag != "name") + $comon_values[$cc[0]][$cltag] = $cc[$cindex++]; + } + } -if ($traceroute) foreach ($traceroute as $t) -$hopcount[$t['dst_hostname']]=$t['hop_count']; -return $hopcount; + return $comon_values; } //Depending on the columns selected more data might need to be fetched from //external sources -function fetch_data($nodes) { +function fetch_live_data($all_nodes) { + + //print("

fetching live data

"); + +//comon data + if ($this->comon_live_data != "") { + + //print ("live data to be fetched =".$this->comon_live_data); + $this->live_data = $this->comon_query_nodes($this->comon_live_data); + //print_r($this->live_data); + } -//TopHat pairwise data +//TopHat pairwise data + //if ($this->tophat_live_data != "") if ($this->reference_node != "") { $dd = array(); - if ($nodes) foreach ($nodes as $n) - $dd[] = $n['hostname']; - - if ($potential_nodes) foreach ($potential_nodes as $n) + if ($all_nodes) foreach ($all_nodes as $n) $dd[] = $n['hostname']; print("Calling tophat api for reference node = ".$this->reference_node); $st = time() + microtime(); $HopCount = $this->getHopCount($this->reference_node, $dd); printf(" (%.2f ms)
", (time() + microtime()-$st)*100); - //print_r($HopCount); + print_r($HopCount); } - } @@ -307,14 +388,14 @@ function checkThreshold($value, $threshold, $hh) { function cells($table, $node) { -$this->fetch_data($node); - foreach ($this->all_headers as $h) { if (!$h['fixed']) { if ($h['visible'] != "") { + +/* if ($this->inTypeC($h['header'])) { $tagname = $h['tagname']; @@ -340,17 +421,37 @@ else if ($this->inTypeA($h['header'])) $v = $this->excludeItems($value, $h['exclude_list'], $h['header']); $table->cell($v[0],$v[1]); } +*/ +if ($h['type'] == "date") +{ + $value = $this->convert_data($node[$h['tagname']], $h['type']); + $table->cell($value,array('name'=>$h['header'], 'display'=>'table-cell')); +} +else if ($h['source'] == "comon") +{ + //print("
Searching for ".$h['tagname']."at ".$node); + $value = $this->convert_data($this->live_data[$node['hostname']][$h['tagname']], $h['tagname']); + + $table->cell($value,array('name'=>$h['header'], 'display'=>'table-cell')); +} else { - $value = $node[$h['tagname']]; + //$value = $node[$h['tagname']]; + $value = $this->convert_data($node[$h['tagname']], $h['type']); $table->cell($value,array('name'=>$h['header'], 'display'=>'table-cell')); } } else if ($node[$h['tagname']]) - $table->cell($node[$h['tagname']], array('name'=>$h['header'], 'display'=>'none')); + { + $value = $this->convert_data($node[$h['tagname']], $h['type']); + $table->cell($value, array('name'=>$h['header'], 'display'=>'none')); + } else - $table->cell("??", array('name'=>$h['header'], 'display'=>'none')); + if ($node[$h['fetched']]) + $table->cell("n/a", array('name'=>$h['header'], 'display'=>'none')); + else + $table->cell("??", array('name'=>$h['header'], 'display'=>'none')); } } @@ -366,7 +467,7 @@ HTML function javascript_init() { -print(""); +print(""); print(""); } - - function quickselect_html() { //return '

This link uses the onclick event handler.
Open popup

'; @@ -481,6 +580,8 @@ print (""); print ("
+ +
diff --git a/plekit/php/updateColumn.php b/plekit/php/updateColumn.php index e4b1a86..de0c605 100644 --- a/plekit/php/updateColumn.php +++ b/plekit/php/updateColumn.php @@ -14,8 +14,13 @@ require_once 'plc_drupal.php'; // Common functions require_once 'plc_functions.php'; +require_once 'columns.php'; + + $slice_id=$_GET["slice_id"]; $tagN=$_GET["tagName"]; +$data_source=$_GET["data_source"]; +$data_type=$_GET["data_type"]; $nodetags = array('node_id'); @@ -23,6 +28,35 @@ $extratags = explode("|", $tagN); if ($slice_id == "nodes") { +if ($data_source == "comon") { + +$comontags = $extratags; +$extratags = array ('hostname'); +$nodes=$api->GetNodes(NULL, array_merge($nodetags, $extratags)); +$ColumnsConfigure = new PlekitColumns(NULL, NULL, NULL); +$comon_data = $ColumnsConfigure->comon_query_nodes(",".$tagN); + +//print ("comon tags = ".$comontags); + +echo "---attached---"; +if ($nodes) foreach ($nodes as $node) { + echo "|".$node['node_id']; + foreach ($comontags as $t) + echo ":".$ColumnsConfigure->convert_data($comon_data[$node['hostname']][$t], $data_type); +} +} +else if ($data_source == "tophat") { +$extratags = array ('hostname'); +$nodes=$api->GetNodes(NULL, array_merge($nodetags, $extratags)); +echo "---attached---"; +if ($nodes) foreach ($nodes as $node) { + echo "|".$node['node_id']; + echo ":n/a"; +} +} +else +{ + echo "---attached---"; $nodes=$api->GetNodes(NULL, array_merge($nodetags, $extratags)); //echo $nodes; @@ -32,9 +66,11 @@ if ($nodes) foreach ($nodes as $node) { foreach ($extratags as $t) echo ":".$node[$t]; } +} - } + +} else { @@ -45,6 +81,50 @@ if (empty($slices)) { $slice=$slices[0]; +if ($data_source == "comon") { + +$comontags = $extratags; +$extratags = array ('hostname'); + +$nodes=$api->GetNodes(array('node_id'=>$slice['node_ids']),array_merge($nodetags, $extratags)); +$potential_nodes=$api->GetNodes(array('~node_id'=>$slice['node_ids']),array_merge($nodetags, $extratags)); + +$ColumnsConfigure = new PlekitColumns(NULL, NULL, NULL); +$comon_data = $ColumnsConfigure->comon_query_nodes(",".$tagN); + +//print ("comon tags = ".$comontags); + +echo "---attached---"; +if ($nodes) foreach ($nodes as $node) { + echo "|".$node['node_id']; + foreach ($comontags as $t) + echo ":".$ColumnsConfigure->convert_data($comon_data[$node['hostname']][$t], $data_type); +} +echo "|---potential---"; +if ($potential_nodes) foreach ($potential_nodes as $potential_node) { + echo "|".$potential_node['node_id']; + foreach ($comontags as $t) + echo ":".$ColumnsConfigure->convert_data($comon_data[$potential_node['hostname']][$t], $data_type); +} +} +else if ($data_source == "tophat") { +$extratags = array ('hostname'); +$nodes=$api->GetNodes(array('node_id'=>$slice['node_ids']),array_merge($nodetags, $extratags)); +$potential_nodes=$api->GetNodes(array('~node_id'=>$slice['node_ids']),array_merge($nodetags, $extratags)); +echo "---attached---"; +if ($nodes) foreach ($nodes as $node) { + echo "|".$node['node_id']; + echo ":n/a"; +} +echo "|---potential---"; +if ($potential_nodes) foreach ($potential_nodes as $potential_node) { + echo "|".$potential_node['node_id']; + echo ":n/a"; +} +} +else +{ + $nodes=$api->GetNodes(array('node_id'=>$slice['node_ids']),array_merge($nodetags, $extratags)); $potential_nodes=$api->GetNodes(array('~node_id'=>$slice['node_ids']),array_merge($nodetags, $extratags)); @@ -61,5 +141,6 @@ if ($potential_nodes) foreach ($potential_nodes as $potential_node) { echo ":".$potential_node[$t]; } } +} ?> diff --git a/plekit/php/updateConfiguration.php b/plekit/php/updateConfiguration.php index 9a0340b..e48f80e 100644 --- a/plekit/php/updateConfiguration.php +++ b/plekit/php/updateConfiguration.php @@ -14,14 +14,21 @@ require_once 'plc_drupal.php'; require_once 'plc_functions.php'; $value=$_GET["value"]; -$person_id=$_GET["person_id"]; +$person_id=intval($_GET["person_id"]); $slice_id=$_GET["slice_id"]; $tag_id=intval($_GET["tag_id"]); +$tag_name=$_GET["tag_name"]; -$api->UpdatePersonTag( $tag_id, $value ); +#$res = $api->UpdatePersonTag( $tag_id, $value ); +if ($tag_name == "columnconf") +$res = $api->SetPersonColumnconf( $person_id, $value ); +else if ($tag_name == "showconf") +$res = $api->SetPersonShowconf( $person_id, $value ); $myFile = "/var/log/myslice.log"; -$fh = fopen($myFile, 'a') or die("can't open file"); +if (file_exists($myFile)) + $fh = fopen($myFile, 'a') or die("can't open file"); + $stringData = "\n".date('Ymd-H:i')."|".$person_id.":".$slice_id.":".$value; fwrite($fh, $stringData); fclose($fh); diff --git a/plekit/table/columns.js b/plekit/table/columns.js index b4dc7f1..daf64d6 100644 --- a/plekit/table/columns.js +++ b/plekit/table/columns.js @@ -15,32 +15,34 @@ var sourceMyPLC = 'MANIACS'; var sourceMaxmind = 'MaxMind'; var sourceMonitor = 'Monitor'; -var selectReferenceNode ='Select reference node: '; -var addButton = ''; -var deleteButton = ''; +var hardwareReqs = 'current PlanetLab hardware requirement'; +var selectReferenceNode ='Select reference node: '; +//var addButton = ''; +//var deleteButton = ''; var descHOSTNAME = "test"; -var titleA = 'Architecture name'; -var detailA = 'The node architecture.'; -var sourceA = 'Source: '+sourceMyPLC; -var valuesA = 'Values: x86_64, i386'; -var descA = ''+titleA+'

'+detailA+'

'+valuesA+'

'+sourceA; - -var titlef = 'Operating system'; -var detailf = 'Fedora or CentOS distribution to use for node or slivers.'; -var sourcef = 'Source: '+sourceMyPLC; -var descf = ''+titlef+'

'+detailf+'

'+sourcef; var titleAU = 'Authority'; var detailAU = 'The authority of the global PlanetLab federation that the site of the node belongs to.'; var valuesAU = 'Values: PLC (PlanetLab Central), PLE (PlanetLab Europe)'; -var sourceAU = 'Source: '+sourceMyPLC; +var sourceAU = 'Source: '+sourceMyPLC; var descAU = ''+titleAU+'

'+detailAU+'

'+valuesAU+'

'+sourceAU; +var titleST = 'Status'; +var sourceST = 'Source: '+sourceMonitor; +var valuesST = 'Values: online (up and running), good (up and running recently), offline (unreachable today), down (node unreachable for more than one day), failboot (reachable, but only by administrators for debugging purposes).'; +var descST = ''+titleST+'

'+valuesST+'

'+sourceST; + +var titleA = 'Architecture name'; +var detailA = 'The node architecture.'; +var sourceA = 'Source: '+sourceMyPLC; +var valuesA = 'Values: x86_64, i386, n/a'; +var descA = ''+titleA+'

'+detailA+'

'+valuesA+'

'+sourceA; + var titleAS = 'Autonomous system ID'; var sourceAS = 'Source: '+sourceCymru+' (via '+sourceTophat+')'; -var valuesAS = 'Unit: Integer between 0 and 65535'; +var valuesAS = 'Values: Integer between 0 and 65535, n/a'; var descAS = ''+titleAS+'

'+valuesAS+'

' + sourceAS; var titleAST = 'Autonomous system type'; @@ -67,18 +69,19 @@ var descBW = ''+titleBW+'

'+detailBW+'

'+ var titleCC = 'Number of CPU cores'; var sourceCC = 'Source: '+sourceComon; -var valuesCC = 'Current PlanetLab hardware requirements: 4 cores min.
(Older nodes may have fewer cores).'; +var valuesCC = 'The number of CPU cores on the node. For reference, the '+hardwareReqs+' is 4 cores min.
(Older nodes may have fewer cores)
.'; var descCC = ''+titleCC+'

'+valuesCC+'

'+sourceCC; var titleCN = 'Number of CPUs'; var sourceCN = 'Source: '+sourceComon; -var valuesCN = 'Current PlanetLab hardware requirements: 1 (if quad core) or 2 (if dual core)'; +var valuesCN = 'The number of CPUs on the node. For reference, the '+hardwareReqs+' is 1 (if quad core) or 2 (if dual core).'; var descCN = ''+titleCN+'

'+valuesCN+'

'+sourceCN; var titleCR = 'CPU clock rate'; +var detailCR = 'The clock rate for the CPUs on the node. For reference, the '+hardwareReqs+' is 2.4 GHz.'; var sourceCR = 'Source: '+sourceComon; -var valuesCR = 'Unit: GHz

Current PlanetLab hardware requirements: 2.4 GHz'; -var descCR = ''+titleCR+'

'+valuesCR+'

'+sourceCR; +var valuesCR = 'Unit: GHz'; +var descCR = ''+titleCR+'

'+detailCR+'

'+valuesCR+'

'+sourceCR; var selectPeriodCF = 'Select period: '; var titleCF = 'Free CPU'; @@ -91,10 +94,16 @@ var titleDN = 'Toplevel domain name'; var sourceDN = 'Source: '+sourceMyPLC; var descDN = ''+titleDN+'

'+sourceDN; +var titleDA = 'Date added'; +var sourceDA = 'Source: '+sourceMyPLC; +var detailDA = ' The date that the noded was added to PlanetLab.'; +var descDA = ''+titleDA+'

'+detailDA+'

'+sourceDA; + var titleDS = 'Disk size'; +var detailDS = 'The size of the hard disk available on the node. For reference, the '+hardwareReqs+' is 500 GB.'; var sourceDS = 'Source: '+sourceComon; -var valuesDS = 'Unit: GB

Current PlanetLab hardware requirements: 500 GB'; -var descDS = ''+titleDS+'

'+valuesDS+'

'+sourceDS; +var valuesDS = 'Unit: GB'; +var descDS = ''+titleDS+'

'+detailDS+'

'+valuesDS+'

'+sourceDS; var titleDU = 'Current disk utilization'; var sourceDU = 'Source: '+sourceComon+' (via '+sourceMySlice+')'; @@ -149,7 +158,7 @@ var descLCY = ''+titleLCY+'

'+detailLCY+'

'+detailLPR+'

'+valuesLPR+'

'+sourceLPR; @@ -159,8 +168,9 @@ var detailLRN = 'Based on the latitude and longitude information.'; var descLRN = ''+titleLRN+'

'+detailLRN+'

'+sourceLRN; var titleMS= 'Memory size'; +var detailMS = 'The memory size (RAM) available on the node. For reference, the '+hardwareReqs+' is 4 GB.'; var sourceMS = 'Source: '+sourceComon; -var valuesMS = 'Unit: GB

Current PlanetLab hardware requirements: 4 GB.'; +var valuesMS = 'Unit: GB.'; var descMS = ''+titleMS+'

'+valuesMS+'

'+sourceMS; var selectPeriodMU = 'Select period: '; @@ -219,8 +229,9 @@ var detailNRR = ' Whether the node can send packets packets using the IP reco var descNRR = ''+titleNRR+'

'+detailNRR+'

'+valuesNRR+'

'+sourceNRR; var titleOS = 'Operating system'; +var detailOS = 'Fedora or CentOS distribution to use for node or slivers.'; var sourceOS = 'Source: '+sourceMyPLC; -var valuesOS = 'Values: Fedora, Cent/OS, other, n/a'; +var valuesOS = 'Values: f8, f12, Cent/OS, other, n/a'; var descOS = ''+titleOS+'

'+valuesOS+'

'+sourceOS; var selectPeriodR = 'Select period: '; @@ -255,10 +266,12 @@ var detailSSH = 'The average response delay of the node to SSH logins over th var sourceSSH ='Source: '+sourceComon+' (via '+sourceMySlice+')'; var descSSH = ''+titleSSH+'

'+detailSSH+'

'+selectPeriodSSH+'

'+valuesSSH+'

'+sourceSSH; -var titleST = 'Status'; -var sourceST = 'Source: '+sourceMonitor; -var valuesST = 'Values: online (up and running), good (up and running recently), offline (unreachable today), down (node unreachable for more than one day), failboot (reachable, but only by administrators for debugging purposes).'; -var descST = ''+titleST+'

'+valuesST+'

'+sourceST; + +var titleUT = 'Uptime'; +var sourceUT = 'Source: '+sourceComon; +var valuesUT = 'Unit: days'; +var detailUT = 'The continuous uptime until the moment that the page is loaded, as reported by the CoMon html query API.'; +var descUT = ''+titleUT+'

'+detailUT+'

'+valuesUT+'

'+sourceUT; //Categorization of columns in different types, useful for filtering @@ -349,20 +362,21 @@ function overrideTitles() { //When the checkbox is clicked. Adds/removes column respectively function changeCheckStatus(column) { + var h = document.getElementById(column).value; + if (document.getElementById('selectdescr')) - showDescription(document.getElementById(column).value); + showDescription(h); + + //debugfilter("HERE: "+column+" - "+document.getElementById('type '+column).value); + //debugfilter("HERE: "+column); + if (document.getElementById(column).checked) - addColumn(document.getElementById(column).value, true); + addColumn(h, true, document.getElementById('type'+h).value); else - deleteColumn(document.getElementById(column).value); + deleteColumn(h); } -function removeSelectHandler(object) -{ - debugfilter(object); - object.onclick = null; -} //This function is used when the alternative "quick" selection list is used @@ -391,6 +405,23 @@ function changeSelectStatus(column) { } } +function updateReferenceNode(new_ref_node) { + + var old_ref_node = document.getElementById('selected_reference_node').value; + document.getElementById('selected_reference_node').value=new_ref_node; + + //debugfilter("changed "+old_ref_node+" with "+new_ref_node); + + if (document.getElementById('checkHC').checked) + { + addColumnAjax('HC', 'HC'); + //debugfilter("replacing "+old_ref_node+" with "+new_ref_node); + replaceColumnConfiguration('HC:'+old_ref_node,'HC:'+new_ref_node); + } + +} + + //When the period of an already selected column is changed function updatePeriod(h, new_period) { @@ -454,7 +485,7 @@ function closeMessage(tab) var person_id = document.getElementById('person_id').value; var tag_id = document.getElementById('show_tag_id').value; - var url = "/plekit/php/updateConfiguration.php?value="+value+"&slice_id="+slice_id+"&person_id="+person_id+"&tag_id="+tag_id; + var url = "/plekit/php/updateConfiguration.php?value="+value+"&slice_id="+slice_id+"&person_id="+person_id+"&tag_name=showconf&tag_id="+tag_id; //debugfilter("updating conf with "+url); document.getElementById('show_configuration').value = value; @@ -525,7 +556,7 @@ function updateColumnConfiguration(value, reload) } } - xmlhttp.open("GET","/plekit/php/updateConfiguration.php?value="+new_configuration+"&slice_id="+slice_id+"&person_id="+person_id+"&tag_id="+tag_id,true); + xmlhttp.open("GET","/plekit/php/updateConfiguration.php?value="+new_configuration+"&slice_id="+slice_id+"&person_id="+person_id+"&tag_name=columnconf&tag_id="+tag_id,true); //xmlhttp.open("GET","/plekit/php/updateConf.php?value="+value+"&slice_id="+slice_id+"&person_id="+person_id+"&tagName=Columnconf",true); xmlhttp.send(); @@ -557,11 +588,17 @@ function sortCompleteCallback(tableid) { for(var i = 0, th; th = ths[i]; i++) { if (th.className.indexOf("Sort") != -1) { + //debugfilter("sorted"+th.getAttribute("name")); + + var column_name = th.getAttribute("name"); var hclass = th.className; var column = hclass.substr(hclass.indexOf("column"),hclass.indexOf("column")+1); - var sortdirection = hclass.substr(hclass.indexOf("Sort")-8,hclass.indexOf("Sort")); + var sortdirection = "forward"; + if (hclass.indexOf("reverse")!=-1) + sortdirection = "reverse"; + if (column.indexOf("column-1")==-1 && column.indexOf("column-0")==-1) - logSortingAction(person_id, slice_id, tableid+"|"+column+"|"+sortdirection); + logSortingAction(person_id, slice_id, tableid+"|"+column_name+"|"+sortdirection); } } } @@ -609,9 +646,11 @@ function replaceColumnConfiguration(column_old, column_new) { var old_columns = old_configuration.split("|"); var new_columns = new Array(); + var olds = column_old.split(':'); + for (var column_index = 0; column_index < old_columns.length ; column_index++) { var conf = old_columns[column_index].split(':'); - if (conf[0] != column_old) + if (conf[0] != olds[0]) new_columns.push(old_columns[column_index]); else new_columns.push(column_new); @@ -629,9 +668,37 @@ ADD/REMOVE COLUMNS */ +function convert_data(value, data_source, data_type, tagname) { + //debugfilter("v["+tagname+"]="+value+"-"); + + if (value == "" || value == "n/a" || value == null || value == "NaN" || value == "None") + return "n/a"; + + if (tagname == "uptime") { + return parseInt((parseFloat(value) / 86400)); + } + + if (data_type == "date") { -function load_data(column, header, url) { + var date = new Date(value*1000); + + var year = date.getFullYear(); + var month = date.getMonth()+1; + if (month < 10) + month = "0"+month; + var day = date.getDate(); + if (day < 10) + day = "0"+day; + + return year + '-' + month + '-' + day; + } + + return value; +} + + +function load_data(column, header, url, data_source, data_type, tagname) { //debugfilter("
loading "+url); var req = getHTTPObject(); @@ -641,13 +708,13 @@ function load_data(column, header, url) { req.onreadystatechange = function() { if (req.readyState == 4) - { updateColumnData(column, header, req.responseText); } + { updateColumnData(column, header, req.responseText, data_source, data_type, tagname); } } req.send(null); } -function updateColumnData(column, header, data) { +function updateColumnData(column, header, data, data_source, data_type, tagname) { var headers = header.split("|"); var data_table = data.split("|"); @@ -655,10 +722,12 @@ var data_table = data.split("|"); //debugfilter("

headers[0] = "+headers[0]); //debugfilter("

data[2] = "+data_table[2]); -//debugfilter("data = "+data); +//debugfilter("data = "+data + " with type "+data_type + " and source "+data_source); if (data != "") { + +//debugfilter("GOT SOME DATA"); var node_data; @@ -680,10 +749,10 @@ if (data != "") for (var h_index=0; h_index < headers.length; h_index++) { - if (node_data[h_index+1] == "") + if (node_data[h_index+1] == "" || node_data[h_index+1] == "None") data_array1[node_data[0]][h_index] = "n/a"; else - data_array1[node_data[0]][h_index] = node_data[h_index+1]; + data_array1[node_data[0]][h_index] = convert_data(node_data[h_index+1], data_source, data_type, tagname); } } @@ -705,8 +774,8 @@ if (data != "") } } + //tablePaginater.init(table_id1); fdTableSort.init(table_id1); - tablePaginater.init(table_id1); //potential nodes if (data_table[node_index] == '---potential---') @@ -733,7 +802,7 @@ if (data_table[node_index] == '---potential---') if (node_data[h_index+1] == "") data_array2[node_data[0]][h_index] = "n/a"; else - data_array2[node_data[0]][h_index] = node_data[h_index+1]; + data_array2[node_data[0]][h_index] = convert_data(node_data[h_index+1], data_source, data_type, tagname); } } @@ -750,12 +819,15 @@ if (data_table[node_index] == '---potential---') } } } - - //fdTableSort.removeTableCache(table_id2); fdTableSort.init(table_id2); - tablePaginater.init(table_id2); + //tablePaginater.init(table_id2); + } + //fdTableSort.removeTableCache(table_id2); + //document.getElementById('loading'+column).innerHTML = ""; + //debugfilter("Reset sorting ....."); + } document.getElementById('loading'+column).innerHTML = ""; @@ -789,6 +861,8 @@ function addColumnAjax(column, header) { var selectedperiod = document.getElementById('period'+column).value; var fetched = document.getElementById('fetched'+column).value; + var data_source = document.getElementById('source'+column).value; + var data_type = document.getElementById('type'+column).value; var to_load = false; //debugfilter("
adding "+column+","+header+','+fetched+','+t); @@ -807,8 +881,8 @@ function addColumnAjax(column, header) { if (to_load) { document.getElementById('loading'+column).innerHTML = ""; - var url = "/plekit/php/updateColumn.php?slice_id="+slice_id+"&tagName="+t; - load_data(column, header, url); + var url = "/plekit/php/updateColumn.php?slice_id="+slice_id+"&tagName="+t+"&data_type="+data_type+"&data_source="+data_source; + load_data(column, header, url, data_source, data_type, t); } } @@ -818,6 +892,7 @@ function addColumn(column, fetch) { var selectedperiod=""; var header=column; + var conf=""; if (inTypeC(column)!=-1) @@ -828,14 +903,22 @@ function addColumn(column, fetch) { selectedperiod = document.getElementById('period'+column).value; header = column+""+selectedperiod; - //debugfilter("adding column "+column+" and header "+header); + if (inTypeD(column)!=-1) + { + conf = header+":"+document.getElementById('reference_node').value; + document.getElementById('selected_reference_node').value=document.getElementById('reference_node').value; + } + else + conf = header; + + //debugfilter("adding column "+column+" and header "+header+" and conf = "+conf); addColumnCells(header); if (fetch) addColumnAjax(column, header); - addColumnToConfiguration(header); + addColumnToConfiguration(conf); } @@ -868,6 +951,13 @@ function deleteColumn(column) { EXTRA + +function removeSelectHandler(object) +{ + debugfilter(object); + object.onclick = null; +} + //to be used for scrolling the column list with down/up arrows function scrollList() { -- 2.43.0

".$h['label']."