Friday, June 27, 2008

Find Hardware details of VMware Host from Command Line

I being non unix guy was struggling to find out how can I find hardware detail of any VMware host without looking at VC. Finally some linux guru came for my rescue and I found the solution. I would like to thank him and would like to put forward for everyone so that if they are dumb like me can make use of this article.

Part 1: Finding Hardware Details with lspci

lspci is a utility for displaying information about all PCI buses in the system and all devices connected to them. By default, it shows a brief list of devices. However you can use the various lspci options to request either a more verbose output or output intended for parsing by other programs.

[root@localhost ~]# lspci
00:00.0 Host bridge: Intel Corporation 82865G/PE/P DRAM Controller/Host-Hub Interface (rev 02)
00:02.0 VGA compatible controller: Intel Corporation 82865G Integrated Graphics Controller (rev 02)
00:1d.0 USB Controller: Intel Corporation 82801EB/ER (ICH5/ICH5R) USB UHCI Controller #1 (rev 02)
00:1e.0 PCI bridge: Intel Corporation 82801 PCI Bridge (rev c2)
00:1f.1 IDE interface: Intel Corporation 82801EB/ER (ICH5/ICH5R) IDE Controller (rev 02)
03:08.0 Ethernet controller: Intel Corporation 82562EZ 10/100 Ethernet Controller (rev 02)
....

So now I know that my Graphics chip is “Intel Corporation 82865G Integrated Graphics Controller"and would take me a minute to search for drivers for that by searching the fine web. Here is the description of the line :

You may also use -v or -vv flags to display more information. When I used lspci -v, I get more details for my Graphic Chip

00:02.0 VGA compatible controller: Intel Corporation 82865G Integrated Graphics Controller (rev 02) (prog-if 00 [VGA])
Subsystem: IBM Unknown device 0285
Flags: bus master, fast devsel, latency 0, IRQ 185
Memory at f0000000 (32-bit, prefetchable) [size=128M]
Memory at e8000000 (32-bit, non-prefetchable) [size=512K]
I/O ports at 1800 [size=8]
Capabilities: [d0] Power Management version 1

Lspci utility reads some information from the PCI bus, and then collects additional information from its own database of hardware id's. This additional information is stored at /usr/share/misc/pci.ids and it contains information such as hardware-id, vendor, devices, classes and subclasses. Let's find our device in this file:

[root@localhost ~]# cat /usr/share/hwdata/pci.ids grep "82865G Integrated Graphics Controller"
82865G Integrated Graphics Controller

As you can see our device is also listed in the hardware list. This hardware list is maintained at http://pciids.sourceforge.net, and you can use the update-pciids utility to download the most recent version.

Part 2: Finding Hardware Details with dmesg

dmesg is Linux command that is used to examine or control the kernel ring buffer. The program helps users to print out their boot-up messages.

Lspci worked well to discover our PCI devices but we want inventory of all devices on the system. Using dmesg we can view hardware details of everything detected by our operating system.

[root@localhost ~]# dmesg less
Normal zone: 59248 pages, LIFO batch:15
DMI present.
Allocating PCI resources starting at 20000000 (gap: 10000000:eec00000)
Detected 2793.055 MHz processor.
Built 1 zonelists. Total pages: 63344
Kernel command line: ro root=/dev/VolGroup00/LogVol00 rhgb quiet
Enabling fast FPU save and restore... done.
Initializing CPU#0
CPU 0 irqstacks, hard=c07ae000 soft=c078e000
Memory: 244136k/253376k available (2139k kernel code, 8732k reserved, 866k data, 240k init, 0k highmem)
.....

As you can see dmesg gives you a lot of details, so we will use grep to restrict information to what we want. Let's say, we are interested in memory installed in the system.

[root@localhost ~]# dmesg grep -i memory
Memory: 244136k/253376k available (2139k kernel code, 8732k reserved, 866k data, 240k init, 0k highmem)
Freeing initrd memory: 2124k freed
Total HugeTLB memory allocated, 0
Non-volatile memory driver v1.2
agpgart: Detected 8060K stolen memory.
Freeing unused kernel memory: 240k freed
.....

Similarly you can grep for whatever hardware you are trying to troubleshoot, for example CPU, USB etc.

Part 3: Finding Hardware Details from /proc

Sometimes you will want to monitor physical memory and CPU information on a running system in real time. For doing this, you will have to read the /proc file system. You might be thinking about `top` utility, but that utility also reads information from /proc file system. Make sure you only use `cat` command to view the information and do not change any of the files in /proc.

Doing an `ls` on /proc folder you will see various files and folders which contain information about your system.

Now let's start looking at what these files contain, starting with cpuinfo.

