I had a couple of options, I could run over to the datacenter and physically look at each server, I could use the blade chassis web management gui, or I could use the OS to pull the needed info.
As it turned out, it took a little of all 3 options to gather all of the info. But this post will be about the last option. How do you pull server specific information from the OS? In this case, the OS is Red Hat.
Well, this is a simple process. First, we will use lshal. This command will tell us about everything that Red Hat sees hardwise during bootup. If you have ever used or viewed the output of lshal, you know that it can be a daunting task to find specific information. This is where grep comes in handy. Grep is used to parse the output of a command. We just pipe the output of the lshal to grep and give it a search string. A good example would be something like this:
cat /etc/fstab | grep sda
# / was on /dev/sda1 during installation
That was cool, now try running lshal and grep for serial:
The command will look like this
lshal | grep serial
Our output will look something like this:
lshal | grep serial
system.board.serial = '123490EN4XXX15' (string)
system.hardware.serial = 'XXXX93DQCX1628' (string)
battery.serial = '' (string)
Great, I now have the serial number of my system, But what brand is my computer?
Try this:
lshal | grep vendor
And we get this:
system.board.vendor = 'SAMSUNG ELECTRONICS CO., LTD.' (string)
system.firmware.vendor = 'Phoenix Technologies Ltd.' (string)
system.hardware.primary_video.vendor = 32902 (0x8086) (int)
system.hardware.vendor = 'SAMSUNG ELECTRONICS CO., LTD.' (string)
battery.vendor = 'SAMSUNG Electronics' (string)
info.vendor = 'Intel Corporation' (string)
pci.subsys_vendor = 'Samsung Electronics Co Ltd' (string)
pci.subsys_vendor_id = 5197 (0x144d) (int)
pci.vendor = 'Intel Corporation' (string)
I now know that the vendor of, in this case my netbook is Samsung.
Hope this was helpful.
What are some examples of how you have used grep in the past?
Thanks for stopping by, and be sure to leave me a comment.
No comments:
Post a Comment