You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Aug 28, 2023. It is now read-only.
Copy file name to clipboardexpand all lines: README.md
+41-12
Original file line number
Diff line number
Diff line change
@@ -13,7 +13,7 @@ There are other projects that do the same: [collectd](http://collectd.org/) has
13
13
Install, configure and run it
14
14
---------------------------------
15
15
16
-
Configuration is done using the a json file. The package includes a default config that you probably can use after changing the hostname for your graphite/carbon node. HoardD was meant to be used with runit and similar tools so no daemonizing is done and all the logging is written on stdout (use `--debug` if you want detailed info on what is happening.) By default scripts sample the data each 10 seconds, and then sends the data to graphite each 6 samples are collected, effectively making one connection each 60 seconds.
16
+
Configuration is done using the a `json` file. The package includes a default config that you probably can use after changing the hostname for your graphite/carbon node. HoardD was meant to be used with runit and similar tools so no daemonizing is done and all the logging is written on stdout (use `--debug` if you want detailed info on what is happening.) By default scripts sample the data each 10 seconds, and then sends the data to graphite each 6 samples are collected, effectively making one connection each 60 seconds.
17
17
18
18
Also, HoardD was made to be used with chef (or any other configuration management system) so while I know that configuring the FQDN on the config JSON is annoying, it was meant to be automatically filled by a template. If you are managing lots of servers and configs by hand in 2012 you are doing it wrong.
19
19
@@ -23,7 +23,7 @@ The master branch will be updated only to working versions (i.e: I will *try* no
23
23
24
24
The MySQL script is an example of how to configure specific scripts. It contains a `mysql.json` file that is read by the script when it starts. Just make sure to:
25
25
26
-
* Keep the configs with the same name as the plugin (like, mysql.coffee and mysql.json)
26
+
* Keep the configs with the same name as the plugin (like, `mysql.coffee` and `mysql.json`)
27
27
* Put/link the configuration on the script path (together with the scripts)
28
28
29
29
For real, you can do whatever you want on your scripts, but it's better to make it easier for other people to configure/understand, so let's stick to a default.
To add new scripts just drop the `.coffee` file on `scriptPath` and restart HoardD (making it detect new scripts without restarting is on TODO).
59
+
To add new scripts just drop the `.coffee`or `.js`file on `scriptPath` and restart HoardD (making it detect new scripts without restarting is on TODO).
60
60
61
61
Writing new scripts should be easy:
62
62
@@ -70,20 +70,48 @@ Writing new scripts should be easy:
70
70
*`cli` has all the methods from the [cli](https://github.com/chriso/cli) module (use it for logging)
71
71
*`fqdn` the server FQDN configured on the JSON config file for you to use on metrics
72
72
73
-
Code speaks better than words in some case, this is the uptime script:
73
+
Code speaks better than words in some case, this is the `load_average.coffee` script:
74
74
75
75
```coffeescript
76
-
77
-
os=require'os'
76
+
Fs=require'fs'
77
+
Path=require'path'
78
78
79
79
module.exports= (server) ->
80
80
run= () ->
81
-
metricPrefix="#{server.fqdn}.uptime"
82
-
server.cli.debug"Running uptime script"
81
+
metricPrefix="#{server.fqdn}.load_average"
82
+
server.cli.debug"Running load average script"
83
+
84
+
# Read from /proc
85
+
procfile='/proc/loadavg'
86
+
ifPath.existsSync procfile
87
+
data=Fs.readFileSync(procfile, 'utf-8')
88
+
[one, five, fifteen] =data.split('', 3)
89
+
server.push_metric"#{metricPrefix}.short", one
90
+
server.push_metric"#{metricPrefix}.medium", five
91
+
server.push_metric"#{metricPrefix}.long", fifteen
92
+
```
93
+
94
+
And this is the `uptime.js` script:
95
+
96
+
```javascript
97
+
var Os;
83
98
84
-
# Node os object makes this easy
85
-
uptime=os.uptime()
86
-
server.push_metric metricPrefix, uptime
99
+
Os =require('os');
100
+
101
+
module.exports=function(server) {
102
+
var run;
103
+
104
+
run=function() {
105
+
var metricPrefix, uptime;
106
+
metricPrefix =server.fqdn+".uptime";
107
+
server.cli.debug("Running uptime script");
108
+
109
+
// Node os object makes this easy
110
+
uptime =Os.uptime();
111
+
server.push_metric(metricPrefix, uptime);
112
+
}
113
+
return run;
114
+
}
87
115
```
88
116
89
117
Take a look at the code of the other scripts and you will see that there's nothing genius going on there.
@@ -94,5 +122,6 @@ License and author
94
122
------------------
95
123
96
124
HoardD is licensed under the MIT License but please, send back your changes :). A copy of the license is included on the LICENSE file.
97
-
You can probably read announcements and news on http://coredump.io
125
+
126
+
You can read announcements and news on http://coredump.io
0 commit comments