Skip to content
This repository has been archived by the owner on Aug 28, 2023. It is now read-only.

Fixed deprecated Path.existsSync #12

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
node_modules/
config.json
7 changes: 7 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

FROM dockerfile/nodejs
MAINTAINER Teemu Heikkilä <[email protected]>

ADD . /data
RUN npm install
CMD /usr/local/bin/node start.js -c config.json
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
HoardD, send ALL metrics to graphite!
HoardD forkd!
=====================================

This fork contains dockerfile and modified HoardD with support for ENV-vars (graphite host and fqnd)
Also fixed deprecated Path.exists functions into Fs.exists.


Running
--------------
`docker build -t hoardd .`

`docker run -d -e CARBON_HOST=carbon.server.org -e FQDN=docker.host.hostname -v /proc:/host_proc:ro -t hoardd`


What is HoardD
---------------

Expand Down
6 changes: 3 additions & 3 deletions config.json.example → config.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"carbonHost": "localhost",
"carbonPort": 2003,
"scriptPath": "/full/path/to/scripts/dir",
"scriptPath": "/data/scripts",
"fqdn": "fqdn.of.this.server",
"sampleInterval": 10,
"sendEach": 6,
"sampleInterval": 5,
"sendEach": 3,
"maxFailedSens": 10000,
"namespace": "hoard"
}
2 changes: 1 addition & 1 deletion scripts/interfaces.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ module.exports = (server) ->
]

# Reads from proc
procfile = '/proc/net/dev'
procfile = '/host_proc/net/dev'
content = Fs.readFileSync(procfile, 'ascii').trim()
for line in content.split('\n')[2...]
continue if line.match /lo:/
Expand Down
4 changes: 2 additions & 2 deletions scripts/load_avg.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ module.exports = (server) ->
server.cli.debug "Running load average script"

# Read from /proc
procfile = '/proc/loadavg'
if Path.existsSync procfile
procfile = '/host_proc/loadavg'
if Fs.existsSync procfile
data = Fs.readFileSync(procfile, 'utf-8')
[one, five, fifteen] = data.split(' ', 3)
server.push_metric "#{metricPrefix}.short", one
Expand Down
2 changes: 1 addition & 1 deletion scripts/memory.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module.exports = (server) ->
metricPrefix = "#{server.fqdn}.memory"
server.cli.debug 'Running the memory script'
# From the proc
memfile = '/proc/meminfo'
memfile = '/host_proc/meminfo'

content = Fs.readFileSync memfile, 'ascii'
mem = {}
Expand Down
4 changes: 3 additions & 1 deletion src/start.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@ module.exports = entry_point = () ->
'config': ['c', 'Configuration file path', 'path', './config.json']

Cli.main (args, options) ->
if Path.existsSync options.config
if Fs.existsSync options.config
try
conf = JSON.parse(Fs.readFileSync(options.config, 'utf-8'))
conf.carbonHost = if process.env.CARBON_HOST then process.env.CARBON_HOST else conf.carbonHost
conf.fqdn = if process.env.FQDN then process.env.FQDN else conf.fqdn
catch error
Cli.debug "Error parsing config file: #{error}"
else
Expand Down