System Administration
cancel
Showing results for 
Search instead for 
Did you mean: 

Scripting Junkies. Need help with a script.

 
SOLVED
Go to solution
RAC_1
Honored Contributor

Scripting Junkies. Need help with a script.

My requirement if to parse the /etc/lvmtab and come up with following.
vg and number of disks for that vg

strings /etc/lvmtab|grep '\/dev'
gives following

vg_cl_PCM01_redo2
/dev/dsk/c1t1d1
/dev/dsk/c2t2d2
vg_cl_PCM01_sys
/dev/dsk/c1t3t4

It should give me as follows.
vg_cl_PCM01_redo2 2 pvs
vg_cl_PCM01_sys 1 pvs
There is no substitute to HARDWORK
7 REPLIES 7
Rita C Workman
Honored Contributor

Re: Scripting Junkies. Need help with a script.

I am NO kind of 'scripter'...but here's a couple a short something that might help you get started:

for a in `strings /etc/lvmtab | grep -v "/dev/dsk/"`
do
echo $a "\c" >> lvm-task.file
vgdisplay -v $a | grep "Cur PV" | awk '{print $3}' >> lvm-task.file
done

Like I said...nothing fancy !

Rgrds,
Rita
Steve Lewis
Honored Contributor
Solution

Re: Scripting Junkies. Need help with a script.

The problem is alternate paths. To include them is easy, all on one line:

strings lvmtab | awk '/vg/{d=$1}{V[d]++}END{for(f in V)print f,(V[f]-1), "pvs"}'

To remove the Alternate Link means taking more of a detailed approach.

Why do you want to look at lvmtab, not just use vgdisplay -v ?

RAC_1
Honored Contributor

Re: Scripting Junkies. Need help with a script.

I dont want to do vgdisplay. I just want the pv count vgwise from lvmtab. I need to match it with alternate node vgs.

vgs being used are in vcs and mcsg environment. the purpose is check if no. of pvs under a vg on primary node and secondary node is matching or not.

Many times sysadmins forget to import the vgs on alternate node for a vg under mcsg package and failovers run into the problem...
There is no substitute to HARDWORK
Rita C Workman
Honored Contributor

Re: Scripting Junkies. Need help with a script.

OK...so your looking at trying to do some sort of "audit" on SG.

Well, this will tell you if you have the same amount disks - but that's it. What about a new lvol. You may have a match on disk amt, but your failover could still cripple. So, I'm guessing your going to add something to compare the mapfiles between SG related nodes too.

This may be a side-bar suggestion, but making a form to confirm certain tasks are done & ck'd off helps. As does a naming standard for new mapfiles with the date created included it in.

Another quick auditing check is to compare the date of the primary nodes vg.map with that of the failover node(s) vg.map to the vg.conf file on the failover nodes.
I just sit on my primary node, check the dates on the latest mapfile on primary node and then just run a remsh to check all failover nodes
remsh -n ll /etc/lvmconf/vg2.mapddmm

and then
remsh -n ll /etc/lvmconf/vg2.conf Do the dates prove latest mapfile was applied? Are the dates current with the primary node?

Just a thought,
Rgrds,
Rita

Re: Scripting Junkies. Need help with a script.

If you are interested in an audit of your cluster consider CCMON. This will entail an end-to-end discovery and resulting report for you of any areas of weakness in the cluster configuration. CCmon runs as a background process that continuously checks thousands of data points for configuration differences. When changes occur, it automatically triggers alarms. In addition, it generates scheduled HTML or ASCII reports that give you advance warning of possible failures - without the need for switchover testing.

RAC_1
Honored Contributor

Re: Scripting Junkies. Need help with a script.

ccmon would address only mcsg. we have vcs too. steve's script looks just fine.
There is no substitute to HARDWORK
RAC_1
Honored Contributor

Re: Scripting Junkies. Need help with a script.

Resolved. Steve's script was used!!
There is no substitute to HARDWORK