[root@localhost ~]# cat /proc/cpuinfo
processor : 0
vendor_id : GenuineIntel
cpu family : 15
model : 2
model name : Intel(R) Pentium(R) 4 CPU 2.80GHz
stepping : 9
cpu MHz : 2793.055
cache size : 512 KB
..

Now let's dig deeper and go inside a folder, I am going inside the `ide` folder and reading details for my hard disk.

[root@localhost ~]# cat /proc/ide/ide0/hda/driver
ide-disk version 1.18
[root@localhost ~]# cat /proc/ide/ide0/hda/capacity
78156288
[root@localhost ~]# cat /proc/ide/ide0/hda/model
IC35L060AVV207-0

Part 4: Getting More Information about your HDD using fdisk

In our last step using /proc, we obtained very basic information about our Hard Disk Settings. Now lets dig deeper by using `fdisk` command available in Linux. We will now try to obtain information about partitions, space available, space allocated, swap and more.

`fdisk` is the partition table manipulator tool for Linux. Generally hard disks are divided into one of more logical disks, also known as partitions. This partition information is stored in partition table found on sector 0 of the disk.

To display all partitions on your system, just type:

[root@localhost ~]# fdisk -l
Disk /dev/hda: 40.0 GB, 40016019456 bytes
255 heads, 63 sectors/track, 4865 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/hda1 * 1 13 104391 83 Linux
/dev/hda2 14 4865 38973690 8e Linux LVM

And to view details of a particular drive, let say you have hda and hdb drives then type fdisk -l /dev/hda

Part 5 (UPDATE) : Reading BIOS information using dmidecode command

dmidecode tool dumps your system's DMI (Desktop Management Interface) table contents in a human-readable format. This table contains information regarding system's hardware components, as well as BIOS revisions etc. dmidecode output not only describes system current configuration, but also reports the BIOS limitations on supported CPU speed, Maximum Memory allowed and more.

Now lets say I want to restrict information to certain areas of DMI, I can do that by using the option -t and specifying what type of information I am interested in. For example, Processor Information is DMI type 4 and Memory Device is DMI type 17.

I hope this tutorial helps you as much as it helped my friend who was installing MythTV on Fedora and kept on opening his box for hardware details :)


Thursday, June 26, 2008

Firewall Ports for VMWare.

It has always been a nightmare for any firewall admin when it comes to implement VMWare if it going to be rolled out in a secured environment. I found some Excel on VMware site which have all the details about the ports which is being used by VMware.



Wednesday, June 18, 2008

Restarting hostd service on the host

Sometime restarting management service on the host will not restart the “hostd ” service. It is in hung state or the script gets stuck when stopping the service. It may happen that the SSH session to the ESX host becomes unresponsive. To restart this without restarting the host follow below steps. This has been documented on KB for VMWare

1. Navigate to the /var/run/vmware directory:
# cd /var/run/vmware
2. List the files vmware-hostd.PID and watchdog-hostd.PID:
# ls -l vmware-hostd.PID watchdog-hostd.PID
3. Determine the Process ID (PID) management service, view the contents of the file vmware-hostd.PID:# cat vmware-hostd.PID
4. For example, [root@vmware]
# cat vmware-hostd.PID
1191[root@vmware]#
5. Use the resulting PID to kill the process. Caution: Type the kill -9 command carefully, it kills the process of the supplied PID without exception or confirmation.
# kill -9 1191
6. Delete the vmware-hostd.PID and watchdog-hostd.PID files:
# rm vmware-hostd.PID watchdog-hostd.PID
7. Restart the management service, run:
# service mgmt-vmware restart

How To Decide Static Mac address for Virtual machine

This is useful for software that is licensed by the MAC address of the server it is running on or if you migrate a physical server to virtual and want to keep the same MAC address. A VM’s MAC address will change if the location of the VM changes, ie. different path on the same host. During a hot migration (Vmotion) the location of the VM does not change, this is also true of a VM that changes hosts due to HA/DRS migration. During a cold migration the location of the VM does change so the MAC address of the VM will change.
MAC addresses are hex values and consist of six groups of hex numbers. The first 3 octets of the MAC address is a unique code assigned to each NIC vendor, this is also called the Organizationally Unique Identifier (OUI), VMware’s OUI is “00:50:56”. The last 3 octets are assigned to all of the NIC’s for that vendor. Each MAC address must be unique to avoid conflicts with other network devices. You do not have to use the VMware assigned range (00:50:56) for your NIC’s. If you are coming from a physical server you can use the previous NIC’s range instead, (ie. HP/Compaq NIC’s use 00:08:02) as the first 3 octets. Just make sure the physical NIC and virtual NIC with the same MAC address are not active on the same physical network at the same time. There are several methods for setting a static MAC address on a VM which are listed below. If you use the first method you must stay inside VMware’s allowed MAC addresses (00:50:56:00:00:00 – 00:50:56:3F:FF:FF) or the VM will not start. You need to maintain the pool of this MAC address to avoid conflict

