forked from bkconrad/screeps-grafana
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit a973007
Showing
24 changed files
with
748 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
docker-compose.env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
FROM node:4-onbuild |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
Copyright (c) 2013-2016 Nathan Hopkins | ||
|
||
MIT License | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining | ||
a copy of this software and associated documentation files (the | ||
"Software"), to deal in the Software without restriction, including | ||
without limitation the rights to use, copy, modify, merge, publish, | ||
distribute, sublicense, and/or sell copies of the Software, and to | ||
permit persons to whom the Software is furnished to do so, subject to | ||
the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be | ||
included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | ||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | ||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | ||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
# screeps-grafana | ||
|
||
Pretty graphs for Screeps stats. There are two ways to get started: | ||
|
||
## Path 1: Easy but not robust | ||
You can run this project locally, with all the drawbacks that entails. | ||
|
||
Install [docker](https://docs.docker.com/engine/installation/) | ||
Install [docker-compose](https://docs.docker.com/compose/install/) | ||
|
||
Copy and edit the example config file: | ||
`` | ||
cp docker-compose.env.example docker-compose.env | ||
$EDITOR docker-compose.env | ||
`` | ||
|
||
Run the docker thing: | ||
``` | ||
docker-compose up | ||
``` | ||
|
||
Go to http://localhost:1337 in your browser, then see SETUP below. | ||
|
||
## Path 2: Robust but not easy | ||
|
||
Acquire a server, I use a t2.micro from Amazon Web Services. You can use anything running ubuntu with passwordless sudo. | ||
|
||
Open ports 80 and 81 in your security groups. | ||
|
||
***SUPER IMPORTANT: MAKE SURE TO MOUNT A DATA VOLUME TO /dev/sdf IN THE AWS CONSOLE. IF YOU FAIL TO DO SO, YOUR DATA AND DASHBOARDS WILL BE LOST IF THE SERVER RESTARTS, THEN YOU WILL BE HELLA SALTY, AND I'LL JUST CROSS MY ARMS AND SAY "I TOLD YOU SO IN BOLDED ITALICS"*** | ||
|
||
Install [ansible](http://docs.ansible.com/ansible/intro_installation.html). | ||
|
||
Create a password for your screeps account if you haven't already. | ||
|
||
You're now ready to run this whale of a command. Replace the stuff in caps with values that makes sense | ||
|
||
``` | ||
ansible-playbook \ | ||
-e screeps_username=YOURUSERNAME \ | ||
-e screeps_password=YOURPASSWORD \ | ||
-e screeps_email=YOUREMAIL \ | ||
--user ubuntu \ | ||
--private-key YOURPRIVATEKEY \ | ||
-i ,YOURSERVERIP \ | ||
playbook.yml | ||
``` | ||
|
||
** Don't remove the comma before `YOURSERVERIP`. You will get a mysterious error. If you pass your IP like `,12.34.56.78` you are doing it correctly.** | ||
|
||
If the run errors out, check your parameters and retry. It is common to see transient errors from Apt or GPG, which are both fixed by re-running. | ||
|
||
You are now ready to Setup | ||
|
||
## Setup | ||
|
||
Got to http://localhost:1337 or your own real-life server's IP. Login with the following default credentials: | ||
|
||
``` | ||
username: admin | ||
password: admin | ||
``` | ||
|
||
*THIS NEXT STEP IS VERY IMPORTANT, AND IF YOU SKIP IT NOTHING WILL SEEM TO WORK* | ||
Add graphite as a data source by going to Data Sources -> Add New, then entering the following Url under Http settings: | ||
|
||
``` | ||
http://localhost:8000 | ||
``` | ||
|
||
Click Add. You are now ready to [make]create some dashboards](https://www.youtube.com/watch?v=OUvJamHeMpw). | ||
|
||
To send stats to the dashboard, simply write them to `Memory.stats`. For example: | ||
``` | ||
Memory.stats["room." + room.name + ".energyAvailable"] = room.energyAvailable; | ||
Memory.stats["room." + room.name + ".energyCapacityAvailable"] = room.energyCapacityAvailable; | ||
Memory.stats["room." + room.name + ".controllerProgress"] = room.controller.progress; | ||
``` | ||
|
||
All values on the `Memory.stats` object are forwarded to Grafana verbatim. | ||
|
||
## License | ||
|
||
This software is licensed under the **MIT License**. See the [LICENSE](LICENSE) file for more information. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
{ | ||
"arrow_spacing": { | ||
"name": "arrow_spacing", | ||
"level": "error" | ||
}, | ||
"line_endings": { | ||
"name": "line_endings", | ||
"level": "error", | ||
"value": "unix" | ||
}, | ||
"max_line_length": { | ||
"name": "max_line_length", | ||
"value": 120, | ||
"level": "warn", | ||
"limitComments": true | ||
}, | ||
"missing_fat_arrows": { | ||
"name": "missing_fat_arrows", | ||
"level": "warn" | ||
}, | ||
"no_stand_alone_at": { | ||
"name": "no_stand_alone_at", | ||
"level": "error" | ||
}, | ||
"newline_at_eof": { | ||
"module": "coffeelint-newline-at-eof", | ||
"level": "error", | ||
"behaviour": "require" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
SCREEPS_USERNAME=bkconrad | ||
SCREEPS_EMAIL=notreally@myemail.com | ||
SCREEPS_PASSWORD=definitelynotmypassword |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
node: | ||
build: . | ||
links: | ||
- graphite | ||
env_file: docker-compose.env | ||
|
||
graphite: | ||
image: kamon/grafana_graphite | ||
ports: | ||
- "1337:80" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,143 @@ | ||
### | ||
hopsoft\screeps-statsd | ||
Licensed under the MIT license | ||
For full copyright and license information, please see the LICENSE file | ||
@author Bryan Conrad <bkconrad@gmail.com> | ||
@copyright 2016 Bryan Conrad | ||
@link https://github.com/hopsoft/docker-graphite-statsd | ||
@license http://choosealicense.com/licenses/MIT MIT License | ||
### | ||
|
||
module.exports = ( grunt ) -> | ||
|
||
### ALIASES ### | ||
|
||
jsonFile = grunt.file.readJSON # Read a json file | ||
define = grunt.registerTask # Register a local task | ||
log = grunt.log.writeln # Write a single line to STDOUT | ||
|
||
|
||
### GRUNT CONFIGURATION ### | ||
|
||
config = | ||
|
||
# Define aliases for known fs locations | ||
srcDir: 'src/' # CoffeeScript or other source files to be compiled or processed | ||
tstDir: 'test/' # Project's tests | ||
resDir: 'res/' # Static resources - images, text files, external deps etc. | ||
docDir: 'docs/' # Automatically-generated or compiled documentation | ||
srcFiles: ['<%= srcDir %>**/*.coffee', 'index.coffee'] | ||
tstFiles: '<%= tstDir %>**/*.test.coffee' | ||
pkg: jsonFile 'package.json' | ||
|
||
|
||
### TASKS DEFINITION ### | ||
|
||
# grunt-contrib-watch: Run tasks on filesystem changes | ||
watch: | ||
options: | ||
# Define default tasks here, then point targets' "tasks" attribute here: '<%= watch.options.tasks %>' | ||
tasks: ['lint', 'test'] # Run these tasks when a change is detected | ||
interrupt: true # Restarts any running tasks on next event | ||
atBegin: true # Runs all defined watch tasks on startup | ||
dateFormat: ( time ) -> log "Done in #{time}ms" | ||
|
||
# Targets | ||
|
||
gruntfile: # Watch the gruntfile for changes ( also dynamically reloads grunt-watch config ) | ||
files: 'gruntfile.coffee' | ||
tasks: '<%= watch.options.tasks %>' | ||
|
||
project: # Watch the project's source files for changes | ||
files: ['<%= srcFiles %>', '<%= tstFiles %>'] | ||
tasks: '<%= watch.options.tasks %>' | ||
|
||
|
||
# grunt-coffeelint: Lint CoffeeScript files | ||
coffeelint: | ||
options: jsonFile 'coffeelint.json' | ||
|
||
# Targets | ||
|
||
gruntfile: 'gruntfile.coffee' # Lint this file | ||
project: ['<%= srcFiles %>', '<%= tstFiles %>'] # Lint application's project files | ||
|
||
|
||
# grunt-mocha-cli: Run tests with Mocha framework | ||
mochacli: | ||
options: | ||
reporter: 'spec' # This report is nice and human-readable | ||
require: ['should'] # Run the tests using Should.js | ||
compilers: ['coffee:coffee-script/register'] | ||
|
||
# Targets | ||
|
||
project: # Run the project's tests | ||
src: ['<%= tstFiles %>'] | ||
|
||
|
||
# grunt-codo: CoffeeScript API documentation generator | ||
codo: | ||
options: | ||
title: 'screeps-statsd' | ||
debug: false | ||
inputs: ['<%= srcDir %>'] | ||
output: '<%= docDir %>' | ||
|
||
|
||
# grunt-contrib-coffee: Compile CoffeeScript into native JavaScript | ||
coffee: | ||
|
||
# Targets | ||
|
||
build: # Compile CoffeeScript into target build directory | ||
expand: true | ||
ext: '.js' | ||
src: '<%= srcFiles %>' | ||
dest: '<%= libDir %>' | ||
|
||
|
||
# grunt-contrib-uglify: Compress and mangle JavaScript files | ||
uglify: | ||
|
||
# Targets | ||
|
||
build: | ||
files: [ | ||
expand: true | ||
src: '<%= srcDir %>**/*.js' | ||
] | ||
|
||
|
||
# grunt-contrib-clean: Clean the target files & folders, deleting anything inside | ||
clean: | ||
|
||
# Targets | ||
|
||
build: ['<%= srcDir %>**/*.js', 'index.js'] # Clean the build products | ||
docs: ['<%= docDir %>'] | ||
|
||
|
||
############################################################################### | ||
|
||
### CUSTOM FUNCTIONS ### | ||
|
||
|
||
### GRUNT MODULES ### | ||
|
||
# Loads all grunt tasks from devDependencies starting with "grunt-" | ||
require( 'load-grunt-tasks' )( grunt ) | ||
|
||
### GRUNT TASKS ### | ||
|
||
define 'lint', ['coffeelint'] | ||
define 'test', ['mochacli'] | ||
define 'docs', ['codo'] | ||
define 'build:dev', ['clean:build', 'lint', 'test', 'coffee:build'] | ||
define 'build', ['build:dev', 'uglify:build'] | ||
define 'default', ['build'] | ||
|
||
############################################################################### | ||
grunt.initConfig config |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
### | ||
hopsoft\screeps-statsd | ||
Licensed under the MIT license | ||
For full copyright and license information, please see the LICENSE file | ||
@author Bryan Conrad <bkconrad@gmail.com> | ||
@copyright 2016 Bryan Conrad | ||
@link https://github.com/hopsoft/docker-graphite-statsd | ||
@license http://choosealicense.com/licenses/MIT MIT License | ||
### | ||
|
||
# Application's initialisation and startup script | ||
ScreepsStatsd = require './src/ScreepsStatsd' | ||
(new ScreepsStatsd).run() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[screeps-statsd] | ||
52.26.114.71 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
{ | ||
"name": "screeps-statsd", | ||
"description": "screeps stats in graphite :3", | ||
"version": "0.9.12", | ||
"homepage": "https://github.com/hopsoft/docker-graphite-statsd", | ||
"author": { | ||
"name": "Bryan Conrad", | ||
"email": "bkconrad@gmail.com" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git://github.com/hopsoft/docker-graphite-statsd.git" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/hopsoft/docker-graphite-statsd/issues" | ||
}, | ||
"licenses": [ | ||
{ | ||
"type": "MIT", | ||
"url": "https://github.com/hopsoft/docker-graphite-statsd/blob/master/LICENSE-MIT" | ||
} | ||
], | ||
"main": "index.js", | ||
"engines": { | ||
"node": ">= 0.10.0" | ||
}, | ||
"scripts": { | ||
"test": "grunt test", | ||
"start": "coffee index.coffee" | ||
}, | ||
"devDependencies": { | ||
"coffee-script": "~1.7.0", | ||
"grunt": "~0.4.2", | ||
"grunt-codo": "~0.1.0", | ||
"grunt-coffeelint": "0.0.8", | ||
"grunt-contrib-clean": "~0.5.0", | ||
"grunt-contrib-coffee": "~0.10.0", | ||
"grunt-contrib-uglify": "~0.3.1", | ||
"grunt-contrib-watch": "~0.5.3", | ||
"grunt-mocha-cli": "~1.5.0", | ||
"load-grunt-tasks": "~0.3.0", | ||
"node-statsd": "^0.1.1", | ||
"request-debug": "^0.2.0", | ||
"should": "~3.1.0" | ||
}, | ||
"keywords": [], | ||
"dependencies": { | ||
"coffee": "^3.0.3", | ||
"node-statsd": "^0.1.1", | ||
"request-promise": "^2.0.0", | ||
"sleep": "^3.0.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
- hosts: all | ||
become: true | ||
roles: | ||
- screeps-statsd |
Oops, something went wrong.