One script for Linux Monitoring-free, sar, vmstat, mpstat


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting One script for Linux Monitoring-free, sar, vmstat, mpstat
# 1  
Old 06-15-2013
One script for Linux Monitoring-free, sar, vmstat, mpstat

HI ,
I am wrirting a script for checking the performance monitoring on Linux System when my application is running.
I have to run a test for 30 minutes on some server and while the test is running i have to capture the perfromance metrics of Linux through vmstat , sar, mpstat, free.
here is the script

Code:
vmstat 1 | awk '{now=strftime("%d-%m-%y     %H:%M:%S    "); print now $0}'> ~/vmstats.txt &

or
Code:
c=0;while [ c != 1800 ]; do vmstat -t 5 ; c=expr`c+1`; done # this will run for 30 minutes

Here i am seeing an issue like :
i am seeing getting the headers as well in the output file(vmstats.txt) which i dont want to have in the output file, as i need to plot graphs of the runnable threads, cs, bi/bo later when the test is completed
Header is
Code:
02-06-13     11:38:53    procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu-----

Please help me in resolving this issue.

Code:
==================================================
sar -B 1 | awk '{now=strftime("%d-%m-%y    "); print now $0}'> ~/paging_report.txt &
>> This script is running file


Last edited by Scott; 06-15-2013 at 04:05 PM.. Reason: Don Cragun: Code tags added; warning sent; Scott: Thread moved from Contact Us forum
# 2  
Old 06-15-2013
One quick way is to pipe it through 'tail' only outputting line 2 through the end:
Code:
tail --lines=+2

# 3  
Old 06-15-2013
Quote:
Originally Posted by spacebar
One quick way is to pipe it through 'tail' only outputting line 2 through the end:
Code:
tail --lines=+2

I realize that the original question is specific to linux, but, still, I see no reason to use --lines instead of the ubiquitous -n.

However, I can think of at least two reasons not to: (1) Even if only by a trivial amount, it increases the learning curve for a new Linux admin with a non-GNU userland background. (2) Novice UNIX scripters may be frustrated when their GNU-only code doesn't run a non-GNU system.

Regards,
Alister
# 4  
Old 06-16-2013
Yes i had solved the problem of mine yesterday only , i should be using -n swtch to repeat headers of vmstat in the output file. manual of vmstat served the purpose:-)
Thanks Alister, u got it right :-)
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Solaris

Understanding & Monitoring CPU performance (Load vs SAR)

Hi all, Been reading a lot of the cpu load and its "analogy of it to car traffic path of expressway" From wiki Most UNIX systems count only processes in the running (on CPU) or runnable (waiting for CPU) states. However, Linux also includes processes in uninterruptible sleep states... (13 Replies)
Discussion started by: javanoob
13 Replies

2. Shell Programming and Scripting

Mpstat script output

I have a script which runs the mpstat and prints the output in a file. In order capture highest cpu ususage from the generated output file, have to manually tail the output file and need to grab which cpu has highest value (which is very annoying) Is there a way we can automate that process of... (3 Replies)
Discussion started by: Optimus81
3 Replies

3. Shell Programming and Scripting

Mpstat and sar

HI I ma using mpstat and sar commands to check the cpu utilisation but the results are not matching .I dont understand why thisis happening? $ sar -u 12 5 Linux 2.6.9-89.35.1.ELhugemem (abcd.efgh.com) 03/07/2013 02:43:16 AM CPU %user %nice %system %iowait %idle... (1 Reply)
Discussion started by: ptappeta
1 Replies

4. Infrastructure Monitoring

what is the best free monitoring tool?

hello everybody, please could you tell me what is the best monitoring tool "Free" to monitoring sun servers in my DC. BR, (1 Reply)
Discussion started by: maxim42
1 Replies

5. SuSE

SUSE 11.4 sar monitoring not run by default.

Hi, I had installed sysstat package below on a SUSE 11.4 box. I can see the sysstat cron file listed under the directory /etc/sysstat. However, it looks like the sysstat sar monitor is never run at all and the daily sar files are not created under the directory /var/log/sa. The cron daemon is also... (1 Reply)
Discussion started by: devtakh
1 Replies

6. Solaris

Memory usage, free and used, using sar, top and vmstat in Solaris zone/container

Hi all, I have a server running an Oracle database that is part of a Solaris M5000 container. Presumably this is referred to as a zone within a cluster, not sure if I get the terminology right. Anyway, a third-party manages the zone and unfortunately is not "helpful/friendly" to assist me on... (1 Reply)
Discussion started by: newbie_01
1 Replies

7. Solaris

prstat,vmstat,sar

Hi All, I have monitored prstat,vmstat and sar -u on sun system for 24 hours. Following is the output. Average Utilization : vmstat : 65% sar : 66% prstat :51%. vmstat and sar output are same but there is a 14-15% difference with prstat. What is the reason of this ? Regards,... (1 Reply)
Discussion started by: snjksh
1 Replies

8. Solaris

VMSTAT and MPSTAT anomalies

All: I have a V445 server with four IIIi CPUs and 8 GB RAM running Solaris 10 and an Oracle database along with some app server components and we have had some performance issues - so I collected some VMSTAT and MPSTAT data over the course of three days with a 15-minute polling interval. I... (1 Reply)
Discussion started by: jeffd4d
1 Replies

9. Solaris

Describe the parameters of iostat,vmstat and mpstat

Hi, I am trying to take the Statistics of the machine during load.Can someone explian the parameters of iostat: tty sd1 sd2 sd3 sd4 cpu tin tout kps tps serv kps tps serv kps tps serv kps tps serv us sy wt id vmstat: kthr ... (1 Reply)
Discussion started by: grrajeish
1 Replies

10. Shell Programming and Scripting

Linux Server Monitoring Script !!!

I am the Linux Admin in my organisation and need to write a shell script which will monitor the machine statistics every day and will send a consolidated report to me on my email id / will display the output into a file. Does anyone have such kind of script fulfilling this kind of purpose? ... (4 Replies)
Discussion started by: csaha
4 Replies
Login or Register to Ask a Question