forked from amonapp/amon
-
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
martinrusev
committed
Aug 8, 2011
1 parent
5c98979
commit 52c5727
Showing
69 changed files
with
901 additions
and
1 deletion.
There are no files selected for viewing
Empty file.
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,97 @@ | ||
Metadata-Version: 1.0 | ||
Name: Amon | ||
Version: 0.2 | ||
Summary: Developer friendly system monitoring and logging tool | ||
Home-page: https://github.com/martinrusev/amon | ||
Author: Martin Rusev | ||
Author-email: martinrusev@live.com | ||
License: GPL | ||
Description: ============================================================= | ||
Amon - developer friendly system monitoring and logging tool | ||
============================================================= | ||
|
||
Introduction | ||
============= | ||
|
||
Amon tries to solve two very common problems for web application developers: | ||
|
||
|
||
**1. System monitoring** | ||
|
||
|
||
When we deploy our web applications it's important to know how much | ||
server resources they use over time, so that we can improve and optimize them. | ||
On other hand installing a sophisticated server monitoring application looks | ||
like overkill, if your app is not that big and probably lives on a single server. | ||
This is where Amon comes in - it is a very small python application with simple web | ||
interface and you can have it up and running in less than 10 minutes. | ||
|
||
|
||
**2. Language agnostic logging** | ||
|
||
|
||
|
||
|
||
|
||
Installation | ||
================ | ||
|
||
1. Download the tarball and install the package with ``python setup.py install`` | ||
|
||
2. Copy the system info collect daemon from ``contrib/amon`` to ``/etc/init.d/amon`` | ||
|
||
3. Make it executable with ``chmod +x /etc/init.d/amon`` and then start the daemon with ``invoke-rc.d/amon start`` | ||
|
||
|
||
Installing Mongodb | ||
================== | ||
|
||
Amon stores the system information in a Mongo database. In this section I will cover just the basics of | ||
how to install and run a mongo instance. You can find much more details at http://mongodb.org | ||
|
||
1. We need to create 3 directories for Mongo: - | ||
|
||
:: | ||
|
||
mkdir /usr/local/mongodb - the main directory | ||
mkdir /usr/local/mongodb/data - for the database | ||
mkdir /usr/local/mongodb/bin - for the mongo executables | ||
touch /var/log/mongodb.log - the mongodb log file | ||
|
||
|
||
2. Download Mongo from http://www.mongodb.org/downloads and copy the ``mongod`` file to ``/usr/local/mongodb/bin`` | ||
|
||
3. Copy the Mongo init script from ``contrib/mongodb`` to ``/etc/init/mongodb.conf`` | ||
|
||
4. Start the database with ``start mongodb`` | ||
|
||
|
||
Usage | ||
====== | ||
|
||
At it's core Amon is a web application. You can start it with ``python cherryd -i amon.web`` | ||
|
||
And then open ``http://127.0.0.1:2464`` ( or your server ip address ) in your browser | ||
|
||
|
||
Requirements | ||
============= | ||
|
||
Python 2.5+ | ||
|
||
pymongo >=1.1 | ||
|
||
CherryPy >=3.2 | ||
|
||
Jinja2 >=2.5 | ||
|
||
MongoDB | ||
|
||
Keywords: Amon,monitoring,logging | ||
Platform: UNKNOWN | ||
Classifier: Development Status :: 3 - Alpha | ||
Classifier: Environment :: Console | ||
Classifier: Intended Audience :: Developers | ||
Classifier: License :: OSI Approved :: GNU General Public License (GPL) | ||
Classifier: Operating System :: OS Independent | ||
Classifier: Programming Language :: Python |
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,47 @@ | ||
LICENSE | ||
MANIFEST.in | ||
setup.py | ||
Amon.egg-info/PKG-INFO | ||
Amon.egg-info/SOURCES.txt | ||
Amon.egg-info/dependency_links.txt | ||
Amon.egg-info/requires.txt | ||
Amon.egg-info/top_level.txt | ||
amon/__init__.py | ||
amon/defaults.py | ||
amon/backends/__init__.py | ||
amon/backends/mongodb.py | ||
amon/core/__init__.py | ||
amon/core/exceptions.py | ||
amon/core/settings.py | ||
amon/system/__init__.py | ||
amon/system/check.py | ||
amon/system/daemon.py | ||
amon/system/runner.py | ||
amon/web/__init__.py | ||
amon/web/devserver.py | ||
amon/web/settings.py | ||
amon/web/template.py | ||
amon/web/utils.py | ||
amon/web/views.py | ||
amon/web/media/css/screen.css | ||
amon/web/media/images/active_page.png | ||
amon/web/media/images/breadcrumb.png | ||
amon/web/media/images/favicon.png | ||
amon/web/media/images/inactive_page.png | ||
amon/web/media/images/left.png | ||
amon/web/media/images/logo.png | ||
amon/web/media/images/status_icons.png | ||
amon/web/media/images/table_heading.png | ||
amon/web/templates/404.html | ||
amon/web/templates/application.html | ||
amon/web/templates/base.html | ||
amon/web/templates/blank.html | ||
amon/web/templates/dashboard.html | ||
amon/web/templates/processes.html | ||
amon/web/templates/system.html | ||
tests/__init__.py | ||
tests/__init__.pyc | ||
tests/test_core/__init__.py | ||
tests/test_core/__init__.pyc | ||
tests/test_core/test_check.py | ||
tests/test_core/test_check.pyc |
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 @@ | ||
|
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 @@ | ||
pymongo | ||
cherrypy==3.2 | ||
Jinja2>=2.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 @@ | ||
amon |
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
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 @@ | ||
__version__ = '0.2' |
Empty file.
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,73 @@ | ||
try: | ||
import pymongo | ||
except ImportError: | ||
pymongo = None | ||
|
||
from amon.core.exceptions import ImproperlyConfigured | ||
from amon.core import settings | ||
|
||
|
||
class MongoBackend(): | ||
|
||
host = settings.MONGO['host'] | ||
port = settings.MONGO['port'] | ||
user = settings.MONGO['user'] | ||
password = settings.MONGO['password'] | ||
database = settings.MONGO['database'] | ||
valid_collections = settings.MONGO['valid_system_collections'] | ||
|
||
def __init__(self): | ||
if not pymongo: | ||
raise ImproperlyConfigured( | ||
"You need to install the pymongo library to use the " | ||
"MongoDB backend.") | ||
|
||
self._database = None | ||
self._connection = None | ||
|
||
def get_connection(self): | ||
"""Connect to the MongoDB server.""" | ||
from pymongo.connection import Connection | ||
|
||
if self._connection is None: | ||
self._connection = Connection(self.host, self.port) | ||
return self._connection | ||
|
||
|
||
def get_database(self): | ||
""""Get database from MongoDB connection. """ | ||
if self._database is None: | ||
conn = self.get_connection() | ||
db = conn[self.database] | ||
self._database = db | ||
|
||
return self._database | ||
|
||
def get_collection(self, collection): | ||
db = self.get_database() | ||
|
||
if collection in self.valid_collections: | ||
collection = "amon_{0}".format(collection) | ||
collection = db[collection] | ||
else: | ||
return False | ||
|
||
return collection | ||
|
||
|
||
def store_entry(self, entry, collection): | ||
""" Stores a system entry """ | ||
|
||
collection = self.get_collection(collection) | ||
|
||
if collection: | ||
collection.save(entry, safe=True) | ||
|
||
def store_entries(self, entries): | ||
''' | ||
Dictionary with entries, loop through all of them and saves them to the database | ||
''' | ||
for key, value in entries.iteritems(): | ||
self.store_entry(value, key) | ||
|
||
backend = MongoBackend() |
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 @@ | ||
from amon.core.settings import Settings | ||
|
||
settings = Settings() |
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,8 @@ | ||
class BackendError(Exception): | ||
""" The storage backend is not working properly """ | ||
|
||
class ImproperlyConfigured(Exception): | ||
""" Amon is improperly configured """ | ||
|
||
class RunnerError(Exception): | ||
""" """ |
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 @@ | ||
from amon import defaults | ||
|
||
class Settings(object): | ||
|
||
def __init__(self): | ||
# update this dict from the defaults dictionary (but only for ALL_CAPS settings) | ||
for setting in dir(defaults): | ||
if setting == setting.upper(): | ||
setattr(self, setting, getattr(defaults, setting)) | ||
|
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,17 @@ | ||
# Amon Defaults | ||
BACKEND = 'mongodb' | ||
|
||
MONGO = { | ||
'port': 27017, | ||
'host': 'localhost', | ||
'user': '', | ||
'password': '', | ||
'database' : 'amon', | ||
'valid_system_collections': ('cpu', 'memory', 'disk', 'network', 'loadavg') | ||
} | ||
|
||
# 1 minute default | ||
SYSTEM_CHECK_PERIOD = 60 | ||
|
||
|
||
ACTIVE_CHECKS = ('cpu', 'memory', 'disk', 'network', 'loadavg') |
Empty file.
Oops, something went wrong.