About nixCraft

Topics

Howto collect Linux system utilization data into a file

Posted by Vivek Gite [Last updated: May 21, 2007]

I’ve already documented the procedure to find out CPU utilization under Linux and UNIX oses using various tools.

However I received a couple of email questions via email:

Howdo I collect Linux system utilization data into a file? How do I email the data or move to another computer?

To be frank you don’t have to do anything data is collected and stored in /var/log/sa location using sa1 and sa2 scripts. It is part of sadc - System activity data collector tools.

The sadc command samples system data a specified number of times ( count ) at a specified interval measured in seconds ( interval ). It writes in binary format to the specified output file.

The sa1 command is a shell procedure variant of the sadc command and handles all of the flags and parameters of that command. The sa1 command collects and store binary data in the /var/log/sa/sadd file, where the dd parameter indicates the current day. The interval and count parameters specify that the record should be written count times at interval seconds.

The sa1 command is designed to be started automatically by the cron command. Type the following command to list files:
# ls /var/log/sa
Output:

sa13  sa14  sa15  sa16  sa17  sa18  sa19  sa20  sa21  sar12  sar13  sar14  sar15  sar16  sar17  sar18  sar19  sar20

How do I copy log files?

You can copy all these logs files using ssh/scp or ftp to another computer. You can run use sar command to read binary raw data files, enter
# sar -f sa13
Output:

Linux 2.6.9-55.ELsmp (monster.labs.nixcraft.in)     05/13/2007

12:00:02 AM       CPU     %user     %nice   %system   %iowait     %idle
12:10:01 AM       all     19.75      0.00      2.29      7.49     70.48
12:20:01 AM       all      2.28      0.00      0.27      0.06     97.39
12:30:01 AM       all      2.58      0.00      0.32      0.07     97.02
12:40:02 AM       all     16.05      0.00      3.12     13.48     67.36
12:50:01 AM       all     10.78      0.00      1.20      3.61     84.41
01:00:01 AM       all      2.42      0.00      0.29      0.30     96.99
01:10:01 AM       all      3.70      0.00      0.42      0.42     95.47
01:20:01 AM       all      2.47      0.00      0.28      0.14     97.11
01:30:01 AM       all      3.20      0.00      0.31      0.15     96.34
01:40:01 AM       all      2.46      0.00      0.27      0.07     97.20
01:50:01 AM       all      2.40      0.00      0.26      0.10     97.24
....
.....

See also:

E-mail this to a friend      Printable version

You may also be interested in other helpful articles:

Leave a Reply

We encourage your comments, and suggestions. But please stay on topic, be polite, and avoid spam. Thank you very much for stopping by our site!

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word

Copyright © 2004-2008 nixCraft. All rights reserved - TOS/Disclaimer - Privacy policy - Sitemap - Powered by Open source software.