├── .gitignore ├── config ├── runtime.json ├── default.json └── external.js ├── monitor.js ├── lib ├── image │ └── configicon.png ├── css │ └── config.css ├── probe │ └── ConfigProbe.js ├── index.js └── view │ ├── ConfigAll.js │ └── Config.js ├── site_db ├── Site │ └── default.json └── Page │ ├── index.json │ └── 404.json ├── History.md ├── package.json ├── LICENSE ├── README.md └── test └── ConfigProbeTest.js /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | -------------------------------------------------------------------------------- /config/runtime.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /monitor.js: -------------------------------------------------------------------------------- 1 | // Bootstrap for standalone development 2 | require('monitor-dashboard'); 3 | -------------------------------------------------------------------------------- /config/default.json: -------------------------------------------------------------------------------- 1 | { 2 | "Monitor": { 3 | "appName": "config-monitor" 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /lib/image/configicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lorenwest/config-monitor/master/lib/image/configicon.png -------------------------------------------------------------------------------- /site_db/Site/default.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "default", 3 | "name": "Node Monitor", 4 | "logo": "/static/css/default/images/monitor.jpg", 5 | "favicon": "/static/css/default/images/favicon.ico", 6 | "css": "", 7 | "tours": [] 8 | } -------------------------------------------------------------------------------- /History.md: -------------------------------------------------------------------------------- 1 | 0.1.2 / 2013-11-06 2 | ================== 3 | 4 | * Update to monitor 6.0 5 | 6 | 0.1.1 / 2013-10-23 7 | ================== 8 | 9 | * Exposed newTray as a probe control 10 | 11 | 0.1.0 / 2013-10-20 12 | ================== 13 | 14 | * Initial checkin 15 | -------------------------------------------------------------------------------- /lib/css/config.css: -------------------------------------------------------------------------------- 1 | .nm-app-config-heading { 2 | margin-left:10px; 3 | font-size: 18px; 4 | } 5 | 6 | .nm-app-config-configs { 7 | font-size: 14px; 8 | margin: 10px 0 15px 10px; 9 | } 10 | 11 | .nm-app-config-heading { 12 | background: #444444; 13 | padding: 5px 0 5px 20px; 14 | margin-left: -10px; 15 | cursor: default; 16 | } 17 | -------------------------------------------------------------------------------- /site_db/Page/index.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "/index", 3 | "title": "MahMonitr", 4 | "components": [ 5 | { 6 | "id": "c1", 7 | "viewClass": "config.Config", 8 | "viewOptions": { 9 | "title": "Config Monitor", 10 | "background": true 11 | }, 12 | "css": { 13 | ".nm-cv": "top:10px; z-index:1; left:0px;", 14 | ".nm-cv-viewport": "height:600px; width:600px;" 15 | }, 16 | "monitor": { 17 | "probeClass": "Config", 18 | "hostName": "Derrick.local", 19 | "appName": "config-monitor", 20 | "appInstance": "1" 21 | } 22 | } 23 | ] 24 | } -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "config-monitor", 3 | "description": "Config Monitor", 4 | "version": "0.6.1", 5 | "main": "lib/index.js", 6 | "author": "Derrick West ", 7 | "homepage": "http://derrickwest.github.com/config-monitor/", 8 | "licenses": ["MIT"], 9 | "repository": { 10 | "type" : "git", 11 | "url" : "http://github.com/derrickwest/config-monitor.git" 12 | }, 13 | "dependencies": { 14 | "config": ">=0.4.31 <0.5.0", 15 | "connect": ">=1.7.2 <1.8.0", 16 | "monitor": ">=0.6.0 <0.7.0", 17 | "monitor-dashboard": ">=0.6.0 <0.7.0" 18 | }, 19 | "devDependencies": { 20 | }, 21 | "engines": {"node": ">0.4.x"}, 22 | "scripts": { 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /lib/probe/ConfigProbe.js: -------------------------------------------------------------------------------- 1 | // ConfigProbe.js (c) 2013 Derrick West 2 | // May be freely distributed under the MIT license. 3 | // For further details and documentation: 4 | // http://derrickwest.github.com/config-monitor-min 5 | var Monitor = require('monitor'), 6 | Probe = Monitor.Probe, 7 | Config = require('config'); 8 | 9 | var ConfigProbe = Probe.extend({ 10 | 11 | probeClass: 'Config', 12 | 13 | initialize: function(){ 14 | 15 | // Set the initial probe state 16 | this.setState(); 17 | 18 | // Change the probe state when the config changes 19 | Config.watch(Config, null, function(){ 20 | this.setState(); 21 | }); 22 | }, 23 | 24 | setState: function(){ 25 | this.set({ 26 | config: Config, 27 | sources: Config.getConfigSources() 28 | }); 29 | } 30 | }); 31 | -------------------------------------------------------------------------------- /config/external.js: -------------------------------------------------------------------------------- 1 | // Configuration overrides when NODE_ENV=external 2 | // Read the comments below before using this configuration. 3 | module.exports = { 4 | 5 | // Overrides for the monitor-min package 6 | Monitor: { 7 | 8 | // This setting allows incoming monitor connections from remote systems. 9 | // It should be used only after assuring the network security policies 10 | // prevent untrusted connections on the monitor service port range (usually 42000+). 11 | allowExternalConnections: true 12 | }, 13 | 14 | // Overrides for the node-monitor application 15 | Dashboard: { 16 | 17 | // This setting allows incoming browser connections from remote systems. 18 | // It should be used only after assuring the network security policies 19 | // prevent untrusted connections on the application service port (usually 4200). 20 | allowExternalConnections: true 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2013 Derrick West 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /lib/index.js: -------------------------------------------------------------------------------- 1 | // This is run when the app is loaded from monitor-dashboard 2 | (function(root){ 3 | 4 | // Create a server, and expose this directory 5 | var Connect = require('connect'), 6 | FS = require('fs'), 7 | Path = require('path'), 8 | Static = Connect['static'](__dirname); 9 | 10 | // Load all probes found in the ./probe directory 11 | // This is synchronous because require() is synchronous 12 | FS.readdirSync(Path.join(__dirname, 'probe')).forEach(function(fileName) { 13 | if (fileName.substr(-3) === '.js') { 14 | require('./probe/' + fileName); 15 | } 16 | }); 17 | 18 | // Export a middleware component 19 | var app = module.exports = function(request, response, next) { 20 | 21 | // Process dynamic app endpoints here 22 | if (request.url === '/status') { 23 | response.writeHead(200, {'Content-Type': 'text/plan'}); 24 | return response.end('ok'); 25 | } 26 | 27 | // Forward to the static endpoint, then to the next step 28 | // if the file isn't there. The next step is a monitor page. 29 | return Static(request, response, next); 30 | } 31 | 32 | }(this)); 33 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | config-monitor 2 | ============== 3 | 4 | Node-Monitor add-on for the npm config module. 5 | 6 | Adding To Your App 7 | ------------------- 8 | 9 | Probes are added to your application by specifying monitor-min and config-monitor as dependencies within your package.json file 10 | 11 | "dependencies": { 12 | ... 13 | "config": ">=0.4.31 <0.5.0", 14 | ... 15 | "monitor": ">=0.6.0 <0.7.0", 16 | "config-monitor": ">=0.1.1 <0.2.0", 17 | ... 18 | 19 | Then including them in your application startup phase 20 | 21 | // Start monitoring, and load monitor probes 22 | var Monitor = require('monitor').start(); 23 | var configMonitor = require('config-monitor'); 24 | 25 | Adding to the Monitor Dashboard 26 | ------------------------------- 27 | 28 | To add these monitors to your dashboard, install config-monitor in your node path (or globally) 29 | 30 | npm install -g monitor-dashboard 31 | npm install -g config-monitor 32 | 33 | Then start the dashboard 34 | 35 | npm start monitor-dashboard 36 | 37 | When adding components into your dashboard, the config-monitor components will be avilable. 38 | 39 | -------------------------------------------------------------------------------- /site_db/Page/404.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "/404", 3 | "title": "New Page Template", 4 | "components": [ 5 | { 6 | "id": "c1", 7 | "viewClass": "core.Html", 8 | "viewOptions": { 9 | "htmlValue": "Page not found.
Create a monitor page at this location?" 10 | }, 11 | "css": { 12 | ".nm-cv": "top:60px; left:0px; z-index:1;", 13 | ".nm-cv-viewport": "font-size:20px; line-height:34px; height:78px; width:367px;" 14 | }, 15 | "monitor": {} 16 | }, 17 | { 18 | "id": "c2", 19 | "viewClass": "core.Button", 20 | "viewOptions": { 21 | "label": "Create Page", 22 | "icon": "icon-magic", 23 | "onPress": "pageView.newPage();" 24 | }, 25 | "css": { 26 | ".nm-cv": "top:170px; left:120px; z-index:2;" 27 | }, 28 | "monitor": {} 29 | }, 30 | { 31 | "id": "c3", 32 | "viewClass": "core.Button", 33 | "viewOptions": { 34 | "label": "Back", 35 | "icon": "icon-arrow-left", 36 | "onPress": "window.history.back();" 37 | }, 38 | "css": { 39 | ".nm-cv": "top:170px; left:0px; z-index:3;" 40 | }, 41 | "monitor": {} 42 | } 43 | ] 44 | } -------------------------------------------------------------------------------- /test/ConfigProbeTest.js: -------------------------------------------------------------------------------- 1 | // ConfigProbeTest.js (c) 2013 Derrick West and other contributors 2 | // May be freely distributed under the MIT license. 3 | // For further details and documentation: 4 | // http://derrickwest.github.com/config-monitor 5 | (function(root){ 6 | 7 | // Dependencies 8 | var Monitor = require('monitor'), 9 | configMonitor = require('../lib/index'), 10 | CONFIG = require('config'), 11 | Backbone = Monitor.Backbone, _ = Monitor._; 12 | 13 | /** 14 | * Monitor Unit Tests 15 | * 16 | * This module contains unit test classes for each of the core classes, and 17 | * some unit tests for baseline probes. 18 | * 19 | * @module UnitTests 20 | */ 21 | 22 | /** 23 | * Unit tests for the Config probe. 24 | * @class ConfigTest 25 | */ 26 | 27 | /** 28 | * Test group for baseline Config probe functionality 29 | * 30 | * @method Config 31 | */ 32 | module.exports['Config'] = { 33 | 34 | /** 35 | * Tests the initial config values 36 | * @method Config-InitialValues 37 | */ 38 | InitialValues: function(test) { 39 | var configMonitor = new Monitor({probeClass:'Config'}); 40 | configMonitor.connect(function() { 41 | var json = configMonitor.toJSON().config; 42 | test.ok(json.Monitor != null, 'Monitor configuration is present'); 43 | test.equal(json.Monitor.appName, 'config-monitor', 'The appName parameter has the correct value'); 44 | test.equal(json.Monitor.serviceBasePort, 42000, 'The serviceBasePort parameter has the correct value'); 45 | test.equal(json.Monitor.portsToScan, 20, 'The portsToScan parameter has the correct value'); 46 | test.equal(json.Monitor.allowExternalConnections, false, 'The allowExternalConnections parameter has the correct value'); 47 | test.done(); 48 | }); 49 | } 50 | }; 51 | 52 | 53 | }(this)); 54 | -------------------------------------------------------------------------------- /lib/view/ConfigAll.js: -------------------------------------------------------------------------------- 1 | // Config.js (c) 2013 Derrick West 2 | // May be freely distributed under the MIT license. 3 | // For further details and documentation: 4 | // http://derrickwest.github.com/config-monitor 5 | (function(root){ 6 | 7 | // Module loading 8 | var Monitor = root.Monitor || require('monitor'), 9 | UI = Monitor.UI, 10 | Backbone = Monitor.Backbone; 11 | 12 | /** 13 | * This is the current configuration with all config sources 14 | * 15 | * @class ConfigAll 16 | * @extends Backbone.View 17 | * @constructor 18 | * @param options {Object} View initialization options (See others in Backbone.View) 19 | */ 20 | var ConfigAll = UI.app.config.ConfigAll = UI.app.config.Config.extend({ 21 | 22 | // Define the view 23 | name: 'Configuration With Sources', 24 | icon: 'image/configicon.png', 25 | description: 'Current configuration with sources', 26 | 27 | initialize: function(options) { 28 | var t = this; 29 | t.monitor = options.monitor; 30 | t.component = options.component; 31 | options.component.setDefaultSize({ 32 | width: 600, 33 | height: 600 34 | }); 35 | 36 | // Set default monitor options 37 | if (!t.monitor.get('probeClass')) { 38 | t.monitor.set({ 39 | probeClass: 'Config' 40 | }); 41 | } 42 | 43 | // Update the view on monitor change 44 | if (t.monitor != null) { 45 | t.monitor.on('change', t.onchange, t); 46 | } 47 | }, 48 | 49 | onchange: function() { 50 | var t = this; 51 | t.$el.html(''); 52 | t.renderSection('Current Configuration', 'Computed (merged) configurations', t.monitor.get('config')); 53 | 54 | var sources = t.monitor.get('sources'); 55 | for (var i = sources.length - 1; i >= 0; i--) { 56 | var source = sources[i], 57 | parts = source.name.split(/[\/\\]/), 58 | heading = parts[parts.length - 1], 59 | title = source.name; 60 | 61 | // Put File: in front of files 62 | if (heading.length < source.name.length) { 63 | heading = 'File: ' + heading; 64 | } 65 | 66 | // Better tooltips 67 | if (heading === 'Module Defaults') { 68 | title = 'From calling setModuleDefaults()'; 69 | } 70 | if (heading === '$NODE_CONFIG') { 71 | title = 'From the $NODE_CONFIG environment variable'; 72 | } 73 | 74 | t.renderSection(heading, title, source.parsed); 75 | } 76 | 77 | // Add tool tips 78 | UI.tooltip(t.$('*[title]')); 79 | } 80 | 81 | }); 82 | 83 | }(this)); 84 | -------------------------------------------------------------------------------- /lib/view/Config.js: -------------------------------------------------------------------------------- 1 | // Config.js (c) 2013 Derrick West 2 | // May be freely distributed under the MIT license. 3 | // For further details and documentation: 4 | // http://derrickwest.github.com/config-monitor 5 | (function(root){ 6 | 7 | // Module loading 8 | var Monitor = root.Monitor || require('monitor'), 9 | UI = Monitor.UI, 10 | Backbone = Monitor.Backbone; 11 | 12 | // Define the app on first load 13 | UI.app.config = UI.app.config || {}; 14 | 15 | /** 16 | * This is the view for the config module 17 | * 18 | * @class Config 19 | * @extends Backbone.View 20 | * @constructor 21 | * @param options {Object} View initialization options (See others in Backbone.View) 22 | */ 23 | var Config = UI.app.config.Config = Backbone.View.extend({ 24 | 25 | // Define the view 26 | name: 'Current Configuration', 27 | icon: 'image/configicon.png', 28 | tags: ['Configuration', 'Utility'], 29 | description: 'A view of the current configuration', 30 | 31 | initialize: function(options) { 32 | var t = this; 33 | t.monitor = options.monitor; 34 | t.component = options.component; 35 | options.component.setDefaultSize({ 36 | width: 400, 37 | height: 300 38 | }); 39 | 40 | // Set default monitor options 41 | if (!t.monitor.get('probeClass')) { 42 | t.monitor.set({ 43 | probeClass: 'Config' 44 | }); 45 | } 46 | 47 | // Update the view on monitor change 48 | if (t.monitor != null) { 49 | t.monitor.on('change', t.onchange, t); 50 | } 51 | }, 52 | 53 | onchange: function() { 54 | var t = this; 55 | t.$el.html(''); 56 | t.renderSection('', '', t.monitor.get('config')); 57 | }, 58 | 59 | renderSection: function(heading, title, data) { 60 | var t = this; 61 | 62 | // Create the heading if specified 63 | var viewTarget = t.$el; 64 | if (heading) { 65 | viewTarget = t.$el.append( 66 | '
' + heading + '
' + 67 | '
' 68 | ).find('.nm-app-config-configs').last(); 69 | } 70 | 71 | // Append the JSON data viewer 72 | t.jsonView = new UI.JsonView({ 73 | model: data 74 | }); 75 | t.jsonView.render(); 76 | viewTarget.append(t.jsonView.$el); 77 | } 78 | 79 | }); 80 | 81 | // Custom settings form 82 | Config.SettingsView = Backbone.View.extend({ 83 | 84 | render: function() { 85 | var t = this; 86 | 87 | // Append a monitor picker 88 | t.monitorPicker = new UI.MonitorPicker({ 89 | el: t.$el, 90 | hideProbe: true, 91 | model: t.options.monitor 92 | }); 93 | t.monitorPicker.render(); 94 | }, 95 | 96 | }); 97 | 98 | }(this)); 99 | --------------------------------------------------------------------------------