script help please


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting script help please
# 1  
Old 03-19-2008
script help please

I wrote script for importing massive amount of volume groups on HP-UX. This is related to ServiceGuard and making sure the alternate nodes have the correct VG information after a change to the primary. Everything works great except for one problem, the paths do not match up between the nodes so that c19t5d0 on the primary looks like c36t5d0 on the alternate. I tried to solve this by using the vgimport -s option but this brought in all the PV links too. Because we use Powerpath we do not want the PV links.

This is the part I am stuck on. What I want is to be able to create a disk file for use with vgimport -f using the lvmtab after doing the vgimport -s. I will then export and reimport again using the correct devices. The script I've got already is big enough so I'd like this part to be as efficient as possible.

For example I want to find all of the disks belonging to vgabc but I do not want the PV links:

root:> strings /etc/lvmtab
/dev/vgaaa
/dev/dsk/c8t9d0
/dev/dsk/c8t9d2
/dev/dsk/c8t9d4
/dev/dsk/c9t9d0
/dev/dsk/c9t9d2
/dev/dsk/c9t9d4
/dev/vgabc
/dev/dsk/c8t9d1
/dev/dsk/c8t9d3
/dev/dsk/c9t9d1
/dev/dsk/c9t9d3

/dev/vgbbb
/dev/dsk/c8t7d0
...etc


Should output only as based on variable <vgabc>:
/dev/dsk/c8t9d1
/dev/dsk/c8t9d3

so that I can write this to the disks file. The first thing I'll have to do is figure out which devices only belong to <vgabc>. Next figure out which of those devices are redundant and only print each disk once without the alternate paths. Also, several VGs have more than one PV link so I cannot assume that I can just cut the number of devices in half.

Any help would be much appreciated.
# 2  
Old 03-19-2008
I don't have access to an HP box anymore, but I think you just remove lvmtab and run vgscan. vgscan should see any attached disks, create the volume group device files and rebuild lvmtab. It will find alternate links (I think). But if the atlernate links are not connected, it can't find them.
# 3  
Old 03-19-2008
Well, see, that's the problem. The alternate paths are connected so when I do a vgscan I get all the devices. Because of EMC's Powerpath we do not want the alternate paths in the lvmtab.
# 4  
Old 03-19-2008
Hammer & Screwdriver One approach....

Note: below that vgbbb refers to same disk twice

Quote:
> cat disklist
/dev/vgaaa
/dev/dsk/c8t9d0
/dev/dsk/c8t9d2
/dev/dsk/c8t9d4
/dev/dsk/c9t9d0
/dev/dsk/c9t9d2
/dev/dsk/c9t9d4
/dev/vgabc
/dev/dsk/c8t9d1
/dev/dsk/c8t9d3
/dev/dsk/c9t9d1
/dev/dsk/c9t9d3
/dev/vgbbb
/dev/dsk/c8t7d0
/dev/dsk/c8t7d0
Code:
> cat rev_dsk
#! /bin/bash

#remove any existing work files
rm tmp_*

#assumes file disklist exists; listing from lvm
while read zf
   do
   chkvar=$(echo "$zf" | cut -c6-8)
   echo $chkvar
   if [ "$chkvar" = "dsk" ]
      then
         echo "$zf" >> "$vgrp"
      else
         filevar=$(echo "$zf" | cut -c6-)
         vgrp="tmp_""$filevar"
   fi
done < disklist 

for yf in tmp_*
   do
   sort -u "$yf" > "$yf"".srt"
done

The group with a duplicate:
Quote:
> cat tmp_vgbbb
/dev/dsk/c8t7d0
/dev/dsk/c8t7d0
And the resulting file from a sort -u
Quote:
> cat tmp_vgbbb.srt
/dev/dsk/c8t7d0
# 5  
Old 03-19-2008
Thank you for the reply Joeyg but I think you might have missed something in my post.

In the lvmtab you will find a disk such as:
/dev/dsk/c8t13d0

If there is an alternate path to this same disk it may show as:
/dev/dsk/c9t13d0

This is the same disk but not the same device file. I am not looking for duplicate lines in this file but need to figure out which device files are for the same disk. Basically, for every VG there will be a number of unique device files. The number of devices is too large because there are multiple paths to the same disk. I need to work one VG at a time and this is not simply a text file I can edit. So I will need to identify via a variable which VG I want to work on, figure out which devices belong to it based on this output and then write only the unique disks, not devices, to a file.
# 6  
Old 03-19-2008
Question How to know they are the same?

How do you know that

/dev/dsk/c8t13d0
and
/dev/dsk/c9t13d0

are the same?

Are you impying:
(a) ignore value immadiately after the c
(b) only consider the t and d data

Any of these could be one digit or two digits, therefore not simply a cut at character positions. (If I understand where you are going with this.)
# 7  
Old 03-19-2008
Quote:
Originally Posted by joeyg
How do you know that

/dev/dsk/c8t13d0
and
/dev/dsk/c9t13d0
Because a change made to /dev/dsk/c8t13d0 is then visible on /dev/dsk/c9t13d0.
Login or Register to Ask a Question

Previous Thread | Next Thread

5 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to block first bash script until second bash script script launches web server/site?

I'm new to utilities like socat and netcat and I'm not clear if they will do what I need. I have a "compileDeployStartWebServer.sh" script and a "StartBrowser.sh" script that are started by emacs/elisp at the same time in two different processes. I'm using Cygwin bash on Windows 10. My... (3 Replies)
Discussion started by: siegfried
3 Replies

2. Shell Programming and Scripting

Shell script works fine as a standalone script but not as part of a bigger script

Hello all, I am facing a weird issue while executing a code below - #!/bin/bash cd /wload/baot/home/baotasa0/sandboxes_finance/ext_ukba_bde/pset sh UKBA_publish.sh UKBA 28082015 3 if then echo "Param file conversion for all the areas are completed, please check in your home directory"... (2 Replies)
Discussion started by: ektubbe
2 Replies

3. UNIX for Dummies Questions & Answers

Calling a script from master script to get value from called script

I am trying to call a script(callingscript.sh) from a master script(masterscript.sh) to get string type value from calling script to master script. I have used scripts mentioned below. #masterscript.sh ./callingscript.sh echo $fileExist #callingscript.sh echo "The script is called"... (2 Replies)
Discussion started by: Raj Roy
2 Replies

4. Shell Programming and Scripting

Script will keep checking running status of another script and also restart called script at night

I am using blow script :-- #!/bin/bash FIND=$(ps -elf | grep "snmp_trap.sh" | grep -v grep) #check snmp_trap.sh is running or not if then # echo "process found" exit 0; else echo "process not found" exec /home/Ketan_r /snmp_trap.sh 2>&1 & disown -h ... (1 Reply)
Discussion started by: ketanraut
1 Replies

5. Shell Programming and Scripting

create a shell script that calls another script and and an awk script

Hi guys I have a shell script that executes sql statemets and sends the output to a file.the script takes in parameters executes sql and sends the result to an output file. #!/bin/sh echo " $2 $3 $4 $5 $6 $7 isql -w400 -U$2 -S$5 -P$3 << xxx use $4 go print"**Changes to the table... (0 Replies)
Discussion started by: magikminox
0 Replies
Login or Register to Ask a Question