#!/bin/bash
. localrcs
CHECKTYPE=get_pci_id
TIMESTAMP=1539948595
RAID_DEV_INFO_LIST='raid_dev_list'
RAID_DEV_PCI_ID_LIST='raid_pci_id_list'

pci_id_info=$(lspci -n)
for i in $(lspci -n | awk '/ 01..: /{print $1}');do
    pattern="$i|$pattern"
done
pattern="${pattern%*|}"
raid_dev_list=$(lspci       | egrep ${pattern} | awk -F ': ' '{printf "\"" $2 "\","}')
raid_pci_id_list=$(lspci -n | egrep ${pattern} | awk -F ' '  '{printf "\"" $3 "\","}')
#return json
CHECKRESULT=pass
CHECKOUTPUT="{\"${RAID_DEV_INFO_LIST}\": [${raid_dev_list%*,}], \"${RAID_DEV_PCI_ID_LIST}\": [${raid_pci_id_list%*,}]}"
feedback $TIMESTAMP $CHECKTYPE $CHECKRESULT "$CHECKOUTPUT"
