Monday, May 2, 2022

Change Hitachi disk attribute using shell script on multiple disk on AIX Lpar

 Script:

Step 1 : create list of server on where u wanted to change disk parameter, create this file

on NIM server from where pass wordless ssh is working.

Example


#vi list

test1

test2

test3

test4

test5


:wq


step 2:


Create script to login on each AIX LPAR using following script:

===========================

for i in `cat list`

do

ssh $i

done

===========================


Above script will connect to each server once you sure that you are host where Hitachi disk 

parameter need to change, execute following script.

=======================================================


for i in `lsdev -c disk |grep -i Hitachi |awk '{print $1}'`

do

echo $i

chdev -Pl $i -a hcheck_interval=90 -a timeout_policy=fail_path

done

==============================================================


Once above script executed check parameter changed or not by following script


for i in `lsdev -c disk |grep -i Hitachi |awk '{print $1}'`

do

echo $i

lsattr -El $i -a hcheck_interval,timeout_policy -F attribute=value |xargs

done


Once done type "exit" on AIX LPAR ,then it will prompt for next AIX LPAR.

This way AIX admin can interactively change disk parameter on AIX LPAR

Thanks :)










Sunday, May 1, 2022

Troubleshoot SAS disk drive name using rmdev and cfgmgr on AIX VIO Server

 Today I am going to share my experience for how to change hot  swappable SAS disk drive name change.

Details of scenario:

On one of the VIO server ,had disk drive failure and in AIX errpt its showing as permanent hardware error. so as per IBM suggestion this was faulty disk drive need to be replaced. from VIO end we performed DIAG procedure for replacement of faulty disk drive.

But when new disk was detected it came up with new disk name and that unexpected, because SAS disk have name as "hdisk0" before replacement. so when IBM CE replaced disk it must come up with hdisk0.

#diag      //Diag procedure for SAS disk replacement

-->Select Hot Plug Task.

-->Certify media task

-->Select RAID Hot Plug Devices.

--->Select SAS disk drive location and press enter to "set faulty SAS disk LED in identify mode"

and ASK IBM CE to confirm


--->once IBM CE confirmed press enter and came to previous screen


---->Choose remove and replace and select faulty SAS disk and make disk ready for replacement


---->Once SAS disk is ready for Replacement, ask IBM CE to replace and confirm.

----> Once disk is replaced detect new disk by selecting following menu


"Configure newly detected Device"


How to check SAS disk after replacement:

======================================


#lspv |grep -w "hdisk0"

#lsdev -Cc disk |grep -w "hdisk0"

#bootinfo -s hdisk0

#lscfg -vpl hdisk0


Make sure that new serial number is on newly replaced hdisk0


Troubleshooting we did to solve this issue:

SAS disk name which was faulty: hdisk0  

New disk name after Hot swap replacement using diag: hdisk400

Soution: when we checked where exactly hdisk0 disappeared, we found that hdisk0 is in defined state.

Ran following command:

#rmdev -dl hdisk0

#rmdev -dl hdisk400   // before deleting we make sure that location is correct and its SAS disk

#cfgmgr 


After running above procedure we able to see "hdisk0" in available state on VIO server.


Thanks !!!! :)





Thursday, April 7, 2022

Kill multiple process using for loop

 Steps to kill multiple number of UNIX process using for loop

First important thing is make sure that killing those process will not impact any application or database.

step 1: create file with name - processlist

#cd /tmp

#vi processlist

12345

45677

98017

10078

10076

10056


save file by key sequence ESC and :wq


after file is saved, check that correct process id are entered.


#cat processlist

12345

45677

98017

10078

10076

10056


step 2:


while executing script make sure that you are in same path where "processlist" file is there


method 1:


for i in `cat processlist`

do

echo $i

kill -9 $i

sleep 2 

done


method 2:

using awk filter if u want to kill process related to "rpm" which are hung state then you can use following script


for i in `ps -eaf |grep -i "rpm"|awk '{print $2}'`

