Skip to content
pvmehta.com

pvmehta.com

  • Home
  • About Me
  • Toggle search form
  • configUOCIOTTO.ora Oracle
  • TABLE SIZING WITH DB_BLOCK ARCHITECTURE Reference : Metalink note : 10640.1 Oracle
  • My FTP Job Scheduling for www.pvmehta.com PHP/MYSQL/Wordpress
  • move_arch_files.ksh Linux/Unix
  • longtx.sql with the flag whether session is blocking any DML locks or not. Oracle
  • 751131.1 New Article Error 2819 While Requesting a Systemstate Dump Oracle
  • Vivek Tuning for Row Locks. Oracle
  • Error Handling in Proc Oracle
  • find_pk.sql /* Find Primary Key */ Oracle
  • sid_wise_sql.sql Oracle
  • Query to Generate aggregate on every 30 mins. Oracle
  • lck.sql Oracle
  • How to set Processes Parameter Oracle
  • nfs mount command Linux/Unix
  • Implementation of key based authentications Linux/Unix

How to collect CPU usage on Linux using Shell script

Posted on 09-Jun-202309-Jun-2023 By Admin No Comments on How to collect CPU usage on Linux using Shell script

Following script will help to collect CPU based on on every SAMPLE_TIME. This will help to collect IDLE CPU our from “vmstat” and store them in a file.

#Setup SAMPLE_TIME for cpu data collection interval
SAMPLE_TIME=5
while true
do
x=`vmstat | grep -v procs | grep -v swpd | awk '{print $15}'`
echo `date +"%m-%d-%y %T"` $x
sleep ${SAMPLE_TIME}
done

Create file with above contents and save it as test_cpu.sh for example. 

Now, to run this collection in background use the following command.

nohup ./test_cpu.sh 1>test_cpu.out 2>&1 &

you can monitor using “tail -f test_cpu.out” for incremental progress of data collection. You can also use any visual tool like power BI or Excel for quick analysis. 

Linux/Unix, shell

Post navigation

Previous Post: Move WordPress site from one hosting service to other.
Next Post: Find which sessions is accessing object that prevent your session to have exclusive locks in Oracle

Related Posts

  • Process Map for CPU and Memory for OS processes Linux/Unix
  • catall.sh Linux/Unix
  • create a folder in multiple places Linux/Unix
  • age_alert.ksh aging out alert.log Linux/Unix
  • Sending email with file attachment. Linux/Unix
  • remove archfiles only when it is applied to DR rm_archfiles.sh Linux/Unix

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Categories

  • Ansible (0)
  • AWS (2)
  • Azure (1)
  • Linux/Unix (149)
  • MYSQL (5)
  • Oracle (392)
  • PHP/MYSQL/Wordpress (10)
  • POSTGRESQL (0)
  • Power-BI (0)
  • Python/PySpark (7)
  • RAC (17)
  • rman-dataguard (26)
  • shell (149)
  • SQL scripts (341)
  • SQL Server (6)
  • Uncategorized (0)
  • Videos (0)

Recent Posts

  • SQL Server Vs Oracle Architecture difference25-Jul-2025
  • SQL Server: How to see historical transactions25-Jul-2025
  • SQL Server: How to see current transactions or requests25-Jul-2025
  • T-SQL Vs PL/SQL Syntax25-Jul-2025
  • Check SQL Server edition25-Jul-2025
  • Checking SQL Server Version25-Jul-2025
  • Oracle vs MYSQL Architecture differences (For DBAs)24-Jul-2025
  • V$INSTANCE of Oracle in MYSQL24-Jul-2025
  • Day to day MYSQL DBA operations (Compared with Oracle DBA)24-Jul-2025
  • MYSQL and Oracle Comparison for Oracle DBA24-Jul-2025

Archives

  • 2025
  • 2024
  • 2023
  • 2010
  • 2009
  • 2008
  • 2007
  • 2006
  • 2005
  • Drop specific SQL plan baseline – spm Oracle
  • Good Oracle Architecture In Short and point to point Oracle
  • Clean up Oracle
  • Running select from V$ views from remote server Linux/Unix
  • How to find who is using which Rollback segment and how many rows or blocks in that rollback segments, Oracle
  • How can I tell if ASO is installed ? Oracle
  • Jai Shree Ram Oracle
  • checking redhat linux version Linux/Unix

Copyright © 2025 pvmehta.com.

Powered by PressBook News WordPress theme