Microsoft Virtualization Discussions

SnapMirror log parser

mg
NetApp
12,982 Views

Hello,

While looking at a way to automate SnapMirror logs extraction and consolidation, I've found Get-NaSystemLog -SnapMirror in the toolkit.

I've written a script close to the parser available in Tool Chest on support website, feel free to send me your comments.

Script requires PS toolkit, so if not loaded, change path to it accordingly in the script.

NEW VERSION 0.2 with following changes:

- Added "Last" parameter to process only <X> last lines from SnapMirror log

- Fixed transfer hash valid key detection

Enjoy!

Michel

7 REPLIES 7

mcgue
12,982 Views

Michel,

Nice work!  Definitely helpful.  I'm wondering if some code could be added to have an option of opening a copy of the snapmirror log from a local drive (well, I'm sure it could be, I'm still cutting my teeth on PS still so I'm challenging myself to figure it out too!).

mg
NetApp
12,982 Views

Thanks!

I had a quick look and there's -Path parameter:

Get-NaSystemLog -SnapMirror [-EventType <String[]>] [-StartTime <DateTime>] [-EndTime <DateTime>] [[-Path] <String>] [-Follow] [-Controller <NaController>] [<CommonParameters>]

Unfortunately -Controller parameter is mandatory, meaning it can't parse a local file, but you could possibly copy the file you got to a local Filer, then parse that specific file:

PS C:\temp> Get-NaSystemLog -SnapMirror -Path /vol/vol0/etc/log/snapmirror.mg

TimeStampDT            Type   EventInfo

-----------            ----   ---------

12/1/2012 1:35:02 AM   dst    naluxfas01:naluxvfvm01_root naluxfas02:naluxvfvm01_root Start

12/1/2012 1:35:02 AM   dst    naluxfas01:naluxvfvm01_data naluxfas02:naluxvfvm01_data Start

12/1/2012 1:35:04 AM   dst    naluxfas01:naluxvfvm01_root naluxfas02:naluxvfvm01_root End (124 KB)

12/1/2012 1:35:05 AM   dst    naluxfas01:naluxvfvm01_data naluxfas02:naluxvfvm01_data End (7948 KB)

12/1/2012 1:50:00 AM   dst    naluxfas01:naluxvfvm01_data naluxfas02:naluxvfvm01_data Request (Scheduled)

12/1/2012 1:50:00 AM   dst    naluxfas01:naluxvfvm01_root naluxfas02:naluxvfvm01_root Request (Scheduled)

12/1/2012 1:50:03 AM   dst    naluxfas01:naluxvfvm01_data naluxfas02:naluxvfvm01_data Start

12/1/2012 1:50:03 AM   dst    naluxfas01:naluxvfvm01_root naluxfas02:naluxvfvm01_root Start

12/1/2012 1:50:04 AM   dst    naluxfas01:naluxvfvm01_root naluxfas02:naluxvfvm01_root End (104 KB)

12/1/2012 1:50:05 AM   dst    naluxfas01:naluxvfvm01_data naluxfas02:naluxvfvm01_data End (8300 KB)

12/1/2012 2:05:00 AM   dst    naluxfas01:naluxvfvm01_root naluxfas02:naluxvfvm01_root Request (Scheduled)

12/1/2012 2:05:00 AM   dst    naluxfas01:naluxvfvm01_data naluxfas02:naluxvfvm01_data Request (Scheduled)

12/1/2012 2:05:02 AM   dst    naluxfas01:naluxvfvm01_root naluxfas02:naluxvfvm01_root Start

12/1/2012 2:05:03 AM   dst    naluxfas01:naluxvfvm01_data naluxfas02:naluxvfvm01_data Start

12/1/2012 2:05:04 AM   dst    naluxfas01:naluxvfvm01_root naluxfas02:naluxvfvm01_root End (256 KB)

12/1/2012 2:05:05 AM   dst    naluxfas01:naluxvfvm01_data naluxfas02:naluxvfvm01_data End (8188 KB)

12/1/2012 2:20:00 AM   dst    naluxfas01:naluxvfvm01_data naluxfas02:naluxvfvm01_data Request (Scheduled)

12/1/2012 2:20:00 AM   dst    naluxfas01:naluxvfvm01_root naluxfas02:naluxvfvm01_root Request (Scheduled)

12/1/2012 2:20:02 AM   dst    naluxfas01:naluxvfvm01_root naluxfas02:naluxvfvm01_root Start

12/1/2012 2:20:02 AM   dst    naluxfas01:naluxvfvm01_data naluxfas02:naluxvfvm01_data Start

12/1/2012 2:20:03 AM   dst    naluxfas01:naluxvfvm01_root naluxfas02:naluxvfvm01_root End (96 KB)

12/1/2012 2:20:05 AM   dst    naluxfas01:naluxvfvm01_data naluxfas02:naluxvfvm01_data End (8304 KB)

TPHANENDRA
12,982 Views

Hi,

I am beginner to PowerShell, Could anyone please tell me what is the Controller input and how I have to run the smsv-parser program.

Regards,

Phani T

vinith
12,982 Views

Hello, Its a CMDLET which would let you extract this information.

From your powershell prompt type in below command to get a detailed help regarding this cmdlet

PS C:\Windows\system32> Get-Help Get-NaSystemLog -Detailed

Check out http://www.powershellpro.com/ , it would help you in getting started with powershell.

mg
NetApp
12,982 Views

Hello,

You can get help about the script using "get-help" command against the script:

PS D:\Scripts> get-help .\smsv-parser.ps1  -detailed

NAME

    D:\Scripts\smsv-parser.ps1

SYNOPSIS

    Produce a CSV file from a specified controller snapmirror.log

SYNTAX

    D:\Scripts\smsv-parser.ps1 [-Controller] <String> [[-Out] <String>] [[-Last] <Int32>] [-LastWeek] [<CommonParameters>]

DESCRIPTION

    Produce a CSV file from a specified controller snapmirror.log

PARAMETERS

    -Controller <String>

        Storage controller which to retrieve logs from

    -Out <String>

        Optional output file name. If not specified, output file will be in current folder

        and will be name "smsv-parser_<controller name>.csv

    -Last <Int32>

        Optional number to retrieve <number> last lines from logs

    -LastWeek [<SwitchParameter>]

        Optional switch to retrieve logs of the previous week (Monday to Sunday)

    <CommonParameters>

        This cmdlet supports the common parameters: Verbose, Debug,

        ErrorAction, ErrorVariable, WarningAction, WarningVariable,

        OutBuffer and OutVariable. For more information, type,

        "get-help about_commonparameters".

    -------------------------- EXAMPLE 1 --------------------------

    C:\PS>smsv-parser.ps1 -Controller naluxfas02

     

    -------------------------- EXAMPLE 2 --------------------------

    C:\PS>smsv-parser.ps1 -Controller naluxfas02 -Out file.csv

     

    -------------------------- EXAMPLE 3 --------------------------

    C:\PS>smsv-parser.ps1 -Controller naluxfas02 -Out file.csv -LastWeek

    -------------------------- EXAMPLE 4 --------------------------

    C:\PS>smsv-parser.ps1 -Controller naluxfas02 -Out file.csv -Last 50

mcgue
12,299 Views

Great script Michel!  I made a few edits to allow the optional reading from a SnapMirror log file as compared to getting the data from a controller.  I have attached it to this reply.

mcgue
11,948 Views

I added a few modifications (getting data from yesterday and time/date stamping the results file).  Attached is the results of those changes.

Public