Package: selena
IntroductionSelena 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.InstallationRequirementsSelena requires Python 2.7 which is included in the latest Ubuntu Server 12.04 LTS systems:$ sudo apt-get install python-dev python-virtualenvMessage queueSelena communicates with a central queue withRedisas the broker. Install redis:$ sudo apt-get install redis-serverSince 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 thesavelines from/etc/redis/redis.conf.We can check the status of the Redis server:$ redis-cli -h localhost -p 6379 -n 0 infoVirtual EnvironmentLet’s create a virtual environment for Python in the user’s home:$ virtualenv . --distribute --no-site-packagesSystem UserUnprivileged and not owned by a person:$ sudo adduser --home /home/selena selena
$ sudo su - selenaIn any shell the user canactivatethe 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/pythonDatabaseSelena uses and supports MySQL. To install MySQL invoke:$ sudo apt-get install mysql-server libmysqlclient-dev libmysqld-devYou now have to create a database and a user for Selena system. You can find many tutorials for that on the Internet.CacheSelena requires some cache system likememcached. Install:$ sudo apt-get install memcachedInstalling from pipSimply invoke:(selena)$ pip install selenaInstalling from sourcesAlternatively, to live on the bleeding edge, you can clone the selena git
repository toprojectand install it manually:(selena)$ git clone git://github.com/allegro/selena.git project
(selena)$ cd project
(selena)$ pip install -e .Selena AgentTo function properly, Selena needsSelena-agentpackage installed and configured.ConfigurationCreate 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 =  30Define RQ queues. Thedefaultqueue is required. You have to also define one queue for main selena agent, for exampleagent_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 breaksarchiving- create partitions, archive datadispacher- run monitoring tasks for servicesmonitors- collect results from agentsstats- calculate statisticsYou also have to configure cache. Sample cache configuration (for defaultmemcachedconfigs):CACHES = {
    'default': {
        'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
        'LOCATION': '127.0.0.1:11211',
    }
}Database preparationAfter creating thesettings-local.pyfile, synchronize the database with
sources by running the standardsyncdbmanagement command:$(selena): selena syncdbthen run migrations command:$(selena): selena migrateCreate partitions in the database by using the command:$(selena): selena createpartitionsRun web interfaceTo run selena web interface use the command:(selena)$ selena runserver 8080Configuration agentsWhen your selena web interface is running you must add a main agents to your selena instance. Open this link in your browserhttp://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 agentsettings-local.pyfile), and check the main agent checkbox. After the agent is added you will seeSaltcolumn in your agent row. Copy this string and add to the Selena-agentsettings-local.pyfile inSALTvariable. It is very important, because without it there will be no communication with the Selena-agent.Add monitored servicesIn administration panel add a service which will be monitored by Selena.
Open this link in browserhttp://localhost:8080/admin/services/service/add/and add a service URL to be monitored.CommandsRun a single monitoring service:(selena)$: selena monitorallSearch incidents:(selena)$: selena searchincidentsActivate/Deactivate technical breaks:(selena)$: selena technicalbreaksFor optimization, there are commands to archive service monitoring results.
If you create partitions in MySQL database run command:(selena)$: selena createpartitionsYou will need to run the command that merges monitoring data older than 8 days and moves it to the archive:(selena)$: selena makearchiveCalculate SLA for active services:(selena)$: selena calculateslaIf you want to run the commands asynchronically, you can add an--async-mode=1option to them.AutomationYou can configure Cron to monitor automatically in background. To edit crontab run command:$(selena): crontab -eand 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 calculateslaOf 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:8080LicenseSelena is licensed under theApache License, v2.0.Copyright (c) 2013-2014Allegro Group.