The software program (SarBox) which parses and analyzes SAR data in charts or text formats.
Collect log using Sar Utility
[user@host ~]# sar -A 30 2 > sar_linux.log
“30 2” reports for every 30 seconds a total of 2 times, which redirects to sar_linux.log
Note: Sar flag (i.e. A) can be anything which Sar utility supports.
Sar log file would like below

Run SarBox
System Requirement
| System | Requirement |
|---|---|
| JDK | 1.7 or above |
| Memory | No minimum requirement |
| Disk Space | No minimum requirement |
| Operating System | No minimum requirement with desktop features |
Verify Java Installation
Verify whether Java is installed in the system where SarBox is intended to run
| OS | Task | Command |
|---|---|---|
| Windows | Open Command Console | c:> java -version |
| Linux | Open Command Terminal | $ java -version |
If there is an error in output then Java is not installed. Install the Java Software Development Kit (SDK) and follow below procedure
| OS | Task |
|---|---|
| Windows | Set the environment variable JAVA_HOME to C:\Program Files\Java\jdk1.7.0_10 and append the string; C:\Program Files\Java\jdk1.7.0_10\bin to the end of the system variable path |
| Linux | export JAVA_HOME=/usr/local/jdk1.7.0_10 and export PATH=$PATH:$JAVA_HOME/bin/ |
Verify again to confirm Java is installed correctly.
Running SarBox
Download SarBox and follow below procedure
| OS | Task |
|---|---|
| Windows | C:\Users\SUMITBISWAS>"C:\Program Files\Java\jdk1.8.0_131\bin\java.exe" -jar "D:\SarBox_Executable_4_0\SarBox.jar" |
| Linux | [user@host ~]# /home/sumitbiswas/java/jdk1.8.0_131/bin/java -jar /home/sumitbiswas/SarBox_Executable_4_0\SarBox.jar |
Note: SarBox.jar can also be double clicked to run SarBox GUI
After a short pause, the SarBox GUI should appear, which is a Swing application, as seen in the following screenshot

To open a project, click File -> Open Sar File. Select Sar Log File and click Open

Enter the values as required. Descriptions are provided below

NOTE: It converts “absolute timestamp” to “relative timestamp”. I.e. 10:21:50 AM is converted to 01-01-2000 00:01:00. This will be incremented for following lines in sar log with incremental increment (sec).
Relative Timestamp is required because there is no date in selected sar log and the log can run for more than 1 day in which case time will be repetitive. In order to maintain the sequence of sar data, a relative date is added based on their occurrence in sar log.
Click Yes after setting correct values

Enter the deration as required. Descriptions are provided below.

