I used to write about how to install zabbix+hyclops to automatically register zabbix hosts on AWS EC2 instance before. Recently, I tried installing the latest version of zabbix-2.2.2 and hyclops-0.2. In fact, it's not working as expected so far because it seems that hyclops.connector.ec2 (ec2.py) python script is not working correctly. I will update this article when finishing to fix the problem (asking the engineers who created hyclops to debug the issue currently).
After uninstalling apache-libcloud from 0.14.1 to 0.13.2, the issue has been resolved.
Ikeda-san, thanks for your quick feedback and support!
# for i in schema images data do mysql -u zabbix -p zabbix < /usr/share/doc/zabbix-server-mysql-2.2.2/create/$i.sql done # mysqladmin -u root -p create zabbix # mysql -u root -p -e 'GRANT ALL PRIVILEGES on zabbix.* to zabbix@localhost IDENTIFIED BY "zabbix"; FLUSH PRIVILEGES;' # mysql -u zabbix zabbix -e 'SHOW TABLES;' +-----------------------+ | Tables_in_zabbix | +-----------------------+ | acknowledges | | actions | | alerts | ... | users_groups | | usrgrp | | valuemaps | +-----------------------+ #service zabbix-server start
Python-2.7, Python packages
# wget -O- https://www.python.org/ftp/python/2.7.5/Python-2.7.5.tgz | tar zxf - # cd Python-2.7.5/ # /configure && make && make install # wget -O- http://pypi.python.org/packages/source/d/distribute/distribute-0.6.35.tar.gz | tar zxf - # cd distribute-0.6.35/ #python2.7 setup.py install #easy_install-2.7 pip
Python modules
# pip install zabbix-api pyzmq psphere python-daemon==1.6 configobj tornado==2.4.1 boto
Python module (apache-libcloud)
Make sure that apache-libcloud-0.13.2 should be compiled and installed from tar ball because it failed to install apache-libcloud-0.13.2 with python-2.7 via pip.
# wget -O- https://pypi.python.org/packages/source/a/apache-libcloud/apache-libcloud-0.13.2.tar.gz#md5=d3d127bb21ee73ca5b30bb367949c898 | tar zxf - # cd apache-libcloud-0.13.2/ #python setup.py install #pip list | grep apache-libcloud apache-libcloud (0.13.2)
#pip install apache-libcloud==0.13.2 Downloading/unpacking apache-libcloud==0.13.2 Downloading apache-libcloud-0.13.2.tar.bz2 (396kB): 396kB downloaded Cleaning up... Exception: Traceback (most recent call last): File "/usr/local/lib/python2.7/site-packages/pip-1.5.4-py2.7.egg/pip/basecommand.py", line 122, in main status = self.run(options, args) File "/usr/local/lib/python2.7/site-packages/pip-1.5.4-py2.7.egg/pip/commands/install.py", line 278, in run requirement_set.prepare_files(finder, force_root_egg_info=self.bundle, bundle=self.bundle) File "/usr/local/lib/python2.7/site-packages/pip-1.5.4-py2.7.egg/pip/req.py", line 1197, in prepare_files do_download, File "/usr/local/lib/python2.7/site-packages/pip-1.5.4-py2.7.egg/pip/req.py", line 1375, in unpack_url self.session, File "/usr/local/lib/python2.7/site-packages/pip-1.5.4-py2.7.egg/pip/download.py", line 582, in unpack_http_url unpack_file(temp_location, location, content_type, link) File "/usr/local/lib/python2.7/site-packages/pip-1.5.4-py2.7.egg/pip/util.py", line 625, in unpack_file untar_file(filename, location) File "/usr/local/lib/python2.7/site-packages/pip-1.5.4-py2.7.egg/pip/util.py", line 543, in untar_file tar = tarfile.open(filename, mode) File "/usr/local/lib/python2.7/tarfile.py", line 1678, in open return func(name, filemode, fileobj, **kwargs) File "/usr/local/lib/python2.7/tarfile.py", line 1744, in bz2open raise CompressionError("bz2 module is not available") CompressionError: bz2 module is not available Storing debug log for failure in /root/.pip/pip.log
After creating value mappings and creating zabbix hosts on zaxbbix dashboard, I got the error message below in fact. I need to dive into the logging...
This issue has been solved by downgrading apache-libcloud from 0.14.1 to 0.13.2.
# tail -f /opt/hyclops/logs/hyclops_server.log [2014-03-25 16:30:17,416] hyclops.connector.ec2 (ec2-For AWS EC2-monitor) ERROR: Traceback (most recent call last): File "/usr/local/lib/python2.7/site-packages/hyclops-0.2.1-py2.7.egg/hyclops/connector/ec2.py", line 46, in __call__ result = self.run_command(hostname, params) File "/usr/local/lib/python2.7/site-packages/hyclops-0.2.1-py2.7.egg/hyclops/connector/ec2.py", line 62, in run_command result = self.monitor(hostname, conn_params) File "/usr/local/lib/python2.7/site-packages/hyclops-0.2.1-py2.7.egg/hyclops/connector/ec2.py", line 126, in monitor self.set_ami_info(node) File "/usr/local/lib/python2.7/site-packages/hyclops-0.2.1-py2.7.egg/hyclops/connector/ec2.py", line 175, in set_ami_info images = node.driver.list_images(ex_image_ids=[node.extra["imageId"]]) KeyError: 'imageId'
See zabbix_server.log to confirm the both python scripts are working to get aws charges and push messages.
# tail -f /var/log/zabbix/zabbix_server.log t 3704:20140326:110510.922 item [For AWS EC2:get_aws_charges.py[{$KEY},{$SECRET}]] became supported 3704:20140326:110510.922 item [For AWS EC2:push_message.py[{$HYCLOPS_SERVER},{$HYCLOPS_PORT},ec2,{HOST.HOST}]] became supported
See hyclops_server.log to confirm that polling and creating zabbix hosts have been successful.
* You need to change "log_level = DEBUG" on /opt/hyclops/hyclops.conf to debug.
The update version on this article is here, composed of Zabbix-2.2 and Hyclops-0.2.
Automation is definitely necessary, and let's say common for the cloud or virtualization environment, especially it saves us lots of time by automatically setting up the servers to be monitored.
I believe that Zabbix is one of the most famous open source monitoring software which has been popular for the recent years.
I am pretty sure that there are other monitoring softwares to achieve it, such as Hinemos, Hyperic HQ, Sensu, and so on.
Here, I tried installing Hyclops for Zabbix to achieve automatically registering the EC2 instances to be monitored on AWS.
This is how to install Hyclops for Zabbix based on the official installation manual with some comments added.
tornade-2.4.1 is recommended because 3.x has some issues in attribute settings and it fails to run gateone with the message below. If pip is used to install tornade, tornade-3.x is installed. Cf. https://github.com/liftoff/GateOne/issues/235
$ sudo /opt/gateone/gateone.py --auth=api --origins="http://zabbix-server-frontend/"
Traceback (most recent call last):
File "/opt/gateone/gateone.py", line 289, in
tornado.options.enable_pretty_logging()
AttributeError: 'module' object has no attribute 'enable_pretty_logging'
$ sudo /opt/gateone/gateone.py --auth=api --origins="https://localhost;https://127.0.0.1;https://"
[I 131120 16:27:32 gateone:2917] Connections to this server will be allowed from the following origins: 'https://localhost https://127.0.0.1 https:// https://'
[I 131120 16:27:32 gateone:2305] Using api authentication
[I 131120 16:27:32 gateone:2404] Loaded plugins: bookmarks, convenience, example, help, logging, logging_plugin, mobile, notice, playback, ssh
[I 131120 16:27:32 gateone:3054] Listening on https://*:443/
[I 131120 16:27:32 gateone:3060] Process running with pid 3255
[I 131120 16:27:38 gateone:1063] WebSocket opened (ANONYMOUS).
[I 131120 16:27:41 web:1462] 200 GET /static/ubuntumono-normal.woff () 10.19ms
[I 131120 16:27:42 web:1462] 200 GET /static/bookmarks/images/star.svg () 1.08ms
Ctrl+c
[I 131120 16:28:52 gateone:3084] Caught KeyboardInterrupt. Killing sessions...
[I 131120 16:28:52 gateone:3088] pid file removed.
[I 131120 16:28:52 termio:1491] Finalizing the log for pid 3260 (this can take some time).
$ sudo /opt/gateone/gateone.py --new_api_key
[I 131120 16:29:13 gateone:2880] A new API key has been generated:
[I 131120 16:29:13 gateone:2881] This key can now be used to embed Gate One into other applications.
$ sudo chkconfig gateone on
$ sudo service gateone start
Installing & Setting up Hyclops
$ wget https://github.com/tech-sketch/hyclops/archive/0.1.0.tar.gz -O- | tar zxf -
$ cd hyclops-0.1.0/
$ sudo ./setup.py install
$ sudo cp -a ./misc/init.d/redhat/hyclops /etc/init.d/
$ sudo cp -a ./misc/init.d/ubuntu/hyclops.conf /etc/init/
$ sudo mkdir /etc/zabbix/externalscripts
$ sudo cp -a ./misc/externalscripts/* /etc/zabbix/externalscripts
$ sudo chown -R zabbix:zabbix /etc/zabbix/externalscripts
$ sudo chmod u+x /etc/zabbix/externalscripts/*
$ sudo chkconfig hyclops on
$ sudo service hyclops start
Replacing some Zabbix dashboard files
$ sudo ./setup.py replace -d /usr/share/zabbix --zabbix-version=2.0
running replace
backup original file /usr/share/zabbix/dashboard.php to /usr/share/zabbix/dashboard.org
create /usr/share/zabbix/dashboard.php
create /usr/share/zabbix/gateone.php
create /usr/share/zabbix/dashboard_scripts_exec.php
create /usr/share/zabbix/custom/additional_blocks.inc.php
create /usr/share/zabbix/custom/additional_blocks_func.inc.php
create /usr/share/zabbix/custom/additional_func.inc.php
create /usr/share/zabbix/custom/monitoring.dashboard.js.php
backup original file /usr/share/zabbix/include/menu.inc.php to /usr/share/zabbix/include/menu.inc.org
create /usr/share/zabbix/include/menu.inc.php
uid=500(hyclops) gid=501(hyclops) groups=501(hyclops)
It is possible to specify 2.2 with the command option, but it has not been actually implemented yet. When I installed Zabbix-2.2 and specified 2.0 to replace the php files, the dashboard did not show because of some permission error or something. This issue has been solved as Hyclops begins to support Zabbix-2.2.
$ sudo ./setup.py replace -d /usr/share/zabbix --zabbix-version=2.4
running replace
Not supported version (Supported only 2.0 or 2.2)
uid=501(hyclops) gid=501(hyclops) groups=501(hyclops)
$ ls ./misc/zabbix-custom/
2.0
Importing Zabbix templates,scripts and globalmacro data
Follow the steps at the official site to setup the macros for AWS access and secret key,
you will be able to see the instances registered at the Zabbix dashboard.
I just only tried AWS EC2 setting, not vSphere ESXi.
I'm looking forward to Hyclops to be updated for Zabbix-2.2!