Showing posts with label Unix Scripts. Show all posts
Showing posts with label Unix Scripts. Show all posts

Friday, 9 November 2018

No space left on device" while fileystem has lots of free space - Inode header full - Unix

No space left on device" while fileystem has lots of free space . Sometime it happens due to inode header is full. Unix keep tack of file details in the inode header. incase if too many files under a file-system or  folder may cause the inode header to become full.


-- df shows it has 61% free space
df -h .
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/rootvg-u01
                      9.8G  5.6G  3.7G  61% /u01


-- df -I  shows it has 100% full.
df -i .
Filesystem           Inodes  IUsed IFree IUse% Mounted on
/dev/mapper/rootvg-u01
                     655360 655360     0  100% /u01






use the below command to find out the folder with huge files




find /u01 -xdev -printf '%h\n' | sort | uniq -c | sort -k 1 -n




we may need to either house keep or move it to different folder the unwanted files to make the inode header free





Monday, 4 June 2018

How to open ASM trace files using vi

When we open ASM trace files using vi command


we may get the following error


Error detected while processing command line:
E492: Not an editor command: ASM1_arb0_396061.trc
Press ENTER or type command to continue








to overcome this challenge, we can use -- option in vi command


vi -- +ASM_arb0_396061.trc





Wednesday, 6 December 2017

SSH script to access multiple servers


#!/bin/ksh
#set -x
LOGFILE=/tmp/scan.log
echo " Scan test` date ` " > $LOGFILE
echo " " >>$LOGFILE
echo " " >>$LOGFILE
echo "==================================================================================================================" >>$LOGFILE
for i in ` cat /tmp/server.lst` ; do
server=`echo $i | awk -F\~ ' { print $1} ' `
echo Scan Status for $server  | tee -a $LOGFILE
/usr/sbin/ping $server
var_ping=$?
if [[ $var_ping -eq 0 ]] ; then
    ssh -o batchmode=yes $server true
    var_date=$?
    if [[ $var_date -eq 0 ]] ; then
      echo $server id | tee -a $LOGFILE
      ssh $server id | tee -a $LOGFILE
      echo "==================================================================================================================" >>$LOGFILE
    else
      echo $server ========== not Accessable =========== >>$LOGFILE2
    fi
else
  echo $server ========== not pingable =========== >>$LOGFILE2
fi
done

Friday, 12 April 2013

Unix Ulitity to grep a search string with few lines before and after the match

OEL Linux has an option in  grep command to search a string with some lines before and after the  match.
This utility helps us to search an ERROR  from the alert.log/trace with timestamp which is recorded one line before the actual error.
Unfortunately this option is not available in some of the platform like the Solaris and AIX ( of course  there are addition packages to have enhanced grep option)
The following small wrapper script to simulate the same grep option available in Linux







Script:
# usage <grep_add.sh> <no_rows_b4> <no_rows_a4> <search_string> <file_name>
b4=$1
a4=$2
search_string=$3
file_name=$4
grep -n $search_string $file_name | cut -d':' -f1 |  xargs  -n1 -I % awk "NR<=%+$a4 && NR>=%-$b4" $file_name




==========================================================
Usage:
grep_add.sh 1 0 force_match coe_xfr_sql_profile_56c1s0454r13x_1115266317.sql
replace     => TRUE,
force_match => FALSE /* TRUE:FORCE (match even when different literals in SQL). FALSE:EXACT (similar to CURSOR_SHARING) */ );
grep_add.sh  2 2 force_match coe_xfr_sql_profile_56c1s0454r13x_1115266317.sql
validate    => TRUE,
replace     => TRUE,
force_match => FALSE /* TRUE:FORCE (match even when different literals in SQL). FALSE:EXACT (similar to CURSOR_SHARING) */ );
DBMS_LOB.FREETEMPORARY(sql_txt);
END;
=======================================================











Linux Option:
In linux ,this option comes with the exisitng grep command , we can use -B and -A option to grep the additional lines
grep -A 3 FIXED awrinfo.txt
FIXED      39,506.7   44.2        3,272      306.7     2,147.2    47% : 53%
EVENTS     32,080.4   35.9        2,657      249.1     1,743.6    39% : 61%
ASH        11,324.3   12.7          938       87.9       615.5    89% : 11%
SPACE       3,275.4    3.7          271       25.4       178.0    68% : 32%
$ grep -B 2 FIXED awrinfo.txt
COMPONENT        MB  % AWR  KB_PER_SNAP MB_PER_DAY MB_PER_WEEK TABLE% : INDEX%
--------- --------- ------ ------------ ---------- ----------- ----------------
FIXED      39,506.7   44.2        3,272      306.7     2,147.2    47% : 53%

ZFS

Public Cloud tools comparison