var $this_table_headers = array();
var $visible_headers = array();
-var $all_columns = array();
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;
$this->parse_configuration($column_configuration);
$this->visible_headers = $this->get_visible();
+ }
//print("<p>VISIBLE<p>");
//print_r($this->visible_headers);
- $this->all_columns = array_merge($fix_columns, $tag_columns, $extra_columns);
}
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');
}
-foreach ($this->tag_columns as $column) {
-$this->all_headers[$column['header']]=array('header'=>$column['header'],'type'=>$column['type'],'tagname'=>$column['tagname'],'title'=>$column['tagname'], 'description'=>$column['title'], 'label'=>$this->removeDuration($column['header']),'visible'=>false);
-}
+$tmp_headers = array();
+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['tagname'], 'description'=>$column['title'], 'label'=>$this->removeDuration($column['header']),'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']);
+
+}
+
+if ($this->tag_columns)
+foreach ($this->tag_columns as $column) {
+
+if ($column['headerId'] != "")
+ $headerId = $column['headerId'];
+else
+ $headerId = $column['header'];
+
+$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');
}
+usort ($tmp_headers, create_function('$col1,$col2','return strcmp($col1["label"],$col2["label"]);'));
+
+foreach ($tmp_headers as $t)
+$this->all_headers[$t['header']] = $t;
+
+//$this->all_headers = array_merge($this->all_headers, $tmp_headers);
+
+//print($this->print_headers());
+
return $this->all_headers;
}
}
+function get_selected_period($label) {
+
+if ($this->all_headers[$label."w"]['visible'])
+ return "w";
+else if ($this->all_headers[$label."m"]['visible'])
+ return "m";
+else if ($this->all_headers[$label."y"]['visible'])
+ return "y";
+else if ($this->all_headers[$label]['visible'])
+ return "";
+
+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)
+ if ($h['visible'] == true && $h['tagname'] != "" && !$h['fetched'] && $h['source']=="myplc")
$fetched_tags[] = $h['tagname'];
}
$headers = "";
- foreach ($this->all_headers as $h)
+ foreach ($this->all_headers as $l => $h)
{
- $headers.="<br>".$h['header'].":".$h['label'].":".$h['tagname'];
+ $headers.="<br>[".$l."]=".$h['header'].":".$h['label'].":".$h['tagname'].":".$h['visible'];
}
return $headers;
}
$headersToShow = $this->visible_headers;
+if (in_array($header_name, $headersToShow))
+ return true;
- if ($this->inTypeC($header_name."w") || $this->inTypeC($header_name."m") || $this->inTypeC($header_name."y"))
- return (in_array($header_name."w", $headersToShow) || in_array($header_name."m", $headersToShow) || in_array($header_name."y", $headersToShow));
- else
- return in_array($header_name, $headersToShow);
+if ($this->inTypeC($header_name."w"))
+ return (in_array($header_name."w", $headersToShow) || in_array($header_name."m", $headersToShow) || in_array($header_name."y", $headersToShow));
}
$this->column_configuration = $column_configuration;
//$this->default_configuration = $default_configuration;
+ //print($this->print_headers());
+
$columns_conf = explode("|", $column_configuration);
+
+
foreach ($columns_conf as $c)
{
$conf = explode(":",$c);
+ if ($conf[0] == "default")
+ continue;
+
+ if (!$this->all_headers[$conf[0]])
+ continue;
+
$this->all_headers[$conf[0]]['visible']=true;
- //print("<p>".$conf[0]."should be visible now");
+
+ 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("<p>-".$conf[0]."-should be visible now - ".$this->all_headers[$conf[0]]['visible']);
//print_r($this->all_headers[$conf[0]]);
+/*
if ($conf[1] == "f")
continue;
$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]);
$threshold = explode(",",$conf[1]);
$this->all_headers[$conf[0]]['threshold']=$threshold;
}
+*/
}
+
}
*/
-function getHopCount($ref_node, $planetlab_nodes)
-{
+function convert_data($value, $data_type) {
+
+ if ($value == "" || $value == null || $value == "n/a" || $value == "None")
+ return "n/a";
-$tophat_auth = array( 'AuthMethod' => 'password', 'Username' => 'guest', 'AuthString' => 'guest');
-$tophat_api = new TopHatAPI($tophat_auth);
+ if ($data_type == "string")
+ return $value;
-$traceroute = $tophat_api->Get('traceroute', 'latest', array('src_hostname' => $ref_node, 'dst_hostname' => $planetlab_nodes), array('dst_hostname', 'hop_count') );
+ if ($data_type == "date")
+ return date("Y-m-d", $value);
-$hopcount = array();
+ if ($data_type == "uptime")
+ return (int)((int) $value / 86400);
+
+ return ((int) ($value * 10))/10;
-if ($traceroute) foreach ($traceroute as $t)
-$hopcount[$t['dst_hostname']]=$t['hop_count'];
-return $hopcount;
+}
+
+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 = '|';
+
+ if( false == ($str=file_get_contents($url)))
+ return '';
+
+ $result=preg_replace( $sPattern, $sReplace, $str );
+ $sPattern = '/\s+/';
+ $sReplace = ';';
+ $result=preg_replace( $sPattern, $sReplace, $result );
+
+ $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++];
+ }
+ }
+
+ 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("<p>fetching live data<p>");
+
+//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)<br/>", (time() + microtime()-$st)*100);
- //print_r($HopCount);
+ print_r($HopCount);
}
-
}
return array($value, array('name'=>$hh, 'display'=>'table-cell'));
}
+
function checkThreshold($value, $threshold, $hh) {
if ($value == "")
function cells($table, $node) {
-
foreach ($this->all_headers as $h)
{
+if (!$h['fixed']) {
-if (!$h['fixed'] && $h['visible'])
+if ($h['visible'] != "")
{
+
+/*
if ($this->inTypeC($h['header']))
{
$tagname = $h['tagname'];
$v = $this->excludeItems($value, $h['exclude_list'], $h['header']);
$table->cell($v[0],$v[1]);
}
-else
+*/
+if ($h['type'] == "date")
{
- $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 ($h['source'] == "comon")
+{
+ //print("<br>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
- $table->cell("??", array('name'=>$h['header'], 'display'=>'none'));
-
+{
+ //$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']])
+ {
+ $value = $this->convert_data($node[$h['tagname']], $h['type']);
+ $table->cell($value, array('name'=>$h['header'], 'display'=>'none'));
+ }
+ else
+ if ($node[$h['fetched']])
+ $table->cell("n/a", array('name'=>$h['header'], 'display'=>'none'));
+ else
+ $table->cell("??", array('name'=>$h['header'], 'display'=>'none'));
+}
}
}
*/
-function javascript_vars() {
+function javascript_init() {
-print("<input type='hidden' id='reference_node' value='".$this->reference_node."' />");
-
-$all_columns_string = "";
-foreach ($this->all_headers as $h)
- $all_columns_string.= $h['header'].",";
+print("<input type='hidden' id='selected_reference_node' value='".$this->reference_node."' />");
print("<script type='text/javascript'>");
+print("highlightOption('AU');");
+print("overrideTitles();");
+print("</script>");
+
+}
+
+function quickselect_html() {
+
+//return '<p>This link uses the onclick event handler.<br><a href="#" onclick="setVisible(\'quicklist\');return false" target="_self">Open popup</a></p>';
+
-print("var column_table = new Array();");
-print ("var column_index=0;");
-print("var column_table2 = new Array();");
-print("var column_headers = new Array();");
-print("var columns_to_fetch = new Array();");
-//document.onkeyup = scrollList('test');
+$quickselection = "<select id='quicklist' onChange=changeSelectStatus(this.value)><option value='0'>Short column descriptions and quick add/remove</option>";
+//$quickselection = "<select id='quicklist'><option value='0'>Short column descriptions and quick add/remove</option>";
+$prev_label="";
+$optionclass = "out";
foreach ($this->all_headers as $h)
{
-/*
- print("column_table2[column_index] = new Array();");
- print("column_table2[column_index]['header'] = ".$h['header'].";");
- print("column_table2[column_index]['label'] = ".$h['label'].";");
- if ($h['visible'])
- {
- print("column_table2[column_index]['visible'] = true;");
- print("column_table2[column_index]['fetched'] = true;");
- }
- else
- {
- print("column_table2[column_index]['visible'] = false;");
- print("column_table2[column_index]]['fetch'] = false;");
- }
- print("column_table2[column_index]['tagname'] = '".$h['tagname']."';");
- print("column_table2[column_index]['description'] = '".$h['description']."';");
-*/
+ if ($h['header'] == "hostname" || $h['header'] == "ID")
+ continue;
- print("column_table[\"".$h['header']."\"] = new Array();");
- if ($h['visible'])
+ if ($h['fixed'])
+ $disabled = "disabled=true";
+ else
+ $disabled = "";
+
+ if ($this->headerIsVisible($h['label']))
{
- print("column_table['".$h['header']."']['visible'] = true;");
- print("column_table['".$h['header']."']['fetched'] = true;");
+ $optionclass = "in";
+ //$selected = "selected=selected";
}
- else
+ else
{
- print("column_table['".$h['header']."']['visible'] = false;");
- print("column_table['".$h['header']."']['fetch'] = false;");
+ $optionclass = "out";
+ //$selected = "";
}
- print("column_table['".$h['header']."']['tagname'] = '".$h['tagname']."';");
- print("column_table['".$h['header']."']['description'] = '".$h['description']."';");
-}
+ if ($prev_label == $h['label'])
+ continue;
+
+ $prev_label = $h['label'];
-foreach ($this->all_headers as $h)
- print("column_headers['".$h['label']."'] = '0';");
-print("var all_columns_string = '".substr($all_columns_string,0,strlen($all_columns_string)-1)."';");
+//$quickselection.="<option onclick=\"debugfilter('here2');removeSelectHandler(this);\" id='option'".$h['label']." class='".$optionclass."' value='".$h['label']."'><b>".$h['label']."</b>: ".$h['title']."</option>";
+$quickselection.="<option id='option'".$h['label']." class='".$optionclass."' value='".$h['label']."'><b>".$h['label']."</b>: ".$h['title']."</option>";
+}
-//if ($first_time == true)
- //print("resetConfiguration();");
-//print("debugfilter('vars are OK');");
-print("</script>");
+$quickselection.="</select>";
+
+return $quickselection;
}
-function configuration_panel_html($showDescription) {
+function configuration_panel_html($showDescription) {
if ($showDescription)
$table_width = 700;
$table_width = 350;
print("<table align=center cellpadding=10 width=".$table_width.">");
-print("<tr><th>Add/delete columns</th>");
+print("<tr><th>Add/remove columns</th>");
if ($showDescription)
print("<th>Column description and configuration</th>");
print("</tr><tr><td valign=top width=300>");
- print('<div id="scrolldiv" onFocusOut="debugfilter(this.id);" style="border : solid 2px grey; padding:4px; width:300px; height:180px; overflow:auto;">');
+ print('<div id="scrolldiv" style="border : solid 2px grey; padding:4px; width:300px; height:180px; overflow:auto;">');
print ("<table>");
$prev_label="";
$optionclass = "out";
foreach ($this->all_headers as $h)
{
- if ($h['header'] == "hostname")
+ if ($h['header'] == "hostname" || $h['header'] == "ID")
continue;
if ($h['fixed'])
if ($this->headerIsVisible($h['label']))
{
$selected = "checked=true";
+ $fetch = "true";
//print("header ".$h['label']." checked!");
}
else
{
$selected = "";
+ if ($h['fetched'])
+ $fetch = "true";
+ else
+ $fetch = "false";
}
+ print("<input type='hidden' id='tagname".$h['header']."' value='".$h['tagname']."'></input>");
+
if ($prev_label == $h['label'])
continue;
$prev_label = $h['label'];
-
- print ("<tr><td><div id='".$h['label']."' class='".$optionclass."' onkeyup='debugfilter(this.id)' onclick='highlightOption(this.id)'><table width=280 id='table".$h['label']."'><tr><td align=left width=30>".$h['label']."</td><td align=left> <span style='height:10px' id ='htitle".$h['label']."'>".$h['title']."</span> </td><td align=right width=20><input id='check".$h['label']."' type='checkbox' ".$selected." ".$disabled." autocomplete='off' value='".$h['label']."' onclick='changeCheckStatus(this.id)'></input></td></tr></table></div></td></tr>");
+ $period = $this->get_selected_period($h['label']);
+
+//<input type='hidden' id='fdesc".$h['label']."' value='".$h['description']."'></input>
+ print ("<tr><td>
+<input type='hidden' id='fetched".$h['label']."' value=',".$period.",".$fetch."'></input>
+<input type='hidden' id='period".$h['label']."' value='".$period."'></input>
+<input type='hidden' id='type".$h['label']."' value='".$h['type']."'></input>
+<input type='hidden' id='source".$h['label']."' value='".$h['source']."'></input>
+ <div id='".$h['label']."' name='columnlist' class='".$optionclass."' onclick='highlightOption(this.id)'>
+<table width=280 id='table".$h['label']."'><tr>
+<td bgcolor=#CAE8EA align=center width=30><b><span style='color:#3399CC'>".$h['label']."</span></b></td>
+<td align=left> <span style='height:10px' id ='htitle".$h['label']."'>".$h['title']."</span> </td>
+<td align=right width=20> <span style='height:10px' id ='loading".$h['label']."'></span> </td>
+<td align=right width=20><input id='check".$h['label']."' name='".$h['tagname']."' type='checkbox' ".$selected." ".$disabled." autocomplete='off' value='".$h['label']."' onclick='changeCheckStatus(this.id)'></input></td>
+</tr></table></div></td></tr>");
}
print("</table> </div></td>");
print("<div class='myslice' id='selectdescr'> </div></td>");
}
-print("</tr><tr><td align=center>");
+print("</tr>");
+//print("<tr><td align=center>");
//print("<input type='button' value='Reset' onclick=resetCols('previousConf') />");
//print("<input type='button' value='Default' onclick=saveConfiguration('defaultConf') />");
-print("<input type='button' value='Reset table' onclick=\"resetConfiguration('defaultConf')\" />");
-print(" <input type='button' value='Save configuration' onclick=saveConfiguration('column_configuration') />");
-print(" <input type='button' id='fetchbutton' onclick='fetchData()' value='Fetch data' disabled=true /> </td>");
+//print("<input type='button' value='Reset table' onclick=\"resetConfiguration()\" />");
+//print("</td>");
+//print(" <input type='button' value='Save configuration' onclick=saveConfiguration('column_configuration') />");
+//print(" <input type='button' id='fetchbutton' onclick='fetchData()' value='Fetch data' disabled=true /> </td>");
if ($showDescription)
print("<td></td>");
print(" </tr> </table>");
}
+
+
function column_filter () {
echo <<< EOF