diff --git a/index.coffee b/index.coffee index 5424c9b..b3046e6 100644 --- a/index.coffee +++ b/index.coffee @@ -13,6 +13,9 @@ pipeworksCmd = env.get 'PIPEWORKS_CMD', 'eth1 -i eth0 @CONTAINER_NAME@ 0/0 @3055 vlan = parseInt(pipeworksCmd.slice(-4)) - 3000 scanCmd = env.get 'NETWORK_SCAN_CMD', "nmap -sP -n 10.25.#{vlan}.51-240" +datastoreScanEnabled = env.get 'DATASTORE_SCAN_ENABLED', true +if datastoreScanEnabled is 'false' then datastoreScanEnabled = false + config = domain: env.assert 'DOMAIN' tld: env.assert 'TLD' @@ -39,6 +42,8 @@ config = pipeworksCmd: pipeworksCmd startcheck: test: "ifconfig #{NETWORK_HEALTHCHECK_TEST_INTERFACE} | grep inet | grep #{NETWORK_HEALTHCHECK_TEST_IP_PREFIX}" + datastore: + scanEnabled: datastoreScanEnabled if ENABLE_NETWORK_HEALTHCHECK and ENABLE_NETWORK_HEALTHCHECK isnt 'false' diff --git a/package.json b/package.json index 874d125..631711f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "docker-dashboard-agent-compose", - "version": "3.1.0", + "version": "3.2.0", "description": "", "main": "index.js", "scripts": { diff --git a/src/coffee/storage.coffee b/src/coffee/storage.coffee index 018fb2f..8456b85 100644 --- a/src/coffee/storage.coffee +++ b/src/coffee/storage.coffee @@ -4,8 +4,9 @@ lib = require './storage/lib.coffee' module.exports = (agent, mqtt, config) -> - lib.runPeriodically lib.publishDataStoreUsage(mqtt, '/agent/storage/size', config.dataDir) - lib.runPeriodically lib.publishDataStoreUsage(mqtt, '/agent/docker/graph', config.docker.graph.path) + if config.datastore?.scanEnabled + lib.runPeriodically lib.publishDataStoreUsage(mqtt, '/agent/storage/size', config.dataDir) + lib.runPeriodically lib.publishDataStoreUsage(mqtt, '/agent/docker/graph', config.docker.graph.path) publishStorageBuckets = (err, buckets) -> mqtt.publish '/agent/storage/buckets', buckets unless err diff --git a/tests/coffee/storage.test.coffee b/tests/coffee/storage.test.coffee index 798ebb6..48c8e5d 100644 --- a/tests/coffee/storage.test.coffee +++ b/tests/coffee/storage.test.coffee @@ -71,18 +71,50 @@ describe 'Storage', -> captor.value() td.verify cb null, {name: 'bucket1', size: 1234} - it 'should periodically publish data storage statistics to mqtt', -> + it 'should periodically publish data storage statistics to mqtt if data store scan is enabled', -> agent = td.object ['on'] - storage agent, null, dataDir: '/rootDir', domain: 'myDomain', docker: graph: path: '/docker/graph' + storage agent, null, + dataDir: '/rootDir' + domain: 'myDomain' + docker: + graph: path: '/docker/graph' + datastore: scanEnabled: true td.verify storageLib.publishDataStoreUsage(null, '/agent/storage/size', '/rootDir') td.verify storageLib.runPeriodically td.matchers.anything() - it 'should periodically publish docker graph statistics to mqtt', -> + it 'should periodically publish docker graph statistics to mqtt if data store scan is enabled', -> agent = td.object ['on'] - storage agent, null, dataDir: '/rootDir', domain: 'myDomain', docker: graph: path: '/docker/graph' + storage agent, null, + dataDir: '/rootDir' + domain: 'myDomain' + docker: + graph: path: '/docker/graph' + datastore: scanEnabled: true td.verify storageLib.publishDataStoreUsage(null, '/agent/docker/graph', '/docker/graph') td.verify storageLib.runPeriodically td.matchers.anything() + it 'should NOT periodically publish data storage statistics to mqtt if data store scan is disabled', -> + agent = td.object ['on'] + storage agent, null, + dataDir: '/rootDir' + domain: 'myDomain' + docker: + graph: path: '/docker/graph' + datastore: scanEnabled: false + td.verify storageLib.publishDataStoreUsage(), {times: 0, ignoreExtraArgs: true} + td.verify storageLib.runPeriodically(), {times: 0, ignoreExtraArgs: true} + + it 'should NOT periodically publish docker graph statistics to mqtt if data store scan is disabled', -> + agent = td.object ['on'] + storage agent, null, + dataDir: '/rootDir' + domain: 'myDomain' + docker: + graph: path: '/docker/graph' + datastore: scanEnabled: false + td.verify storageLib.publishDataStoreUsage(), {times: 0, ignoreExtraArgs: true} + td.verify storageLib.runPeriodically(), {times: 0, ignoreExtraArgs: true} + it 'should watch for changes on the base path and publish storage buckets', -> agent = td.object ['on'] mqtt = td.object ['publish']