#!/bin/sh
#
# ############################################################################
# Copyright (c) 2012-2018 Dell Inc. or its subsidiaries. All rights reserved.
# All trademarks used herein are the property of their respective owners.
#
# This script displays all the 'dead' paths known to PowerPath.
# ############################################################################
#

####
#   import platform specific check routines here if needed.
#   DO NOT REMOVE THE FOLLOWING LINE
####

powermt display dev=all | awk '
BEGIN {
    cnt = 0
    dead = 0
    tot_dead = 0
}
{
    if (NF > 0) {
        lines[cnt]  = $0
        cnt++
        if ($0 ~ /dead/ && $1 !~ /^state/) {
               dead++
               tot_dead++
        }
    }

    if (NF == 0) {
        if (dead > 0) {
            for ( x = 0; x < cnt; x++)
                print lines[x]
            print ""
        }
        cnt = 0
        dead = 0
   }
}
END {
    if (dead > 0) {
        for ( x = 0; x < cnt; x++)
            print lines[x]
        print ""
    }
    print "Total dead paths:", tot_dead
}'

