Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-31-2008 12:09 PM
10-31-2008 12:09 PM
for loop
Can anybody tell me that how can i use "for" loop in finding out the stale physical extends in all mirrored logical volumes.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-31-2008 12:18 PM
10-31-2008 12:18 PM
Re: for loop
Something like:
# cat mirrored_lvs
/dev/vg00/lvol1
/dev/vg00/lvol2
/dev/vg00/lvol3
/dev/vg01/oralv1
/dev/vg02/oralv2
Now your for loop:
for LV in $(< mirrored_lvs)
do
echo ${LV}
lvdisplay -v ${LV} | grep stale
done
That is the simplest form of the script. More elaborate things could be done with dynamically building the list of LVs and checking for a count of stale extents, etc.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-31-2008 12:26 PM
10-31-2008 12:26 PM
Re: for loop
vgdisplay -v vg00 | grep -i 'lv name' | awk '{print $NF}' | \
while read lv
do
stale=$(lvdisplay -v ${lv} | sed -n -e '/Logical extents/,$p' | \
grep stale | wc -l)
printf "%-20s %3d\n" ${lv} ${stale}
done
/dev/vg00/lvol1 0
/dev/vg00/lvol2 0
/dev/vg00/lvol3 0
/dev/vg00/lvol4 0
/dev/vg00/lvol5 0
/dev/vg00/lvol6 0
/dev/vg00/lvol7 0
/dev/vg00/lvol8 0
/dev/vg00/crash 0
/dev/vg00/usrsap 0
/dev/vg00/dazel 0
/dev/vg00/oracle 0
/dev/vg00/swap 0
/dev/vg00/swap1 0
If you want to do all vgs on the system, just remove the vg00 fro the top line of the inline script.
Doug O'Leary
------
Senior UNIX Admin
O'Leary Computers Inc
linkedin: http://www.linkedin.com/dkoleary
Resume: http://www.olearycomputers.com/resume.html
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-31-2008 12:29 PM
10-31-2008 12:29 PM
Re: for loop
How about:
# vgdisplay -v|awk '/LV Name/ {print $3}'|while read LINE;do echo ${LINE};lvdisplay -v ${LINE}|grep stale;done
The name of each logical volume will be listed unconditionally with any stale extents lists beneath.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-31-2008 12:44 PM
10-31-2008 12:44 PM
Re: for loop
Feel free to modify as you see fit. While not necessarily a FOR loop, it does close to the same thing.
Doug's script above was the base/inspiration for this one.
#!/usr/bin/sh
typeset -i MIRROR
typeset -i NUMSTALE
vgdisplay -v 2>/dev/null | awk '/LV Name/ {print $3}' | \
while read LV
do
MIRROR=$(lvdisplay ${LV} | awk '/Mirror copies/ {print $3}')
if (( ${MIRROR} > 0 )) ; then
NUMSTALE=$(lvdisplay -v ${LV} |grep stale | wc -l)
echo "${LV} has ${NUMSTALE} stale extents"
if (( ${NUMSTALE} > 0 )) ; then
lvdisplay -v ${LV} | grep stale
fi
else
echo "${LV} is not mirrored"
fi
done