Friday, June 6, 2008

Trying to be Photographer Part8

Aperture, ISO and Shutter Speed - The Good Kind of Threesome

PS: I have to admit that I have stolen this from blog site fearing that this information might go sometime

. I would like to thanks Choln for wonderful tutorial.


Canon 24-70mmL, f/2.8, ISO 1600, 0.125s

I thought I would take a little time and whip up an article about some photography basics. Please, please note the use of the word “basics” in that last sentence. If you’re been shooting for any appreciable length of time then you’re probably not going to get too much out of this. But given that we’re smack in the middle of the present giving time of year, it’s likely that in a few days there’s going to be a glut of new DSLR owners out there. What I’m aiming for is the article I wish I’d found when I first got my camera, to help explain the relationship between three critically important parameters: the ISO speed, aperture (or f-stop number), and shutter speed.

To lead with, the easiest way I think to approach these three things is to understand physically what they mean inside your camera. So, here we go.

  • ISO speed: A measurement of how quickly your camera’s sensor absorbs light.

  • Shutter speed: A measurement of how long your camera’s shutter is open for when you take a shot.

  • Aperture: A measurement of how wide the shutter on your camera’s lens opens up when you take a shot.

For completeness I should note that ISO speed is not specific to digital cameras with sensors. On film cameras, a particular roll of film will have a specific ISO speed that it is rated for. Fortunately for DSLR users like us, we can change the ISO speed without having to change film. All three of these parameters affect how light gets to your camera’s sensor to create an image, so let’s start looking at them in more detail.

ISO Speed

The ISO speed changes how quickly the sensor absorbs light. Lower numbers mean less quickly and higher numbers mean more quickly. Now, the thing to keep in mind is that at high ISO speeds, you will introduce some graininess into your image. Therefore, the basic rule of thumb is that you want to shoot at the lowest ISO speed that you can get away with given the environment you are in. For example, if you are outdoors in the middle of a sunny day, you can probably shoot at a very low ISO speed like 100 or 200. Conversely, if you are shooting indoors or at night (or both) you will probably need to shoot at a high ISO speed in order to properly expose your image.

Shutter Speed

This one is probably the easiest of the three to get your head around. It’s exactly what it sounds like: the length of time that the shutter is open and light can get in through the lens to your sensor. Shutter speeds on Canon cameras are displayed as inverse numbers against one second. So, if your camera’s shutter speed is set to 125, that means that the shutter will be open for 1/125th of a second. Therefore, higher numbers mean that the shutter is open for less time. The effect this has is on the sharpness of the image. If the shutter is open for a very short amount of time, then even if the thing you are shooting is moving you will be able to get a sharp image of it, because it won’t have time to move around before the shutter closes again. The downside is that if the shutter is only open for a instant, then not a lot of light can get in to the sensor.

Aperture (or F-Number)

The third and final member of our roster here is the aperture. This is a measurement of how wide the shutter opens up when you take the shot. In terms of the F-Number, it can be a little bit confusing at first. You’ll see lenses listed with specs that read like “35mm f/2″ which doesn’t mean too much at first, so let’s take a look at that. The “35mm” part is the focal length of the lens, in this case fixed at 35 millimeters. Now, the “f/2″ part means that the ratio of the focal length to the maximum width that the shutter can open up to is 2. Confused? Let’s use some real numbers. This is saying that on this 35mm focal length lens, the maximum diameter that the shutter can open up to is 17.5mm. So, the smaller the F-number is, the wider the lens can open up relative to its focal length.

Understanding the effect this has on your image is a little more complex than with the others because two different effects come into play. The first is the depth of field in your shot. I’ve personally always thought that the term “depth of field” is a bit, well, wrong for what it’s used to describe. In my opinion, a more accurate description would be “plane of focus” so I’m going to run with that. Here we go. Imagine you are taking a picture, and that there is a magical plane of glass somewhere in front of you that is parallel to the front of your lens. “Magical” because it can pass through other objects, like the ones you’re taking pictures of. Everything within the plane of glass will be in focus, and things that are in front of or behind the plane of glass will be blurred. Got that? Good. Now here’s the neat trick: the wider your lens opens up when you take the shot (low F-number), the thinner that plane of glass becomes. Conversely, if your lens opens up only a teeny amount (high F-number), then the plane of glass becomes very very thick. So, a very high F-number means that probably everything in your shot will be in focus. A very low F-number means that only a thin plane will be in focus in your shot.

Still not quite making sense? It’s a little hard to visualize at first. Fortunately, Ryan’s taken a great shot at a wide aperture that should help make things clearer.


Canon 100mm macro, f/4, ISO 400, 0.001s

As you can see, with a wide aperture, the caterpillar is in focus but the areas both in front of and behind it are a bit blurred out. This is often used to make objects in the foreground pop into sharp relief by blurring out the background, which is a standard portrait shooting technique shown here.


