Shell Script to Ping Hostnames and Send SMS if Host is not Available

We use the below procedure to ping hosts and based on availability send SMS to our team. The SMS is send by calling a web service from the BASH Shell script using curl  The hosts are defined in a file called hosts.txt -- Shell Script -- #!/bin/bash current_time=$(date "+%Y%m%d%H%M%S%3N") #### Above Date Format is in … Continue reading Shell Script to Ping Hostnames and Send SMS if Host is not Available

Shell Script to Add Date to Filenames

Below Shell Script will append Date to all FileNames in Directory with extension .TXT. Also it will create a folder with the Date and move the files to it. #!/bin/bash FILE="$(date +%Y%m%d)" cd /bi_dataload mkdir -p /bi_dataload/BI_$FILE for f in *.TXT do mv -n "$f" /bi_dataload/BI_$FILE/"${f%%.*}"_"$FILE".TXT done

Linux Matrix Effects Shell Script

Sometimes to have a funky time on the BASH shell you can run the below shell script [code language="bash"] #!/bin/bash clear virtcent=$((`tput lines`/2)) horcent=$((`tput cols`/2-10)) tput setf 6 tput cup $virtcent $horcent && echo "entering the matrix" sleep 1 tput cup $virtcent $horcent && echo " " sleep 1 tput cup $virtcent $horcent && echo … Continue reading Linux Matrix Effects Shell Script

Shell Script to Monitor Oracle Tablespace and Send Email Alert Only If Threshold Exceeds

[code language="bash"] export MMSG=/tmp/$$.mail export ADDR="email address here" export ORACLE_HOME=/u02/app/oracle/product/11.2.0/dbhome_1 export ORACLE_SID=appdev1 file=/tmp/${$}_`date +%Y%m%d` sqlplus -s system/password << .eof > $file set pages 0 select df.tablespace_name tspace, round(sum(fs.bytes)/(df.bytes) * 100) "%_free", round(sum(fs.bytes)/(1024*1024)) free_ts_size, df.bytes/(1024*1024) tot_ts_size from dba_free_space fs, (select tablespace_name, sum(bytes) bytes from dba_data_files group by tablespace_name ) df where fs.tablespace_name = df.tablespace_name group by … Continue reading Shell Script to Monitor Oracle Tablespace and Send Email Alert Only If Threshold Exceeds

Simple Shell Script to Check Diskspace and Send Email on AIX

The below simple shell script will check all filesystems and create output file for only filesystems which are more than 80% full and send the log by email. The below has been checked on AIX7.1 , not too Sure if it works on Solaris. I suppose the -P flag does not work on Solaris. [code language="bash"] … Continue reading Simple Shell Script to Check Diskspace and Send Email on AIX

Shell Script to Monitor AIX Filesystem and Send Email

The Below Shell Script checks the Filesystem mount points and using AWK outputs all filesystem exceeding 90% space to a file called diskspacepoll. Once that is done the sed command removes any special character like '%' from the output file and cleans it to a file called output.log The next important logic is in the … Continue reading Shell Script to Monitor AIX Filesystem and Send Email

How many cores is a process using in Linux

Script to check no. of cores being utilized by a process in linux. Save the script below as a shell script and execute: [root@~]#  sh check_cpu_cores.sh  1111 #!/bin/bash pids=() while [ $# != 0 ]; do pids=("${pids[@]}" "$1") shift done if [ -z "${pids[0]}" ]; then echo "Usage: $0 <pid1> [pid2] ..." exit 1 fi for … Continue reading How many cores is a process using in Linux

RLWRAP SQL*PLUS to have BASH like Functionality in SQLPLUS

So you are an Oracle DBA and have got used to the luxury of BASH shell in nix systems. Where you can scroll up and down and commands from a time long forgotten magically appear. Wouldn't it be wonderful to have a similar thing for good ole sqlplus. Well here's how you do it, via an … Continue reading RLWRAP SQL*PLUS to have BASH like Functionality in SQLPLUS

Running SQL Script for Multiple Databases SQL*PLUS | Mutiple Servers SQL*PLUS in Shell Script | BASH Script Looping SQL*PLUS commands

For running a single SQL Command via sqlplus on multiple servers, we have to first do a few pre-requisites 1. Oracle client should be installed on the Unix/Linux Server 2. Create Local TNS entry in the tnsnames.ora file for the databases where you will run the commands 3. All databases should have one common user … Continue reading Running SQL Script for Multiple Databases SQL*PLUS | Mutiple Servers SQL*PLUS in Shell Script | BASH Script Looping SQL*PLUS commands

Setting up user profiles for Grid and Oracle user : Oracle RAC 11gR2 on Solaris 10

Below is the Solaris user profiles for "grid" and "oracle" user. If you have followed Oracles official documentation for installation ORacle Rac 11gR2. It is best practice to install Oracle clusterware under grid user and oracle database with Oracle user. It takes a little time to get used to this setup specially for RAC users … Continue reading Setting up user profiles for Grid and Oracle user : Oracle RAC 11gR2 on Solaris 10