Vinod Subramaniam

Audit your VSP and G1000 Arrays using Perl Hashes

Discussion created by Vinod Subramaniam Employee on Dec 15, 2015

Quite often you are asked by supervisors to report on what changes were made to a VSP or a G1000 on a particular day.

This script allows you to automate this task.


There are two scripts - genhash.pl and compare.pl.


genhash.pl generates array config hashes for all arrays listed in arrays.conf and stores the hashes on the filesystem in the .hash directory.

The hash files are named as ARRAYCONFIG.yyyymmdd for each day.


You can schedule this script in crontab and run at midnight every day.


compare.pl takes two array config hashes as command parameters and compares the differences between them and reports the differences to the console.

You can write a wrapper shell script that redirects the output to the filesystem and email the diffs every day to you email id.


The compare.pl script is an example script only and will get you started.

It has been tested for LDEV additions and deletions.


The code for other config changes is still there but is not tested.

Feel free to modify and post the changes, bugs etc to this thread.


Here's how you get started :-


1. Download the attached auditvsp.tar file

 

2. Untar to any directory


3. Run a ls command and check if listing is similar to below


suse-linux:/home/user/auditvsp # ls -ltr

total 28

-rwxr-x--- 1 root root 13155 Dec 14 20:05 genhash.pl

-rwxr-x--- 1 root root 1174 Dec 14 21:03 compare.pl

-rw-r----- 1 root root 295 Dec 14 21:06 arrays.conf

-rw-r----- 1 root root 323 Dec 14 21:09 horcm10.conf

drwxr-x--- 1 root root 80 Dec 14 21:11 .hash

 

4. Edit horcm10.conf and to include all your arrays and copy to /etc and start up horcm10

    [ Note that the first array in the command device section is UNIT 0 the next one is UNIT 1 and so on ]


5. Edit arrays.conf and include the raidcom username and password for each UNIT


suse-linux:/home/user/auditvsp # cat arrays.conf

[ARRAYS]

65664=VSP_65664

356644=G1000_356664

356111=G1000_356111

 

[65664]

unit=0

user=user

pass=pass

cmd=/dev/sdg

 

[356644]

unit=1

user=user

pass=pass

cmd=/dev/sdn

 

[356111]

unit=2

user=user

pass=pass

cmd=/dev/sdae

 

[HORCM]

BASE=/opt/HORCM

INST=10

 

[GENERAL]

SCRIPT_DIR=/home/user/auditvsp

 

6. Run /home/user/auditvsp/genhash.pl


suse-linux:/home/user/auditvsp # ./genhash.pl

User for Serial#[65664] : Password :

User for Serial#[356644] : Password :

User for Serial#[356111] : Password :

Retrieving LDEV data via raidcom

Retrieving PORT data via raidcom

Retrieving MP data via raidcom

Retrieving DP data via raidcom

Retrieving Pool data via raidcom

Retrieving LDEV data via raidcom

Retrieving PORT data via raidcom

Retrieving MP data via raidcom

Retrieving DP data via raidcom

Retrieving Pool data via raidcom

Retrieving LDEV data via raidcom

Retrieving PORT data via raidcom

Retrieving MP data via raidcom

Retrieving DP data via raidcom

Retrieving Pool data via raidcom

 

7. Check the .hash directory and make a copy of the hash file as below

 

suse-linux:/home/subramav/auditvsp # cd .hash

suse-linux:/home/subramav/auditvsp/.hash # ls

ARRAYCONFIG.20151214

dc2prhdscs01:/home/subramav/auditvsp/.hash # cp ARRAYCONFIG.20151214 ARRAYCONFIG.20151213

 

8. Now run the compare script as below. There should be no differences reported as both hashes are copies.

 

suse-linux:/home/subramav/auditvsp # ./compare.pl 20151214 20151213

 

9. Now make a change to array i.e map a ldev to a hostgroup and run genhash.pl again


10. Run the compare script again as below. You should see an output that reports the HG, Port, MPB and Pool for the newly added LDEV.


suse-linux:/home/subramav/auditvsp # ./compare.pl 20151214 20151213

dc2prhdscs01:/home/subramav/auditvsp # ./compare.pl 20151213 20151215

 

----------------- Parsing 356644 -----------------

 

----------------- Parsing 356111 -----------------

 

----------- Host Group ------------------------------------

Added to Host Groups

Added 00:12:B8 : dchostgroup

Deleted from Host Groups

 

 

----------- Port ------------------------------------------

Added to Port(s)

Added 00:12:B8 : CL5-C CL6-C

Deleted from Port(s)

 

 

----------- MPB ------------------------------------------

Added to MPB

Added 00:12:B8 : MPB13

Deleted from MPB

 

 

----------- Pool ------------------------------------------

Added to Pool

Added 00:12:B8 : PID_10

Deleted from Pool

 

 

----------------- Parsing 65664 -----------------

Attachments

Outcomes