-
Notifications
You must be signed in to change notification settings - Fork 0
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 13ebcb3
Showing
14 changed files
with
1,133 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,15 @@ | ||
# This file is for unifying the coding style for different editors and IDEs | ||
# editorconfig.org | ||
|
||
root = true | ||
|
||
[**] | ||
indent_style = tab | ||
end_of_line = lf | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
|
||
[**.py] | ||
indent_style = space | ||
indent_size = 4 |
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,56 @@ | ||
### OSX ### | ||
|
||
.DS_Store | ||
.AppleDouble | ||
.LSOverride | ||
Icon | ||
|
||
# Thumbnails | ||
._* | ||
|
||
# Files that might appear on external disk | ||
.Spotlight-V100 | ||
.Trashes | ||
|
||
### PYTHON ### | ||
|
||
*.py[cod] | ||
|
||
# C extensions | ||
*.so | ||
|
||
# Packages | ||
*.egg | ||
*.egg-info | ||
dist | ||
build | ||
eggs | ||
parts | ||
bin | ||
var | ||
sdist | ||
develop-eggs | ||
.installed.cfg | ||
lib | ||
lib64 | ||
__pycache__ | ||
|
||
# Virtualenv | ||
.Python | ||
include | ||
|
||
# Installer logs | ||
pip-log.txt | ||
|
||
# Unit test / coverage reports | ||
.coverage | ||
.tox | ||
nosetests.xml | ||
|
||
# Translations | ||
*.mo | ||
|
||
# Mr Developer | ||
.mr.developer.cfg | ||
.project | ||
.pydevproject |
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,14 @@ | ||
Up - A next generation status monitor | ||
===================================== | ||
|
||
|
||
Developers Setup | ||
---------------- | ||
|
||
```sh | ||
$ virtualenv . -p python3 --no-site-packages | ||
``` | ||
|
||
```sh | ||
$ bin/python setup.py develop | ||
``` |
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,49 @@ | ||
Status API | ||
========== | ||
|
||
A status has a name, a value 'up' indicating if the corrosponding serivce will | ||
give a good response, and a reason that gives additional, human readable, | ||
information on why the service is not up. | ||
|
||
The name should be unique, it will be the key used to aggregate statistics. | ||
|
||
{ | ||
"name": "Statusey Thing", | ||
"date": 1371302613.0897678, | ||
"duration": 3424.004, | ||
"up": true, | ||
"reason": "This really only has meaning of 'up' is false." | ||
} | ||
|
||
Statuses can take the form of trees. Each node in the tree has a status and | ||
then each branch points to a status that gives more detailed information. | ||
|
||
In the case of downstream services names must be unique to its parent status. | ||
|
||
{ | ||
"name": "Statusey Cluster", | ||
"up": false, | ||
"reason": "One or more Statusey Things in this cluster are down.", | ||
"downstream": [ | ||
{ | ||
"name": "Statusey Thing 1", | ||
"up": true | ||
}, { | ||
"name": "Statusey Thing 2", | ||
"up": false, | ||
"reason": "Something happened, and it was bad." | ||
} | ||
] | ||
} | ||
|
||
You can also point to another status api compliant server. | ||
|
||
{ | ||
"name": "Statusey Proxy", | ||
"up": false, | ||
"reason": "One or more Statusey Things in this cluster are down.", | ||
"downstream": [ | ||
"http://status1.example.com/status", | ||
"http://status2.example.com/status" | ||
] | ||
} |
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,41 @@ | ||
import os | ||
|
||
from setuptools import setup, find_packages | ||
|
||
here = os.path.abspath(os.path.dirname(__file__)) | ||
README = open(os.path.join(here, 'README.md')).read() | ||
|
||
requires = [ | ||
'pymongo', | ||
'flask' | ||
] | ||
|
||
setup( | ||
name='up', | ||
version='0.1.0', | ||
description='Up - A next generation status monitor', | ||
long_description=README, | ||
classifiers=[ | ||
"Programming Language :: Python", | ||
"Development Status :: 3 - Alpha", | ||
"Intended Audience :: Developers", | ||
"Intended Audience :: End Users/Desktop", | ||
"Programming Language :: Python :: 3.3", | ||
"Topic :: Internet :: WWW/HTTP", | ||
"Topic :: Internet :: WWW/HTTP :: WSGI :: Application", | ||
"Topic :: Office/Business" | ||
], | ||
author='Aaron Spaulding', | ||
author_email='[email protected]', | ||
packages=find_packages('src'), | ||
package_dir={'': 'src'}, | ||
include_package_data=True, | ||
zip_safe=False, | ||
install_requires=requires, | ||
tests_require=requires, | ||
test_suite="up", | ||
entry_points="""\ | ||
[console_scripts] | ||
up = up.status:main | ||
""", | ||
) |
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,67 @@ | ||
from flask import Flask, request, render_template | ||
from pymongo import MongoClient, ASCENDING | ||
import json | ||
import datetime | ||
from bson.objectid import ObjectId | ||
from werkzeug import Response | ||
|
||
app = Flask(__name__) | ||
|
||
DB_NAME = 'up' | ||
DB_DOMAIN = 'localhost' | ||
DB_PORT = 27017 | ||
COLLECTION_NAME = 'statuses' | ||
|
||
client = MongoClient(DB_DOMAIN, DB_PORT) | ||
db = client[DB_NAME] | ||
collection = db[COLLECTION_NAME] | ||
|
||
|
||
class MongoJsonEncoder(json.JSONEncoder): | ||
def default(self, obj): | ||
if isinstance(obj, (datetime.datetime, datetime.date)): | ||
return obj.isoformat() | ||
elif isinstance(obj, ObjectId): | ||
return str(obj) | ||
return json.JSONEncoder.default(self, obj) | ||
|
||
|
||
def jsonify(obj): | ||
""" jsonify with support for MongoDB ObjectId | ||
""" | ||
return Response(json.dumps(obj, cls=MongoJsonEncoder), mimetype='application/json') | ||
|
||
|
||
@app.route("/aggregate/by_name/") | ||
def by_name(): | ||
data = [] | ||
|
||
if 'name' in request.args: | ||
cursor = collection.find({ | ||
'path': request.args['name'] | ||
}) | ||
cursor.sort('date', ASCENDING) | ||
data = list(cursor) | ||
|
||
return jsonify(data) | ||
|
||
|
||
@app.route("/annotations/") | ||
def annotations(): | ||
cursor = db.annotations.find() | ||
cursor.sort('date', ASCENDING) | ||
data = list(cursor) | ||
|
||
return jsonify(data) | ||
|
||
|
||
@app.route('/') | ||
def home(): | ||
paths = collection.distinct('path') | ||
paths.sort() | ||
|
||
return render_template('home.html', paths=paths) | ||
|
||
if __name__ == "__main__": | ||
app.debug = True | ||
app.run() |
Oops, something went wrong.