One leader in this field is Citrix — with the XenServer product family. XenServer is the most known commercial implementation of of the open source Xen hypervisor. By the way, you should pronounced Xen like “zen.” It comes from a Greek word meaning “guest.”
In the IT world, Xen originated as a research project, led by Ian Pratt at England’s Cambridge University. It was first developed by XenSource Inc., and after acquisition, the work was continued by Citrix. Currently, you can choose between 4 editions of XenServer:
- XenServer [Free Edition]
- XenServer Advanced Edition
- XenServer Enterprise Edition
- XenServer Platinum Edition
Other Citrix “Xen” technology, like XenApp or XenDesktop, are not related to the original Xen project.
In 2009, Citrix decided to open the source of XenServer, and the company created XCP (Xen Cloud Platform). In the first phase, XCP was a whole Linux distribution. Recently, the initiative has been extended to provide XAPI toolstack on standard Linux distribution, in the first place for Debian and Ubuntu. What this means is that you can try XAPI on your home machine.
In the article below, we’ll learn how to apply daemon exporting XenServer metrics to Monitis. This is only proof of concept, but it can be easily modified to do exactly what you want. (This is the power you get using Monitis Open API).
There is a dedicated XenServer monitoring tool included in all paid editions. You can also find some third-party tools. Obviously, we are interested in how we can monitor XenServer and XCP with Monitis. One possible way is to enable SNMP on XenServer and treat it as a standard Linux in Monitis. After all, XenServer and XCP dom0 are based on CentOS. Another method that we are going to give an overview of today is XenServer/XCP-specific. XenServer enables you to download, host and store all VM statistic in a RRD (Round Robin Database) using HTTP handler. You can find some information on how to use XenServer RRD data in two documents from the Citrix Community page (Click here and here). In the second document, you’ll see that there are two examples of Python scripts that we are going to use for the base to our daemon updating XenServer monitors in Monitis. Both scripts use the python “rrd_update” module. You can also find on this on the Citrix page or grab it from github.
Monitis has dedicated libraries in many programing languages. You need to use python to export XenServer RRD; therefore to update results on Monitis, we are going to use the python library, too. The code can be obtained from our github repository. Please remember that you need the elementtree module, which is not a part of standard python distribution. Plus, you have to get it from the official website or obtain it from your distribution repository. There is a note about it in the code, but not in the original article.
Having these two weapons, we are now ready to attack. First, there is the example code in our git repository that you can install on XenServer or Linux distribution with XCP. Alternately, you can choose another server with a connection to both Monitis and the XenServer that you want to monitor. However, installing our daemon on XenServer/XCP seems to be the best choice.
Here are some easy directions:
1.) Create the Xen2Monitis default directory:
2.) Download the xen2monitis code which is part of Monitis-Linux-Scripts:
3.) Copy Xen2Monits file to default location:
cp Monitis-Linux-Scripts.git/Xen2Monits/* /var/local/lib/xen2monitis
4.) Go to created directory:
5.) Obtain the elementtree module:
– You can get the source code:
– Or you can get a dedicated package for your distribution. If you plan to use XenServer, the elementtree is already installed there.
6.) Install the elementtree (if not already done by your distribution)
– for source code (the last command as root):
tar -xzf elementtree-1.2.6-20050316.tar.gz cd elementtree-1.2.6-20050316 python setup.py install
7.) Next, add your API Key and Secret to a file. Please separate them with “,”.The default ‘secret file’ is /usr/local/xen2monitis/secret
8.) Add the xenserver root password to your secret file, so it should be similar to:
5DQQ0460S18ERNRNRUI7M905N1, 7MA9XJNDL3KAMBAKFR9981N04J, secret_password
9.) Now you can start the daemon:
10.) You need to wait few minutes. You can check if your script works without any problems in /var/log/xs2monitis.log.
11.) After a few minutes, you should have a bunch of new graphs that you can add to the Dashboard by Monitors->Custom Monitor menu.
Monitor Name Conventions
When you look at newly created monitor names, you might be a bit confused. The names tend to be very long and have a strange set of strings separated by ‘-’, for example:
lisbon – cpu1 (HOST: 0c1bb847-d867-75ff-27e0-7b468f1385f2)
Such name conventions were chosen to ensure the uniqueness of each monitor. Imagine that you have two VMs called “Win7”. Daemon would not be able to distinguish between them and would save all data into one monitor! To address it, XenServer UUID (universally unique identifier), what looks like set of strings separated by “-“, is added to each title.
Using xen2monitis.py script, please remember that there are some values you can define at the beginning of the file, for example:
- where is the secret file (default /usr/local/lib/xen2monitis/secret)
- where is the lock file (default /var/run/xen2monitis.pid)
- where is the log file (default /var/log/xen2monitis.log)
- the url to pool master (default http://localhost)
You might prefer not to use daemon, but, instead, call up script from cron job. It’s not a big problem. You need to copy the main loop, start after line 115 to separate the file and convert it.
We hope this article showing you how to monitor your XenServer with Monitis makes your IT life a lot easier. Please share some tips of your own!