Sunday 16 May 2021

PT - OS TOP Monitoring commands

 

PT - OS TOP commands Monitoring 

Top Command Header 

Top  | users | load average | Tasks | cpu  | Memory | swapping 


Field/Section Meaning
load average This line displays the load averages over the last 1, 5 and 15 minutes. The
higher the load average, the more work the machine is doing.
A high rise in the load average could indicate a serious performance problem.
Tasks Number of processes that are running, sleeping, stopped, or zombie. In a
healthy system, this number does not change a lot by time.
Cpu(s) CPU% usage by user (%us), system (%sy), nice (%ni), idle (%id), I/O wait
(%wa), Hard Interrupt (%hi), soft interrupt (%si), and iosteal (%st) which is
used in VM environments.
Note: in top output, %wa is the only I/O load indicator.
Mem Total physical memory, used memory, and free memory.
Swap Information about swapping.
PID Process Id. Used to know the relationship between the processes and for
killing processes
USER The effective user name of the task’s owner.
PR Process priority
NI Process nice value
VIRT Total virtual memory used by the process
RES Non-swapped physical memory used
SHR Shared memory used by the process
S Process status
%CPU Processes percent of CPU consumption since last screen refresh
%MEM Percentage of memory consumption by the process
TIME+ Total CPU time, showing hundredths of seconds
COMMAND Command used to start the process



Key Impact
[Shift]+[O] Sort by a selected field (try sorting by memory, swapped size, command
name)
[Shift]+[P] Sort processes as per CPU utilization
z highlight running processes. Press again to disable it.
c Display the absolute path of running processes
d Change screen refresh interval (by default it is 3)
k Kill a process by its PID
q Quit



  • Top command based on particular user 
top -u oracle


  • Display first 20 line output.

top -bc | head -20 display first 20 lines 

  • Display order by memory usage 
top -bc -a | head -n 20 



  • Enter Z  highlighting current running process.




PT - OS performance Monitoring using VMSTAT

 

PT - OS performance Monitoring using  VMSTAT 

vmstat

process ---- Memory ---- swap ---- i/o ----- system ----  cpu 

Process : r | b

Memory : spwd | spwd | free | buffer | cache

Swap : si | so

I/O:  bi | bo

System : cs | us | sy 

CPU : id |wt | st 

Field Meaning


r number of processes waiting for run time  
b number of processes in uninterruptible
sleep
spwd Virtual memory swapped out to disk

spwd Virtual memory swapped out to disk
free Amount of free memory

si Amount of memory swapped in from disk
so Amount of memory swapped to disk
us User CPU time
bi Blocks received from a block        device
(blocks/s)                        
bo Blocks sent to a block device
sy System CPU time
id CPU idle time


  • vmstat command output example 




  • vmstat 2 ( output every 2 second)





  • Example to apply load on OS by executing i/o 30 times using apply_io_stress.sh file.

cat > apply_io_stress.sh <<EOL

#!/bin/bash

counter=1

while [ \$counter -le 30 ]

do

dd if=/dev/zero of=/tmp/test1.img bs=500M count=1 oflag=dsync

((counter++))

done

rm -f /tmp/test1.img

EOL

  • Provide execute permission below.

chmod +x apply_io_stress.sh

srv1:~ # sh apply_io_stress.sh



^Z

[1]+  Stopped                 sh apply_io_stress.sh


srv1:~ #

  • We can see after executing sh file number of r b  process increases also I/O bi bo  reading blocks and write block increase.



^Z

[1]+  Stopped                 sh apply_io_stress.sh


  • Once stopping apply_io_stress.sh file processes and I/O value came back to normal.



vmstat -d 2

  • vmstat -d 2 ( Disk output at every 2 seconds) Examples below.











Tuesday 11 May 2021

OCI : Create DIRECTORIES for expdp impdp on autonomous database

 OCI : Create DIRECTORIES for expdp impdp on autonomous database  and uploading  files.

  • We can not drop directory from sql prompt if bucket having data stored on particular directory .

dbms_cloud package : 

  • dbms_cloud.get_object : Copy object from storage bucket to autonomous DB
  • dbms_cloud.put_object : Copy object from autonomous Db to object bucket storage


  • Check the current status of database directories

SELECT * FROM DBA_DIRECTORIES;



  • Create new directory  and provide  privilege's to test user

GRANT CREATE ANY DIRECTORY TO TEST;

GRANT DROP ANY DIRECTORY TO TEST;




  • Create a directory that points to the root directory of the user. 

CREATE OR REPLACE DIRECTORY ROOT_DIR AS '';




  • Check the location of root directories
SELECT * FROM DBA_DIRECTORIES WHERE DIRECTORY_NAME='ROOT_DIR';





CREATE OR REPLACE DIRECTORY ROOT_DIR AS '';




  • Create a directory object to points to a sub-directory named as stage
CREATE DIRECTORY staging AS 'stage';


  • Check the location of staging directories

SELECT * FROM dba_directories where directory_name='STAGING';




  • The LIST_FILES function returns no row because there is no file under any directory. 

SELECT * FROM DBMS_CLOUD.LIST_FILES('ROOT_DIR');



  • Copying Files from bucket to object storage.
  • Upload object into bucket  storage and check the details. 





  • Copy object profiles 







  • Generate token 


  • Copy the authentication  token clipboard


  • Authentication token obtained from the previous step

SET DEFINE OFF

BEGIN

DBMS_CLOUD.CREATE_CREDENTIAL (

 CREDENTIAL_NAME => 'ADMIN_CRED_NAME',

 USERNAME => 'varunyadav@gmail.com',

 PASSWORD => '.ypEHus4L01bAYeZd+H0

);

END;





  • Verify the staging directory 
SELECT CREDENTIAL_NAME FROM USER_CREDENTIALS;



  • Uploaded file from the object storage to the directory objects.

BEGIN

DBMS_CLOUD.GET_OBJECT(

CREDENTIAL_NAME => 'ADMIN_CRED_NAME',

OBJECT_URI => 'https://objectstorage.ap.xxxxxx.oraclecloud.com/n/bmdsoh48o0kf/b/bucket-20210415-1806/o/wallet%20zip%20fileWallet_ORCLADB.zip',

DIRECTORY_NAME => 'STAGING');

END;


  • Check the staging file directory status

 SELECT OBJECT_NAME FROM DBMS_CLOUD.LIST_FILES('STAGING');

  • Check files in the staging directory status from root directory

SELECT OBJECT_NAME FROM DBMS_CLOUD.LIST_FILES('ROOT_DIR');