#!/pkg/bin/ksh
# -----------------------------------------------------------------------------
# show_tech_pd_lc - Show tech-support pd lc 
#
# Copyright (c) 2011, 2013, 2015-2017 by cisco Systems, Inc.
# All rights reserved.
#------------------------------------------------------------------------------

uname -a | grep -i Linux

#Flexr
if [ "$?" == 0 ]; then
 
#
# Grab out PCIe logs.
#
cat /misc/scratch/pcie/*

#
# dmesg logs from the kernal
#
dmesg

#
#The regular expression used below only takes cares of tomahawk and light speed LCs, which the
#LCs with below process names are taken cared.
#process name : vic_0_0 to vic_0_11, vic_1_0 to vic_1_9 and vic_ls.
#
#Regular expression needs to be changed accordingly when any new LC/Prev Gen LC is
#ported to eXR.
#
# The regular expression below will avoid duplicate entries w.r.t process name from ps -ef o/p
# and match the exact process name
#
for p in `ps -ef | awk '!x[$8]++' | awk '$8 ~/(vic_[0-1]_[0-9]\y)|(vic_ls\y)|(vic_0_10\y)|(vic_0_11\y)/  {print $8 ;}' `; do pcli $p  show tech; done
#
# The regular expression below will avoid duplicate entries w.r.t process id from ps -ef o/p
# and match the exact process name
#
ps -ef | awk '!x[$2]++' | awk '$8 ~/(vic_[0-1]_[0-9]\y)|(vic_ls\y)|(vic_0_10\y)|(vic_0_11\y)/ {print $2}' | xargs -t -i attach_process -i 1 -p {} 

#Classic
else

pidin A | grep " vic" | grep -v grep | cut -c10-20 | cut -f1 -d' '|  xargs -t -i  pcli {}  show tech

pidin A | grep " vic" | grep -v grep | cut -c1-9 | xargs -t -i attach_process -i 1 -p {}

fi