Introduction of SarBox 4.0
SarBox helps user to parse or analyze sar data. SarBox show selected counter data in graphical format which can be exported in CSV.
About sar: The sar command writes to standard output the contents of selected cumulative activity counters in the operating system, usually in Unix or equivalent OS.
In computing, sar (system activity monitor) is a Solaris-derived system monitor command used to report on various system loads, including CPU activity, memory/paging, device load, network. Linux distributions provide sar through the sysstat package.
Usage or how to get sar data and redirect to log file from an OS: user@localhost:$ sar -A 5 > sar.log
Background
Sample sar data is provided below to understand what SarBox does and how it is going to help end user who uses sar data from the log file.
Let us understand a bit about sar data obtained from usually unix like OS. This will also help us to understand what SarBox will do for us. There are various version of sar available for different OS. But this is a general format and most of sar data will looks similar.
As we can see for the above example log, the first line is always a info line for sar which has nothing to do with sar data. SarBox can be configured for this to remove the line.
Each line starts with timetsamp to denote the duration of the counter value and also what is the interval for each set of counter value. Here the interval can be easily seen as 5 sec because 11:59:16 PM minus 11:59:11 PM at the beginning of above example. SarBox has the capability to set any date time format and also can be set with any interval duration.
As we see from above example that it contains 3 set of counter collection, namely CPU, Processes and Interrupts which can be differentiate with their counter names e.g. %usr or proc/s or intr/sec. Originally sar contains 30+ counter collections which has not been demonstrated here and to keep the article simple. These counter names will be displayed as tree view in SarBox. Each counter collection can also have series which will be displayed as subnode in tree view in SarBox (e.g. CPU has series like all or 0). There could also be counter collection which does not have any series and there won't be any sub node for the same (e.g. Process does not have series). This can be very easily seen in left side tree view of the SarBox.
SarBox will help user to parse or analyze the sar data into various counters and series (if it is available) and display in tree view format which then can be viewed in graphical format or export in csv format.
UI Description
SarBox Main Window
This is the main window of SarBox which will parse or analyze sar data based on user selected sar log file. Counter collection and associated series names will be shown in left hand side tree view. Once user selected any counter or its associated series from the tree view, SarBox will parse the data and represent the data in graphical format on bottom right hand side and also calculate metric values for each counter like %usr, %nice, etc and display on right top hand side. These data can be exported in CSV format.
SarBox User Setting
This window helps user to configure SarBox on how the log file will be parsed. The first thing is to truncate / remove the number of lines from top of sar log which is used for providing sar information and does not provide any counter related values and hence not required for SarBox.
The next is Date Time format. User needs to select the appropriate format based on matching sar Date Time format.
Last but not the least is the Interval duration for each set of sar data.
Note: SarBox will convert absolute timestamp to relative timestamp. E.g. In above example, it starts from 11:59:11 PM, 11:59:16 PM, etc. But SarBox will convert this and will start from 01/01/2000 00:00:00, 01/01/2000 00:00:05, etc. This will help SarBox to display graph properly and there are lot other usage which we will see in below topic.
SarBox Sar Duration
Here user can select whole duration of selected sar log file or selective duration of user choice. This gives user flexibility to view data of their choice and remove unwanted time frame data.
SarBox Sar Export
This helps user to export data in meanigful csv format which is not possible in raw sar data. User can select data of their choice duration.
SarBox Zoom Graph using mouse right or left click
This helps user to zoom in or zoom out or set default size of graph. This helps user to view the portion of graph which interest them the most. When mouse cursor is placed on a graph line mark, it displays the information of it.
Using the code
Code is very simple. It is segregated into below parts.
Read sar log file from user
Get User Setting from user
Convert full sar data from absolute timestamp to relative timestamp. This will help to remove arbitrary timestamp like 21:38 and start from 01/01/2000 00:00:00
Get all the counters and associated series (if available) and display in tree.
Get all associated data for user selected counter
Display the data in graph and display the metric in table.
These data can be exported in csv format for later usage.
There are 2 seperate package. One is for UI and another for background work. Under UI package, I have did everything which has to be part of UI and usually does less work in processing and more work to display information to user. In UI get the user interaction and get the associated values which is then passed to methods for processing. The method process the data and returns back meaningful data back to UI. The UI takes it and displays to user.
Points of Interest
SarBox can be customized for any version of sar.
The customizable file resides under <sarbox installed="" directory="">/Bin/SarCounterCollection.dat. It contains 3 columns seperated by "|". The first column is the CounterName which has to be unique. The second column can have -1 or 0 or 1. -1 is default and SarBox will determine whether the counter has any series or not. E.g. CPU has series like 0, 1, 2, 3 ... but Process does not have any series. 0 is maual setting forcing SarBox to not consider any series even if it is available and 1 is also manual setting forcing SarBox to consider series. Hence SarBox will try to get the series if it is available for that counter. The third column is the search criteria of the counter. Usually it has to be unique counter names to seperate it from other counter collection. E.g. NFS_Clinet can be identified with "access/s getatt/s" and NFS_Server can be identified with "saccess/s sgetatt/s". It can have any number of counter and seperated by single space.</sarbox>
If SarBox cannot find any predefined counter collection, then that will be named as "Unrecognized_1", "Unrecognized_2", etc. User can set it in SarCounterCollection.dat accordingly.
The SarBox has been developed by me keeping one point in mind that nothing should be hard coded and hence user has the flexibility to customiz the SarBox as they feel. But saying that, there are few things which SarBox will assume is that sar format remains constant
History
SarBox version 4.0 has been realsed on 19-Sep-2012.