{"id":690,"date":"2021-12-16T11:42:17","date_gmt":"2021-12-16T16:42:17","guid":{"rendered":"http:\/\/www.hpux.ws\/?p=690"},"modified":"2021-12-16T11:54:07","modified_gmt":"2021-12-16T16:54:07","slug":"linux-vgs-port-for-hpux-updated-to-work-with-vg-versions-2-2","status":"publish","type":"post","link":"https:\/\/www.hpux.ws\/?p=690","title":{"rendered":"Linux vgs port for HPUX (updated to work with vg version 2.2)"},"content":{"rendered":"\n<p>A while back, I came across a port of the very nice linux vgs command for HP-UX.  A h\/t to Juan Manuel Rey (juanmanuel.reyportal@gmail.com) for that original version.<\/p>\n\n\n\n<p>But, upon using it recently, I noted it was not working now that we have some volume groups with vg version 2.2.  Here is a modified version of the script that works for version 2.2 volume groups!<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#!\/sbin\/sh\n#\n# vgs.sh - script to emulate the Linux LVM command vgs in HP-UX 11iv3\n#\n# (C) 2010 - Juan Manuel Rey (juanmanuel.reyportal@gmail.com)\n#\n# This program is free software; you can redistribute it and\/or\n# modify it under the terms of the GNU General Public License\n# as published by the Free Software Foundation; either version 2\n# of the License, or (at your option) any later version.\n#\n# This program is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n# GNU General Public License for more details.\n#\n# You should have received a copy of the GNU General Public License\n# along with this program; if not, write to the Free Software\n# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.\n#\n\nversion=\"v0.2 2021\/12\/15\"\n\nusage() {\n  echo\n  echo \"VGS for HP-UX ${version}\"\n  echo\n  echo \"Usage: vgs [-v vg_name]\"\n  echo\n  exit 1\n}\n\nif [ ! \"$(uname -r)\" = \"B.11.31\" ]; then\n   echo \"VGS for HP-UX only works on HP-UX 11iv3\"\n   exit 1\nfi\n\nif [ \"$1\" ]; then\n\"vgs\" 87 lines, 3053 characters\n\nif [ \"$1\" ]; then\n   case \"$1\" in\n   -v) shift; [  \"$1\" = \"\" ] &amp;&amp; usage || vg_name=${1};;\n   *)  usage;;\n   esac\nfi\n\nvg_display=\"vgdisplay -F\"\n[ ! \"${vg_name}\" = \"\" ] &amp;&amp; vg_display=\"vgdisplay -F ${vg_name}\"\n\nprintf \"%-10s %-5s %-5s %-20s %-8s %-6s %-5s\\n\" VG PVs LVs Status Version VGSize Free\n\n# First, we must determine which VG Version we have\n\neval ${vg_display} | \\\n  while IFS=\":\" read vgdisplay; do\n     version=$(echo ${vgdisplay} | awk -F: '{for (i=1;i&lt;=NF;i++) print $i}' | grep vg_version | cut -d= -f2)\n     case \"$version\" in\n       2.2) total_pe_index=15\n            pe_size_index=13\n            free_pe_index=18\n            cur_pv_index=9\n            ;;\n         *) total_pe_index=13\n            pe_size_index=12\n            free_pe_index=15\n            cur_pv_index=8\n            ;;\n     esac\n\n     echo ${vgdisplay} | cut -d \":\" -f 2 | cut -d \"=\" -f 2 | read status\n     if [ \"${status}\" = \"deactivated\" ]; then\n        status=deactivated\n        vg_size=\"\"\n        vg_free=\"\"\n     else\n        echo ${vgdisplay} | cut -d \":\" -f 3  | cut -d \"=\" -f 2 | read status\n     else\n        echo ${vgdisplay} | cut -d \":\" -f 3  | cut -d \"=\" -f 2 | read status\n        echo ${vgdisplay} | cut -d \":\" -f ${total_pe_index} | cut -d \"=\" -f 2 | read total_pe\n        echo ${vgdisplay} | cut -d \":\" -f ${pe_size_index} | cut -d \"=\" -f 2 | read pe_size\n        echo ${vgdisplay} | cut -d \":\" -f ${free_pe_index} | cut -d \"=\" -f 2 | read free_pe\n        vg_size=\"`\/usr\/bin\/expr $total_pe \\* $pe_size \/ 1024`G\"\n        vg_free=\"`\/usr\/bin\/expr $free_pe \\* $pe_size \/ 1024`G\"\n     fi\n\n     echo ${vgdisplay} | cut -d \":\" -f 1 | cut -d \"=\" -f 2 | cut -d \"\/\" -f 3 | read vg_name\n     echo ${vgdisplay} | cut -d \":\" -f ${cur_pv_index} | cut -d \"=\" -f 2 | read pvs\n     echo ${vgdisplay} | cut -d \":\" -f 5 | cut -d \"=\" -f 2 | read lvs\n     #echo ${vgdisplay} | cut -d \":\" -f 19 | cut -d \"=\" -f 2 | read version\n     printf \"%-10s %-5s %-5s %-20s %-8s %-6s %-5s\\n\" \"${vg_name}\" \"${pvs}\" \"${lvs}\" \"${status}\" \"${version}\" \"${vg_size}\" \"${vg_free}\"\ndone<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>A while back, I came across a port of the very nice linux vgs command for HP-UX. A h\/t to Juan Manuel Rey (juanmanuel.reyportal@gmail.com) for that original version. But, upon using it recently, I noted it was not working now that we have some volume groups with vg version 2.2. Here is a modified version [&hellip;]<\/p>\n","protected":false},"author":1002497,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_bbp_topic_count":0,"_bbp_reply_count":0,"_bbp_total_topic_count":0,"_bbp_total_reply_count":0,"_bbp_voice_count":0,"_bbp_anonymous_reply_count":0,"_bbp_topic_count_hidden":0,"_bbp_reply_count_hidden":0,"_bbp_forum_subforum_count":0,"_kadence_starter_templates_imported_post":false,"footnotes":""},"categories":[],"tags":[],"class_list":["post-690","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/www.hpux.ws\/index.php?rest_route=\/wp\/v2\/posts\/690"}],"collection":[{"href":"https:\/\/www.hpux.ws\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hpux.ws\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hpux.ws\/index.php?rest_route=\/wp\/v2\/users\/1002497"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hpux.ws\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=690"}],"version-history":[{"count":0,"href":"https:\/\/www.hpux.ws\/index.php?rest_route=\/wp\/v2\/posts\/690\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.hpux.ws\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=690"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hpux.ws\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=690"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hpux.ws\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=690"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}