Skip to content
This repository has been archived by the owner on Jul 19, 2021. It is now read-only.

Commit

Permalink
added ability to disable data store and docker graph size scan
Browse files Browse the repository at this point in the history
  • Loading branch information
greyarch committed Jun 7, 2017
1 parent e6ae67c commit 6c98594
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 7 deletions.
5 changes: 5 additions & 0 deletions index.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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'
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "docker-dashboard-agent-compose",
"version": "3.1.0",
"version": "3.2.0",
"description": "",
"main": "index.js",
"scripts": {
Expand Down
5 changes: 3 additions & 2 deletions src/coffee/storage.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
40 changes: 36 additions & 4 deletions tests/coffee/storage.test.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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']
Expand Down

0 comments on commit 6c98594

Please sign in to comment.