Howto: Sar and Ksar ( Part two )

This is the part two of my test with sar and ksar. I tested the remote feature in ksar. In short, you use ksar to execute the same command that got executed just before midnight in the second post, in other words, the daily summary.

Having spare time tonight, here’s few screenshot..

Ksar remote connection

Click on: Data => “Launch SSH Command”

Enter the login information: user@ip-address, and click on yes.

You can click on yes here.

After you are asked to enter the SAR command. The default will be good. Click on Yes.

After that you can see the classic view, the same on we’ve got when we loaded text files.

I’d like to show you another sweet things with ksar. You can open few windows within ksar and arrange them, so you can compare your server stats. Open more than one window ( click on file => New window  ) and then click on Window => Tile

That’s it! It not harder than loading a local text file.. I’ll post a third post on Sar and kSar this week for people who would like to get a multiple day report.

Thanks for reading!

++

Howto: Sar and Ksar ( Part one )

This week a friend show me the SAR tool and ksar. So I gave it a try, and here’s how I setup the tools and few information on both tools.

SAR stand for “System Activity Report” on Linux this tool included in the sysstat package. It’s an incredible tool used to collect and display system data. SAR is the perfect tool to track down performance bottlenecks and multiple stats of your servers 24/7. The only “problem” is the readability of the displayed data.. It’s not perfect but you can find the information you are looking for, but if you are looking for a more “cute” and easy to read way to display the result, the answer is Ksar.

Ksar is a java SAR Grapher tool, it use the text file generated by SAR on Linux, Mac OS/X, Solaris, AIX, HPUX and you can load your SAR data using three different method: local file, local command execution, and remote command execution via SSH. Great isn’t ? Guest what, the tool even let you export the data in PDF/JPG/PNG/CSV.

I did this howto using Fedora 12. But as I said before you can use SAR under Linux, Mac OS/X, Solaris, AIX, HPUX.

Install and setup of SAR

First of all we will install the sysstat package, it’s available via the official Fedora repository.

# yum install sysstat

Once it’s done you will have to check  the file : /etc/cron.d/sysstat

You should see something like this:

 # cat /etc/cron.d/sysstat
 # Run system activity accounting tool every 10 minutes
 */10 * * * * root /usr/lib/sa/sa1 -S DISK 1 1
 # 0 * * * * root /usr/lib/sa/sa1 -S DISK 600 6 &
 # Generate a daily summary of process accounting at 23:53
 53 23 * * * root /usr/lib/sa/sa2 -A

We will need to generate the SAR files using C local because this is what Ksar will try to read.

According to the Ksar official Doc:

This parser use the output text file of the sar command. you need to have a spe-
cial precaution to make this file, since the parser is not locale time aware. The
parser is waiting for C locale output file

So make the /etc/crond./sysstat look like this:

# vim /etc/cron.d/sysstat
 # Run system activity accounting tool every 10 minutes
 */10 * * * * root LC_ALL=C /usr/lib/sa/sa1 -S DISK 1 1
 # 0 * * * * root /usr/lib/sa/sa1 -S DISK 600 6 &
 # Generate a daily summary of process accounting at 23:53
 53 23 * * * root LC_ALL=C /usr/lib/sa/sa2 -A

Now the sysstat cron is in place using C locale and it will gather information every 10 minutes, and generate a daily summary just before midnight. All the files generated by SAR will be put in /var/log/sa/. That’s it for the SAR part, now let’s take a look at Ksar.

Installing and using Ksar

You can download Ksar here: http://ksar.atomique.net/download.html

An interesting fact is that you can run Ksar direct from the website if you click on the “Run kSar via webstart” you open the Ksar.jnlp and Iced Tea webstart will handle the rest of the job.

We want to install the apps locally so click on “Download the Application locally” and save the zip file on your disk.

# unzip kSar-5.0.6
# cd kSar-5.0.6

You will need to execute Ksar using the root user to access the data generated by SAR.

# sh run.sh

You’ll see a screen like this:

Now you need to load the text file in Ksar. Click on the Data menu.

And then click on “Load from text file…”

Select the file SAR has generated in /var/log/sa/sar*. The number after “sar” should be the date of the day..

The sar* file is the result of the summary process accounting generated just before midnight every day. If you can’t see it, that mean you just setup your cron and you’re before midnight, or there’s something wrong with your setup. If you’ve just setup SAR minutes ago, simply execute those commands with the root user:

# LC_ALL=C /usr/lib/sa/sa1 -S DISK 1 1
# LC_ALL=C /usr/lib/sa/sa2 -A

And you can try to load the file again, the last commands put some data in the sar files and generated the summary.

Click Ok on the “Data Import is finished” message.

Now you can see the Ksar and all the stats in the left column, and a summary on the main page.

You can navigate the left menu and select the stats you want to watch!

Here’s a screenshot of what those graph look like:

That’s it! Once your data is loaded into Ksar if you click on data, you’ll be able to export the data or select a time frame for the generated graph.

I’ll test the ssh feature to load data from a command executed on a remote host and I’ll post the result soon!

References:

Sar: http://www.softpanorama.org/Admin/Monitoring/Sar/linux_implementation_of_sar.shtml

Ksar: http://ksar.atomique.net/index.html

Please leave comments if there’s error or if you have suggestions!