We want storage to check performance on three possibly problematic LUNS.
Need to get the 4 character LUN ID’s on three disks:
disk82 disk83 and disk123
/usr/bin/inq -nodots -sym_wwn | egrep “disk82|disk83|disk123″| awk ‘{print $3}’ |awk ‘{ print substr( $0, length($0) – 3, length($0) ) }’
Output:
5422
5423
5826
HP-UX 11.31 September 2011 OE.
A good day is an awkful day.
Ever try and do system reporting based on bdf?
Annoying as all heck that sometimes the output is two line and sometimes one? I was forced to solve that problem today.
if [ “$OS” = “HP-UX” ]
then
dcmd=bdf
fi
arraypointer=0
exec $dcmd | egrep -v “%used|/dev/deviceFileSystem” | awk ‘{lvn=$1;v=$2;if (v==””) {getline;cap=$1;ucap=$2;acap=$3;puse=$4;mp=$5;printf “%s %s %s %s %s %s\n”, lvn,cap,ucap,acap,puse,mp} else {printf “%s %s %s %s %s %s\n”, $1,$2,$3,$4,$5,$6} }’ | while read -r p1 p2 p3 p4 p5 p6
do
#### calculations
done
Typical bdf output:
/dev/vg00/lvol9 4096000 3140019 896285 78% /var/adm/crash
/dev/vg_stgb1/lvol1
1572765696 1382813225 178080447 89% /steven05stgb
More when the script is done
Tags: awk, awk with if else logic, bdf, hpux, systems administration
Lets say I have a list of servers a mile long to visit. Got a help desk request with the servers listed separated by commas.
server1,server2,server3
Lets say It is actually about 30 or 40 servers and I’m too lazy to edit the list
echo “server1,server2,server3” > olist
awk -F, -v nr=1 ‘{ for (x=nr; x<=NF; x++) {printf $x ” \n”; }; print ” ” }’ olist
Output:
server1
server2
server3
Plug and play time here, you can take care of any delimited format like this.
Spaces input by wordpress (thanks)