This is just memorandum to extract CPUUtilization with AWS CLI because I'm considering using Zabbix or Sensu to monitor the instances on AWS and thinking of how to extract each metrics, such as CPU usage, Memory usage, or Traffic.
Writing plugins will be helpful but the simplest way and using functions which they offer are easier than writing plugins, I believe.
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!
I've got some opportunities to use zabbix not only for monitoring but mainly calculating system availability. It is just memorandum for me this time, but after introducing how to install zabbix-2.x on CentOS-6.x, I'm going to try some functions such as IT Services and Discovery.
Overview of System Structure/Middleware
OS
CentOS release 6.4 (Final)
Kernel
2.6.32-358.6.2.el6.x86_64
Language
ja_JP.UTF-8
role
package
WEB
httpd-2.2.15
DB
mysql-5.6.10
Monitoring
zabbix-2.0.11
Scripting Language
php-5.3.3
Note: I fixed to install zabbix-2.0.11 by referring to the URL where zabbix-2.0.11 have been stored because the latest version is being installed without specifying the version.