Changeset 1fa32a0fe64c969c502d0a488ffbc31f55667404

Show
Ignore:
Timestamp:
06/16/09 16:06:42 (5 years ago)
Author:
Theo Schlossnagle <jesus@omniti.com>
git-committer:
Theo Schlossnagle <jesus@omniti.com> 1245168402 +0000
git-parent:

[9d912628f9c34c2d71a0893d6fb80b5c3730e7f1]

git-author:
Theo Schlossnagle <jesus@omniti.com> 1245168402 +0000
Message:

make the web app pull the realtime info (document.domain and hostname) from the database. Stratcon stores it there as a part of its config. refs #145

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • ui/web/htdocs/drawing_board.php

    rc87819b r1fa32a0  
    55$end = $_GET['end']; 
    66$gran = $_GET['gran']; 
     7 
     8require_once('Reconnoiter_DB.php'); 
     9$db = Reconnoiter_DB::getDB(); 
    710?> 
    811 
     
    4043<script src="js/recon.js" type="text/javascript"></script> 
    4144<script src="js/reconui.js" type="text/javascript"></script> 
    42  
     45<script type="text/javascript"> 
     46<!-- 
     47recon_realtime_hostname = '<?php echo $db->realtime_config('hostname'); ?>'; 
     48--> 
     49</script> 
    4350<!-- color picker --> 
    4451<link rel="stylesheet" href="css/colorpicker.css"> 
  • ui/web/htdocs/graph_panel.inc

    rc87819b r1fa32a0  
    5959function graph_stream_data() { 
    6060 
    61 polltime = 5000; 
    62 time_width = 50000; 
     61polltime = 1000; 
     62time_width = 300000; 
    6363stream_object = maingraph; 
    6464stream_dirty = false; 
     
    7878 
    7979maingraph.everyTime(1000, function() { 
     80 
     81console.log("checking if stream dirty"); 
     82                           
    8083    if(!gstreaming) {    
    8184       $('#gstreambox').html(''); 
     
    9093}); 
    9194 
    92 //console.log("sids requestd from noit server = ", sids); 
    93  
    94 $('#gstreambox').html('<iframe src="http://bob.office.omniti.com/data'+sids+'"></iframe>'); 
    95  
     95console.log("sids requestd from noit server = ", sids); 
     96 
     97$('#gstreambox').html('<iframe src="http://' + recon_realtime_hostname + '/data'+sids+'"></iframe>'); 
     98     
    9699} 
    97100function set_current_graph_id(id) { 
  • ui/web/htdocs/index.php

    rfcb3fa5 r1fa32a0  
    11<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
     2<?php 
     3  require_once('Reconnoiter_DB.php'); 
     4  $db = Reconnoiter_DB::getDB(); 
     5?> 
    26<html xmlns="http://www.w3.org/1999/xhtml"> 
    37<head> 
     
    812<link href="css/colorpicker.css" rel="stylesheet" type="text/css" /> 
    913<link rel="icon" type="image/vnd.microsoft.icon" href="images/favicon.ico" /> 
    10 <script>document.domain='omniti.com';</script> 
     14<script>document.domain='<?php echo $db->realtime_config('document_domain'); ?>';</script> 
    1115<script src="js/htmlentities.js"></script> 
    1216<script src="js/json2.js"></script> 
     
    3135<script src="js/jquery.ajaxq-0.0.1.js" type="text/javascript"></script> 
    3236<script src="js/recon.js" type="text/javascript"></script> 
     37<script type="text/javascript"> 
     38<!-- 
     39recon_realtime_hostname = '<?php echo $db->realtime_config('hostname'); ?>'; 
     40--> 
     41</script> 
    3342 
    3443<!-- color picker --> 
  • ui/web/htdocs/js/recon.js

    r1efd693 r1fa32a0  
    55var stream_object; 
    66var stream_dirty; 
     7var recon_realtime_hostname = ''; 
    78 
    89//set the global streaming object to the local ReconGraph object to use, 
    910// and init,update the global streaming boolean to then call this from a server 
    1011function plot_iframe_data(xdata, uuid, metric_name, ydata) { 
     12    //    console.log("plot_iframe_date with:", metric_name, ydata); 
     13 
    1114    stream_object.ReconGraphAddPoint(xdata, uuid, metric_name, ydata); 
    1215    stream_dirty = true; 
     
    231234                    && !ddata[i].hidden ) { 
    232235 
    233 //                console.log("got data from stream for ",uuid,"-",metric_name," data = ",tdata, "hidden = ", ddata[i].hidden); 
     236                   //             console.log("got data from stream for ",uuid,"-",metric_name," data = ",tdata, "hidden = ", ddata[i].hidden); 
    234237 
    235238                    if((xdata*1000)>doptions.max_time) { doptions.max_time = xdata*1000; } 
     
    729732//setup functionality so that every second check if we are streaming and dirty, plot if true 
    730733    stream_graph.everyTime(1000, function() { 
     734            console.log("checking if stream dirty"); 
    731735      if(!streaming) { 
    732736       $('#streambox').html(''); 
     
    757761        } 
    758762 
    759         //console.log("sids requestd from noit server = ", sids); 
    760          $('#streambox').html('<iframe src="http://bob.office.omniti.com/data'+sids+'"></iframe>'); 
     763        console.log("sids requestd from noit server = ", sids); 
     764       $('#streambox').html('<iframe src="http://' + recon_realtime_hostname + '/data'+sids+'"></iframe>'); 
    761765     }); 
    762766  } 
  • ui/web/lib/Reconnoiter_DB.php

    ra6f44d6 r1fa32a0  
    66  private $db; 
    77  private $time_kludge; 
     8  private $config_cache; 
    89 
    910  function __construct() { 
    1011    $this->time_kludge = "(? ::timestamp::text || '-00')::timestamptz"; 
     12    $this->config_cache = array(); 
    1113  } 
    1214  function getDB() { 
     
    3032    return $this->db->prepare($sql); 
    3133  } 
    32  
     34  function realtime_config($attr) { 
     35    if(isset($this->config_cache[$attr])) return $this->config_cache[$attr]; 
     36    $sql = " 
     37        select array_to_string( 
     38                 xpath('//*[@type=\"stratcon_realtime_http\"]//config/' || 
     39                       param || '/text()', config), ',') as value 
     40          from stratcon.current_node_config, (select ? ::text as param) p 
     41         where node_type = 'stratcond'"; 
     42    $sth = $this->db->prepare($sql); 
     43    $sth->execute(array($attr)); 
     44    $row = $sth->fetch(); 
     45    $this->config_cache[$attr] = $row['value']; 
     46    return $row['value']; 
     47  } 
    3348  // Crazy extract syntax to pull out the timestamps so that it looks like the current timezone, but in UTC 
    3449  function get_data_for_window($uuid, $name, $start, $end, $expected, $derive) {