sysstat sar provides command line based monitoring data. Those who are new or migrating from Windows or MAC and used to the graphical output, it might get confusing and boring. Hence the development of kSar sar grapher. kSar sar grapher is a graphing tool that can graph for Linux, MAC and Solaris sar outputs. Using KSar you can output graphs to a pdf file. kSar sar grapher is developed by Alexandre Cherif and uses a BSD license for distribution.
kSar sar grapher is a java based application that graphs your sar data.
You can load data from three method :
- local file
- local command execution and
- remote command execution via SSH
kSar sar grapher supports the sar output of the following OS:
- Solaris 8, 9 and 10
- Mac OS/X 10.4+
- Linux (Systat Version >= 5.0.5)
- AIX (4.3 & 5.3)
- HPUX 11.00+
So let’s get onto business and install kSar sar grapher.
Step 1: How to download ksar using wget?
kSar sar grapheris not available in Linux repositories. You have the go to the Sourceforge project page and download it manually.
Link: http://sourceforge.net/projects/ksar/
Run the following command to download it to any folder. I’ve downloaded it to my /root
directory. At the time of writing this guide, kSar v 5.0.6
was available.
root@kali:~# wget http://downloads.sourceforge.net/project/ksar/ksar/5.0.6/kSar-5.0.6.zip
Step 2: How to unpack kSar zip file?
There’s no installation for kSar sar grapher. You just unpack it and put in any directory. I prefer /opt
folder (opt = optional packages).
Run the following command to unzip kSar-5.0.6.zip
and move the extracted directory to /opt
folder.
root@kali:~# unzip kSar-5.0.6.zip root@kali:~# root@kali:~# mv kSar-5.0.6 /opt/ root@kali:~# root@kali:~# cd /opt/kSar-5.0.6/
Step 2.1: kSar dependencies and requirements
kSar sar grapher got only one dependency as far I can see. You just to install Java JDK on your machine. There are lot’s of guides on how to do that. Those who are Kali Linux used like me should use this guide to install Java JDK.
Minimum Requirements:
- sysstat or SAR in the system
- JRE Version 1.5 or +
Step 3: How to run kSar?
By default the run.sh
file is not executable. You need to chmod +x
it.
root@kali:/opt/kSar-5.0.6/# ls root@kali:/opt/kSar-5.0.6/# root@kali:/opt/kSar-5.0.6/# chmod +x run.sh root@kali:/opt/kSar-5.0.6/# root@kali:/opt/kSar-5.0.6/# ./run.sh
Once kSar is running, leave the terminal open, if you close the terminal kSar will close too.
Step 4: How to generate graphs using kSar?
As I’ve mentioned before, you can generate sar graphs using kSar from three different inputs:
- Local text file
- Remote command execution via SSH and
- Local command execution.
Let’s go through them all.
Step 4.1 How to generate graphs using kSar from local text file?
Run the following command to generate a sar file that will be used in kSar sar grapher.
First, you need to grab sar command statistics. Type the following command to get stats, enter (type it on your server):
root@kali:~# LC_ALL=C sar -A > /root/sar.data.txt
I’ve saved this file in my /root
directory.
In kSar, click on Data
> Load from text file
option.
Browse to /root
folder and open sar.data.txt
file.
Now double click on kSar icon
(it changes when the file is loaded) and select Processes
. Click on each options (memory, swap, page etc.). You should be able to drag your mouse to zoom in or out.
Step 4.2 How to generate graphs using kSar via Launch SSH command?
What SSH command does is it allows you to connect to any machine that is running a SSH server and view and generate SAR graphs remotely or locally is realtime. There’s two step to this option:
- You connect to a machine via SSH
- You run a SAR command which then collects data.
In kSar
, click on Data
> Launch SSH command
.
On the next popup window, it should come up a SSH connection popup.
In my case I am just going to login to localhost (which is own machine). If you know IP address for a remote host (a remote host can be anything from a Linux machine, Webserver, Solaris machine) running SAR. In my case I just press YES
.
Next window asks me if I am to trust the authenticity key for the host. Because it’s my OWN machines, I am going to press YES
.
If you are not able to connect, via SSH command, that just means following following 3 things:
- The remote server does not have SSH server enabled
- You are not allowed
- A Firewall is blocking connection
In case it’s your local machine, you MUST install and enable openssh-server on your local machine.
Next popup should ask you for your password. Type in the correct password and press OK
.
On the next popup window, it should come up with SAR -A
command by default. Press OK
now.
Give it a few minutes and you should see the graphs are loaded.
Step 4.3 How to generate graphs using kSar using local SSH command?
For Step 4.2 I’ve used root@localhost which logs on to my own machine. If you are really going to view your own machines graphs only, then Running Local command is the better and faster way. It allows you to view your own workstations SAR graphs in a nice and easy to understand graphical interface.
In kSar
, click on Data
> Run Local command
.
On the next popup window, it should come up with SAR -A
command by default. Press OK
now.
Give it a few minutes and you should see the graphs are loaded.
How to zoom in and out on kSar graphs?
If you drag your mouse on the graphs, you can zoom on that part of it. To unzoom, do the drag your mouse to the opposite direction. Another way is to right click and select zoom.
Command specific to kSar:
Running kSar GUI:
You can run the GUI with 4 ways:
- GUI only :
java -jar kSar-x.x.x.jar
- GUI default data grabbing :
java -jar kSar-x.x.x.jar -startup
- GUI with the “
one login for all
” function :java -jar kSar-x.x.x.jar -wizard
- GUI and collect :
java -jar kSar-x.x.x.jar -input 'ssh:// or file:// or cmd://'
- eg. :
java -jar kSar-x.x.x.jar -input 'cmd:///usr/bin/sar -f /tmp/mysar.file'
- eg. :
Running kSar from command line
To run kSar sar grapher on the command line, you MUST specify input and output argument:
example: java -jar kSar-x.x.x.jar -input 'file:///var/log/sa/sarXX' -outputPDF today.pdf
kSar help
To show kSar sar grapher help menu/instructions
java -jar kSar-x.x.x.jar -help
Using shortcut XML
You can make template of data collection via XML (see contrib/shortcut.xml
). This shortcut can be open with (-startup
or -wizard cf
. upper)
Replace current shortcut
java -jar kSar-x.x.x.jar -replaceShortcut newxml_shortcut_file.xml
Add some shortcut
java -jar kSar-x.x.x.jar -addShortcut newxml_shortcut_file.xml
ADMIN commands:
Clear all the preferences on kSar sar grapher
java -jar kSar-x.x.x.jar -ClearAllPrefs
That’s it. Thanks for reading. Please share.
References and help doco
- sysstat (sar): http://sebastien.godard.pagesperso-orange.fr/]
- ksar: http://sourceforge.net/projects/ksar/
- Howtoforge: http://www.howtoforge.com/system-monitoring-with-sar-and-ksar
- Cyberciti: http://www.cyberciti.biz/tips/identifying-linux-bottlenecks-sar-graphs-with-ksar.html
- Debian: http://www.debian.org/
- Ubuntu: http://www.ubuntu.com/
- CentOS: http://www.centos.org/
- Gentoo: http://www.gentoo.org/
Looks that you are inspired by
http://www.howtoforge.com/system-monitoring-with-sar-and-ksar
Yes of course … and http://www.cyberciti.biz/tips/identifying-linux-bottlenecks-sar-graphs-with-ksar.html. Thanks for reminding, I will update my references accordingly.
How can I graph the data across days rather than the data from a single day? I would like a single graph with historical relevance
Hi,
When i open ksar graphical window,I couldnt see data tab window to open a ssh or to run a local command in gui.Please let me know what the issue is here
if you want to convert to image use this
java -jar kSar.jar -input ‘file_name’ -outputJPG file_output_path
How do I enable the export to PDF, JPG etc. They all are grayed out