Netapp Protection Manager is good in handling the snapvault and snapmirror relationship. However, the snapvault relationship will become “broken” once the source qtree deleted/removed. Using command like “snapvault status” is killing me especially when you have hundred of lines to view, though ssh method with “grep” command is helpful but it would be great to have a script to spoon feed us(almost) !

Here is the python script to run in Linux environment:

import sys
import os
#Define max tolerate hour , 168 = 7days
if filer_input not in ["filerA","filerB","filerC"]:
    print """This script only works for 3 filers: filerA,filerB,filerC .
python /home/thinkway/myscript/python/ filerA
    print "Running..."
f=os.popen("ssh %s snapvault status | grep vol" % (filer_input))
for x in f.readlines():
    output_data = x.split()
    #Define variable
    source_path = output_data[0]
    dest_path = output_data[1]
    relationship = output_data[2]
    #We are only interested with hour,split it out!
    buffer_time = output_data[3].split(":",1)
    relationship_status = output_data[4]
    #Get destination nas hostname
    dest_nas = output_data[1].split(":",1)
    dest_nas_hostname = dest_nas[0]
    #Get the exact hour number and convert it into int
    extracted_hour = int(buffer_time[0])
    if relationship_status == "Idle":
        if extracted_hour > max_tolerate_hour:
            print "Source path         : ",source_path
            print "Destination path    : ",dest_path
            print "Max threshold(hours): ",max_tolerate_hour
            print "Idle (hours)        : ",extracted_hour
            print "Command             : ssh ",dest_nas_hostname," snapvault stop ",dest_path
            print "======================================================================"
print "Scan completed!"

The output will be…..

Source path         :  Source_filer:/vol/testvol/qtreeA
Destination path    :  filerA:/vol/filerX_testvol/qtreeA
Max threshold(hours):  168
Idle (hours)        :  10207
Command             : ssh  filerA  snapvault stop  filerA:/vol/filerX_testvol/qtreeA
Source path         :  Source_filer:/vol/rnd/r&d
Destination path    :  filerA:/vol/filerX_rnd/rxd
Max threshold(hours):  168
Idle (hours)        :  9884
Command             : ssh  filerA  snapvault stop  filerA:/vol/filerX_rnd/rxd
Source path         :  Source_filer:/vol/shared/sample
Destination path    :  filerA:/vol/filerX_shared/sample
Max threshold(hours):  168
Idle (hours)        :  5875
Command             : ssh  filerA  snapvault stop  filerA:/vol/filerX_shared/sample

See! Just copy and paste the “Command” line!!
P/S: If you have more simplified code to do this job, feel free to share with me and I will post it out 🙂