Last active
February 13, 2017 21:47
-
-
Save gmillerd/43a8f16d7c8e6c16565c932bfc565f4c to your computer and use it in GitHub Desktop.
example of how to gather data from isilon logsets for serial2logset type lookups.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/perl | |
| use strict; | |
| use warnings; | |
| use Data::Dumper; | |
| use XML::Simple; | |
| # | |
| # perl thiscript.pl > tmp.lst | |
| # sort tmp.list master.lst -o master.lst | |
| # | |
| # read /logs for dirs from today, read /logs/customer for dirs from today, read /logs/cluster/logsets from xml that exist and are from today | |
| my $cli = 'find /logs/ -maxdepth 1 -mindepth 1 -type d -print0 | xargs -0 -r -P4 -n1 -I% find % -maxdepth 1 -mindepth 1 -type d -print0 | xargs -0 -r -P4 -n1 -I% find % -maxdepth 1 -mindepth 1 -type f -name "celog_events.xml" -print0'; | |
| open(my $FH, "-|", "$cli") || die($!); | |
| { | |
| for my $path (split(/\0/, <$FH>)) { | |
| my $data = idlogset($path); | |
| for my $serial (@{ $data->{'serials'} }) { | |
| print join("\t", | |
| $serial, | |
| $data->{'version'}, | |
| $data->{'cluster'}, | |
| $data->{'gather_date'}, | |
| scalar localtime($data->{'stat9'}), | |
| $data->{'logset'}, | |
| $data->{'command'}, | |
| ), "\n"; | |
| } | |
| } | |
| } | |
| close($FH); | |
| sub idlogset { | |
| my $fqfn = shift; | |
| my $ref = XMLin($fqfn, ForceArray => 1); | |
| my $data = {}; | |
| ($data->{'logset'}) = $fqfn =~ m!(.*)/!; | |
| $data->{'stat9'} = (stat($fqfn))[9]; | |
| # 8.x style | |
| if( $ref->{'celog'}[0] ) { | |
| $data->{'gather_date'} = $ref->{'gather_date'}[0]; | |
| $data->{'command'} = $ref->{'command'}[0]; | |
| $data->{'command'} =~ s!.*isi_gather_info !!; | |
| $data->{'cluster'} = $ref->{'celog'}[0]->{'cluster'}[0]->{'name'}[0]; | |
| for my $node (@{ $ref->{'celog'}[0]->{'cluster'}[0]->{'node'} }) { | |
| my $serial = lc($node->{'serial'}[0]); | |
| $serial =~ s/\W+//g; | |
| push(@{ $data->{'serials'} }, $serial); | |
| $data->{'version'} ||= $node->{'version'}[0]; | |
| } | |
| } # elsif ... 5/6/7 cluster not available atm | |
| $data->{'version'} =~ s/(^Isilon OneFS v| .*$)//g; | |
| return $data; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment