Code Monkey home page Code Monkey logo

selena's Introduction

Selena

Introduction

Selena is a tool for monitoring website performance by monitoring response times, response codes and site content (via keyword checks).

It's distributed by design via agents which can be geographically separate allowing for monitoring the user experience from multiple ISP-s.

Installation

Requirements

Selena requires Python 2.7 which is included in the latest Ubuntu Server 12.04 LTS systems:

$ sudo apt-get install python-dev python-virtualenv

Message queue

Selena communicates with a central queue with Redis as the broker. Install redis:

$ sudo apt-get install redis-server

Since lost tasks can always be resent, the durability guarantees that Redis provides by default are not necessary. You can significantly speed up the queue by commenting out the save lines from /etc/redis/redis.conf.

We can check the status of the Redis server:

$ redis-cli -h localhost -p 6379 -n 0 info

Virtual Environment

Let's create a virtual environment for Python in the user's home:

$ virtualenv . --distribute --no-site-packages

System User

Unprivileged and not owned by a person:

$ sudo adduser --home /home/selena selena
$ sudo su - selena

In any shell the user can activate the virtual environment. As a result of that, the default Python executable and helper scripts will point to those within the virtualenv directory structure:

$ which python
/usr/local/bin/python
$ . bin/activate
(selena)$ which python
/home/selena/bin/python

Database

Selena uses and supports MySQL. To install MySQL invoke:

$ sudo apt-get install mysql-server libmysqlclient-dev libmysqld-dev

You now have to create a database and a user for Selena system. You can find many tutorials for that on the Internet.

Cache

Selena requires some cache system like memcached. Install:

$ sudo apt-get install memcached

Installing from pip

Simply invoke:

(selena)$ pip install selena

Installing from sources

Alternatively, to live on the bleeding edge, you can clone the selena git repository to project and install it manually:

(selena)$ git clone git://github.com/allegro/selena.git project
(selena)$ cd project
(selena)$ pip install -e .

Selena Agent

To function properly, Selena needs Selena-agent package installed and configured.

Configuration

Create file /INSTALL_DIR/src/selena/selena/settings-local.py and fill in the appropriate data.

Fill MySQL connection data:

DATABASES = {
  'default': {
      'ENGINE': 'django.db.backends.mysql',
      'NAME': 'your database name',
      'USER': 'your database username',
      'PASSWORD': 'your database password',
      'HOST': 'localhost',
      'PORT': '3306',
      'OPTIONS': {
          'init_command': 'SET storage_engine=INNODB,character_set_connection=utf8,collation_connection=utf8_unicode_ci'
      }
  }
}

Generate new secret keys:

SECRET_KEY = 'very_unique_string'
AES_SECRET_KEY = b'sixteen byte key'

Set the number of minutes that will be displayed by the service errors, example 30:

ERROR_TIME_INTERVAL =  30

Define RQ queues. The default queue is required. You have to also define one queue for main selena agent, for example agent_1:

RQ_QUEUES = {
    'default': {
        'HOST': '127.0.0.1',  # Redis host
        'PORT': 6379,  # Redis port
        'DB': None,
        'PASSWORD': None,
    },
    'agent_1': {
        'HOST': '127.0.0.1',
        'PORT': 6379,
        'DB': None,
        'PASSWORD': None,
   },
}

You can define additional queues: planner, archiving, dispacher, monitors, stats. They are used as follows:

planner - enable or disable planned technical breaks

archiving - create partitions, archive data

dispacher - run monitoring tasks for services

monitors - collect results from agents

stats - calculate statistics

You also have to configure cache. Sample cache configuration (for default memcached configs):

CACHES = {
    'default': {
        'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
        'LOCATION': '127.0.0.1:11211',
    }
}

Database preparation

After creating the settings-local.py file, synchronize the database with sources by running the standard syncdb management command:

$(selena): selena syncdb

then run migrations command:

$(selena): selena migrate

Create partitions in the database by using the command:

$(selena): selena createpartitions

Run web interface

To run selena web interface use the command:

(selena)$ selena runserver 8080

Configuration agents

When your selena web interface is running you must add a main agents to your selena instance. Open this link in your browser http://localhost:8080/admin/services/agent/add/ and log in into administration panel.

You will see a form where you have to fill the name of your main agent, add a queue (remember the name of the queue must be set in your Selena agent settings-local.py file), and check the main agent checkbox. After the agent is added you will see Salt column in your agent row. Copy this string and add to the Selena-agent settings-local.py file in SALT variable. It is very important, because without it there will be no communication with the Selena-agent.

Add monitored services

In administration panel add a service which will be monitored by Selena. Open this link in browser http://localhost:8080/admin/services/service/add/ and add a service URL to be monitored.

Commands

Run a single monitoring service:

(selena)$: selena monitorall

Search incidents:

(selena)$: selena searchincidents

Activate/Deactivate technical breaks:

(selena)$: selena technicalbreaks

For optimization, there are commands to archive service monitoring results. If you create partitions in MySQL database run command:

(selena)$: selena createpartitions

You will need to run the command that merges monitoring data older than 8 days and moves it to the archive:

(selena)$: selena makearchive

Calculate SLA for active services:

(selena)$: selena calculatesla

If you want to run the commands asynchronically, you can add an --async-mode=1 option to them.

Automation

You can configure Cron to monitor automatically in background. To edit crontab run command:

$(selena): crontab -e

and add this content:

*/1 * * * * /YOUR_VIRTUAL_ENV_PATH/bin/selena monitorall
*/1 * * * * /YOUR_VIRTUAL_ENV_PATH/bin/selena searchincidents --async-mode=1
*/5 * * * * /YOUR_VIRTUAL_ENV_PATH/bin/selena technicalbreaks --async-mode=1
0 1 * * * /YOUR_VIRTUAL_ENV_PATH/bin/selena createpartitions --async-mode=1
30 1 * * * /YOUR_VIRTUAL_ENV_PATH/bin/selena makearchive --async-mode=1
0 3 * * * /YOUR_VIRTUAL_ENV_PATH/bin/selena calculatesla

Of course you can set your own time to execute these commands in Cron.

To see the results of the monitoring in a browser, open the following address: http://localhost:8080

License

Selena is licensed under the Apache License, v2.0.

Copyright (c) 2013-2014 Allegro Group.

selena's People

Contributors

ambv avatar andrzej-jankowski avatar deejay1 avatar h00dy avatar inc0 avatar jjdlugosz avatar nigras avatar pnuckowski avatar quamilek avatar wmatyskiewicz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

selena's Issues

Follow good rules in css development

stylesheet.css needs some work to make it modern-rules-compliant:

don't select elements by tag name (which decreases performance)

.service-info p {...}
.input-append input {...}
#show-header h1 {...}

never use !important

span.service-hist-wrap span.popover-open {
    border-top: 4px solid #008c00 !important;
    border-bottom: 4px solid #008c00 !important;
}

.input-append input {
    width: 150px !important;
}

don't mix underscores "_" with dashes "-" - use one of them

.service_ico {...}
span.service-hist-wrap {...}

don't inline css

<div id="main_plot_{{ group.group_id }}" style="width: 850px; height: 450px;"></div>

fix code formatting (take a look at .service-info declaration)

User and groups/projects support

As an admin I'd like to allow users to have more control of their services. We should be able to:

  • assign services to user groups (aka projects)
  • services should only be editable by the respective project members and superadmins (aka staff)
  • each project should have their custom own dashboard list
  • every service and dashboard should have the option to be available to all users in RO mode (or even RW, but that's not a strict requirement)

Agents should be assigned either to everyone or a specific user group, so an admin can restrict access to certain agents.

Feel free to separate this issue into smaller ones if you start working on something.

django.core.exceptions.ImproperlyConfigured: The SECRET_KEY setting must not be empty.

Hi

I have setup selena and made config as it was written in README. But when I try prepare database I get the error:

(selena)selena@selena:~$ selena syncdb
Traceback (most recent call last):
File "/home/std/selena/bin/selena", line 9, in
load_entry_point('selena==1.0.0', 'console_scripts', 'selena')()
File "/home/std/selena/local/lib/python2.7/site-packages/selena/main.py", line 9, in main
execute_from_command_line(sys.argv)
File "/home/std/selena/local/lib/python2.7/site-packages/django/core/management/init.py", line 453, in execute_from_command_line
utility.execute()
File "/home/std/selena/local/lib/python2.7/site-packages/django/core/management/init.py", line 392, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/std/selena/local/lib/python2.7/site-packages/django/core/management/init.py", line 272, in fetch_command
klass = load_command_class(app_name, subcommand)
File "/home/std/selena/local/lib/python2.7/site-packages/django/core/management/init.py", line 77, in load_command_class
module = import_module('%s.management.commands.%s' % (app_name, name))
File "/home/std/selena/local/lib/python2.7/site-packages/django/utils/importlib.py", line 35, in import_module
import(name)
File "/home/std/selena/local/lib/python2.7/site-packages/django/core/management/commands/syncdb.py", line 8, in
from django.core.management.sql import custom_sql_for_model, emit_post_sync_signal
File "/home/std/selena/local/lib/python2.7/site-packages/django/core/management/sql.py", line 9, in
from django.db import models
File "/home/std/selena/local/lib/python2.7/site-packages/django/db/init.py", line 11, in
if settings.DATABASES and DEFAULT_DB_ALIAS not in settings.DATABASES:
File "/home/std/selena/local/lib/python2.7/site-packages/django/conf/init.py", line 53, in getattr
self._setup(name)
File "/home/std/selena/local/lib/python2.7/site-packages/django/conf/init.py", line 48, in _setup
self._wrapped = Settings(settings_module)
File "/home/std/selena/local/lib/python2.7/site-packages/django/conf/init.py", line 152, in init
raise ImproperlyConfigured("The SECRET_KEY setting must not be empty.")
django.core.exceptions.ImproperlyConfigured: The SECRET_KEY setting must not be empty.

Seems SECRET_KEY doesn't import to Django environment. Could you help me fix it?

Info:
Debian 6.0 x64 with enabled testing repo.
Python 2.7
Django 1.5.1

Adding agents shouldn't require restarting the frontend

Adding a new agent queues shouldn't require restarting the frontend or any workers.
As the queue settings are already duplicated in the database we should just use it and either add redis server info to the DB (which would require a password there - may be bad) or just a separate static setting for it and get the queues from DB + cache.

What is the purpose, what does it do?

Any information about the purpose of this software would be appreciated. Maybe some screenshots of how does it look?
Right now readme file is just an instalation tutorial, haw can I decide if I need this?

Remove deprecated attributes in html templates

In ./src/selena/boards/templates/boards/*.html scripts are included using

<script language="javascript" type="text/javascript" src="..."></script>

The language attribute on the script element is deprecated and produces warning in W3C Validator. We can safely omit it. Moreover, templates extends base.html which is HTML5 document thus type="text/javascript" is completely unnecessary.

Install documentation is out of date

Completely leaves out the part that you need to have selena (not agent!) workers set up...
IMHO best would be to create move it out of the readme to some proper Sphinx based documentation.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.