Skip to content
Snippets Groups Projects
Select Git revision
  • bf6ec5bbbd6e6400329a4abec6c7e50db14663e3
  • release default protected
  • workshop
3 results

start_ccs

Blame
  • Lspath 3.92 KiB
    #!/usr/bin/perl
    # $Id: Lspath,v 1.6 2012/04/22 20:04:59 gonter Exp $
    
    =pod
    
    =head1 USAGE
    
      Lspath
    
    display FC MPIO information hdisks
    
    =head1 OPTIONS
    
     -vg .. show VG info
     -hd .. sort by hdisk
     -p  .. sort by path
     -D  .. debug
     -watch .. continously watch paths
     -nagios .. prepare nagios health state
    
    =cut
    
    use strict;
    use SAN::Policy;
    use Util::ts;
    use Data::Dumper;
    $Data::Dumper::Indent= 1;
    
    my $LSPATH= '/usr/sbin/lspath';
    my $MPIO_PATHS= '/etc/mpio_paths';
    my $policy_file= '/etc/sanpolicy';
    
    my $sort_mode= 'none';
    my $show_paths= 1;
    my $show_stats= 0;
    my $show_nagios= 0;
    my $watch= 0;
    my $sleep_time= 60*5;
    my @LEVEL= qw(OK UNKNOWN CRITICAL);
    
    my $DEBUG= 0;
    my $show_vg= 0;
    while (defined (my $arg= shift (@ARGV)))
    {
      if ($arg =~ /^-/)
      {
           if ($arg eq '-vg')     { $show_vg= 1; }
        elsif ($arg eq '-D')      { $DEBUG= 1; }
        elsif ($arg eq '-hd')     { $sort_mode= 'hdisk'; }
        elsif ($arg eq '-p')      { $sort_mode= 'path'; }
        elsif ($arg eq '-watch')  { $watch= 1; }
        elsif ($arg eq '-stats')  { $show_stats= 1; }
        elsif ($arg eq '-nagios') { $watch= $show_stats= 1; $show_paths= 0; }
        else { &usage; exit (0); }
      }
    }
    
    my $policy= new SAN::Policy ('policy_file' => $policy_file, 'get_spports' => 1);
    $policy->refresh_policy (); # '@lspath.dump'
    # print "policy: ", Dumper ($policy);
    my $paths= $policy->{'paths'};
    print "paths: ", Dumper ($paths);
    
    if ($DEBUG)
    {
      print Dumper ($paths), "\n";
    }
    
    while (1)
    {