Alerta在CentOS6.6安装全过程

Alerta (官网: http://docs.alerta.io/en/latest/index.html

0. 准备工作

Alerta用Python写成,所以首先要确定系统里安装了Python。貌似对Python 2.* 或者 Python 3.*都可以支持。当然CentOS 6.6里默认是Python 2.6.6。


0.1 安装一下pip,否则自己给自己找麻烦...

yum install python-pip.noarch


0.2 安装MongoDB,首先查找一下都有什么package:

[root@XXX ~]# yum search mongo | grep -i mongod
libmongodb.x86_64 : MongoDB shared libraries
libmongodb-devel.i686 : MongoDB header files
libmongodb-devel.x86_64 : MongoDB header files
mongodb-server.x86_64 : MongoDB server, sharding server and support scripts
nodejs-mongodb.noarch : A node driver for MongoDB
php-pecl-mongo.x86_64 : PHP MongoDB database driver
pymongo.x86_64 : Python driver for MongoDB
pymongo-gridfs.x86_64 : Python GridFS driver for MongoDB
python-asyncmongo.noarch : An asynchronous Python MongoDB library
                          : MongoDB
python-pymongo.x86_64 : Python driver for MongoDB
python-pymongo-gridfs.x86_64 : Python GridFS driver for MongoDB
mongodb.x86_64 : High-performance, schema-free document-oriented database


0.3 安装MongoDB的包以及Python+MongoDB的包,简单粗暴,跟系统架构一致的都装上。

yum install $(yum search mongo | grep -i mongod | egrep -v "i686|php|nodejs" | awk '{print $1}')

尤其要注意:mongodb-server必须装上!


0.4 启动MongoDB服务

service mongod start


1. 接下来安装Alerta

1.1 安装Alerta-Server,使用pip方式最快捷

pip install alerta-server

此处有坑,此处有坑,此处有坑...重要的事情说三遍!!!

猫哥在安装过程中遇到了需要单独安装CentOS系统的 libiff-devel 包的情况...自己单独装一下好了...还有几个坑确实记不住了,见招拆招好了。

有时候因为网络原因,pip install 会报错,再执行一遍有时候就通过了。


1.2 启动Alerta-server

[root@xxx ~]# alertad

确保之前MongoDB服务启动了,Alerta-Server就不会有问题,否则会自动报错退出...


2. 安装Alert Web Console

这一步比较轻松,没有坑...

wget -O alerta-web.tgz https://github.com/alerta/angular-alerta-webui/tarball/master
tar zxvf alerta-web.tgz
cd alerta-angular-alerta-webui-*/app
python -m SimpleHTTPServer 8000

>> browse to http://localhost:8000

出现上面这张图,说明大体上没问题了...


3. 发一条报警信息试试看?又有坑,又有坑,又有坑!!!重要的事情还是要说三次!!

alerta send -r web01 -e NodeDown -E Production -S Website -s major -t "Web server is down." -v ERROR

当你以为这样就万事大吉了吗?没有吧... Python 2.6和2.7还是有区别滴...

反正猫哥遇到问题了... 报错信息如下:

[root@xxx ~]# alerta send -r web01 -e NodeDown -E Production -S Website -s major -t "Web server is down." -v ERROR
2015-10-09 18:13:53,607 - alerta.shell - ERROR - zero length field name in format
Traceback (most recent call last):
  File "/usr/lib/python2.6/site-packages/alerta/shell.py", line 1316, in main
    AlertaShell().run()
  File "/usr/lib/python2.6/site-packages/alerta/shell.py", line 1304, in run
    args.func(args)
  File "/usr/lib/python2.6/site-packages/alerta/shell.py", line 118, in send
    print("{} ({})".format(response['id'], info))
ValueError: zero length field name in format


搜索一下,解决方案依旧“简单粗暴”,直接改/usr/lib/python2.6/site-packages/alerta/shell.py 的第118行。

---      print("{} ({})".format(response['id'], info))
+++   print("{0} ({1})".format(response['id'], info))

再运行一次(忽略最后的“4 duplicates”):

[root@vm-144-193-buy01-hp ~]# alerta send -r web01 -e NodeDown -E Production -S Website -s major -t "Web server is down again." -v ERROR
7572e6be-b033-4fc9-8a30-6085d1a009b3 (4 duplicates)


完毕!!


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值