Changeset 1fa32a0fe64c969c502d0a488ffbc31f55667404
- Timestamp:
- 06/16/09 16:06:42
(4 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
| rc87819b |
r1fa32a0 |
|
| 5 | 5 | $end = $_GET['end']; |
|---|
| 6 | 6 | $gran = $_GET['gran']; |
|---|
| | 7 | |
|---|
| | 8 | require_once('Reconnoiter_DB.php'); |
|---|
| | 9 | $db = Reconnoiter_DB::getDB(); |
|---|
| 7 | 10 | ?> |
|---|
| 8 | 11 | |
|---|
| … | … | |
| 40 | 43 | <script src="js/recon.js" type="text/javascript"></script> |
|---|
| 41 | 44 | <script src="js/reconui.js" type="text/javascript"></script> |
|---|
| 42 | | |
|---|
| | 45 | <script type="text/javascript"> |
|---|
| | 46 | <!-- |
|---|
| | 47 | recon_realtime_hostname = '<?php echo $db->realtime_config('hostname'); ?>'; |
|---|
| | 48 | --> |
|---|
| | 49 | </script> |
|---|
| 43 | 50 | <!-- color picker --> |
|---|
| 44 | 51 | <link rel="stylesheet" href="css/colorpicker.css"> |
|---|
| rc87819b |
r1fa32a0 |
|
| 59 | 59 | function graph_stream_data() { |
|---|
| 60 | 60 | |
|---|
| 61 | | polltime = 5000; |
|---|
| 62 | | time_width = 50000; |
|---|
| | 61 | polltime = 1000; |
|---|
| | 62 | time_width = 300000; |
|---|
| 63 | 63 | stream_object = maingraph; |
|---|
| 64 | 64 | stream_dirty = false; |
|---|
| … | … | |
| 78 | 78 | |
|---|
| 79 | 79 | maingraph.everyTime(1000, function() { |
|---|
| | 80 | |
|---|
| | 81 | console.log("checking if stream dirty"); |
|---|
| | 82 | |
|---|
| 80 | 83 | if(!gstreaming) { |
|---|
| 81 | 84 | $('#gstreambox').html(''); |
|---|
| … | … | |
| 90 | 93 | }); |
|---|
| 91 | 94 | |
|---|
| 92 | | //console.log("sids requestd from noit server = ", sids); |
|---|
| 93 | | |
|---|
| 94 | | $('#gstreambox').html('<iframe src="http://bob.office.omniti.com/data'+sids+'"></iframe>'); |
|---|
| 95 | | |
|---|
| | 95 | console.log("sids requestd from noit server = ", sids); |
|---|
| | 96 | |
|---|
| | 97 | $('#gstreambox').html('<iframe src="http://' + recon_realtime_hostname + '/data'+sids+'"></iframe>'); |
|---|
| | 98 | |
|---|
| 96 | 99 | } |
|---|
| 97 | 100 | function set_current_graph_id(id) { |
|---|
| rfcb3fa5 |
r1fa32a0 |
|
| 1 | 1 | <!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 | ?> |
|---|
| 2 | 6 | <html xmlns="http://www.w3.org/1999/xhtml"> |
|---|
| 3 | 7 | <head> |
|---|
| … | … | |
| 8 | 12 | <link href="css/colorpicker.css" rel="stylesheet" type="text/css" /> |
|---|
| 9 | 13 | <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> |
|---|
| 11 | 15 | <script src="js/htmlentities.js"></script> |
|---|
| 12 | 16 | <script src="js/json2.js"></script> |
|---|
| … | … | |
| 31 | 35 | <script src="js/jquery.ajaxq-0.0.1.js" type="text/javascript"></script> |
|---|
| 32 | 36 | <script src="js/recon.js" type="text/javascript"></script> |
|---|
| | 37 | <script type="text/javascript"> |
|---|
| | 38 | <!-- |
|---|
| | 39 | recon_realtime_hostname = '<?php echo $db->realtime_config('hostname'); ?>'; |
|---|
| | 40 | --> |
|---|
| | 41 | </script> |
|---|
| 33 | 42 | |
|---|
| 34 | 43 | <!-- color picker --> |
|---|
| r1efd693 |
r1fa32a0 |
|
| 5 | 5 | var stream_object; |
|---|
| 6 | 6 | var stream_dirty; |
|---|
| | 7 | var recon_realtime_hostname = ''; |
|---|
| 7 | 8 | |
|---|
| 8 | 9 | //set the global streaming object to the local ReconGraph object to use, |
|---|
| 9 | 10 | // and init,update the global streaming boolean to then call this from a server |
|---|
| 10 | 11 | function plot_iframe_data(xdata, uuid, metric_name, ydata) { |
|---|
| | 12 | // console.log("plot_iframe_date with:", metric_name, ydata); |
|---|
| | 13 | |
|---|
| 11 | 14 | stream_object.ReconGraphAddPoint(xdata, uuid, metric_name, ydata); |
|---|
| 12 | 15 | stream_dirty = true; |
|---|
| … | … | |
| 231 | 234 | && !ddata[i].hidden ) { |
|---|
| 232 | 235 | |
|---|
| 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); |
|---|
| 234 | 237 | |
|---|
| 235 | 238 | if((xdata*1000)>doptions.max_time) { doptions.max_time = xdata*1000; } |
|---|
| … | … | |
| 729 | 732 | //setup functionality so that every second check if we are streaming and dirty, plot if true |
|---|
| 730 | 733 | stream_graph.everyTime(1000, function() { |
|---|
| | 734 | console.log("checking if stream dirty"); |
|---|
| 731 | 735 | if(!streaming) { |
|---|
| 732 | 736 | $('#streambox').html(''); |
|---|
| … | … | |
| 757 | 761 | } |
|---|
| 758 | 762 | |
|---|
| 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>'); |
|---|
| 761 | 765 | }); |
|---|
| 762 | 766 | } |
|---|
| ra6f44d6 |
r1fa32a0 |
|
| 6 | 6 | private $db; |
|---|
| 7 | 7 | private $time_kludge; |
|---|
| | 8 | private $config_cache; |
|---|
| 8 | 9 | |
|---|
| 9 | 10 | function __construct() { |
|---|
| 10 | 11 | $this->time_kludge = "(? ::timestamp::text || '-00')::timestamptz"; |
|---|
| | 12 | $this->config_cache = array(); |
|---|
| 11 | 13 | } |
|---|
| 12 | 14 | function getDB() { |
|---|
| … | … | |
| 30 | 32 | return $this->db->prepare($sql); |
|---|
| 31 | 33 | } |
|---|
| 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 | } |
|---|
| 33 | 48 | // Crazy extract syntax to pull out the timestamps so that it looks like the current timezone, but in UTC |
|---|
| 34 | 49 | function get_data_for_window($uuid, $name, $start, $end, $expected, $derive) { |
|---|