MikroTik Cloud Hosted Router (CHR) is a RouterOS version intended to be used as a virtual machine instance.
It runs on x86-64-bit architecture and can be deployed on most hypervisors such as:
VMWare, ESXi, Player and Workstation
Microsoft Hyper-V
Oracle VirtualBox
KVM
And others, like Xen, but I haven’t tested it yet
Some special requeriments apply depending on the subyacent hypervisor.
ESXi
Network adapters must be vmxnet3 or E1000. Just use vmxnet3 to get the most. Disks must be IDE, VMware paravirtual SCSI, LSI Logic SAS or LSI Logic Parallel.
Hyper-V
Network adapters must be Network adapter or Legacy Network adapter .Disks IDE or SCSI.
Qemu/KVM
Virtio, E1000 or vmxnet3 NICs. IDE, Sata or Virtio disks.
VirtualBox
Networking using E1000 or rtl8193, and disks with IDE, SATA, SCSI or SAS interfaces.
Licensing
The CHR images have full RouterOS features enabled by default, but they use a different licensing model than other RouterOS versions.
Paid licenses
p1
p1 (perpetual-1), which allows CHR to run indefinitely. It comes with a limit of 1Gbps upload per interface. All the rest of the features provided by CHR are available without restrictions. It can be upgraded p1 to p10 or p-unlimited.
p10
p10 (perpetual-10), which also allows CHR to run indefinitely, with a 10Gbps upload limit per interface. All features are available without restrictions. It can be upgraded to p-unlimited.
p-unlimited (really?)
The p-unlimited (perpetual-unlimited) license level allows CHR to run indefinitely. It is the highest tier license and it has no enforced limitations.
Free licenses (yay!)
There are two ways to use and try CHR free of charge.
free
The free license level allows CHR to run indefinitely, with a limit of 1Mbps upload per interface. All the rest of the features have no restrictions. This level comes activated by default on all images.
60-day trial
Th p1/p10/pU licenses can be tested with a 60 days trial.
Cool. How can i try it?
The easiest way to spin up a working instance of CHR is using the OVA appliance provided by MikroTik.
Once downloaded, the OVA can be used to deploy a new instance. I’ll be using ESXi on this example. The OVA comes preconfigured with a single network adapter, but more interfaces can be added on a later stage.
Initial Configuration
After the VM boots, log in via CLI with the default credentials:
Username: admin
Password: none
CHR comes with a free licence by default, limited to 1Mbps upload limit. This is handy for lab purposes, or low traffic scenarios like stand-alone DHCP servers.
A DHCP client is enabled by default on the single existing ether1 interface. Use any of the following methods to find out the adquired address.
/ip dhcp-client print
/ip address print
Let’s get a trial licence. You will need the credentials for your MikroTik account. If you don’t have a MikroTik account, get one here.
The CHR instance will also need Internet access, so be sure to connect the virtual NIC to a VM network where it can make its way to the outside.
Zabbix is an open source monitoring tool for diverse IT components, including networks, servers, virtual machines (VMs) and cloud services. It provides monitoring metrics, among others network utilization, CPU load and disk space consumption. Data can be collected in a agent-less fashion using SNMP, ICMP, or with an multi-platform agent, available for most operating systems.
Even when it is considered one of the best NMS on the market, its reporting capabilities are very limited. For example, this is an availability report created with PRTG.
And this is a Zabbix Report. There is no graphs, no data tables, and it is difficult to establish a defined time span for the data collection.
My client required an executive report with the following information.
Host / Service Name
Minimum SLA for ICMP echo request monitoring
Achieved SLA for ICMP echo request monitoring
Memory usage graph, if host is being SNMP-monitored
Main network interface graph, if host is being SNMP-monitored
And storage usage graph, also if the host is being SNMP-monitored
Using the Zabbix API
To do call the API, we need to send HTTP POST requests to the api_jsonrpc.php file located in the frontend directory. For example, if the Zabbix frontend is installed under http://company.com/zabbix, the HTTP request to call the apiinfo.version method may look like this:
An object has to be created to initialize the client. I prefer to set url, username, and password dynamically, with data provided by the end user, so no credentials are stored here.
server = new $.jqzabbix({
url: url, // URL of Zabbix API
username: user, // Zabbix login user name
password: pass, // Zabbix login password
basicauth: false, // If you use basic authentication, set true for this option
busername: '', // User name for basic authentication
bpassword: '', // Password for basic authentication
timeout: 5000, // Request timeout (milli second)
limit: 1000, // Max data number for one request
});
As told before, the first step is to authenticate with the API, and save the authorization token. This is handled by the jqzabbix library by first making a request to get the API version, and then authenticating.
server.getApiVersion();
server.userLogin();
If the authentication procedure is completed properly, the API version and authentication ID are stored as properties of the server object. The userlogin() method allows to set callbacks for both success and error.
var success = function() { console.log('Success!'); }
var error = function() { console.error('Error!'); }
server.userLogin(null, success, error)
Once authenticated, the Zabbix API methods are called in the following fashion with the sendAjaxRequest method.
I set a global array hosts to store the hosts information. Another global array called SEARCH_GROUPS is used to define which hosts groups should considered on the API request. By setting the selectHosts parameter to true, the hosts on the host groups are retrieved too on the response.
On success, the result is stored on the hosts array, and the get_graphs function is called. If there is an error, the default error callback is fired.
Previously, user defined graphs were configured on Zabbix, to match the client requeriments of specific information. All names for the graphs that should be included on the report were terminated the ” – Report” suffix.
This function retrieves all those graphs, and by setting the selectHosts to true, the hosts linked to each graph are retrieved too.
On success, the result is stored on the graphs array, and the render function is called. If there is an error, the default error callback is fired.
By this time you should have noticed that the Zabbix API allows to retrieve values for the graphs, but no images. An additional PHP file will be stored with the HTML and JS files, as a helper to call the web interface by using php_curl.
You can get it on https://zabbix.org/wiki/Get_Graph_Image_PHP. I made a couple modifications to it in order to pass username and password on the URL query, with parameters for the graph ID, the timespan, and the image dimensions.