Skip to content
pvmehta.com

pvmehta.com

  • Home
  • About Me
  • Toggle search form
  • Good Doc 28-JUN-2006 Oracle
  • oracle tips… from http://www.bijoos.com/oracle/douknow.htm Oracle
  • DBMS_UTILITY.ANALYZE_SCHEMA Oracle
  • Adding or Dropping Online Redo Log Files When Physical Standby in place Oracle
  • oracle fast start failover best practice Oracle
  • How to find pinned objects from shared pool. (pinned via dbms_shared_pool.keep) Oracle
  • V$transaction notes for finding XID composition. Oracle
  • create PLAN_TABLE command. Oracle
  • Insert cause enqueue locks Oracle
  • How To Transfer Passwords Between Databases (ref note: 199582.1) Oracle
  • TABLE SIZING WITH DB_BLOCK ARCHITECTURE Reference : Metalink note : 10640.1 Oracle
  • Vivek’s egrep commands to trace problem. (on linux x86-64) Linux/Unix
  • Oracle Identifiers Oracle
  • Sending SQLPLUS output in HTML format Oracle
  • sess1.sql Oracle

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

  • catting.sh Linux/Unix
  • send attachment from unix-shell script Linux/Unix
  • Remove DOS CR/LFs (^M) Linux/Unix
  • Find long Running Transaction Linux/Unix
  • Useful Solaris Commands on 28-SEP-2005 Linux/Unix
  • Find total file sizes Linux/Unix

Leave a Reply Cancel reply

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

Categories

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

Recent Posts

  • load SPM baseline from cursor cache05-Jun-2025
  • Drop all SPM baselines for SQL handle05-Jun-2025
  • Load SPM baseline from AWR05-Jun-2025
  • Drop specific SQL plan baseline – spm05-Jun-2025
  • findinfo.sql (SQL for getting CPU and Active session info)27-May-2025
  • SQL Tracker by SID sqltrackerbysid.sql22-Apr-2025
  • How to connect to Oracle Database with Wallet with Python.21-Mar-2025
  • JSON/XML Types in Oracle18-Mar-2025
  • CPU Core related projections12-Mar-2025
  • Exadata Basics10-Dec-2024

Archives

  • 2025
  • 2024
  • 2023
  • 2010
  • 2009
  • 2008
  • 2007
  • 2006
  • 2005
  • DBMS_JOB all example Oracle
  • ORACLE_SID in sqlplus Oracle
  • Insert cause enqueue locks Oracle
  • Restoring a user’s original password 1051962.101 Oracle
  • sqlnet.ora paramters Oracle
  • compile_inv.sql Oracle
  • oracle 10g on linux Linux/Unix
  • ORA-4031 issue and solution on 09-MAY-2008 Oracle

Copyright © 2025 pvmehta.com.

Powered by PressBook News WordPress theme