do

echo $i

kill -9 $i

sleep 2 

done


Monday, April 4, 2022

find 100% full filesystem using script on AIX LPAR

find 100% full filesystem using script on AIX LPAR

for i in `df -gi |grep -i '100%'|awk '{print $7}'`
do
echo "$i"
df -g $I
Sleep 2
done

Sunday, November 28, 2021

How to check and change hdisk attributes on AIX LPAR using script.

Today I am sharing script to change disk attributes using script.

precheck
Create directory with name aix_automation
#mkdir aix_automation
#cd aix_automation
Inside this directory create file with name list_hdisk

#touch list_hdisk
#vi list_hdisk
hdisk10
hdisk11
hdisk12
hdisk13
hdisk14
Add hdisk name in this file and save it .

#for i in 'cat list_hdisk'
do
echo $i
chdev -l $i -a algorithm=round_robin -a reserve_policy=no_reserve
sleep 2
lsattr -El $i |egrep -i 'algorithm | reserve_policy'
done

Using this simple script AIX admin can change and display multiple attributes and display.

Thanks !!!

Saturday, October 30, 2021

How to check and change VIO shared ethernet adapter status,ha_mode using script

Use following scripts for shared ethernet adapter failover, status and priority check

Let's start

1.
Check ha_mode on multiple shared ethernet adapter in VIO .

for i in `lsdev -Cc adapter | grep -i shared |awk '{print $1}'`
do
echo "-------shared SEA $i  ha mode------ "
lsattr -El $i |grep -i ha_mode
sleep 2
done
≠==≠=========
Output will be:
All shared ethernet adapter in VIO and their ha_mode


2.Script to display shared ethernet adapter "state, priority and active status.

for i in `lsdev -Cc adapter | grep -i shared |awk '{print $1}'`
do
echo "-------shared SEA $i  state priority and active status ------ "
entstat -d $i | grep -E  "^ *state|priority.*Active"
echo "---------------------"
sleep 2
done

3.Script to change shared ethernet adapter "ha_mode" . This script useful for failover and failback.

If Unix admin execute following script on vio server on which shared ethernet adapter is primary it will become backup.

for i in `lsdev -Cc adapter | grep -i shared |awk '{print $1}'`
do
echo "-------shared SEA $i  failover to partner VIO------ "
chdev -l $i -a ha_mode=standby
echo "---------------------"
sleep 2
done

4.If Unix admin execute following script on primary VIO where shared ethernet adapter already fail overed to its partner VIO because of some incident and admin wanted to failback from parter VIO or secondary VIO to primary VIO .


for i in `lsdev -Cc adapter | grep -i shared |awk '{print $1}'`
do
echo "-------shared SEA $i  failback to primary VIO------ "
chdev -l $i -a ha_mode=auto
echo "---------------------"
sleep 2
done


Thanks!!!!


How to gzip thousands of files using for loop

UNIX admin may get task like housekeep Unix filesystem.

 In such situations he may housekeep existing files in the file system or increase file system. Few day back I got such ticket but there was no scope for increasing file system size, so decided to find which files occupying space on that file system.

Finally found more than  2000 files, now question is how to gzip those??

Solution:

Step 1 created directory named like following,
#mkdir /tmp/housekeep

Then created file "listfiles" using touch command and redirected all files inside that file. Cross check done whether it contain correct files only , which we are going to gzip.
Step 2
#touch listfiles
#vi listfiles // add all files which need to be gzip
Step 3

Use following for loop
for i in `cat listfiles`
do
gzip $i
done

UNIX admin can check whether gzip happening or not by executing a following command  in target directory

#ls -lrt *.gz |wc -l

Or by simply take another session of server and execute while loop with above command

While true
do
ls -lrt *.gz |wc -l
sleep 1
done

**Before doing gzip make sure that it will not impact any production application or database.

Usefull command to find files modified in last hours
Print files which are modified in last 24 hrs
#find /var -mtime -1 -print

Thanks !!