Operating System - HP-UX
1840699 Members
3353 Online
110167 Solutions
New Discussion

Re: I need a simple shell program!

 
SHENFENG_1
Occasional Advisor

I need a simple shell program!

I want to check my machine information,when we use "lvdisplay" to list the detail.I just want to get the special notes,if the 'VG Status' is 'stale' or 'IO Timeout (Seconds)' is not 'default',I can get the 'dev/vg00/lvolx' warning information after the shell runs.thanks!
6 REPLIES 6
Bharat Katkar
Honored Contributor

Re: I need a simple shell program!

Hi,
See if this works for you:

#!/usr/bin/ksh
var1=`lvdisplay /dev/vg00/lvol4 | grep Status | awk '{ print $3 }'`
if [ $var1 -ne "stale" ]
then
echo " LV is fine "
else
echo " LV in Error "
fi

Modify it as per your requiremnt.
Regards,

ps.Remember in var1 assignment i have used back quotes at the begining and end.
You need to know a lot to actually know how little you know
Franky_1
Respected Contributor

Re: I need a simple shell program!

Hi,

you can try

lvdisplay /dev/vgxx/lvolx | egrep "(LV Status|IO Timeout)"
(where x should be replaced by the number)

Regards

Franky
Don't worry be happy
Muthukumar_5
Honored Contributor

Re: I need a simple shell program!

IF you want get the Volume group status then, directly use vgdisplay.

vgdisplay | grep -E 'Name |Status'
VG Name /dev/vg00
VG Status available
VG Name /dev/vgscu
VG Status available

It will give you the full status of all volume groups to keep track


Easy to suggest when don't know about the problem!
john korterman
Honored Contributor

Re: I need a simple shell program!

Hi,

try the attached script; you might need to adapt it.

regards,
John K.
it would be nice if you always got a second chance
Geoff Wild
Honored Contributor

Re: I need a simple shell program!

And here's yet another script:

#!/bin/sh
# Identifies and displays stale extends on all system volume groups.
# Useful to determine defect harddisks in mirrored enviroments


vgdisplay -v | awk '/LV Name/ { print $3 }' | xargs lvdisplay -v | grep -i -e "lv name" -e "lv status" -e stale -e '?'


Rgds...Geoff
Proverbs 3:5,6 Trust in the Lord with all your heart and lean not on your own understanding; in all your ways acknowledge him, and he will make all your paths straight.
rmueller58
Valued Contributor

Re: I need a simple shell program!

here is one that we used to build multiple vgs for several different school districts we manage. I'm a lazy admin, I don't like typing when there is a bunch of redundancy..





# more volbuild

echo 'This script will build and create database space,
Please not you should know about how much disk space is required
and available.. Below is a listing of free space in existing
Volume Groups'


echo "Enter Enter District ID:"
read district
for vg in `grep "LV Name" vg.txt |awk '{print $3}' |grep dbs |grep -v vg00 |grep -v log |grep -v root |grep -v tmp |grep
$district`
do
vgrp=`lvdisplay $vg |grep "VG Name"|awk '{print $3}'`
echo -------- Logical Volume `lvdisplay $vg |grep "LV Name"` --------
lvdisplay $vg |grep "LV Name"
echo $vgrp
lvdisplay $vg |grep "LV Size"
vgdisplay $vgrp |grep Free
export dbspace=`lvdisplay $vg |grep "LV Name" |awk '{print substr($3, 11, 6)}'`
export vgrp=`lvdisplay $vg |grep "VG Name"|awk '{print $3}'`
export nvol=`lvdisplay $vg |grep "LV Name" |awk '{print substr($3, 17, 1)}'`


if [ -z "$nvol" ]
then export nvol=0
fi

export i=`expr $nvol + 1`

done

echo "Enter Size of Volume"
read size
export size
echo lvcreate -L $size -n $dbspace$i $vgrp
cd $vgrp
echo chown informix:informix r$dbspace$i
echo chmod 660 r$dbspace$i
export fname=r$dbspace$i

cd /dev/online
#
ls $fname


echo ln -s $vgrp/$fname $dbspace$i
echo onspaces -a $dbspace$i -p /dev/online/$fname -o 0 -s "$size"000