- 为StackTach创建database,默认使用MySql,也可以 在settings.py 文件中配置其他的.
create stack db mysql -u root -p mysql> create database stacktach; mysql> grant all privileges on stacktach.* to 'root'@'localhost' indentified by '123'; exit
- 安装django和
./etc/pip-requires.txt
由于pip-requires.txt中要求django >=1.5.1 < 1.6.0 ,否则在版本1.8.1出错:
nuc:/opt/stack/stacktach$ python worker/start_workers.py Traceback (most recent call last): File "worker/start_workers.py", line 15, in <module> from django.db import close_connection ImportError: cannot import name close_connection
stacktach$ virtualenv env1 stacktach$ cd env1/ stacktach$ source bin/activate $ pip install -r etc/pip-requires.txt
- Clone this repo
git clone git://github/openstack/stacktach
- Copy and configure the config files in
./etc
(see below for details)
mv etc/sample_stacktach_config.sh etc/stacktach_config.json
mv etc/sample_stacktach_worker_config.json etc/stacktach_worker_config.json
stack_config.json:
export STACKTACH_DB_NAME="stacktach" export STACKTACH_DB_HOST="127.0.0.1" export STACKTACH_DB_USERNAME="root" export STACKTACH_DB_PASSWORD="123" export STACKTACH_DB_PORT="3306" export STACKTACH_INSTALL_DIR="./" export STACKTACH_DEPLOYMENTS_FILE="etc/stacktach_worker_config.json" export STACKTACH_VERIFIER_CONFIG="etc/stacktach_verifier_config.json" export DJANGO_SETTINGS_MODULE="settings"
-
[[local|localrc]] SERVICE_HOST=localhost DATABASE_PASSWORD=123 ADMIN_PASSWORD=123 MYSQL_PASSWORD=123 DATABASE_TYPE=mysql RABBIT_PASSWORD=guest SERVICE_PASSWORD=123 SERVICE_TOKEN=ADMIN
stacktach_worker_config.json可以配置为:{"deployments": [ { "name": "east_coast.prod.global", "durable_queue": false, "rabbit_host": "127.0.0.1", "rabbit_port": 5672, "rabbit_userid": "guest", "rabbit_password": "guest", "rabbit_virtual_host": "/", "exit_on_exception": true, "queue_name": "stacktach", "topics": { "nova": [ { "queue": "notifications.info", "routing_key": "notifications.info" }, { "queue": "notifications.error", "routing_key": "notifications.error" } ], "glance": [ { "queue": "notifications.info", "routing_key": "notifications.info" }, { "queue": "notifications.error", "routing_key": "notifications.error" } ] } } ] }
- 创建db tables
python manage.py syncdb You have installed Django's auth system, and don't have any superusers defined. Would you like to create one now? (yes/no): yes Username (leave blank to use 'yuntong'): Email address: ***@gmail.com Password: 123 Password (again): 123 Superuser created successfully.
- Configure OpenStack to publish Notifications back into RabbitMQ (see below)
- Restart the OpenStack services.
- Run the Worker to start consuming messages. (see below)
先fix一个bug:
diff --git a/settings.py b/settings.py index b6d27e5..dba5f2d 100644 --- a/settings.py +++ b/settings.py @@ -127,8 +127,9 @@ TEMPLATE_DIRS = ( # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates". # Always use forward slashes, even on Windows. # Don't forget to use absolute paths, not relative paths. - install_dir + "templates" + install_dir + "templates",
运行start_workers:
-
source etc/stacktach_config.sh $ python worker/start_workers.py
Starting worker for 'east_coast.prod.global glance'
Starting worker for 'east_coast.prod.global nova'打开rabbitmq的管理界面localhost:15672
- Run the web server (
python manage.py runserver --insecure
)
python manage.py runserver --insecure
- Point your browser to
http://127.0.0.1:8000
(the default server location)
StackTach v2 Fork me on GitHub Choose the Deployment to monitor All east_coast.prod.global
或者访问API: curl -H "Content-Type: application/json" http://localhost:8000/stacky/deployments/ #The list of all available deployments [["#", "Name"], [1, "east_coast.prod.global"]]
curl -H "Content-Type: application/json" http://localhost:8000/stacky/events/ #The distinct list of all event names
[["Event Name"],
["compute.instance.create.end"], ["compute.instance.create.start"], ["compute.instance.exists"], ["compute.instance.update"],
["port.create.end"], ["port.create.start"], ["port.update.end"], ["port.update.start"], ["scheduler.select_destinations.end"], ["scheduler.select_destinations.start"],
["image.update"], ["scheduler.select_destinations.start"]]
$ curl -H "Content-Type: application/json" http://localhost:8000/stacky/5b329e1f-c7d1-4fbe-bf15-80fcfbb22024/ #Retrieve all notifications for instances with a given UUID. - Click on stuff, see what happens. You can’t hurt anything, it’s all read-only.
参考:
http://stacktach.com/api.html
http://stacktach.com/install.html
http://stacktach.readthedocs.io/en/latest/setup.html