Canon 50mmL, f/2, ISO 1000, 0.013s

So the first of the two effects is related to which parts of your shot are in focus and which aren’t. The second again relates to light. The wider your lens opens up, the more light gets in to the sensor. So shooting with a wide open lens can help you in low-light situations. On the other hand, if you have tons of light, then you can shoot with much smaller apertures if you so choose.

Putting it Together

Now you should have a good understanding of what these three numbers are actually doing on your camera. Let’s talk a little bit about how the three are interrelated. All three of them share a common trait, namely that they affect how light gets into your camera to produce an image. This is one of the reasons that you’ll read over and over that lighting is the most important thing in photography. Let’s look at a few scenarios, starting with a situation in which you are doing social shooting in very low light. In this case, you will typically want to set your ISO speed very high at something like 1600, and you’ll want to open your lens up as wide as it will go (low F-number.) Then, you will set the shutter speed as fast as you can get away with while still getting a reasonable exposure. A good rule of thumb for the shutter speed is it’s the inverse of the focal length of your lens. Meaning, if you’re shooting with a 50mm lens, try to have the shutter speed 1/50th of a second or faster. Practically, I get away with a slightly slower shutter speed than this rule dictates all the time, but it’s a good thing to keep in mind.


Canon 50mmL, f/1.2, ISO 1600, 0.025s

You definitely see the grain here due to the high ISO setting of 1600. Also, you’ll note that while the subject’s left eye is right in focus, her hair over her right shoulder is a bit blurred. This is due to the very wide aperture of f/1.2. The shutter speed was 1/40th of a second, and fortunately she wasn’t moving very much so I was able to get a sharp shot. This was despite the fact that there were only a few tea light candles to illuminate this frame.

Let’s look at a more extreme kind of shot next. Low light, but where you want a low ISO to avoid the grain, and a reasonably small aperture so things are in focus. If that’s the situation you are in, then in order to get enough light into the camera to get the image, you have to have a very, very slow shutter speed.


Canon 17-85mm, f/8, ISO 100, 25s

In the shot above, taken by Ryan, the ISO speed is very low at 100, and the aperture is at f/8. In order to get the exposure correct, the shutter was open for 25 seconds. Obviously, in order to do this effectively, you need to be using a tripod or some sort of stabilizing device to keep the camera still so that the image comes out sharp.

Let’s look at one more that’s not in such an extreme low-light situation.


Canon 24-70mmL, f/2.8, ISO 100, 0.001s

This photo was taken in the late afternoon when there was a reasonable amount of ambient light out. The ISO speed is set very low at 100 so the image isn’t grainy. I have the aperture open quite wide at f/2.8, so Demian’s head is in focus but the background is nicely blurred out. The shutter speed was 1/1000th of a second in this shot, so I didn’t have to worry about movement from Demian or the camera affecting the sharpness of the shot.

Do I really have to worry about all of this?

At this point hopefully you have a better understanding of why these three magic numbers are important for your photography. Nonetheless, you may also be there thinking “Seriously? Do I have to worry about all of this stuff all the time?” The answer in this day and age is “no, you can make the camera do at least some of the work for you.”

If you’re just getting into your DSLR, you’ve probably noticed that it has a variety of different shooting modes. When I first started learning about all of this, my more experienced friends advised me to use Aperture Priority mode when taking pictures. I recommend that you do the same. In Aperture Priority mode on my Canon rig, you select an ISO speed and the aperture to use, and the camera will pick out the shutter speed for you. This is convenient because you don’t have to constantly readjust the shutter speed as you’re trying to get your shots. There’s also a Shutter Priority mode, which I’ve barely ever used, and it does more or less the opposite. In that mode, you pick the ISO speed and the shutter speed, and the camera will select the aperture for you. I know that on some cameras like the new Nikon D300 there are modes that will also select ISO speeds for you, but I don’t have a rig that has this functionality personally so I don’t know too much about how to use it.

At any rate, shooting in Aperture Priority mode is a great way to start out since it lowers the number of things you need to concern yourself with. And you can always see what the camera is recommending for you in the viewfinder, or by looking at the EXIF data later on when you’ve processed the image. I’ve personally been shooting in fully manual mode a great deal as of late, but that’s mostly because I keep finding myself in very dark situations and I’m generally insistent on getting a sufficiently fast shutter speed so that the shots are clear. That said, for normal daytime shooting, myself and many of my friends use Aperture Priority mode a great deal of the time.

In Conclusion

I hope this serves to clarify some of the jargon that you may be absorbing. There’s definitely a learning curve with photography, but once you get the basics down it’s an incredibly fun endeavor. If anybody has questions please ask them via comments and I’ll do my best to answer them. Happy Holidays!