<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: for loop in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/for-loop/m-p/4298326#M337708</link>
    <description>&lt;!--!*#--&gt;Hey;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;vgdisplay -v vg00 | grep -i 'lv name' | awk '{print $NF}' | \&lt;BR /&gt;while read lv&lt;BR /&gt;do&lt;BR /&gt;stale=$(lvdisplay -v ${lv} | sed -n -e '/Logical extents/,$p' | \&lt;BR /&gt;        grep stale | wc -l)&lt;BR /&gt;printf "%-20s %3d\n" ${lv} ${stale}&lt;BR /&gt;done&lt;BR /&gt;/dev/vg00/lvol1        0&lt;BR /&gt;/dev/vg00/lvol2        0&lt;BR /&gt;/dev/vg00/lvol3        0&lt;BR /&gt;/dev/vg00/lvol4        0&lt;BR /&gt;/dev/vg00/lvol5        0&lt;BR /&gt;/dev/vg00/lvol6        0&lt;BR /&gt;/dev/vg00/lvol7        0&lt;BR /&gt;/dev/vg00/lvol8        0&lt;BR /&gt;/dev/vg00/crash        0&lt;BR /&gt;/dev/vg00/usrsap       0&lt;BR /&gt;/dev/vg00/dazel        0&lt;BR /&gt;/dev/vg00/oracle       0&lt;BR /&gt;/dev/vg00/swap         0&lt;BR /&gt;/dev/vg00/swap1        0&lt;BR /&gt;&lt;BR /&gt;If you want to do all vgs on the system, just remove the vg00 fro the top line of the inline script.&lt;BR /&gt;&lt;BR /&gt;Doug O'Leary&lt;BR /&gt;</description>
    <pubDate>Fri, 31 Oct 2008 19:26:20 GMT</pubDate>
    <dc:creator>Doug O'Leary</dc:creator>
    <dc:date>2008-10-31T19:26:20Z</dc:date>
    <item>
      <title>for loop</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/for-loop/m-p/4298324#M337706</link>
      <description>Hi all,&lt;BR /&gt;&lt;BR /&gt;Can anybody tell me that how can i use "for" loop in finding out the stale physical extends in all mirrored logical volumes.</description>
      <pubDate>Fri, 31 Oct 2008 19:09:50 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/for-loop/m-p/4298324#M337706</guid>
      <dc:creator>j.bobby</dc:creator>
      <dc:date>2008-10-31T19:09:50Z</dc:date>
    </item>
    <item>
      <title>Re: for loop</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/for-loop/m-p/4298325#M337707</link>
      <description>First you need a list of all of your mirrored LVs.  This is a simple text file you could create with vi.&lt;BR /&gt;&lt;BR /&gt;Something like:&lt;BR /&gt;&lt;BR /&gt;# cat mirrored_lvs&lt;BR /&gt;/dev/vg00/lvol1&lt;BR /&gt;/dev/vg00/lvol2&lt;BR /&gt;/dev/vg00/lvol3&lt;BR /&gt;/dev/vg01/oralv1&lt;BR /&gt;/dev/vg02/oralv2&lt;BR /&gt;&lt;BR /&gt;Now your for loop:&lt;BR /&gt;&lt;BR /&gt;for LV in $(&amp;lt; mirrored_lvs)&lt;BR /&gt;do&lt;BR /&gt;echo ${LV}&lt;BR /&gt;lvdisplay -v ${LV} | grep stale&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;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.</description>
      <pubDate>Fri, 31 Oct 2008 19:18:33 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/for-loop/m-p/4298325#M337707</guid>
      <dc:creator>Patrick Wallek</dc:creator>
      <dc:date>2008-10-31T19:18:33Z</dc:date>
    </item>
    <item>
      <title>Re: for loop</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/for-loop/m-p/4298326#M337708</link>
      <description>&lt;!--!*#--&gt;Hey;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;vgdisplay -v vg00 | grep -i 'lv name' | awk '{print $NF}' | \&lt;BR /&gt;while read lv&lt;BR /&gt;do&lt;BR /&gt;stale=$(lvdisplay -v ${lv} | sed -n -e '/Logical extents/,$p' | \&lt;BR /&gt;        grep stale | wc -l)&lt;BR /&gt;printf "%-20s %3d\n" ${lv} ${stale}&lt;BR /&gt;done&lt;BR /&gt;/dev/vg00/lvol1        0&lt;BR /&gt;/dev/vg00/lvol2        0&lt;BR /&gt;/dev/vg00/lvol3        0&lt;BR /&gt;/dev/vg00/lvol4        0&lt;BR /&gt;/dev/vg00/lvol5        0&lt;BR /&gt;/dev/vg00/lvol6        0&lt;BR /&gt;/dev/vg00/lvol7        0&lt;BR /&gt;/dev/vg00/lvol8        0&lt;BR /&gt;/dev/vg00/crash        0&lt;BR /&gt;/dev/vg00/usrsap       0&lt;BR /&gt;/dev/vg00/dazel        0&lt;BR /&gt;/dev/vg00/oracle       0&lt;BR /&gt;/dev/vg00/swap         0&lt;BR /&gt;/dev/vg00/swap1        0&lt;BR /&gt;&lt;BR /&gt;If you want to do all vgs on the system, just remove the vg00 fro the top line of the inline script.&lt;BR /&gt;&lt;BR /&gt;Doug O'Leary&lt;BR /&gt;</description>
      <pubDate>Fri, 31 Oct 2008 19:26:20 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/for-loop/m-p/4298326#M337708</guid>
      <dc:creator>Doug O'Leary</dc:creator>
      <dc:date>2008-10-31T19:26:20Z</dc:date>
    </item>
    <item>
      <title>Re: for loop</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/for-loop/m-p/4298327#M337709</link>
      <description>Hi:&lt;BR /&gt;&lt;BR /&gt;How about:&lt;BR /&gt;&lt;BR /&gt;# vgdisplay -v|awk '/LV Name/ {print $3}'|while read LINE;do echo ${LINE};lvdisplay -v ${LINE}|grep stale;done&lt;BR /&gt;&lt;BR /&gt;The name of each logical volume will be listed unconditionally with any stale extents lists beneath.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Fri, 31 Oct 2008 19:29:26 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/for-loop/m-p/4298327#M337709</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2008-10-31T19:29:26Z</dc:date>
    </item>
    <item>
      <title>Re: for loop</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/for-loop/m-p/4298328#M337710</link>
      <description>&lt;!--!*#--&gt;Here's another version that builds the list of LV's dynamically.  It then checks to see if the "Mirror Copies" is greater than 0.  If it is not the script does nothing.  If it is it checks for the number of stale extents.  If number of stale extents is 0, it prints that.  If it is greater than 0, it prints that and the does an 'lvdisplay -v ${LV} | grep stale' to show you which extents are stale.&lt;BR /&gt;&lt;BR /&gt;Feel free to modify as you see fit.  While not necessarily a FOR loop, it does close to the same thing.  &lt;BR /&gt;&lt;BR /&gt;Doug's script above was the base/inspiration for this one.&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;&lt;BR /&gt;typeset -i MIRROR&lt;BR /&gt;typeset -i NUMSTALE&lt;BR /&gt;&lt;BR /&gt;vgdisplay -v 2&amp;gt;/dev/null | awk '/LV Name/ {print $3}' | \&lt;BR /&gt;while read LV&lt;BR /&gt;do&lt;BR /&gt;   MIRROR=$(lvdisplay ${LV} | awk '/Mirror copies/ {print $3}')&lt;BR /&gt;   if (( ${MIRROR} &amp;gt; 0 )) ; then&lt;BR /&gt;      NUMSTALE=$(lvdisplay -v ${LV} |grep stale | wc -l)&lt;BR /&gt;      echo "${LV} has ${NUMSTALE} stale extents"&lt;BR /&gt;      if (( ${NUMSTALE} &amp;gt; 0 )) ; then&lt;BR /&gt;         lvdisplay -v ${LV} | grep stale&lt;BR /&gt;      fi&lt;BR /&gt;   else&lt;BR /&gt;      echo "${LV} is not mirrored"&lt;BR /&gt;   fi&lt;BR /&gt;done</description>
      <pubDate>Fri, 31 Oct 2008 19:44:39 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/for-loop/m-p/4298328#M337710</guid>
      <dc:creator>Patrick Wallek</dc:creator>
      <dc:date>2008-10-31T19:44:39Z</dc:date>
    </item>
  </channel>
</rss>

