ciphermethod.com

20091229: find_controller.sh

by on Dec.29, 2009, under Scripts

#!/bin/sh
#
# Created: 20091229 Jamey Hopkins
#              Find PCI controller and output matches into $STR.servers
# 20100406 jah - added ping check

if [ "$1" = "" ]
then
	echo "Please pass a search string."
	echo "Example: find_controller.sh AAC-RAID"
	exit
else
	STR="$1"
fi

>$STR.servers

for SERVER in `cat linux.servers`
do
	echo -n $SERVER
	MSG="Controller not found."

	ping -c1 $SERVER >/dev/null 2>&1
	if [ $? -eq 0 ]
	then
	   DATA=`ssh $SERVER sudo /sbin/lspci 2>/dev/null | grep $STR`
	   [ "$DATA" != "" ] && MSG="Controller: $DATA"
	   [ "$DATA" != "" ] && echo $SERVER >>$STR.servers
	   # echo what we found
	   echo -e "\t$MSG"
	else
	   echo -e "\tServer not reachable."
	fi
done
No comments for this entry yet...

Leave a Reply

You must be logged in to post a comment.

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

But Wait, There's More!

A few highly recommended friends...