Skip to content

Importing data from CloudReports to MATLAB

thiagotts edited this page May 12, 2012 · 1 revision

Importing data from CloudReports to MATLAB

CloudReports generates a raw data file for each simulation it performs. This file is located in the raw folder at the report's directory. The content of this file follows the pattern below:

label \t value1 \t value2 \t (...) valuen \t \r

where the label is formed like so:

SimulationId_Entity_Scope_TypeOfResource_TypeOfValues

The simulation ID identifies a particular repetition of the experiment. The entity indicates the specific datacenter or customer the values are related to. The scope tells if the values represent overall usage, host usage or virtual machine usage. The type of resource identifies the resource: CPU, RAM or bandwidth. Finally, the type of values indicates if the values represent time or resource utilization.

The steps below demonstrate how to import the data recorded in the raw file into MATLAB.

Method 1: using the Graphical User Interface (GUI)

First, click on the import data button:

![importadatabutton] (http://dl.dropbox.com/u/737234/CloudReports/wiki/importdatabutton.png)

Then select the rawData.crd file in the report's directory and click Open:

![importrawdatafile] (http://dl.dropbox.com/u/737234/CloudReports/wiki/openrawdatafile.png)

In the Import Wizard, select tab as column separator at the top left corner of the window and click Next:

![importwizard] (http://dl.dropbox.com/u/737234/CloudReports/wiki/importwizard.png)

Now select the option "Create vectors from each row using row names" and click Finish:

![createrows] (http://dl.dropbox.com/u/737234/CloudReports/wiki/createrows.png)

The data is now loaded in the workspace and ready for use:

![loadeddata] (http://dl.dropbox.com/u/737234/CloudReports/wiki/loadeddata.png)

Method 2: loading data programmatically

If you performed multiple simulations using CloudReports, you'll probably want to load data from all simulations into MATLAB automatically, since doing this through GUI is very time-consuming (not to say extremely boring). The code below can be used to load data from several reports at once:

% Number of simulations
N = 3;

% Loads data from all raw data files
for n=1:N
  path = strcat('report', int2str(n), '/raw/rawData.crd');
  newData = importdata(path);

  for i = 1:size(newData.rowheaders, 1)
    assignin('base', genvarname(newData.rowheaders{i}), newData.data(i,:));
  end
end

Make sure you set MATLAB's current folder to your reports directory before you run the code:

![currentfolder] (http://dl.dropbox.com/u/737234/CloudReports/wiki/currentfolder.png)

A simple plot example

Now that we have successfully loaded simulation data into MATLAB, let's make use of it. The code below plots the overall usage of CPU by Datacenter 1 in simulation 1:

figure('Color','w');
plot(Sim1_Datacenter1_overall_cpu_time, Sim1_Datacenter1_overall_cpu_values);
xlabel('Time (minutes)');
ylabel('CPU Utilization (MIPS)');
axis([0 60 0 5]);

You should see an outcome like this:

![plotexample] (http://dl.dropbox.com/u/737234/CloudReports/wiki/plotexample.png)