Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Increased plugin polling interval to 1 second, and data is now actual…

…ly rendered! Both the table and text plugin types are supportesd so far.
  • Loading branch information...
commit fb449b92d90b4700253ee6ccf1fcf53745808a54 1 parent 66554fd
@meltingice authored
View
2  NodeMonitor_Node.js
@@ -63,7 +63,7 @@ MonitorNode.execute_plugins = function() {
MonitorNode.send_data(plugin_name, render, data);
});
}
- }, 500);
+ }, 1000);
}
MonitorNode.send_data = function(plugin, render, data) {
View
89 html/css/default.css
@@ -0,0 +1,89 @@
+body {
+ background-color: #f2f2f2;
+ font-family: arial, sans-serif;
+}
+
+#header {
+ padding: 20px;
+ border-bottom: 1px #d2d2d2 solid;
+}
+
+#header h1 {
+ font-weight: bold;
+ font-family: Georgia, serif;
+ font-size: 32px;
+ color: rgba(47, 30, 0, 0.8);
+ text-shadow: 0 1px 0 rgba(255, 255, 255, 0.8)
+}
+
+#header h2 {
+ color: #222222;
+ font-family: georgia, serif;
+ margin-top: -2px;
+ font-size: 16px;
+}
+
+#nodes {
+ width: 900px;
+ padding: 20px;
+}
+
+.node {
+ margin-bottom: 10px;
+ overflow: hidden;
+ width: 100%;
+}
+
+.node > h1 {
+ font-family: georgia, serif;
+ font-size: 20px;
+ color: rgba(47, 30, 0, 0.9);
+ text-shadow: 0 1px 0 rgba(255, 255, 255, 0.8);
+}
+
+.node-content {
+ padding: 5px 0 0 10px;
+}
+
+.plugin {
+ float: left;
+ width:430px;
+ margin-right: 15px;
+}
+
+.plugin > h1 {
+ font-family: georgia, serif;
+ margin: 5px 0 5px 0;
+ color: #222222;
+}
+
+.text-plugin > .plugin-content {
+ border: 1px #c2c2c2 solid;
+ background-color: #e8e8e8;
+ padding: 10px;
+ font-family: arial, sans-serif;
+ font-size: 14px;
+ color: #333333;
+}
+
+.table-plugin > .plugin-content table {
+ width: 100%;
+ border-collapse: collapse;
+}
+
+.table-plugin > .plugin-content th {
+ background-color: #e8e8e8;
+ padding: 5px;
+ font-size: 14px;
+ font-weight: bold;
+ color: #333333;
+ border: 1px #c2c2c2 solid;
+}
+
+.table-plugin > .plugin-content td {
+ background-color: #e8e8e8;
+ padding: 5px;
+ font-size: 14px;
+ color: #333333;
+ border: 1px #c2c2c2 solid;
+}
View
24 html/index.html
@@ -15,10 +15,34 @@
<body>
<div id="header">
<h1>NodeMonitor</h1>
+ <h2>Distributed Realtime Server Monitoring</h2>
</div>
<div id="nodes">
+ <!--
+ EXAMPLE OUTPUT:
+ <div id="node-Server1" class="node">
+ <h1>Server 1</h1>
+ <div class="node-content">
+ <div class="plugin plugin-uptime text-plugin">
+ <h1>System Uptime</h1>
+ <div class="plugin-content">
+
+ </div>
+ </div>
+ <div class="plugin plugin-memcached table-plugin">
+ <h1>Memcached Stats</h1>
+ <div class="plugin-content">
+ <table>
+ <thead></thead>
+ <tbody></tbody>
+ </table>
+ </div>
+ </div>
+ </div>
+ </div>
+ -->
</div>
</body>
</html>
View
61 html/js/nodemonitor.js
@@ -47,13 +47,13 @@ var NM = window.NM || {};
* For some reason its not reconnecting though. Input welcome.
*/
- /*var timeout = setTimeout(function() {
+ var timeout = setTimeout(function() {
if(NM.socket.connected) {
clearTimeout(timeout);
} else {
NM.connect();
}
- }, 2000);*/
+ }, 2000);
}
NM.parse_data = function(data) {
@@ -69,9 +69,9 @@ var NM = window.NM || {};
}
this.nodes[data.origin].plugins[data.plugin].data = data.data;
- this.render_data(data);
+ this.render_data(this.nodes[data.origin], data.plugin);
- } catch(err){ }
+ } catch(err){ return; }
}
NM.add_node = function(name) {
@@ -94,8 +94,14 @@ var NM = window.NM || {};
NMR.add_plugin(node, name);
}
+ NM.render_data = function(node, plugin) {
+ NMR.render[node.plugins[plugin].render.type](node, plugin);
+ }
+
// The rendering class
- var NMR = {};
+ var NMR = {
+ render: {}
+ };
NMR.name_to_css = function(name) {
return name.replace(/([^A-Za-z0-9_-]+)/g, '');
@@ -105,6 +111,7 @@ var NM = window.NM || {};
var div_name = 'node-'+this.name_to_css(name);
$('<div />')
.attr('id', div_name)
+ .addClass('node')
.html('<h1>'+name+'</h1>\n<div class="node-content"></div>\n')
.appendTo('#nodes');
}
@@ -124,9 +131,51 @@ var NM = window.NM || {};
var class = 'plugin-'+this.name_to_css(name);
$('<div />')
.addClass(class)
- .addClass('text-plugin')
+ .addClass('text-plugin plugin')
.html('<h1>'+plugin.render.title+'</h1><div class="plugin-content"></div>')
.appendTo('#'+parent+'> .node-content');
}
+ NMR.add_table_plugin = function(node, name) {
+ var plugin = NM.nodes[node].plugins[name];
+
+ var parent = 'node-'+this.name_to_css(node);
+ var class = 'plugin-'+this.name_to_css(name);
+ var div = $('<div />')
+ .addClass(class)
+ .addClass('table-plugin plugin')
+ .html('<h1>'+plugin.render.title+'</h1><div class="plugin-content"><table></table></div>')
+ .appendTo('#'+parent+'> .node-content');
+
+ var table = div.find('.plugin-content > table');
+ table.append('<thead />');
+ var tr = $('<tr />');
+ $.each(plugin.render.cols, function(i, col) {
+ var th = $('<th />').html(col);
+ tr.append(th);
+ });
+ table.find('thead').append(tr);
+ table.append('<tbody />');
+ }
+
+ NMR.render.text = function(node, plugin) {
+ var div_name = 'plugin-' + NMR.name_to_css(plugin);
+ $('.'+div_name+' > .plugin-content').html(node.plugins[plugin].data);
+ }
+
+ NMR.render.table = function(node, plugin) {
+ var div_name = 'plugin-' + NMR.name_to_css(plugin);
+ //var tbody = $('.'+div_name+' > .plugin-content tbody');
+ var tbody = $('<tbody />');
+ $.each(node.plugins[plugin].data, function(i, row) {
+ var tr = $('<tr />');
+ $.each(row, function(k, col) {
+ var td = $('<td />').html(col);
+ tr.append(td);
+ });
+ tbody.append(tr);
+ });
+ $('.'+div_name+' > .plugin-content tbody').replaceWith(tbody);
+ }
+
})(window);
Please sign in to comment.
Something went wrong with that request. Please try again.